[U-Boot] [PATCH v2 5/5] cgtqmx6eval: Protect the manufacturing information in SPI NOR

Jagan Teki jteki at openedev.com
Wed Sep 23 17:56:05 CEST 2015


On 23 September 2015 at 19:06, Otavio Salvador
<otavio.salvador at ossystems.com.br> wrote:
> On Wed, Sep 23, 2015 at 5:15 AM, Jagan Teki <jteki at openedev.com> wrote:
>
>> Sorry, I didn't understand why protection range or bits are specific
>> to board, is it different in Congetc because the flash area being
>> protected by means of sector range which is obviously the flash
>> offset.
>
> The protection range is board specific. For example: certain boards
> don't need any region to be protected at all, other boards may want
> the entire SPI flash to be protected. In Congatec's boards we only
> need to protect the last 16KiB sector because it contains data that
> are pre-programmed in the factory and we don't want the user to erase
> it.
>
> That's why we set in the congatec board code the BP bits to 001.
>
>>
>> m25p32
>>
>> BP2/BP1/BP0=protected sectors
>> 000 = sector (none)
>> 001 = sector (63)
>> 010 = sector (63, 62)
>> ....
>> 111 = sector (all)
>>
>> I understand your concept of protecting sectors once you find the BP2,
>> BP1 and BP0 bits on board and then you locked the particular sectors,
>
> Yes, this is the idea.
>
>> is it? it's totally reverse way that you're trying to do is it?
>
> No, the logic is correct. In Congatec's board we only want the last
> sector to be protected, hence BP2 BP1 BP0 is set to 001.

All looks fine as per your patches, but probing flash from board files
isn't a good approach if one more board add similar  approach.

I have an idea similar to "cfi_flash" approach.

"sf protect on off len" then based on the offset and len write the
protected bits and skips the sectors which are protected by showing
warning say "protected sectors will not be erased!" [1]

Use the Linux approach[2] for more information, let me know for any more inputs.

[1] http://www.denx.de/wiki/view/DULG/UBootCmdGroupFlash#Section_5.9.3.4.
[2] http://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/commit/drivers/mtd/devices/m25p80.c?id=972e1b7b450a93589b2a4c709e68f68da059aa5c


thanks!
-- 
Jagan | openedev.


More information about the U-Boot mailing list