[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: Solved: cubox-i does not boot after upgrade to bullseye



Am Donnerstag, 30. Dezember 2021, 14:16:14 CET schrieb Rainer Dorsch:
> Am Mittwoch, 29. Dezember 2021, 22:18:31 CET schrieb Vagrant Cascadian:
> > On 2021-12-29, Rainer Dorsch wrote:
> > > Am Mittwoch, 29. Dezember 2021, 19:33:20 CET schrieb Vagrant Cascadian:
> > >> If you've used "saveenv" to save the u-boot environment variables, even
> > >> if you upgrade u-boot, the environment will remain frozen in the state
> > >> when you ran "saveenv".
> > >> 
> > >> I strongly discourage using "saveenv" as this makes upgrading u-boot
> > >> more difficult as you end up with inconsistent values between the
> > >> u-boot
> > >> version you're running and the environment you've saved.  This will
> > >> often work fine, although as you've discovered, sometimes updates to
> > >> the
> > >> environment fixes bugs.
> > >> 
> > >> You have to erase or overwrite the environment area on the microSD to
> > >> get new defaults; not sure off the top of my head where exactly this is
> > >> for the cubox-i.
> > >> 
> > >> If there is no saved environment, u-boot uses built-in defaults from
> > >> the
> > >> version of u-boot you're running.
> > > 
> > > Wouldn't
> > > 
> > > => env default -a
> > > 
> > > enforce a reset to a default environment
> > > 
> > > https://www.vermasachin.com/posts/3-u-boot-environment-variables/
> > 
> > Only for the running u-boot, it will load from the environment at next
> > boot... and if you use saveenv, it will save exactly that
> > environment... and possibly some other quirks such as missing or changed
> > auto-detected environment variables at boot which can cause
> > inconsistancies if you then run saveenv.
> > 
> > To really reset it for the cubox-i, you need to overwrite at least the
> > 
> > beginning of address 0xFE000 on your boot media:
> >   $ grep ENV configs/mx6cuboxi_defconfig
> >   CONFIG_ENV_SIZE=0x2000
> >   CONFIG_ENV_OFFSET=0xFE000
> > 
> > The mx6cuboxi defconfig should also be findable in
> > /usr/share/doc/u-boot-imx/configs/ if you have u-boot-imx:armhf
> 
> Hmm....to delete the user environment I tried:
> 
> # dd if=/dev/zero of=/dev/mmcblk1 bs=512 seek=127 count=16 conv=fsync
> 
> (for reference:
> root@bc-text:~# ls -l /dev/mmcblk1
> brw-rw---- 1 root disk 179, 0 Jul 13 19:29 /dev/mmcblk1
> root@bc-text:~# ls -l /dev/mmcblk0
> ls: cannot access '/dev/mmcblk0': No such file or directory
> root@bc-text:~#
> 
> root@bc-text:/usr/share/doc/u-boot-imx# zgrep CONFIG_ENV_OFFSET /usr/share/
> doc/u-boot-imx/configs/config.mx6cuboxi.gz
> CONFIG_ENV_OFFSET=0xFE000
> root@bc-text:/usr/share/doc/u-boot-imx# zgrep CONFIG_ENV_SIZE
> /usr/share/doc/ u-boot-imx/configs/config.mx6cuboxi.gz
> CONFIG_ENV_SIZE=0x2000
> root@bc-text:/usr/share/doc/u-boot-imx#
> 
> >>> 0xFE00/512
> 
> 127.0
> 
> )
> 
> and ended with
> 
> U-Boot SPL 2021.01+dfsg-5 (May 23 2021 - 04:32:45 +0000)
> WDT:   Not found!
> Trying to boot from MMC1
> mmc_load_image_raw_sector: mmc block read error
> spl_load_image_ext: ext4fs mount err - 0
> SPL: Unsupported Boot Device!
> SPL: failed to boot from all boot devices
> ### ERROR ### Please RESET the board ###
> 
> (I tried this on a test microSD, so it does not matter if I break the
> installation)
> 
> Do you see what went wrong?

I digged somewhat further and found


https://elixir.bootlin.com/u-boot/latest/source/env/Kconfig

config ENV_IS_IN_MMC
	bool "Environment in an MMC device"
	depends on !CHAIN_OF_TRUST
	depends on MMC
	default y if ARCH_EXYNOS4
	default y if MX6SX || MX7D
	default y if TEGRA30 || TEGRA124
	default y if TEGRA_ARMV8_COMMON
	help
	  Define this if you have an MMC device which you want to use for the
	  environment.

	  CONFIG_SYS_MMC_ENV_DEV:

	  Specifies which MMC device the environment is stored in.

	  CONFIG_SYS_MMC_ENV_PART (optional):

	  Specifies which MMC partition the environment is stored in. If not
	  set, defaults to partition 0, the user area. Common values might be
	  1 (first MMC boot partition), 2 (second MMC boot partition).

	  CONFIG_ENV_OFFSET:
	  CONFIG_ENV_SIZE:

	  These two #defines specify the offset and size of the environment
	  area within the specified MMC device.

	  If offset is positive (the usual case), it is treated as relative to
	  the start of the MMC partition. If offset is negative, it is treated
	  as relative to the end of the MMC partition. This can be useful if
	  your board may be fitted with different MMC devices, which have
	  different sizes for the MMC partitions, and you always want the
	  environment placed at the very end of the partition, to leave the
	  maximum possible space before it, to store other data.

	  These two values are in units of bytes, but must be aligned to an
	  MMC sector boundary.

	  CONFIG_ENV_OFFSET_REDUND (optional):

	  Specifies a second storage area, of CONFIG_ENV_SIZE size, used to
	  hold a redundant copy of the environment data. This provides a
	  valid backup copy in case the other copy is corrupted, e.g. due
	  to a power failure during a "saveenv" operation.

	  This value may also be positive or negative; this is handled in the
	  same way as CONFIG_ENV_OFFSET.

	  This value is also in units of bytes, but must also be aligned to
	  an MMC sector boundary.

U-Boot config is in
/usr/share/doc/u-boot-imx/configs/config.mx6cuboxi.gz

root@bc-text:~# zgrep ENV_IS_IN_MMC /usr/share/doc/u-boot-imx/configs/
config.mx6cuboxi.gz
CONFIG_ENV_IS_IN_MMC=y
root@bc-text:~# zgrep CONFIG_SYS_MMC_ENV_DEV /usr/share/doc/u-boot-imx/configs/
config.mx6cuboxi.gz
CONFIG_SYS_MMC_ENV_DEV=0
root@bc-text:~# zgrep CONFIG_SYS_MMC_ENV_PART /usr/share/doc/u-boot-imx/
configs/config.mx6cuboxi.gz
CONFIG_SYS_MMC_ENV_PART=0
root@bc-text:~# zgrep CONFIG_ENV_OFFSET /usr/share/doc/u-boot-imx/configs/
config.mx6cuboxi.gz
CONFIG_ENV_OFFSET=0xFE000
root@bc-text:~# zgrep CONFIG_ENV_SIZE /usr/share/doc/u-boot-imx/configs/
config.mx6cuboxi.gz
CONFIG_ENV_SIZE=0x2000
root@bc-text:~#


root@bc-text:~# sfdisk -l /dev/mmcblk1
Disk /dev/mmcblk1: 58.56 GiB, 62878384128 bytes, 122809344 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: dos
Disk identifier: 0x8ad3fb70

Device         Boot     Start       End   Sectors   Size Id Type
/dev/mmcblk1p1          32768    299999    267232 130.5M  c W95 FAT32 (LBA)
/dev/mmcblk1p2 *       301056   1300479    999424   488M 83 Linux
/dev/mmcblk1p3        1300480 120815615 119515136    57G 83 Linux
/dev/mmcblk1p4      120817662 122808319   1990658   972M  5 Extended
/dev/mmcblk1p5      120817664 122808319   1990656   972M 82 Linux swap / 
Solaris
root@bc-text:~# sfdisk -F /dev/mmcblk1
Unpartitioned space /dev/mmcblk1: 15 MiB, 15728640 bytes, 30720 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes

Start   End Sectors Size
 2048 32767   30720  15M
root@bc-text:~# 


But what is partition 0 specified in CONFIG_SYS_MMC_ENV_PART ? The free space 
starting at 2048?

If yes, would that imply that  I need 

# dd if=/dev/zero of=/dev/mmcblk1 bs=512 seek=127 count=16 conv=fsync

to delete the user environment?

Thanks
Rainer


-- 
Rainer Dorsch
http://bokomoko.de/



Reply to: