Flashing NAND with UBIFS and burning fuses on an i.MX53 board using the MfgTool

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Flashing NAND with UBIFS and burning fuses on an i.MX53 board using the MfgTool

14,190 Views
mdc
Contributor V

Here are some guidelines on how to create a UBIFS NAND image and use the MfgTool (available on the i.MX53 page at freescale.com) to flash a board that contains NAND flash and also how to use the MfgTool to burn fuses.

 

First of all, the attached "wiki_ubifs.pdf" is from our internal wiki and has some good background on creating a UBIFS image. It's written for an i.MX35, but the concepts are relevant. Ignore the stuff towards the end about Redboot - we're using uboot for the MX53, see instructions below.

 

The following were the steps taken to create and flash a UBI file system on a custom i.MX53 board. The ubifs was created on an Ubuntu 64-bit 10.10 host, and was then flashed using the Mfgtool. The NAND was a 2GB Micron MT29F16G08ABACA.

Do need to make sure all the UBI stuff is turned on in the kernel config menu and that the desired mtd partitions are defined in the kernel mach directory, look at ltib/rpm/BUILD/linux/arch/arm/mach-mx5/mach_ard.c for an example.

First need some info on the NAND from the target. The following was run with the rootfs mounted from an SD card to get the NAND parameters to create the ubifs. If you don't have the ability to boot from SD, you could also add the below to a Mfgtool profile to get the info.

root@freescale ~$ cat /proc/mtd
dev:    size   erasesize  name
mtd0: 01000000 00080000 "bootloader"
mtd1: 00500000 00080000 "nand.kernel"
mtd2: 10000000 00080000 "nand.rootfs"
mtd3: 10000000 00080000 "nand.userfs1"
mtd4: 5eb00000 00080000 "nand.userfs2"

root@freescale ~$ ubidetach /dev/ubi_ctrl -m 2
UBI: mtd2 is detached from ubi0
root@freescale ~$ ubiformat /dev/mtd2
ubiformat: mtd2 (nand), size 268435456 bytes (256.0 MiB), 512 eraseblocks of 524288 bytes (512.0 KiB), min. I/O size 4096 bytes
libscan: scanning eraseblock 0 --  0 % complete
libscan: scanning eraseblock 1 --  0 % complete
libscan: scanning eraseblock 2 --  0 % complete
.
.
.
ubiformat: formatting eraseblock 511 -- 100 % complete 

root@freescale ~$ ubiattach /dev/ubi_ctrl -m 2
UBI: attaching mtd2 to ubi0
UBI: physical eraseblock size:   524288 bytes (512 KiB)
UBI: logical eraseblock size:    520192 bytes
UBI: smallest flash I/O unit:    4096
UBI: sub-page size:              1024
UBI: VID header offset:          1024 (aligned 1024)
UBI: data offset:                4096
UBI: attached mtd2 to ubi0
UBI: MTD device name:            "nand.rootfs"
UBI: MTD device size:            256 MiB
UBI: number of good PEBs:        512
UBI: number of bad PEBs:         0
UBI: max. allowed volumes:       128
UBI: wear-leveling threshold:    4096
UBI: number of internal volumes: 1
UBI: number of user volumes:     0
UBI: available PEBs:             503
UBI: total number of reserved PEBs: 9
UBI: number of PEBs reserved for bad PEB handling: 5
UBI: max/mean erase counter: 2/1
UBI: image sequence number: 1818357544
UBI: background thread "ubi_bgt0d" started, PID 2124
UBI device number 0, total 512 LEBs (266338304 bytes, 254.0 MiB), available 503 LEBs (261656576 bytes, 249.5 MiB), LEB size 520192 bytes (508.0 KiB)

Then move to the host and the following are the steps to create the ubifs.

$ sudo mkfs.ubifs -v -r rootfs -m 4096 -e 520192 -c 503 -o ubifs.img
mkfs.ubifs
    root:         rootfs/
    min_io_size:  4096
    leb_size:     520192
    max_leb_cnt:  503
    output:       ubifs.img
    jrn_size:     8388608
    reserved:     0
    compr:        lzo
    keyhash:      r5
    fanout:       8
    orph_lebs:    1
    super lebs:   1
    master lebs:  2
    log_lebs:     4
    lpt_lebs:     2
    orph_lebs:    1
    main_lebs:    57
    gc lebs:      1
    index lebs:   1
    leb_cnt:      67
    UUID:         6C021AF3-9C9D-4F00-A3B5-BBB215E56DE9
Success!

Note, before running ubinize, edit ubinize.cfg (see attached) and set vol_size = leb_size * max_leb_cnt.

$ sudo ubinize -v -o ubi.img -m 4096 -p 512KiB -s 1024 ubinize.cfg
ubinize: LEB size:                  520192
ubinize: PEB size:                  524288
ubinize: min. I/O size:             4096
ubinize: sub-page size:             1024
ubinize: VID offset:                1024
ubinize: data offset:               4096
ubinize: UBI image sequence number: 442085310
ubinize: loaded the ini-file "ubinize.cfg"
ubinize: count of sections: 1

ubinize: parsing section "ubifs"
ubinize: mode=ubi, keep parsing
ubinize: volume type: dynamic
ubinize: volume ID: 0
ubinize: volume size: 261095424 bytes
ubinize: volume name: rootfs
ubinize: volume alignment: 1
ubinize: autoresize flags found
ubinize: adding volume 0
ubinize: writing volume 0
ubinize: image file: ubifs.img

ubinize: writing layout volume
ubinize: done

$ sudo mv ubi.img rootfs.ubifs.img
$ ls -l *ubi*
-rw-r--r-- 1 root root 36175872 2011-07-14 10:37 rootfs.ubifs.img
-rw-r--r-- 1 root root 34852864 2011-07-14 10:34 ubifs.img
-rwxr-x--- 1 matt matt      113 2011-07-14 10:31 ubinize.cfg

Then copy rootfs.ubifs.img to the mfgtool files directory. This is the file name the ucl.xml file is looking for (can be changed in the xml if desired).

One final note - I had trouble using a UBI image I created on a 64-bit Ubuntu 10.10 system. I get a bad CRC and the image would not mount. The same rootfs directory copied to a 32-bit Ubuntu vmware image (vm image included on the QSB DVD, which is Ubuntu 10.04), and I was able to use the UBI image created.

======================================================================================

UBIFS error (pid 1): ubifs_check_node: bad CRC: calculated 0xad72356, read 0xae61acd0
UBIFS error (pid 1): ubifs_check_node: bad node at LEB 0:0
UBIFS error (pid 1): ubifs_read_node: expected node type 6
VFS: Cannot open root device "ubi0:rootfs" or unknown-block(0,0)
Please append a correct "root=" boot option; here are the available partitions:
1f00           16384 mtdblock0 (driver?)
1f01            5120 mtdblock1 (driver?)
1f02          262144 mtdblock2 (driver?)
1f03          262144 mtdblock3 (driver?)
1f04         1551360 mtdblock4 (driver?)
Kernel panic - not syncing: VFS: Unable to mount root fs on unknown-block(0,0)

Searching the internet, turns out there's a bug in mkfs.ubifs that included with mtd-utils in Ubuntu 10.10.

http://comments.gmane.org/gmane.linux.drivers.mtd/33352

Solved by uninstalling the version of mtd-utils included with 10.10 and building the latest mtd-utils:

$ sudo apt-get remove mtd-utils
$ git clone git://git.infradead.org/~dedekind/ubifs-userspace.git
$ cd mtd-utils
$ make
$ sudo make install

Note you need to have liblzo2-dev and libacl1-dev installed for the make to work.

Once I did this though LTIB was unable to create a ubi filesystem if selected in the Target Image Generation menu. Shouldn't be a problem if you create your ubifs manually outside of LTIB.

Finally, you'll want to set your u-boot env variables and kernel command line similar to what's below. The key variable is bootargs_nand - make sure the mtd partition and vol_name you set for your rootfs in ubinize.cfg match what's here.

