[U-Boot] U-Boot: using nand write to flash an ubi image, ubi part fails
Matthew L. Creech
mlcreech at gmail.com
Thu Sep 29 04:43:11 CEST 2011
On Wed, Jun 1, 2011 at 3:57 AM, Lars Michael <lh_post at yahoo.com> wrote:
> Hello,
>
> Using mkfs.ubifs and ubinize I have created an image with 5 volumes. In Linux I could flash it using "ubiformat /dev/mtd1 -f /root/ubi.img" and attach it using "ubiattach /dev/ubi_ctrl -m 1". It worked.
>
> In production I would prefer to write the image from U-Boot. So in U-Boot I used "nand erase" then "nand write" to flash the image. Then I want to attach by "ubi part" command - but this fails: "UBI error: ubi_init: UBI error: cannot initialize UBI, error -17"
>
Basically, this isn't a valid combination: "nand write" doesn't know
anything about UBI, and a UBIFS image isn't suitable for flashing
directly to NAND - it expects to sit on top of UBI.
There are 2 ways to get it working:
1. Don't use "nand write". If U-Boot is built with UBI support, you
can use "ubi write" to write a UBI image to flash. I _think_ you can
use this to overwrite an existing volume with a new image, preserving
ECs (haven't tried it myself). It certainly works fine to write a new
image to blank flash.
2. Use the "ubinize" tool to create an image suitable for writing
directly to NAND. This takes a UBIFS image and "wraps" it to turn it
into a UBI image, which you can then use with "nand write".
I've used both these methods to write UBIFS images to flash within
U-Boot, and the 2nd method also works with industrial NAND
programmers.
Hope this helps
--
Matthew L. Creech
More information about the U-Boot
mailing list