NAND OTP operations (preliminary patch)

Harald Welte laforge at
Wed Apr 18 11:29:24 CEST 2007

On Wed, Apr 18, 2007 at 01:30:31AM -0300, Werner Almesberger wrote:
> Hi Harald,
> my first version of the NAND OTP code is in SVN:
> trunk/src/target/u-boot/patches/nand-otp.patch

cool, thanks.

> It allows arbitrary reads within any OTP page, and writes of entire
> pages (enforced by nand_write_ecc), with "nand read.otp" and
> "nand write.otp". 


> Addresses are "linearized", so OTP is in the area 0-0xBFF.


> By the way, the OTP can be updated incrementally, so it's not strictly
> "one time". If we want to put data there that really ought to be hard
> to change, e.g., a serial number, we could protect it with an MD5 hash
> or similar.

mh.  The 'usual' method I have seen is to store the whole content twice:
non-inverted and inverted.

Even with a MD5 sum there is the slight non-zero probability that the
checksum might be updated incrementally ;)   So maybe at least storing
that checksum non-inverted and inverted should give us the absolute
guarantee that nothing has changed.

> We could store data in the form of strings "foo=bar", followed by a
> checksum/CRC/hash. u-boot could then scan some or all of the OTP pages
> for such strings, and load them into its environment.

have you seen my proposal at ?

> A byte with value 0 at the place of the first character of a string
> would be skipped, so entries could be "erased" by overwriting them
> with zeroes. A 0xff byte would indicate the end of the strings in the
> current page.

I really don't like having more strings.  just too difficult to parse.

> Ideally, I'd supporting writing only from under Linux, to keep that
> somewhat complex code out of u-boot. (Writing should also allow the
> page to be selected, in case we have a pattern we know to cause
> fragmentation.)

No, I also don't think that's an option.  If we want to store BT MAC
address here, during production we don't have a Linux kernel but rather
only u-boot / devirginator running.

- Harald Welte <laforge at>         
Software for the world's first truly open Free Software mobile phone

More information about the openmoko-uboot mailing list