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

On Wed, Jun 1, 2011 at 3:57 AM, Lars Michael lh_post@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

--- On Thu, 29/9/11, Matthew L. Creech mlcreech@gmail.com wrote:
On Wed, Jun 1, 2011 at 3:57 AM, Lars Michael lh_post@yahoo.com 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"
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.
Hi Matthew,
I agree, which is why I used ubinize to create a UBI image (with 5 UBIFS images) and then tried to write that image.
There are 2 ways to get it working:
- 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.
- 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".
This is what I am doing (or plan to do). But to get it to work, I need the space fixup feature for the nand write in U-Boot. I got that feature in Linux, so in Linux it works. Unfortunately it is not easy to patch that one in my 2009.08 U-Boot.
Thanks for your comments.
Regards Lars

On 09/29/2011 10:44 PM, Lars Michael wrote:
--- On Thu, 29/9/11, Matthew L. Creech mlcreech@gmail.com wrote:
- 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".
This is what I am doing (or plan to do). But to get it to work, I need the space fixup feature for the nand write in U-Boot. I got that feature in Linux, so in Linux it works. Unfortunately it is not easy to patch that one in my 2009.08 U-Boot.
Try using a current U-Boot, and use "nand write.trimffs".
-Scott
participants (3)
-
Lars Michael
-
Matthew L. Creech
-
Scott Wood