1

I have a working system with u-boot and a UBIFS partition on SLC NAND.

I've copied the UBIFS partition into a binary image file by reading the whole range of blocks it occupies, including spare area.

I can successfully program this image to another NAND device (skipping empty pages) and mount it, thus duplicating the partition. However, if there's a bad block in the new NAND device, I don't know what would be the correct action?

When I try to skip bad blocks (during programming), which seems to be the most reasonable solution, mount from u-boot fails! Can't UBIFS mount process identify that a bad block was skipped? Is there any other simple solution?

Adashi
  • 461
  • 1
  • 4
  • 8
  • You should not be writing a UBIFS image directly to NAND Flash. The UBIFS needs to be written to a UBI volume using **ubiupdatevol**. Check your boot logs. You don't have a *"UBIFS partition"*. You should have a MTD partition, a UBI volume and a UBIFS (root)filesystem. – sawdust Oct 01 '14 at 17:56
  • Thanks for you comment, you are correct, I do have a UBIFS mounted on a UBI volume, in an MTD partition. I'm trying to produce a binary file that is a mirror image of the volume, and then use it to duplicate the volume on another NAND device. In a way, like good old Norton Ghost. Now, I'm able to do so, but a simple NAND programmer machine in mass production needs a way to deal with bad blocks... – Adashi Oct 03 '14 at 18:15
  • [How to create a UBIFS or UBI image](http://www.linux-mtd.infradead.org/faq/ubifs.html#L_mkfubifs). Either NFS mount the target Flash on your development system, or cross compile the utilities and install on the target. – sawdust Oct 05 '14 at 01:34

1 Answers1

1

Found a working method!

The whole purpose of this was to find a simple algorithm for programming NAND flash parts, before soldeing it to the board.

This is done during mass production by a programming machine, and there's no way to use Linux to do that. Since the NAND part is new, no need for wear leveling information, however, it may have 0 to any number of bad blocks, randomly located in the partition area. The only available steps are:

  • skip bad block
  • erase
  • write

Preparimg image for mass production:

  • Make sure UBI volume is smaller that the MTD partition (5% smaller, for example)
  • Create UBI volume and UBIFS, and populate it.
  • Dump NAND blocks + spare area of pages into a binary file.

It's possible to prepare UBIFS using mkfs and other tools, but than you need to add the ECC information, which the programming machine may not be able to calculate on the fly, and sometimes just don't have the knowledge.

Programming algorithm is as follows:

  • Starting at the MTD partition offset, program each image block to NAND block.
  • If NAND block is bad skip it, program image block N to NAND block N+1.
  • If image block is empty, don't program, advance to next block on both image and NAND chip.
  • Continue the same way until last block of UBI volume.
  • Program the last block of image at the last good block of MTD partition on the NAND chip.

Hope that helps anyone :-)

Adashi
  • 461
  • 1
  • 4
  • 8