setenv 'uboot=u-boot.bin'
setenv 'kernel=uImage'
setenv 'bootargs_base=setenv bootargs console=ttymxc0,115200'
setenv 'loadaddr=0x90800000'
setenv 'bootargs_nand=setenv bootargs ${bootargs} ip=none ubi.mtd=2 root=ubi0:rootfs rootfstype=ubifs rootwait rw'
setenv 'bootcmd_nand=run bootargs_base bootargs_nand;nand read ${loadaddr} 0x1000000 0x300000;bootm'
setenv 'bootcmd=run bootcmd_nand'

The attached mx53-fuse-ubifs-ucl.xml file can be used as the ucl.xml file for the Mfgtool. It has a few profiles added (look at the end of the file) to fuse a board to use the above flash, read the fuses back, program the nand flash, and fuse+program all at once.

 

DON’T use the NAND fuse profiles blindly on a board (i.e. the QuickStart board) or you will render it unbootable from anything but the above NAND. Look for the MX53-FUSE-EXAMPLE profile for an example that blows one of the general purpose fuses.

 

 

The following were the steps taken to create and flash a UBI file system on a customer's board. The ubifs was
created on an Ubuntu 64-bit 10.10 host, and was then flashed using the Mfgtool. The NAND was a 2GB Micron
MT29F16G08ABACA.

Do need to make sure all the UBI stuff is turned on in the kernel config menu and
that the desired mtd partitions are defined in the kernel mach directory,
look at ltib/rpm/BUILD/linux/arch/arm/mach-mx5/mach_ard.c for an example.

First need some info on the NAND from the target. The following was run with the rootfs mounted
from an SD card to get the NAND parameters to create the ubifs. If you don't have the ability
to boot from SD, you could also add the below plans to a Mfgtool profile to get the info.

root@freescale ~$ cat /proc/mtd
dev:    size   erasesize  name
mtd0: 01000000 00080000 "bootloader"
mtd1: 00500000 00080000 "nand.kernel"
mtd2: 10000000 00080000 "nand.rootfs"
mtd3: 10000000 00080000 "nand.userfs1"
mtd4: 5eb00000 00080000 "nand.userfs2"

root@freescale ~$ ubidetach /dev/ubi_ctrl -m 2
UBI: mtd2 is detached from ubi0
root@freescale ~$ ubiformat /dev/mtd2
ubiformat: mtd2 (nand), size 268435456 bytes (256.0 MiB), 512 eraseblocks of 524288 bytes (512.0 KiB), min. I/O size 4096 bytes
libscan: scanning eraseblock 0 --  0 % complete
libscan: scanning eraseblock 1 --  0 % complete
libscan: scanning eraseblock 2 --  0 % complete
.
.
.
ubiformat: formatting eraseblock 511 -- 100 % complete 

root@freescale ~$ ubiattach /dev/ubi_ctrl -m 2
UBI: attaching mtd2 to ubi0
UBI: physical eraseblock size:   524288 bytes (512 KiB)
UBI: logical eraseblock size:    520192 bytes
UBI: smallest flash I/O unit:    4096
UBI: sub-page size:              1024
UBI: VID header offset:          1024 (aligned 1024)
UBI: data offset:                4096
UBI: attached mtd2 to ubi0
UBI: MTD device name:            "nand.rootfs"
UBI: MTD device size:            256 MiB
UBI: number of good PEBs:        512
UBI: number of bad PEBs:         0
UBI: max. allowed volumes:       128
UBI: wear-leveling threshold:    4096
UBI: number of internal volumes: 1
UBI: number of user volumes:     0
UBI: available PEBs:             503
UBI: total number of reserved PEBs: 9
UBI: number of PEBs reserved for bad PEB handling: 5
UBI: max/mean erase counter: 2/1
UBI: image sequence number: 1818357544
UBI: background thread "ubi_bgt0d" started, PID 2124
UBI device number 0, total 512 LEBs (266338304 bytes, 254.0 MiB), available 503 LEBs (261656576 bytes, 249.5 MiB), LEB size 520192 bytes (508.0 KiB)

