Depending on a few configurations I tried in /etc/fw_env.config such as one or two entries, I got the following errors when trying to read the U-boot environment variables:
root@varsomam33:~# fw_printenv serverip
Warning: Bad CRC, using default environment
or
root@varsomam33:~# fw_printenv serverip
Cannot read bad block mark: Invalid argument
According to this tutorial (https://developer.ridgerun.com/wiki/index.php/Setting_up_fw_printenv_to_modify_u-boot_environment_variables), I constructed my /etc/fw_env.config to look like this:
# MTD device name Device offset Env. size Flash sector size Number of sectors
/dev/mtd6 0x1C0000 0x20000 0x20000 1
/dev/mtd7 0x1E0000 0x20000 0x20000 1
FYI I'm using a TI Omap ARM chip (var-som-am33) with Yocto Fido default out-of-box from Variscite with these software versions:
U-boot version:
u-boot-var-som-am33 2014-+gitrAUTOINC+adf9a14020U-boot-fw-utils version:
u-boot-fw-utils v2014.07+gitAUTOINC+524123a707-r0-arago0-var
The main problem is that "Device offset" is incorrectly described in the RidgeRun tutorial. It is not the absolute offset in NAND flash, but rather the offset from the partition which should be "0x0" in my case.
Here is my working
/etc/fw_env.configFurther, the CRC error I was getting is thrown when there is not a U-boot backup (redundant) environment described in the
/etc/fw_env.configfile. Thefw_printenvutility works by copying the "selected" environment, modifying the variable you have changed, and writing it out to the "new" environment. Then it swaps "selected" and "new".So if you only have one environment in
/etc/fw_env.config, it uses default values for the "selected" environment.Here is the code
tools/env/fw_env.c