Project

General

Profile

Create ubifs

Added by Mary Frantz about 9 years ago

I need to create a ubifs. Our product will not have a SD card interface, so first article booting will have to be over UART. I understand how to load MLO, U-boot, and the kernel image into NAND.

I have the EVM board: 3354-GX-X38RC

I have already created a new kernel image. I will use the MLO and u-boot.img from the SD card that came with the kit.

I have a question about creating a ubi.img file.

Here are the instructions from: https://support.criticallink.com/redmine/projects/armc8-platforms/wiki/UBIFS_Nand_Boot

Creating UBIFS file system

Create config: ubinize.cfg

  mtd-utils# vi ubinize.cfg
  [ubifs]                <== Section header
  mode=ubi              <== Volume mode (other option is static)
  image=ubifs.img       <== Source image
  vol_id=0              <== Volume ID in UBI image
  vol_size=192MiB       <== Volume size
  vol_type=dynamic      <== Allow for dynamic resize
  vol_name=rootfs       <== Volume name
  vol_flags=autoresize  <== Autoresize volume at first mount

Create image: ubi.img

sudo mkfs.ubifs -r filesystem/ -F -o ubifs.img -m 4096 -e 253952 -c 1580
ubinize -o ubi.img -m 4096 -p 256KiB -s 4096 -O 4096 ubinize.cfg

Where "filesystem/" is an exported root filesystem less than 382MiB. If more space is needed the LEB (-c) number can be set to 1991 which will fill the partition and give about 482MiB of filesystem space. 
The ubinize.cfg is set to autoresize so if the image is smaller than the available space it will expand to fit the first time ubiattach is called on it.

What is a "exported root filesystem"? How do I create the ubifs from the rfs on the EVM's SD card? Is there a baseline ubi.img file somewhere? I just need a basic rfs that doesn't load all the demo firmware, as we will not have a display either.

Mary


Replies (12)

RE: Create ubifs - Added by Bob Duke about 9 years ago

Hi Mary,

The exported root filesystem is the contents of the rootfs partition on your SD card. If you mount your SD on a Linux host, you can archive that partition using tar:

$ cd /path/to/mounted/sdcard/rootfs
$ sudo tar czvf ~/rootfs.tar.gz .
$ cd ~/
$ mkdir exported_root
$ cd exported_root
$ sudo tar zxvf ../rootfs.tar.gz .

There are other ways to do this. Just make sure you do the tar operation as the root user.

If you follow these steps, the "exported root filesystem" would be in ~/exported_root.

You can download a very basic rootfs from the Files tab, but you'll need to test it to make sure it has everything you need. It may be easier to disable/remove unnecessary items from your current rootfs.

https://support.criticallink.com/redmine/projects/armc8-platforms/files
Filename: Angstrom-mityarm335x-base-eglibc-ipk-v2012.05-mityarm335x.rootfs.tar.bz2

-Bob

RE: Create ubifs - Added by Mary Frantz about 9 years ago

I downloaded the base rfs from the Files tab. Ran the following:

$ sudo apt-get install mtd-utils

$ sudo mkfs.ubifs -r exported_base_root/ -F -o ubifs.img -m 4096 -e 253952 -c 1580
mkfs.ubifs: invalid option -- 'F'
Usage: mkfs.ubifs [OPTIONS] target
Make a UBIFS file system image from an existing directory tree

Examples:
Build file system from directory /opt/img, writting the result in the ubifs.img file
    mkfs.ubifs -m 512 -e 128KiB -c 100 -r /opt/img ubifs.img
The same, but writting directly to an UBI volume
    mkfs.ubifs -r /opt/img /dev/ubi0_0
Creating an empty UBIFS filesystem on an UBI volume
    mkfs.ubifs /dev/ubi0_0

Options:
-r, -d, --root=DIR       build file system from directory DIR
-m, --min-io-size=SIZE   minimum I/O unit size
-e, --leb-size=SIZE      logical erase block size
-c, --max-leb-cnt=COUNT  maximum logical erase block count
-o, --output=FILE        output to FILE
-j, --jrn-size=SIZE      journal size
-R, --reserved=SIZE      how much space should be reserved for the super-user
-x, --compr=TYPE         compression type - "lzo", "favor_lzo", "zlib" or
                         "none" (default: "lzo")
-X, --favor-percent      may only be used with favor LZO compression and defines
                         how many percent better zlib should compress to make
                         mkfs.ubifs use zlib instead of LZO (default 20%)
-f, --fanout=NUM         fanout NUM (default: 8)
-k, --keyhash=TYPE       key hash type - "r5" or "test" (default: "r5")
-p, --orph-lebs=COUNT    count of erase blocks for orphans (default: 1)
-D, --devtable=FILE      use device table FILE
-U, --squash-uids        squash owners making all files owned by root
-l, --log-lebs=COUNT     count of erase blocks for the log (used only for
                         debugging)
-v, --verbose            verbose operation
-V, --version            display version information
-g, --debug=LEVEL        display debug information (0 - none, 1 - statistics,
                         2 - files, 3 - more details)
-h, --help               display this help text

Note, SIZE is specified in bytes, but it may also be specified in Kilobytes,
Megabytes, and Gigabytes if a KiB, MiB, or GiB suffix is used.

If you specify "lzo" or "zlib" compressors, mkfs.ubifs will use this compressor
for all data. The "none" disables any data compression. The "favor_lzo" is not
really a separate compressor. It is just a method of combining "lzo" and "zlib" 
compressors. Namely, mkfs.ubifs tries to compress data with both "lzo" and "zlib" 
compressors, then it compares which compressor is better. If "zlib" compresses 20
or more percent better than "lzo", mkfs.ubifs chooses "lzo", otherwise it chooses
"zlib". The "--favor-percent" may specify arbitrary threshold instead of the
default 20%.