Then move to the host and the following are the steps to create the ubifs.

matt@Dell-M4500:~/imx/ge/11.03/ltib$ sudo mkfs.ubifs -v -r rootfs -m 4096 -e 520192 -c 503 -o ubifs.img
mkfs.ubifs
    root:         rootfs/
    min_io_size:  4096
    leb_size:     520192
    max_leb_cnt:  503
    output:       ubifs.img
    jrn_size:     8388608
    reserved:     0
    compr:        lzo
    keyhash:      r5
    fanout:       8
    orph_lebs:    1
    super lebs:   1
    master lebs:  2
    log_lebs:     4
    lpt_lebs:     2
    orph_lebs:    1
    main_lebs:    57
    gc lebs:      1
    index lebs:   1
    leb_cnt:      67
    UUID:         6C021AF3-9C9D-4F00-A3B5-BBB215E56DE9
Success!

Note, before running ubinize, edit ubinize.cfg and set vol_size = leb_size * max_leb_cnt.

matt@Dell-M4500:~/imx/ge/11.03/ltib$ sudo ubinize -v -o ubi.img -m 4096 -p 512KiB -s 1024 ubinize.cfg
ubinize: LEB size:                  520192
ubinize: PEB size:                  524288
ubinize: min. I/O size:             4096
ubinize: sub-page size:             1024
ubinize: VID offset:                1024
ubinize: data offset:               4096
ubinize: UBI image sequence number: 442085310
ubinize: loaded the ini-file "ubinize.cfg"
ubinize: count of sections: 1

ubinize: parsing section "ubifs"
ubinize: mode=ubi, keep parsing
ubinize: volume type: dynamic
ubinize: volume ID: 0
ubinize: volume size: 261095424 bytes
ubinize: volume name: rootfs
ubinize: volume alignment: 1
ubinize: autoresize flags found
ubinize: adding volume 0
ubinize: writing volume 0
ubinize: image file: ubifs.img

ubinize: writing layout volume
ubinize: done

matt@Dell-M4500:~/imx/ge/11.03/ltib$ sudo mv ubi.img rootfs.ubifs.img
matt@Dell-M4500:~/imx/ge/11.03/ltib$ ls -l *ubi*
-rw-r--r-- 1 root root 36175872 2011-07-14 10:37 rootfs.ubifs.img
-rw-r--r-- 1 root root 34852864 2011-07-14 10:34 ubifs.img
-rwxr-x--- 1 matt matt      113 2011-07-14 10:31 ubinize.cfg

Then copy rootfs.ubifs.img to the mfgtool files directory. This is the file name the ucl.xml file is lookinig for (can be changed in the xml if desired).

One final note - I had trouble using a UBI image I created on a 64-bit Ubuntu 10.10 system. I get a bad CRC and the image would not mount. The same rootfs directory copied to a 32-bit Ubuntu vmware image (vm image included on the QSB DVD, think is Ubuntu 10.04), and I was able to use the UBI image created.

======================================================================================

UBIFS error (pid 1): ubifs_check_node: bad CRC: calculated 0xad72356, read 0xae61acd0
UBIFS error (pid 1): ubifs_check_node: bad node at LEB 0:0
UBIFS error (pid 1): ubifs_read_node: expected node type 6
VFS: Cannot open root device "ubi0:rootfs" or unknown-block(0,0)
Please append a correct "root=" boot option; here are the available partitions:
1f00           16384 mtdblock0 (driver?)
1f01            5120 mtdblock1 (driver?)
1f02          262144 mtdblock2 (driver?)
1f03          262144 mtdblock3 (driver?)
1f04         1551360 mtdblock4 (driver?)
Kernel panic - not syncing: VFS: Unable to mount root fs on unknown-block(0,0)

Searching the internet, turns out there's a bug in mkfs.ubifs that included with mtd-utils in Ubuntu 10.10.

http://comments.gmane.org/gmane.linux.drivers.mtd/33352

Solved by uninstalling the version of mtd-utils included with 10.10 and building the latest mtd-utils:

