1

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+adf9a14020

  • U-boot-fw-utils version: u-boot-fw-utils v2014.07+gitAUTOINC+524123a707-r0-arago0-var

Brad Grissom
  • 3,633
  • 3
  • 21
  • 23

1 Answers1

1

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.config

root@varsomam33:~# cat /etc/fw_env.config
# MTD device name   Device offset   Env. size   Flash sector size   Number of sectors
/dev/mtd6           0x0             0x20000     0x20000             1
/dev/mtd7           0x0             0x20000     0x20000             1

Further, the CRC error I was getting is thrown when there is not a U-boot backup (redundant) environment described in the /etc/fw_env.config file. The fw_printenv utility 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

1230     crc0_ok = (crc0 == *environment.crc);
1231     if (!HaveRedundEnv) {
1232         if (!crc0_ok) {
1233             fprintf (stderr,
1234                 "Warning: Bad CRC, using default environment\n");
1235             memcpy(environment.data, default_environment, sizeof default_environment);
Brad Grissom
  • 3,633
  • 3
  • 21
  • 23
  • Just a comment, `fw_printenv` and `fw_setenv` does only use a redundant copy of the environment, if the U-Boot build which built them, were configured to do so. For NAND-flash, you really **should** be using that feature. Also, if this is for production quality, I'd recommend adding a few spare blocks to each environment partition, and configure U-Boot accordingly. – Anders Sep 08 '16 at 04:42