0

I'm using u-boot on raspberry pi 4, A/B booting from USB attached SSD, integrated with mender without yocto. Everything works fine except the env saving: initially configured to use MMC and offsets, fw_printenv complained about a bad CRC and output the default config instead. I changed the env saving to FAT files on the boot partition, and I'm now troubleshooting 2 issues:

  • uboot.env does not get written by issuing saveenv in the u-boot prompt
  • uboot-redund.env gets written but its CRC is incorrect.

I'm checking the CRC by issuing the fw_printenv command from linux. Its config file states:

/boot/u-boot/uboot-redund.env  0x0000     0x4000

U-Boot is compiled with 0x4000 as env size, and using hexdump to check the file shows a correct file with a length of 0x4000.

When booting up, u-boot outputs the following log over TTL serial:

U-Boot 2021.07-rc2-00246-gd64b3c608d-dirty (Jun 16 2021 - 12:16:24 +0200)

DRAM:  7.9 GiB
RPI 4 Model B (0xd03114)
MMC:   mmcnr@7e300000: 1, emmc2@7e340000: 0
Loading Environment from FAT... In:    serial
Out:   vidconsole
Err:   vidconsole
Net:   eth0: ethernet@7d580000
PCIe BRCM: link up, 5.0 Gbps x1 (SSC)
starting USB...
Bus xhci_pci: Register 5000420 NbrPorts 5
Starting the controller
USB XHCI 1.00
scanning bus xhci_pci for devices... 3 USB Device(s) found
       scanning usb for storage devices... 1 Storage Device(s) found
Hit any key to stop autoboot:  0 

which shows that u-boot does load the env from FAT correctly.

How can I investigate further why u-boot does not write uboot.env, and why when it does write uboot-redund.env, writes it with a wrong CRC from fw_printenv's point of view?

Pierre-Alexis Ciavaldini
  • 3,369
  • 1
  • 14
  • 16

1 Answers1

0

env save

In function env_fat_save only one file is written. If CONFIG_SYS_REDUNDAND_ENVIRONMENT is defined, alternatively either file CONFIG_ENV_FAT_FILE_REDUND or file CONFIG_ENV_FAT_FILE is written.

You have to execute the command env save twice if you want to write both files.

Command env infoindicates which instance was written last via field env_valid:

=> env select FAT
Select Environment on FAT: OK
=> env info
env_valid = invalid
env_ready = true
env_use_default = false
=> env save
Saving Environment to FAT... OK
=> env info
env_valid = redundant
env_ready = true
env_use_default = false
=> env save
Saving Environment to FAT... OK
=> env info
env_valid = valid
env_ready = true
env_use_default = false
=> 

fw_printenv

When using fw_printenv you must specify the configuration which matches your U-Boot build. By default file /etc/fw_env.config is used. You can pass the configuration file on the command line:

tools/env/fw_printenv -c fw_env.config

This is what your configuration file could look like:

uboot.env        0x0000          0x2000
uboot-redund.env 0x0000          0x2000

There is an example file in tools/env/fw_env.config explaining the available fields.

Xypron
  • 2,215
  • 1
  • 12
  • 24