Flash an UBI/UBIFS root filesystem

Introduction

This section describes how to load a UBI root filesystem image into the NAND FLASH of the board with SAM-BA and right through the U-Boot command line.

Note that the root filesystem is installed at offset 0x400000 in the NAND FLASH. From a Linux kernel point of view, this corresponds to the index 0 of the MTD subsystem device (/dev/mtd1 and /dev/mtdblock1).

Using SAM-BA

SAM9N12_Rootfs.PNG

1. Choose the NandFlash media tab in the SAM-BA GUI.

2. Initialize the media choosing the Enable NandFlash action in the Scripts rolling menu and press Execute.

3. Select Enable OS PMECC parameters in the Scripts rolling menu and press Execute. Configure ECC as done on the following picture:
SAM9N12_ecc.jpg

Beware: the trimffs option must be selected for UBI filesystem. Then press the OK button.

4. Press Send File Name Browse button and choose your UBI filesystem.

5. Enter the proper address on media in the Address text field. You can find the product map in At91GettingStarted_9n12. So in our case, the value for the filesystem is 0x400000.

6. Press Send File button. A Please Wait... dialog window is appearing: wait for the end of the flashing process.

7. Close SAM-BA, remove the USB cable.

Ok, now you must have the Linux root filesystem flashed on your board.

Using U-Boot

You can also flash root filesystem image with U-Boot. You must have configured your network access in U-Boot as the binary image will be transferred to the target using TFTP protocol.
Download your ubi file (choose the proper name instead of <my_rootfs.ubi>):

tftp 0x22000000 <my_rootfs.ubi>
Erase the rootfs flash partition (252 MB):
nand erase 0x400000 0xfc00000
And write the downloaded ubi file on the flash memory. You must use the nand write.trimffs function to avoid ECC errors.
nand write.trimffs 0x22000000 0x400000 0x8200000
If the default arguments are not correct, you can also set them with this command:
setenv bootargs 'mem=128M console=ttyS0,115200 mtdparts=atmel_nand:4M(bootstrap/uboot/kernel)ro,-(rootfs) root=/dev/mtdblock1 rw rootfstype=ubifs ubi.mtd=1 root=ubi0:rootfs'

Additional information

Pointing hand Check for additional information about specific Open source embedded distributions on their dedicated page:


-- EricXu - 15 Mar 2012