NOR Flash

Initial setup

Kernel modules needed for UBIFS (2.6.30.5):

Module Size Used by

deflate 1124 -

zlib_deflate 18168 -

zlib_inflate 15940 -

lzo 740 -

crypto_algapi 7300 -

lzo_decompress 1956 -

lzo_compress 1828 -

ubifs 278088 - Yes, it's massive!

crypto 5516 -

crc16 964 -

ubi 94632 -

physmap 1796 -

cfi_cmdset_0002 22052 -

cfi_probe 2852 -

gen_probe 1732 -

cfi_util 4164 -

bifferboard_flash 1012 -

mtd 10600 -

chipreg 836 -

Make sure they're loaded as follows (order seems important somehow):

modprobe deflate

modprobe crypto

modprobe lzo

modprobe crc16

modprobe cfi_probe

modprobe cfi_util

modprobe cfi_cmdset_0002

modprobe mtd

modprobe ubi

modprobe bifferboard_flash

modprobe physmap

modprobe ubifs

On my 2.6.32 slackware bifferboard system built from svn, the module physmap.ko was not compiled as standard. A change to .config and a make modules solved that.

UBI

You will need to get hold of some utilities to prepare your flash partition for use with UBI. I see no point in repeating info here that can be found on the UBI homepage, so install them following instructions here.

The first utility you need is ubiformat, use it to prepare your rootfs partition for use with UBI:

root@darkstar:~# ./ubiformat /dev/mtd1

Attach that mtd volume (-m) to UBI volume (-d):

root@darkstar:~# ./ubiattach /dev/ubi_ctrl -m 1 -d 1

Make a file system on that volume, and give it a name.

root@darkstar:~# ./ubimkvol /dev/ubi1 -m -N ubifs

Mount it, proc/sys style:

root@darkstar:~# mount -t ubifs ubi1:ubifs /mnt/ubifs/

On each boot

Load the modules above.

Specify the mtd device number that you want to attach to, and the ubi device you want that to correspond to:

root@darkstar:~# ./ubiattach /dev/ubi_ctrl -m 1 -d 1

Now mount the newly created volume to read/write files:

root@darkstar:~# mount -t ubifs ubi1:ubifs /mnt/ubifs/

Do not count too much on what df indicates as free space on an ubifs volume.

From the ubifs FAQ: "Why df reports too few free space?"

"UBIFS flash space accounting is quite challenging and it is not always possible to report accurate amount of free space. The df utility usually reports less free space than users may actually write to the file-system, but it never reports more space.

UBIFS cannot precisely predict how much data the user will be able to write to the file-system. There are several reasons for this - compression, write-back, space wastage at the end of logical eraseblocks, garbage-collection, etc."

On my system df reports (empty uibfs volume) just 4 Mb. free where dmesg messages from ubifs suggest more than 5 Mb. free.

For UBI-root

When you load the ubi module, you can specify the flash partition to attach to by name:

root@darkstar:~# modprobe ubi mtd=rootfs

So you can pass this as an argument to the kernel (ubi.mtd=rootfs), I guess you might have to set rootfstype= and root= to get a boot.