How to run a ubifs on IGEP boards
From IGEP - ISEE Wiki
Contents
Ubifs on the IGEP
General Information
This page try`s to summarize informations which is needed to create and run a ubifs based rootfilesystem on the igep boards. For now this information apply`s to revB boards only. Feel free to add details for the other boards here.
Ubifs is a next generation flash filesystem and is considered to become the successor of the well known jffs2 filesystem. There a many advantages using ubifs. In total, ubifs will performs better, is more stable against corruption and scales alot better then jffs2. You can find all details about it on the following websites. Ubifs homepage
As for all its benefits, it is also very different in the way it is setup up and configured. Below you will find a short story on how to get your igep up and running ubifs.
Create Ubi Container and Ubifs filesystems
First you will need to create a ubifs image from a directory containing your wished rootfs. mkfs.ubifs is the command for that. The following command shows a example for that:
sudo mkfs.ubifs -v -r YOURROOTFSDIR/ -o igep0020.rootfs.ubifs -m 4096 -e 258048 -c 1990
That will result in a file container called igep0020.rootfs.ubifs The next command we need is ubinize. That will pack the file from above into a so called ubi container as a volume. One could add multiple volumes in one ubi container.
sudo ubinize -vv -o igep0020.ubi -m 4096 -p 256KiB -s 1024 ubinize.cfg
You noticed that this call takes a path to a cfg config file which will carry some more paramters to the ubinize call. In this example the ubinize.cfg file looked like this:
[ubifs] mode=ubi image=igep0020.rootfs.ubifs vol_id=0 vol_type=dynamic vol_name=igep0020-rootfs vol_flags=autoresize
Your eagle eye will notice that this config file names the vol_name to igep0020-rootfs. That is a important information, as later on the kernel will need this name to identify your volume inside the ubi container and mount it. More on that below. Please check out the ubifs website for all the parameters and their meanings and tailor them to your needs.
Flashing to the board
Flashing the boards is as easy as with all the other images you are used to. You can either used nandwrite, mtd-info, or u-boots onenandwrite. I choose u-boot and so my u-boot command is looking something like this:
onenand ecc hw; tftp 80000000 igep-latest.ubi; onenand erase 580000 1FA80000 ; onenand write 80000000 580000 2080000
Of course the onenand write command will look different to you as my image had a size of 2080000 -- yours will be different. Just take the size you recieved by the tftp upload.
Mounting your rootfs
Now you are only 1step away from booting your ubifs. What you are still missing is a suitable kernel command line, so your linux knows where to look for his root device. Mine was flashed to /dev/mtd4 and therefore the command line looks like this:
set onenand-bootargs "setenv bootargs ${bootargs-base} ubi.mtd=4 root=ubi0:igep0020-rootfs rootfstype=ubifs"
You notice the vol_name which is given as parameter to the well known linux kernel parameter root=ubi0:igep0020-rootfs
Now when you boot up ( of course you have a compiled a linux kernel with ubifs support build in) your boot log should carry some entry similar to the following ones:
[ 5.311584] OneNAND version = 0x0031 [ 5.315216] Chip support all block unlock [ 5.315216] Chip has 2 plane [ 5.317596] Scanning device for bad blocks [ 5.500366] Creating 5 MTD partitions on "omap2-onenand": [ 5.505828] 0x00000000-0x00080000 : "X-Loader" [ 5.511505] 0x00080000-0x00200000 : "U-Boot" [ 5.516448] 0x00200000-0x00280000 : "U-Boot Env" [ 5.521789] 0x00280000-0x00580000 : "Kernel" [ 5.526947] 0x00580000-0x20000000 : "File System" [ 5.533782] UBI: attaching mtd4 to ubi0 [ 5.537719] UBI: physical eraseblock size: 262144 bytes (256 KiB) [ 5.544067] UBI: logical eraseblock size: 258048 bytes [ 5.549499] UBI: smallest flash I/O unit: 4096 [ 5.554260] UBI: sub-page size: 1024 [ 5.559020] UBI: VID header offset: 1024 (aligned 1024) [ 5.565063] UBI: data offset: 4096 [ 5.799438] UBI: attached mtd4 to ubi0 [ 5.803314] UBI: MTD device name: "File System" [ 5.808929] UBI: MTD device size: 506 MiB [ 5.813934] UBI: number of good PEBs: 2026 [ 5.818695] UBI: number of bad PEBs: 0 [ 5.823181] UBI: max. allowed volumes: 128 [ 5.827819] UBI: wear-leveling threshold: 4096 [ 5.832580] UBI: number of internal volumes: 1 [ 5.837066] UBI: number of user volumes: 1 [ 5.841552] UBI: available PEBs: 0 [ 5.846038] UBI: total number of reserved PEBs: 2026 [ 5.851074] UBI: number of PEBs reserved for bad PEB handling: 20 [ 5.857238] UBI: max/mean erase counter: 2/1 [ 5.861694] UBI: background thread "ubi_bgt0d" started, PID 317 ---------------------------- [ 6.040039] UBIFS: recovery needed [ 6.103118] UBIFS: recovery completed [ 6.106872] UBIFS: mounted UBI device 0, volume 0, name "igep0020-rootfs" [ 6.113739] UBIFS: file system size: 510935040 bytes (498960 KiB, 487 MiB, 1980 LEBs) [ 6.121826] UBIFS: journal size: 9420800 bytes (9200 KiB, 8 MiB, 37 LEBs) [ 6.129211] UBIFS: media format: 4 (latest is 4) [ 6.134399] UBIFS: default compressor: LZO [ 6.138549] UBIFS: reserved for root: 0 bytes (0 KiB) [ 6.144073] VFS: Mounted root (ubifs filesystem). [ 6.148925] Freeing init memory: 116K
voila your done and finished. Enjoy
Issues
Ive ran at some issues with some boards which came with existing bad blocks. Although the onenand driver ( and u-boot) show that they are aware of them , ubifs fails to initialize and mount. I will further investigate this and hopefully get an answer why the mighty ubifs fails to load on them. Comments are welcome.
I've also had this problems, you can solve it by booting on a SD card and writing the ubi filesystem with nandwrite, then it detects the badblocks correctly and boots. The whole process would be:
1.- boot into OS
2.- flash_eraseall /dev/mtd4
3.- nandwrite -p /dev/mtd4 rootfs.ubi
4.- reboot
Be careful with your distribution mtd-utils version, ubuntu 10.10 version of mtd-utils has a bug in mkfs.ubifs which doesn't allow the igep to boot from the newly created image. If you use ubuntu 10.10 download and compile yourself mtd-utils > 1.3. Here's a link to a discussion explaining this issue: [1]