Brad Grissom
Brad Grissom

Reputation: 3943

fw_printenv fw_setenv on var-som-am33 is failing

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:

Upvotes: 2

Views: 1562

Answers (1)

Brad Grissom
Brad Grissom

Reputation: 3943

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);

Upvotes: 2

Related Questions