U-Boot Env Vars in Flash and EEPROM at the same time (hybrid env)?
(puts on flame retardant underwear) Can environment variables be pulled from Flash and EEPROM?
Why would I want to do this? I need to provide fail safe upgrade path and need to do something similar to the bootcount feature in PPC (I'm using ARM though).
I have a internal SRAM that I can use for the bootcount feature (no registers survive reset so SRAM is next best option) but I want to be able to select Kernel B or Kernel A. Let me explain more. Right now the bootcount feature boots a primary kernel and if it fails it tries a secondary kernel. So in my case the bootcount feature would translate to Kernel A always tried first, then B and we want to be able to say boot B first, then A on failure (make the choice configurable based on upgrades etc).
The goal is to not brick a device during a upgrade. Whatever bank you are running out of, you upgrade by flashing the bank not being used. Once a bank has been upgraded, if I want to select that bank to boot ... I would need to modify a environment variable but if it is stored in flash then while that sector (a 256k sector in my case) is being updated ... if power is lost I just hosed myself. If the environment variable I update was stored in EEPROM, then it would be closer to an atomic action that couldn't be interrupted with say a power failure.
So what I'm asking about is a Hybrid environment were some variables are in flash and some are in EEPROM. The env is read from both locations and saveenv writes some vars in flash and some in EEPROM. With the current u-boot code I have (1.1.6) the environment choices are mutually exclusive (flash, eeprom, nvram etc.)
Is this a sane approach or am I heading for heart ache? This has to be something that others have dealt with but I didn't see any similar discussions in the archives.
Regards,
Brian
... oops, one glaring thing I didn't think about in the approach I presented was the I2C transaction. If power is lost during that transaction I have a similar problem to a loss of power during a saveenv and the flash sector being erased and re written.
Dear Brian Hutchinson,
Quoted 2 lines · In message <[email protected]> you…
(puts on flame retardant underwear) Can environment variables be pulled from Flash and EEPROM?
Not directly.
Quoted 3 lines
Why would I want to do this? I need to provide fail safe upgrade path and need to do something similar to the bootcount feature in PPC (I'm using ARM though).
Hm... And redundant environment is not safe enough for you?
Quoted 8 lines
The goal is to not brick a device during a upgrade. Whatever bank you are running out of, you upgrade by flashing the bank not being used. Once a bank has been upgraded, if I want to select that bank to boot ... I would need to modify a environment variable but if it is stored in flash then while that sector (a 256k sector in my case) is being updated ... if power is lost I just hosed myself. If the environment variable I update was stored in EEPROM, then it would be closer to an atomic action that couldn't be interrupted with say a power failure.
EEPROM is not a bit more reliable than NOR, on contrary (read for example doc/I2C_Edge_Conditions - unless you write-protect your EEPROm in hardware it is actually way less reliable).
And redundant environment should cover your use case just fine.
Quoted 5 lines
So what I'm asking about is a Hybrid environment were some variables are in flash and some are in EEPROM. The env is read from both locations and saveenv writes some vars in flash and some in EEPROM. With the current u-boot code I have (1.1.6) the environment choices are mutually exclusive (flash, eeprom, nvram etc.)
This makes little sense to me.
If you really fell like it, you can of course store some script image in EEPROM which you can then read and run (using "eeprom read" plus "source" commands).
Quoted 3 lines
Is this a sane approach or am I heading for heart ache? This has to be something that others have dealt with but I didn't see any similar discussions in the archives.
Maybe because redundant environment is good enough for all practical purposes?
Best regards,
Wolfgang Denk
Signature · 4 lines
DENX Software Engineering GmbH, MD: Wolfgang Denk & Detlev Zundel HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de Objects in mirror are closer than they appear.
Quoted 2 lines
Hm... And redundant environment is not safe enough for you?
I don't know much about redundant env but now that you mention it ... I do remember seeing something about that in the code. I'll look into it. Thanks!
Quoted 10 lines
Quoted 9 lines
The goal is to not brick a device during a upgrade. ?Whatever bank you are running out of, you upgrade by flashing the bank not being used. Once a bank has been upgraded, if I want to select that bank to boot ... I would need to modify a environment variable but if it is stored in flash then while that sector (a 256k sector in my case) is being updated ... if power is lost I just hosed myself. ?If the environment variable I update was stored in EEPROM, then it would be closer to an atomic action that couldn't be interrupted with say a power failure.
Quoted 3 lines
EEPROM is not a bit more reliable than NOR, on contrary (read for example doc/I2C_Edge_Conditions - unless you write-protect your EEPROm in hardware it is actually way less reliable).
I've seen that document and have raised the issues (and discussions I found about it in the archives) to those that "really" want to use the EEPROM.
I guess when I first thought about this I had sector erase time of flash vs hitting a single byte of the EEPROM but I wasn't thinking of the I2C transaction. That realization hit me right after I hit send and realized what I posted was heading in the weeds.
Quoted 2 lines
And redundant environment should cover your use case just fine.
Cool! I will surely read all I can on it.
Quoted 8 lines
Quoted 6 lines
So what I'm asking about is a Hybrid environment were some variables are in flash and some are in EEPROM. ?The env is read from both locations and saveenv writes some vars in flash and some in EEPROM. With the current u-boot code I have (1.1.6) the environment choices are mutually exclusive (flash, eeprom, nvram etc.)
This makes little sense to me.
Thanks for being gentle. I had temporary insanity.
Regards,
Brian