$ sudo apt-get remove mtd-utils
$ git clone git://git.infradead.org/~dedekind/ubifs-userspace.git
$ cd mtd-utils
$ make
$ sudo make install

Note you need to have liblzo2-dev and libacl1-dev installed for the make to work.

Once I did this though LTIB was unable to create a ubi filesystem if selected in the
Target Image Generation menu. Shouldn't be a problem if you create your ubifs manually outside
of LTIB.

Finally, you'll want to set your u-boot env variables and kernel command line similar to what's below. The
key variable is bootargs_nand - make sure the mtd partition and vol_name you set for your rootfs in ubinize.cfg
match what's here.

setenv 'uboot=u-boot.bin'
setenv 'kernel=uImage'
setenv 'bootargs_base=setenv bootargs console=ttymxc0,115200'
setenv 'loadaddr=0x90800000'
setenv 'bootargs_nand=setenv bootargs ${bootargs} ip=none ubi.mtd=2 root=ubi0:rootfs rootfstype=ubifs rootwait rw'
setenv 'bootcmd_nand=run bootargs_base bootargs_nand;nand read ${loadaddr} 0x1000000 0x300000;bootm'
setenv 'bootcmd=run bootcmd_nand'

Original Attachment has been moved to: 654-ubinize.cfg

Original Attachment has been moved to: 655-mx53fuseubifsucl.xml

Labels (1)
0 Kudos
5 Replies

2,192 Views
sanu
Contributor I

Hi,

We are also trying to boot our imx53 based board from nand flash.

it is booting from nand flash but failed to load the root fs.

We tried jffs2 and ubifs both case kernel panic

see the ubifs log

VFS: Cannot open root device "ubi0:rootfs" or unknown-block(31,2)
Please append a correct "root=" boot option; here are the available partitions:
1f00           20480 mtdblock0 (driver?)
1f01            5120 mtdblock1 (driver?)
1f02          262144 mtdblock2 (driver?)
1f03          262144 mtdblock3 (driver?)
1f04          498688 mtdblock4 (driver?)
Kernel panic - not syncing: VFS: Unable to mount root fs on unknown-block(31,2)
[<8002a4d0>] (unwind_backtrace+0x0/0xf0) from [<802ed630>] (panic+0x5c/0xd8)
[<802ed630>] (panic+0x5c/0xd8) from [<80008d84>] (mount_block_root+0x258/0x2a8)
[<80008d84>] (mount_block_root+0x258/0x2a8) from [<80008f50>] (prepare_namespace+0x11c/0x174)
[<80008f50>] (prepare_namespace+0x11c/0x174) from [<80008480>] (kernel_init+0x120/0x168)
[<80008480>] (kernel_init+0x120/0x168) from [<800269c8>] (kernel_thread_exit+0x0/0x8)

We are using ltib 11.09 version only

0 Kudos

2,193 Views
hitlin37
Contributor I
I got my rootfs and kernel up from Nand.(i was missing some nand settings in kernel options.)

Are you booting u-boot from NAND,as im not seeing any message when im trying to boot u-boot from nand.

My board is based on mx53 .

0 Kudos

2,193 Views
hitlin37
Contributor I

Thanks for your reply.


Yes i have started downloading 11.09.

Will update here the status.

Regards

Suvir
Matt Clemens said:

I was using 11.03 when I was testing this. I didn't change anything in the NAND driver. FYI, 11.09 is now available on the mx53 page on freescale.com so you might try that and see if it impacts what you are seeing.
0 Kudos

2,193 Views
mdc
Contributor V
I was using 11.03 when I was testing this. I didn't change anything in the NAND driver. FYI, 11.09 is now available on the mx53 page on freescale.com so you might try that and see if it impacts what you are seeing.
0 Kudos

2,193 Views
hitlin37
Contributor I

Can you please share your ltib version?

Did you change anyhting in nand driver for your nand chip as we are facing problems

(UnCorrectable RS-ECC Error

Data Read ) when writing from kernel.

In our case writing to nand from u-boot works fine.

Thanks in advance

Regards

Suvir

0 Kudos