The -R parameter specifies amount of bytes reserved for the super-user.

In the mtd-utils.control file the version is given as 1.4.4-r0.6

This predates the -F option. see http://www.linux-mtd.infradead.org/index.html

How do I install the latest version of mkfs.ubifs?

Mary

RE: Create ubifs - Added by Jonathan Cormier about 9 years ago

Here is a copy of instructions from the 1GB part. I'm going to copy it for the other parts as well.

Note: The "-F" option enables free space fixup. The version of mkfs.ubifs that ships with older versions of ubuntu will probably not have this option. If you are using the ubiformat tool from linux to flash you image than you can do without it. If you are flashing from u-boot it is a necessary option and you may have to build the latest version of mtd-utils.

RE: Create ubifs - Added by Mary Frantz about 9 years ago

I recompiled mtd-utils and made a ubi.img.

Also recompiled u-boot to get u-boot-spl.bin from u-boot-2013.10

Booted over UART, loaded u-boot-spl.bin, loaded u-boot.img and booted u-boot.

So far, so good.

Loaded NAND as follows:
MLO at 0x0
MLO at 0x4000
MLO at 0x8000
MLO at 0xc000
u-boot at 0x100000
uImage at 0x340000
ubi.img at 0x840000

Pulled out the SD card.
Set boot cfg pins:
[11 .. 0]
000011110011 (ROM handles ECC) ---> goes to UART boot (CCCCCCCCCC...)
001011110011 (NAND handles ECC) ----> nothing, bricked, no output on console

DK# 80-000587
SOM# 3354-GX-X38-RC

The MLO doesn't seem to be running. What did I do wrong?

I tried loading u-boot-spl.bin, the MLO from the SD card in the dev kit, and the MLO created when I recompiled u-boot. Same results.
Mary

RE: Create ubifs - Added by Mary Frantz about 9 years ago

From that page:

To boot from Nand: Pins 2,3,8,9,10,11
BOOTCONFIG [0..11]
::[:][:]::::[:][:][:][:]

That's the same as above (the pins are pulled up, so jumpers set the input to 0):

Set boot cfg pins:
[11 .. 0]
000011110011 (ROM handles ECC) ---> goes to UART boot (CCCCCCCCCC...)

RE: Create ubifs - Added by Jonathan Cormier about 9 years ago

Right, I forgot that they were inverted.

I'm not seeing anything wrong in what you posted, could you provide the console log when you program it?

Also when you rebuilt u-boot did you use the mityarm335x_4kpage config?

RE: Create ubifs - Added by Mary Frantz about 9 years ago

See attached console log file.

Yes. I did the following:

#bash> cd ~/projects
#bash> mkdir u-boot-2013.10
#bash> cd u-boot-2013.10

#bash> git clone git://support.criticallink.com/home/git/u-boot-mityarm-335x.git u-boot-mityarm-335x
#bash> cd u-boot-mityarm-335x
#bash> git checkout -b  u-boot-2013.10 origin/u-boot-2013.10

(this last call failed "fatal: git checkout: branch u-boot-2013.10 already exists")

# establish proper toolchain

user@host: . /usr/local/ti-sdk-am335x-evm-05.03.02.00/linux-devkit/environment-setup    
[linux-devkit]:~> alias makearm='make ARCH=arm CROSS_COMPILE=arm-arago-linux-gnueabi-'

Now you are ready to configure and compile the u-boot image.
In u-boot-2013.10 branch three configs are available:
    mityarm335x - Config for 3359 modules and 3354/2 modules with 256MB of NAND.
    mityarm335x_askram - Config set to ask user for ram config on boot.
    mityarm335x_4kpage - Config for 335x modules with 512MB of NAND.
    mityarm335x_1gb_nand - Config for 335x modules with 1GB of NAND

Example shown for mityarm335x 512MB config option

#bash> makearm mityarm335x_4kpage

NandWriteMLO_U-boot.txt (2.36 KB) NandWriteMLO_U-boot.txt Console log for programmng MLO and u-boot.img

RE: Create ubifs - Added by Mary Frantz about 9 years ago

So, of course, after reloading MLO and u-boot.img to get the console log....it boots from NAND.

RE: Create ubifs - Added by Jonathan Cormier about 9 years ago

Ran the same commands on our board and was able to boot from nand. Note that I didn't boot from UART but this shouldn't matter.

I started from a newer u-boot version but there doesn't appear to be any relevant changes between your version and mine. The only notable change is the following commit: "net: cpsw: am335x: Drop constant link checking from rx/tx path's" which increases the tftp throughput which you may notice when comparing your log with mine.

Could you post the MLO and u-boot.img that you are flashing?

RE: Create ubifs - Added by Jonathan Cormier about 9 years ago

Mary Frantz wrote:

So, of course, after reloading MLO and u-boot.img to get the console log....it boots from NAND.

Go figure. Glad you got it working. If your going to be flashing a bunch of units over UART, you may want to update UART u-boot to get the tftp speed fix.

RE: Create ubifs - Added by Mary Frantz about 9 years ago

My mistake... misstyped MLO load addresses (0x4000 instead of 0x40000).

Started over an loaded everything from the UART boot. Successfully.

    (1-12/12)
    Go to top
    Add picture from clipboard (Maximum size: 1 GB)