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 filesystemffee0000 to ff000000: readwrite ext2 filesystem fff00000 to fff20000: u-bootfff20000 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 368CFG_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.
Quoted 6 lines · In message <[email protected]> you wrote:
We define:
#defineCFG_MONITOR_BASE0xFFF00000
#defineCFG_ENV_SECT_SIZE(128*1024)
#defineCFG_ENV_SIZE(2*1024)
#defineCFG_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.
Quoted 3 lines
Memory location
fff1f800contains nothing, but after a 'saveenv' my environment is saved there. Memory locationfff08174contains my default environment and is unchanged after a 'saveenv'.
Sounds good to me...
Quoted 7 lines
Shouldn't
gd->env_addrbe equal toCFG_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.
Quoted 3 lines
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.ldsfile but I don't know what.
Of course the linker script must match your flash layout.
Best regards,
Wolfgang Denk
Signature · 4 lines
Software Engineering: Embedded and Realtime Systems, Embedded Linux Phone: (+49)-8142-4596-87 Fax: (+49)-8142-4596-88 Email: wd at denx.de While money can't buy happiness, it certainly lets you choose your own form of misery.
Quoted 9 lines · Wolfgang Denk
Quoted 5 lines · In message <[email protected]> you wrote:
We define:
#defineCFG_MONITOR_BASE0xFFF00000
#defineCFG_ENV_SECT_SIZE(128*1024)
#defineCFG_ENV_SIZE(2*1024)
#defineCFG_ENV_ADDR(CFG_MONITOR_BASE+CFG_ENV_SECT_SIZE-CFG_ENV_SIZE)
Quoted 4 lines
The
CFG_ENV_ADDRdefinition 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)
Quoted 11 lines
Quoted 3 lines
Shouldn't
gd->env_addrbe equal toCFG_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
Quoted 8 lines
Quoted 3 lines
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.ldsfile 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,
Quoted 4 lines · in message <[email protected]> you wrote:
U-boot is located at
0xfff00000up to0xfff20000. 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.
Quoted 1 line
(
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.
Quoted 8 lines
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.ldsI get "cannot move location counter backwards (fromfff07b10to0061f800)". Where does the0061f800comes from?
That's what was computed as env_offset given your definitions.
Quoted 3 lines
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
Signature · 3 lines
Software Engineering: Embedded and Realtime Systems, Embedded Linux Phone: (+49)-8142-4596-87 Fax: (+49)-8142-4596-88 Email: wd at denx.de Weekends were made for programming. - Karl Lehenbauer