U-Boot: using nand write to flash an ubi image, ubi part fails

Lars Michael lh_post at yahoo.com
Mon Jul 18 05:29:08 EDT 2011

Hello Ben,

--- On Wed, 1/6/11, Ben Gardiner <bengardiner at nanometrics.ca> wrote:
> > 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"
> > [...]
> > I realize that the U-Boot 'nand erase' does not
> preserve the erase counters. So what would be the correct
> way to erase and write in U-Boot? And why is the ubiformat
> not able to correct the problems?
> It's true that the ECs are not preserved. But it's also
> true that
> trailing pages of 0xff are not trimmed either. You
> definitely need to
> drop trailing 0xff pages when writing ubinized images
> containing UBIFS
> volumes. To do this you can use either the new 'nand write'
> variant,
> .trimffs [1] which is currently patches that have been
> Acked. Or you
> can use the free-space-fixup feature which is available in
> the
> ubifs-2.6 tree and requires that you use a mkfs.ubifs built
> from the
> the mtd-utils tree.

Ok, I have updated my mtd-utils and recompiled the mkfs.ubifs to get
support for the free-space-fixup feature. Next I have pulled
all ubi updates from the 2.6.29 backport tree which gave med 154 patches
including the fixup.

Now I can build the image, ubiformat, ubiattach and mount with success.
After a reboot I can ubiattach and mount with success.

Next step is to get it to work in U-Boot too.

Thanks and regards,
- Lars

More information about the linux-mtd mailing list