[U-Boot] A command to discard saved environments?

James Chargin jimccrown at gmail.com
Wed Aug 3 22:26:02 CEST 2016


Dear Wolfgang,

On 08/03/2016 12:59 PM, Wolfgang Denk wrote:
> Dear James,
>
> In message <fcff97bb-d146-fc77-28e4-050cac0922f4 at gmail.com> you wrote:
>> I know my non-volatile copy of the environment is in NOR flash so I use
>> the command
>>
>> protect all off;erase <saved env address> +1
>>
>> But, of course this is specific to NOR flash.
>>
>> I'm not aware of a way to do this in the general case, independent of NV
>> environment storage media and redundancy.
>
> The idea applies to all kinds of persistent storage: just overwrite a
> few (4 or more) bytes at the beginning of each copy of the persistent
> envrionment.
>
> In your case, you could save the "erase" by overwriting the first 4
> bytes (where the CRC32 checksum is stored) with 0xFFFFFFFF.

In the case of my NOR flash storage, telling erase to do one byte 
actually causes the erasure of an entire flash sector, which we've 
reserved for the NV environment.  You are of course correct that 
overwriting the CRC will have the same operational effect.

In my shop, time is not critical, whereas simplicity of commands is 
valued by those I have to instruct to get this sort of operation done.

It's a rare occurrence that we need to do this, we don't use this sort 
of operation as a normal part of doing business.

>
>> I'd be supportive of having a way to do this.
>
> No, I don't think we want to support this.  The persistent copy of the
> environment is a precious resource, and I cannot think of a regular
> use case to invalidate this.  If you do, the result is that you will
> use the default settings at next boot - and the samve effect can be
> acchieved by using "env reset" + "env save" as already recommended.
> [The only difference is that you will not see the "invalid CRC, using
> the default env" warning then, but I consider this a pro, not a con.]

Thank you for this perspective. I often feel a bit isolated in my way of 
doing things and I find it valuable to read things like this.

I agree that there is not a regular use for an operation of this sort.

During development and debug, I will occasionally need to restore a 
particular system to the physical state it would be in had we just 
received it from our contract manufacturer, which would include a blank 
area in NOR flash where the U-Boot environment is kept. This is done 
usually to "prove" that processes will work on those systems from the CM 
when production starts.

Up to now, I've used the erase command to do this and I will continue to 
do things this way. I guess I've been at this long enough that the rare 
times I need to erase this area of flash has become noticeable as a pattern.

Again, thank you for your reply.

Regards,
Jim

>
> Best regards,
>
> Wolfgang Denk
>

-- 
Jim Chargin
AJA Video Systems                       jimc at aja.com
(530) 271-3334                          http://www.aja.com


More information about the U-Boot mailing list