write bootpartition<>.tgz & rootfs<>.tgz to nand using ubifs

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

write bootpartition<>.tgz & rootfs<>.tgz to nand using ubifs

Jump to solution
739 Views
sergey_gavrish
Contributor II

Custom board, ls1046ardb based. LSDK 2012 or 2108. NANDchip is mt29f8g08....

Builded output images are "-b" "-r" "-f" : bootpartition, rootfs & firmware - placed to SDcard.

Firmware write on qspi_NOR.

How to write bootpartition and rootfs through uboot using ubifs on ifc_NAND, and boot from this?

...tfa_defconfig now has next options:

+CONFIG_MTD_DEVICE=y
+CONFIG_MTD_PARTITIONS=y
+CONFIG_CMD_MTDPARTS=y
+CONFIG_CMD_UBI=y
+CONFIG_RBTREE=y
+CONFIG_CMD_UBIFS=y
+CONFIG_LZO=y

=> nand erase.chip

NAND erase.chip: device 0 whole chip........OK

=> env print mtdparts
mtdparts=mtdparts=7e800000.flash:256m(boot),768m(rootfs) //I'd setup this myself

=> mtdparts

device nand0 <7e800000.flash>, # parts = 2
#: name size offset mask_flags
0: boot 0x10000000 0x00000000 0
1: rootfs 0x28000000 0x10000000 0

active partition: nand0,0 - (boot) 0x10000000 @ 0x00000000

=> ubi part boot
ubi0: attaching mtd1
ubi0: scanning is finished
ubi0: empty MTD device detected
ubi0: attached mtd1 (name "boot", size 256 MiB)
ubi0: PEB size: 262144 bytes (256 KiB), LEB size: 253952 bytes
ubi0: min./max. I/O unit sizes: 4096/4096, sub-page size 4096
ubi0: VID header offset: 4096 (aligned 4096), data offset: 8192
ubi0: good PEBs: 1024, bad PEBs: 0, corrupted PEBs: 0
ubi0: user volume: 0, internal volumes: 1, max. volumes count: 128
ubi0: max/mean erase counter: 0/0, WL threshold: 4096, image sequence number: 0
ubi0: available PEBs: 940, total reserved PEBs: 84, PEBs reserved for bad PEB handling: 80

=> ubi create boot
No size specified -> Using max size (238714880)
Creating dynamic volume boot of size 238714880

=> ubifsmount ubi0:boot
UBIFS error (ubi0:0 pid 0): mount_ubifs: can't format empty UBI volume: read-only mount
Error reading superblock on volume 'ubi0:boot' errno=-30!

 

Also reading some docs i need to change uboot env bootargsbootcmd..?

0 Kudos
1 Solution
666 Views
yipingwang
NXP TechSupport
NXP TechSupport

No need to  write "Image" and "fsl-ls1046a-rdb-sdk.dtb" to ubi rootfs

View solution in original post

0 Kudos
4 Replies
705 Views
sergey_gavrish
Contributor II

Thank you for answer. The sequence is working. But one more question is still open.

So "Image" and "fsl-ls1046a-rdb-sdk.dtb" I had load for test from MMC, its clear that I also can do this from qspi through "sf read" command. But how to load it from ubi in u-boot, if they was previously writing in linux on another mtd partition by a way like rootfs?

root@localhost:~# cat /proc/mtd
dev: size erasesize name
mtd0: 08000000 00040000 "boot"
mtd1: 08000000 00040000 "backup"
mtd2: 30000000 00040000 "system"
mtd3: 04000000 00010000 "1550000.spi"

root@localhost:~# ubiattach /dev/ubi_ctrl -m 2
UBI device number 0, total 3068 LEBs (779124736 bytes, 743.0 MiB), available 2860 LEBs (726302720 bytes, 692.6 MiB), LEB size 253952 bytes (248.0 KiB)
root@localhost:~# cat /sys/class/ubi/ubi0/max_vol_count
128
root@localhost:~# mount -t ubifs ubi0_0 /tmp

root@localhost:~# ls -l /tmp/
total 15916
drwxr-xr-x 2 root root 5416 Nov 18 2022 bin
drwxr-xr-x 4 root root 608 Nov 2 2022 dev
drwxr-xr-x 10 root root 2392 Nov 18 2022 etc
drwxr-xr-x 5 root root 3832 Nov 18 2022 lib
lrwxrwxrwx 1 root root 3 Nov 2 2022 lib64 -> lib
drwxr-xr-x 2 root root 224 Nov 18 2022 libexec
lrwxrwxrwx 1 root root 11 Nov 2 2022 linuxrc -> bin/busybox
drwxr-xr-x 2 root root 160 Nov 2 2022 media
drwxr-xr-x 2 root root 160 Nov 2 2022 mnt
drwxr-xr-x 2 root root 160 Nov 2 2022 opt
drwxr-xr-x 2 root root 160 Nov 2 2022 proc
drwxr-xr-x 2 root root 232 Jan 1 1970 root
-rw-r--r-- 1 root root 16294932 Jul 21 2021 rootfs_lsdk2108_buildroot_tiny_arm64.tgz
drwxr-xr-x 5 root root 352 Jan 1 1970 run
drwxr-xr-x 2 root root 6640 Nov 18 2022 sbin
drwxr-xr-x 2 root root 160 Nov 2 2022 sys
drwxr-xr-x 3 root root 224 Nov 2 2022 tmp
drwxr-xr-x 4 root root 352 Nov 18 2022 usr
drwxr-xr-x 3 root root 224 Jan 1 1970 var

