[U-Boot] Saving environment question

I have an MPC8323ERDB that I am trying to update from an older version of u-boot to 2010.12 and am having trouble saving the environment with "saveenv". I turn on the debug in env_flash.c and can see the failure is at line 271 near the beginning of the saveenv() routine where we are trying to mallic(up_data).
up_data = (end_addr + 1 - ((long)flash_addr + CONFIG_ENV_SIZE)); debug("2 Data to save 0x%lx end:%lx new:%lx\n", up_data, end_addr, flash_addr); if (up_data) { if ((saved_data = malloc(up_data)) == NULL) { printf("Unable to save the rest of sector (%ld)\n", up_data); goto done; }
At the debug statement, up_data = 0x1E000, end_addr = 0xFE07FFFF and flash_addr = 0xFE060000. The end_addr and flash_addr seem reasonable to me as the flash in 128Kb sectors in the MPC8323ERDB so the first few sectors are:
FE000000 - FE01FFFF FE020000 - FE03FFFF FE040000 - FE05FFFF *FE060000 - FE07FFFF*
The malloc itself appears to be failing and this puzzles me.
Would anyone be willing to point out the location of the "naievety hole" I have fallen into with this little sub-project??

Dear Charles Krinke,
In message AANLkTikJFQLX4LrA7BZsAQ2nJy0EhinH+Evwe8Csorkf@mail.gmail.com you wrote:
up_data = (end_addr + 1 - ((long)flash_addr + CONFIG_ENV_SIZE)); debug("2 Data to save 0x%lx end:%lx new:%lx\n", up_data, end_addr,
flash_addr); if (up_data) { if ((saved_data = malloc(up_data)) == NULL) { printf("Unable to save the rest of sector (%ld)\n", up_data); goto done; }
At the debug statement, up_data = 0x1E000, end_addr = 0xFE07FFFF and flash_addr = 0xFE060000. The end_addr and flash_addr seem reasonable to me as the flash in 128Kb sectors in the MPC8323ERDB so the first few sectors are:
Hmm...
up_data = (end_addr + 1 - ((long)flash_addr + CONFIG_ENV_SIZE));
so
CONFIG_ENV_SIZE = up_data + flash_addr - end_addr - 1 = 0x1E000 + 0xFE060000 - 0xFE07FFFF - 1 = -8192
The values you give here make no sense to me, as CONFIG_ENV_SIZE is supposed to be a positive number.
Best regards,
Wolfgang Denk
participants (2)
-
Charles Krinke
-
Wolfgang Denk