[U-Boot-Users] reading environment from flash fails

Hi all,
I need some help converting a patch for ppcboot-1.1.6 to u-boot.
I've got the following patch for ppcoot-1.1.6: http://wkamphuis.student.utwente.nl/u-boot/ppcboot-1_1_6_qs.patch
This patch is for the QSLinux QST23/QS850/QS860T boards. See http://www.snmc.com/prod_qs850.html The patch is made by Daris Nevil (SNMC), it works fine but hasn't been ported to u-boot yet, it's also very large (+500k).
The past few days I've been busy porting this patch to u-boot, version 1.0.0. While porting I've run into a problem. Saving the environment to flash ('saveenv') works but this environment isn't read when rebooting. I can't figure out why.
Our board has 8Mb flash, mapped to ff800000. Here's the layout: ff800000 to ffee0000: root filesystem ffee0000 to ff000000: readwrite ext2 filesystem fff00000 to fff20000: u-boot fff20000 to ffffffff: linux kernel
We define: #define CFG_MONITOR_BASE 0xFFF00000 #define CFG_ENV_SECT_SIZE (128*1024) #define CFG_ENV_SIZE (2*1024) #define CFG_ENV_ADDR (CFG_MONITOR_BASE + CFG_ENV_SECT_SIZE - CFG_ENV_SIZE)
So the environment is located at fff1f800. I've added some debugging into the source, which results in:
file console.c, func console_init_f, line 368 CFG_ENV_ADDR = 'fff1f800' gd->env_addr = 'fff08174'
Memory location fff1f800 contains nothing, but after a 'saveenv' my environment is saved there. Memory location fff08174 contains my default environment and is unchanged after a 'saveenv'.
Shouldn't gd->env_addr be equal to CFG_ENV_ADDR? Now my saved environment settings aren't read and after a reset all settings are restored to the defaults.
The original patch, my unfinished patch and some screendumps are available on my website: http://wkamphuis.student.utwente.nl/u-boot/
Could someone give me a tip pointer where to look for a solution? I have a feeling it has something to do with the u-boot.lds file but I don't know what.
thanks in advance, Wolter Kamphuis, MuLogic B.V.

In message 3FC7802B.7010506@wkamphuis.student.utwente.nl you wrote:
We define: #define CFG_MONITOR_BASE 0xFFF00000 #define CFG_ENV_SECT_SIZE (128*1024) #define CFG_ENV_SIZE (2*1024) #define CFG_ENV_ADDR (CFG_MONITOR_BASE + CFG_ENV_SECT_SIZE - CFG_ENV_SIZE)
The CFG_ENV_ADDR definition makes no sense to me. If it results in the intended value than by pure chance, not by any deeper logic.
Memory location fff1f800 contains nothing, but after a 'saveenv' my environment is saved there. Memory location fff08174 contains my default environment and is unchanged after a 'saveenv'.
Sounds good to me...
Shouldn't gd->env_addr be equal to CFG_ENV_ADDR? Now my saved environment settings aren't read and after a reset all settings are restored to the defaults.
The original patch, my unfinished patch and some screendumps are available on my website: http://wkamphuis.student.utwente.nl/u-boot/
I don't know which board you're talking about, and I don't understand how your patch and your question are related to each other. From this message it sounds as if you want to put the environment in flash, but your code #defines CFG_ENV_IS_IN_NVRAM (at least in some cases).
No big surprise you run into problems?
Just a remark: Please note that many lists in U-Boot (board names etc. in Makefile, README, MAKEALL, ...) are SORTED. I will reject a patch that breaks this (read: please fix your code).
Also, I will insist in properly formatted source code. See the Linux "CodingStyle" for details.
Could someone give me a tip pointer where to look for a solution? I have a feeling it has something to do with the u-boot.lds file but I don't know what.
Of course the linker script must match your flash layout.
Best regards,
Wolfgang Denk

Wolfgang Denk wrote:
In message 3FC7802B.7010506@wkamphuis.student.utwente.nl you wrote:
We define: #define CFG_MONITOR_BASE 0xFFF00000 #define CFG_ENV_SECT_SIZE (128*1024) #define CFG_ENV_SIZE (2*1024) #define CFG_ENV_ADDR (CFG_MONITOR_BASE + CFG_ENV_SECT_SIZE - CFG_ENV_SIZE)
The CFG_ENV_ADDR definition makes no sense to me. If it results in the intended value than by pure chance, not by any deeper logic.
U-boot is located at 0xfff00000 up to 0xfff20000. I would like to save my environment in the same sector as u-boot, but in the last two Kb's, thus at 0xfff1f800-0xfff20000
(0xfff00000 + 0x20000 - 0x800 = 0xfff1f800 = starting address for env)
Shouldn't gd->env_addr be equal to CFG_ENV_ADDR? Now my saved environment settings aren't read and after a reset all settings are restored to the defaults.
I don't know which board you're talking about, and I don't understand how your patch and your question are related to each other. From this message it sounds as if you want to put the environment in flash, but your code #defines CFG_ENV_IS_IN_NVRAM (at least in some cases).
Sorry, forgot to tell. This patch is for 3 boards, the QS823, QS850 and the QS860T. We only got the QS850 boards so I'm only talking about the QS850. The QS850 only has flash ram, no nvram. The board I'm testing on has 8Mb flash but we also got boards with 4Mb flash. Full spec's can be found at http://www.snmc.com/prod_qs850.html
Could someone give me a tip pointer where to look for a solution? I have a feeling it has something to do with the u-boot.lds file but I don't know what.
Of course the linker script must match your flash layout.
Ok, now the problem is I don't know how to tell the linker where to store the environment. If I add
. = env_offset; common/environment.o (.text)
to the u-boot.lds I get "cannot move location counter backwards (from fff07b10 to 0061f800)". Where does the 0061f800 comes from?
If I force the offset to 0xfff1f800 and add
. = 0xfff10000; common/environment.o (.text)
to the u-boot.lds I get "cannot move location counter backwards (from fff07b10 to ffe1f800)". Anyone here knows why 0xfff10000 becomes ffe1f800?
Letting u-boot store its environment outside the u-boot sector (<0xfff0000) works perfectly but will cost me a flash sector dedicated for the environment. I rather do without since I realy need that space.
thanks in advance, Wolter Kamphuis

Dear Wolter,
in message 3FCB7600.6040402@wkamphuis.student.utwente.nl you wrote:
U-boot is located at 0xfff00000 up to 0xfff20000. I would like to save my environment in the same sector as u-boot, but in the last two Kb's, thus at 0xfff1f800-0xfff20000
Don't do this. This is by far too dangerous. Each "saveenv" will open a window in time where your system will not recover from a power loss. DO NOT DO THIS.
(0xfff00000 + 0x20000 - 0x800 = 0xfff1f800 = starting address for env)
This makes no sense. Never place the environment in any flash sector that contains any other data you need.
Ok, now the problem is I don't know how to tell the linker where to store the environment. If I add
. = env_offset; common/environment.o (.text)
to the u-boot.lds I get "cannot move location counter backwards (from fff07b10 to 0061f800)". Where does the 0061f800 comes from?
That's what was computed as env_offset given your definitions.
Letting u-boot store its environment outside the u-boot sector (<0xfff0000) works perfectly but will cost me a flash sector dedicated for the environment. I rather do without since I realy need that space.
I'd rather have a reliably working system instead of one which is broken by design just to save a flash sector.
Best regards,
Wolfgang Denk
participants (2)
-
Wolfgang Denk
-
Wolter Kamphuis