root@localhost:~# ls /dev/ub*
/dev/ubi0 /dev/ubi0_0 /dev/ubi_ctrl

root@localhost:~# flash_erase /dev/mtd0 0 0
Erasing 256 Kibyte @ 7fc0000 -- 100 % complete
root@localhost:~# ubiattach /dev/ubi_ctrl -m 0
UBI device number 1, total 512 LEBs (130023424 bytes, 124.0 MiB), available 428 LEBs (108691456 bytes, 103.6 MiB), LEB size 253952 bytes (248.0 KiB)
root@localhost:~# ls /dev/ub*
/dev/ubi0 /dev/ubi0_0 /dev/ubi1 /dev/ubi_ctrl

root@localhost:~# cat /sys/class/ubi/ubi1/max_vol_count
128
root@localhost:~# ubimkvol /dev/ubi1 -N ubi_boot -S 128
Volume ID 0, size 128 LEBs (32505856 bytes, 31.0 MiB), LEB size 253952 bytes (248.0 KiB), dynamic, name "ubi_boot", alignment 1
root@localhost:~# mkdir /tmp_boot/
root@localhost:~# ls /dev/ub*
/dev/ubi0 /dev/ubi0_0 /dev/ubi1 /dev/ubi1_0 /dev/ubi_ctrl
root@localhost:~# mount -t ubifs ubi1_0 /tmp_boot/

root@localhost:~# cp /boot/Image /tmp_boot/

root@localhost:~# cp /boot/fsl-ls1046a-rdb-sdk.dtb /tmp_boot/

0 Kudos
667 Views
yipingwang
NXP TechSupport
NXP TechSupport

No need to  write "Image" and "fsl-ls1046a-rdb-sdk.dtb" to ubi rootfs

0 Kudos
661 Views
sergey_gavrish
Contributor II

Nice answer

By other way thank you at all

0 Kudos
724 Views
yipingwang
NXP TechSupport
NXP TechSupport

Please refer to the following example on LS1043ARDB.

Boot the target board with the following Kernel command line.

Kernel command line: root=/dev/mmcblk0p4 rw rootdelay=10 console=ttyS0,115200 ramdisk_size=0x10000000 mtdparts=60000000.nor:1m(nor_bank0_rcw),2m(nor_bank0_uboot),13m(nor_bank0_uboot_env),48m(nor_bank0_itb),1m(nor_bank4_rcw),2m(nor_bank4_uboot),13m(nor_bank4_uboot_env),48m(nor_Usertest);7e800000.flash:1m(nand_uboot),1m(nand_uboot_env),60m(nand_Usertest);spi0.0:1m(uboot),5m(kernel),1m(dtb),9m(dspi_Usertest)

In Linux, do the following operation to deploy ubi rootfs.

root@localhost:~# zcat /proc/config.gz | grep CONFIG_MTD_UBI=y
CONFIG_MTD_UBI=y

root@localhost:~# mtdinfo /dev/mtd10
mtd10
Name: nand_Usertest
Type: nand
Eraseblock size: 131072 bytes, 128.0 KiB
Amount of eraseblocks: 480 (62914560 bytes, 60.0 MiB)
Minimum input/output unit size: 2048 bytes
Sub-page size: 2048 bytes
OOB size: 64 bytes
Character device major/minor: 90:20
Bad blocks are allowed: true
Device is writable: true

root@localhost:~# flash_erase /dev/mtd10 0 0

root@localhost:~# ubiattach /dev/ubi_ctrl -m 10

root@localhost:~# cat /sys/class/ubi/ubi0/max_vol_count
128

root@localhost:~# ubimkvol /dev/ubi0 -N ubi_rootfs -S 128

root@localhost:~# mount -t ubifs ubi0_0 /tmp

root@localhost:~# cp rootfs.tgz /tmp

root@localhost:~# cd /tmp

root@localhost:~# tar -xzvf rootfs.tgz

Reboot the target board, in u-boot configure bootargs as the following.

=> setenv bootargs ubi.mtd=10 root=ubi0_0 rw rootfstype=ubifs rootdelay=10 console=ttyS0,115200 mtdparts=60000000.nor:1m(nor_bank0_rcw),2m(nor_bank0_uboot),13m(nor_bank0_uboot_env),48m(nor_bank0_itb),1m(nor_bank4_rcw),2m(nor_bank4_uboot),13m(nor_bank4_uboot_env),48m(nor_Usertest)\;7e800000.flash:1m(nand_uboot),1m(nand_uboot_env),60m(nand_Usertest)\;spi0.0:1m(uboot),5m(kernel),1m(dtb),9m(dspi_Usertest)

=> tftp 0x82000000 Image

=> tftp 0x8f000000 fsl-ls1043a-rdb-sdk.dtb

=> booti 0x82000000 - 0x8f000000

0 Kudos