UBIFS rootfs_data with ramboot rootfs

Hello, I have a problem with mounting my ubifs partitions as a overlay rw part. After reboot all changes dissapears. I have kernel+dtb+rootfs FIT image.
OpenWRT 21.02.0 tag

nand
[    1.010826] nand: device found, Manufacturer ID: 0xc8, Chip ID: 0xd1
[    1.017182] nand: ESMT NAND 128MiB 3,3V 8-bit
[    1.021514] nand: 128 MiB, SLC, erase size: 128 KiB, page size: 2048, OOB size: 64
[    1.029407] Bad block table found at page 65472, version 0x01
[    1.035706] Bad block table found at page 65408, version 0x01
[    1.042126] 2 fixed-partitions partitions found on MTD device 60000000.flash
[    1.049158] Creating 2 MTD partitions on "60000000.flash":
[    1.054617] 0x000000000000-0x000000200000 : "u-boot"
[    1.060258] 0x000000200000-0x000008000000 : "ubi"
ubi
[    1.434047] ubi0: attaching mtd1
[    1.497685] random: fast init done
[    2.068628] ubi0: scanning is finished
[    2.082669] ubi0: attached mtd1 (name "ubi", size 126 MiB)
[    2.088188] ubi0: PEB size: 131072 bytes (128 KiB), LEB size: 126976 bytes
[    2.095031] ubi0: min./max. I/O unit sizes: 2048/2048, sub-page size 2048
[    2.101806] ubi0: VID header offset: 2048 (aligned 2048), data offset: 4096
[    2.108767] ubi0: good PEBs: 1004, bad PEBs: 4, corrupted PEBs: 0
[    2.114831] ubi0: user volume: 5, internal volumes: 1, max. volumes count: 128
[    2.122040] ubi0: max/mean erase counter: 2/0, WL threshold: 4096, image sequence number: 1640802555
[    2.131153] ubi0: available PEBs: 0, total reserved PEBs: 1004, PEBs reserved for bad PEB handling: 16
[    2.140458] ubi0: background thread "ubi_bgt0d" started, PID 73

Image was created with the help of append-ubi, but add second rootfs

ubinize parameters
[u-boot-env-1]
mode=ubi
vol_id=0
vol_type=dynamic
vol_name=u-boot-env-1
vol_size=1MiB
[u-boot-env-2]
mode=ubi
vol_id=1
vol_type=dynamic
vol_name=u-boot-env-2
vol_size=1MiB
[rootfsa]
mode=ubi
vol_id=2
vol_type=dynamic
vol_name=rootfsa
image=openwrt-layerscape-armv7-fsl_ls1021a-nand-squashfs-factory.bin
vol_size=35MiB
[rootfsb]
mode=ubi
vol_id=3
vol_type=dynamic
vol_name=rootfsb
image=/openwrt-layerscape-armv7-fsl_ls1021a-nand-squashfs-factory.bin
vol_size=35MiB
[rootfs_data]
mode=ubi
vol_id=4
vol_type=dynamic
vol_name=rootfs_data
vol_size=1MiB
vol_flags=autoresize

But when it tries to mount rootfs_data, it throw error and mount f2fs tmpfs overlay instead:

overlay mount
[    8.237678] mount_root: loading kmods from internal overlay
[    8.251450] kmodloader: loading kernel modules from //etc/modules-boot.d/*
[    8.259085] kmodloader: done loading kernel modules from //etc/modules-boot.d/*
[    8.657645] UBIFS (ubi0:4): default file-system created
[    8.663487] UBIFS (ubi0:4): Mounting in unauthenticated mode
[    8.667458] urandom_read: 5 callbacks suppressed
[    8.667464] random: procd: uninitialized urandom read (4 bytes read)
[    8.680230] UBIFS (ubi0:4): background thread "ubifs_bgt0_4" started, PID 158
[    8.748536] UBIFS (ubi0:4): UBIFS: mounted UBI device 0, volume 4, name "rootfs_data"
[    8.756341] UBIFS (ubi0:4): LEB size: 126976 bytes (124 KiB), min./max. I/O unit sizes: 2048 bytes/2048 bytes
[    8.766273] UBIFS (ubi0:4): FS size: 47742976 bytes (45 MiB, 376 LEBs), journal size 2412544 bytes (2 MiB, 19 LEBs)
[    8.776682] UBIFS (ubi0:4): reserved for root: 2255018 bytes (2202 KiB)
[    8.783291] UBIFS (ubi0:4): media format: w5/r0 (latest is w5/r0), UUID D7E31124-F8DD-40DE-BF7B-65455F6C831A, small LPT model
[    8.795381] block: attempting to load /tmp/ubifs_cfg/upper/etc/config/fstab
[    8.802452] block: unable to load configuration (fstab: Entry not found)
[    8.809193] block: attempting to load /tmp/ubifs_cfg/etc/config/fstab
[    8.815650] block: unable to load configuration (fstab: Entry not found)
[    8.822381] block: attempting to load /etc/config/fstab
[    8.829069] block: unable to load configuration (fstab: Entry not found)
[    8.835762] block: no usable configuration
[    8.843355] UBIFS (ubi0:4): un-mount UBI device 0
[    8.848079] UBIFS (ubi0:4): background thread "ubifs_bgt0_4" stops
[    8.917420] mount_root: rootdisk overlay filesystem has not been formatted yet
[    9.026251] random: mkfs.f2fs: uninitialized urandom read (16 bytes read)
[    9.125564] F2FS-fs (loop0): Found nat_bits in checkpoint
[    9.143772] F2FS-fs (loop0): Mounted with checkpoint version = 351ed69f
[    9.327298] fsl-gianfar soc:ethernet@2d10000 eth0: Link is Up - 1Gbps/Full - flow control off
[    9.335835] IPv6: ADDRCONF(NETDEV_CHANGE): eth0: link becomes ready
[    9.447037] UBIFS (ubi0:4): Mounting in unauthenticated mode
[    9.452851] UBIFS (ubi0:4): background thread "ubifs_bgt0_4" started, PID 166
[    9.513820] UBIFS (ubi0:4): UBIFS: mounted UBI device 0, volume 4, name "rootfs_data"
[    9.521679] UBIFS (ubi0:4): LEB size: 126976 bytes (124 KiB), min./max. I/O unit sizes: 2048 bytes/2048 bytes
[    9.531588] UBIFS (ubi0:4): FS size: 47742976 bytes (45 MiB, 376 LEBs), journal size 2412544 bytes (2 MiB, 19 LEBs)
[    9.541994] UBIFS (ubi0:4): reserved for root: 2255018 bytes (2202 KiB)
[    9.548611] UBIFS (ubi0:4): media format: w5/r0 (latest is w5/r0), UUID D7E31124-F8DD-40DE-BF7B-65455F6C831A, small LPT model
[    9.560691] block: attempting to load /tmp/ubifs_cfg/upper/etc/config/fstab
[    9.567768] block: unable to load configuration (fstab: Entry not found)
[    9.574467] block: attempting to load /tmp/ubifs_cfg/etc/config/fstab
[    9.580968] block: unable to load configuration (fstab: Entry not found)
[    9.587698] block: attempting to load /etc/config/fstab
[    9.592940] block: unable to load configuration (fstab: Entry not found)
[    9.599661] block: no usable configuration
[    9.607200] UBIFS (ubi0:4): un-mount UBI device 0
[    9.611908] UBIFS (ubi0:4): background thread "ubifs_bgt0_4" stops
[    9.620662] mount_root: overlay filesystem has not been fully initialized yet
[    9.628094] mount_root: switching to f2fs overlay

Some system commands:

cat /proc/mtd
root@OpenWrt:/# cat /proc/mtd
dev:    size   erasesize  name
mtd0: 00200000 00020000 "u-boot"
mtd1: 07e00000 00020000 "ubi"
mtd2: 00117000 0001f000 "u-boot-env-1"
mtd3: 00117000 0001f000 "u-boot-env-2"
mtd4: 0231e000 0001f000 "rootfsa"
mtd5: 0231e000 0001f000 "rootfsb"
mtd6: 02ebe000 0001f000 "rootfs_data"
ubinfo -a
UBI version:                    1
Count of UBI devices:           1
UBI control device major/minor: 10:62
Present UBI devices:            ubi0

ubi0
Volumes count:                           5
Logical eraseblock size:                 126976 bytes, 124.0 KiB
Total amount of logical eraseblocks:     1004 (127483904 bytes, 121.5 MiB)
Amount of available logical eraseblocks: 0 (0 bytes)
Maximum count of volumes                 128
Count of bad physical eraseblocks:       4
Count of reserved physical eraseblocks:  16
Current maximum erase counter value:     2
Minimum input/output unit size:          2048 bytes
Character device major/minor:            244:0
Present volumes:                         0, 1, 2, 3, 4

Volume ID:   0 (on ubi0)
Type:        dynamic
Alignment:   1
Size:        9 LEBs (1142784 bytes, 1.0 MiB)
State:       OK
Name:        u-boot-env-1
Character device major/minor: 244:1
-----------------------------------
Volume ID:   1 (on ubi0)
Type:        dynamic
Alignment:   1
Size:        9 LEBs (1142784 bytes, 1.0 MiB)
State:       OK
Name:        u-boot-env-2
Character device major/minor: 244:2
-----------------------------------
Volume ID:   2 (on ubi0)
Type:        dynamic
Alignment:   1
Size:        290 LEBs (36823040 bytes, 35.1 MiB)
State:       OK
Name:        rootfsa
Character device major/minor: 244:3
-----------------------------------
Volume ID:   3 (on ubi0)
Type:        dynamic
Alignment:   1
Size:        290 LEBs (36823040 bytes, 35.1 MiB)
State:       OK
Name:        rootfsb
Character device major/minor: 244:4
-----------------------------------
Volume ID:   4 (on ubi0)
Type:        dynamic
Alignment:   1
Size:        386 LEBs (49012736 bytes, 46.7 MiB)
State:       OK
Name:        rootfs_data
Character device major/minor: 244:5
mount
root@OpenWrt:/# mount
/dev/root on /rom type squashfs (ro,relatime)
proc on /proc type proc (rw,nosuid,nodev,noexec,noatime)
sysfs on /sys type sysfs (rw,nosuid,nodev,noexec,noatime)
cgroup2 on /sys/fs/cgroup type cgroup2 (rw,nosuid,nodev,noexec,relatime,nsdelegate)
tmpfs on /tmp type tmpfs (rw,nosuid,nodev,noatime)
/dev/loop0 on /overlay type f2fs (rw,lazytime,noatime,background_gc=on,discard,no_heap,user_xattr,inline_xattr,inline_data,inline_dentry,flush_merge,extent_cache,mode=adaptive,active_logs=6,alloc_mode=reuse,fsync_mode=posix)
overlayfs:/overlay on / type overlay (rw,noatime,lowerdir=/,upperdir=/overlay/upper,workdir=/overlay/work)
tmpfs on /dev type tmpfs (rw,nosuid,relatime,size=512k,mode=755)
devpts on /dev/pts type devpts (rw,nosuid,noexec,relatime,mode=600,ptmxmode=000)
debugfs on /sys/kernel/debug type debugfs (rw,noatime)
none on /sys/fs/bpf type bpf (rw,nosuid,nodev,noexec,noatime,mode=700)
pstore on /sys/fs/pstore type pstore (rw,noatime)
mountd(pid1807) on /tmp/run/blockd type autofs (rw,relatime,fd=7,pgrp=1,timeout=30,minproto=5,maxproto=5,indirect,pipe_ino=4057)
block info
root@OpenWrt:/# block info
/dev/mtdblock1: UUID="1640802555" VERSION="1" TYPE="ubi"
/dev/mtdblock6: UUID="d7e31124-f8dd-40de-bf7b-65455f6c831a" VERSION="w5r0" TYPE="ubifs"
/dev/ubi0_4: UUID="d7e31124-f8dd-40de-bf7b-65455f6c831a" VERSION="w5r0" TYPE="ubifs"
/dev/loop0: UUID="93a44fb3-e4ac-4580-b828-820e37ed5e2b" LABEL="rootfs_data" VERSION="1.14" MOUNT="/overlay" TYPE="f2fs"
df -Th
root@OpenWrt:/# df -Th
Filesystem           Type            Size      Used Available Use% Mounted on
/dev/root            squashfs       28.0M     28.0M         0 100% /rom
tmpfs                tmpfs         215.0M    176.0K    214.8M   0% /tmp
/dev/loop0           f2fs          226.0M     81.1M    144.9M  36% /overlay
overlayfs:/overlay   overlay       226.0M     81.1M    144.9M  36% /
tmpfs                tmpfs         512.0K         0    512.0K   0% /dev

After boot I can easily mount it and write/read:

mount to /mnt
[   67.155449] UBIFS (ubi0:4): Mounting in unauthenticated mode
[   67.161408] UBIFS (ubi0:4): background thread "ubifs_bgt0_4" started, PID 2915
[   67.222358] UBIFS (ubi0:4): UBIFS: mounted UBI device 0, volume 4, name "rootfs_data"
[   67.230204] UBIFS (ubi0:4): LEB size: 126976 bytes (124 KiB), min./max. I/O unit sizes: 2048 bytes/2048 bytes
[   67.240126] UBIFS (ubi0:4): FS size: 47742976 bytes (45 MiB, 376 LEBs), journal size 2412544 bytes (2 MiB, 19 LEBs)
[   67.250537] UBIFS (ubi0:4): reserved for root: 2255018 bytes (2202 KiB)
[   67.257153] UBIFS (ubi0:4): media format: w5/r0 (latest is w5/r0), UUID F80A8FAC-501D-4BA4-A5B4-B728E7B2E883, small LPT model


As you are apparently booting off a block device/disk or got extroot configured, the fstools rootdisk handler automatically creates a loop device for rootfs_data with offset above the squashfs, formats and mounts it.

[    8.917420] mount_root: rootdisk overlay filesystem has not been formatted yet
[    9.026251] random: mkfs.f2fs: uninitialized urandom read (16 bytes read)
[    9.125564] F2FS-fs (loop0): Found nat_bits in checkpoint
[    9.143772] F2FS-fs (loop0): Mounted with checkpoint version = 351ed69f

Please also share:

  • complete bootlog
  • details about boot method (loader and devices involved)
  • /etc/config/fstab

I am booting from FIT image (dtb+kernel+rootfs). I read them from ubi volume and load as RAMDISK. I didn't configure extroot, I read somewhere that I just need to name one of ubi volumes "rootfs_data".

boot log
U-Boot SPL 2021.04-00056-geadae5c9 (Dec 30 2021 - 11:30:59 +0300)


U-Boot 2021.04-00056-geadae5c9 (Dec 30 2021 - 11:30:59 +0300)

CPU:   Freescale LayerScape LS1021, Version: 2.0, (0x87001120)
Clock Configuration:
       CPU0(ARMV7):1200 MHz,
       Bus:300  MHz, DDR:800  MHz (1600 MT/s data rate),
Reset Configuration Word (RCW):
       00000000: 0608000c 00000000 00000000 00000000
       00000010: 20000000 08447900 e0105a00 21046000
       00000020: 00000000 00000000 00000000 00030200
       00000030: 00000000 2484b340 00000000 00000000
Model: LS1021A CUSTOM Board
Board: LS1021A-CUSTOM
NAND BOOT
DRAM:  512 MiB
Using SERDES1 Protocol: 32 (0x20)
WDT:   Started with servicing (10s timeout)
NAND:  128 MiB
MMC:   FSL_SDHC: 0
Loading Environment from UBI... Read 1048576 bytes from volume u-boot-env-1 to 9eb15000
Read 1048576 bytes from volume u-boot-env-2 to 9ec15040
*** Warning - bad CRC, using default environment

EEPROM: Invalid ID (ff ff ff ff)
In:    serial
Out:   serial
Err:   serial
Net:
Warning: ethernet@2d10000 (eth0) using random MAC address - 1e:a4:da:a0:bf:b2
eth0: ethernet@2d10000 [PRIME]
Warning: ethernet@2d50000 (eth1) using random MAC address - ba:6a:01:5a:98:9b
, eth1: ethernet@2d50000
Hit any key to stop autoboot:  0
Saving Environment to UBI... Writing to redundant UBI... done
OK
Saving Environment to UBI... Writing to UBI... done
OK
Saving Environment to UBI... Writing to redundant UBI... done
OK
No size specified -> Using max size (36823040)
Read 36823040 bytes from volume rootfsa to 82000000
PCIe1: pcie@3400000 Root Complex: no link
PCIe2: pcie@3500000 Root Complex: x1 gen2
## Loading kernel from FIT Image at 82000000 ...
   Using 'conf-1' configuration
   Trying 'kernel-0' kernel subimage
     Description:  Linux Kernel
     Type:         Kernel Image
     Compression:  gzip compressed
     Data Start:   0x820000d4
     Data Size:    5126236 Bytes = 4.9 MiB
     Architecture: ARM
     OS:           Linux
     Load Address: 0x81000000
     Entry Point:  0x81000000
     Hash algo:    sha1
     Hash value:   c8f17db2a155ff29cdf7d578f91f1fdea3cdb505
   Verifying Hash Integrity ... sha1+ OK
## Loading ramdisk from FIT Image at 82000000 ...
   Using 'conf-1' configuration
   Trying 'ramdisk-0' ramdisk subimage
     Description:  ramdisk
     Type:         RAMDisk Image
     Compression:  uncompressed
     Data Start:   0x824e8fcc
     Data Size:    29348518 Bytes = 28 MiB
     Architecture: ARM
     OS:           Linux
     Load Address: unavailable
     Entry Point:  unavailable
     Hash algo:    sha1
     Hash value:   1bbb3d0976b20ed45726d6f70a52b04fd0076f85
   Verifying Hash Integrity ... sha1+ OK
## Loading fdt from FIT Image at 82000000 ...
   Using 'conf-1' configuration
   Trying 'fdt-0' fdt subimage
     Description:  Flattened Device Tree blob Custom_LS1021A
     Type:         Flat Device Tree
     Compression:  uncompressed
     Data Start:   0x824e3a34
     Data Size:    21720 Bytes = 21.2 KiB
     Architecture: ARM
     Load Address: 0x8f000000
     Hash algo:    sha1
     Hash value:   7b5d2b92b3e61b6f4fb20e42beafe1640704b07d
   Verifying Hash Integrity ... sha1+ OK
   Loading fdt from 0x824e3a34 to 0x8f000000
   Booting using the fdt blob at 0x8f000000
   Uncompressing Kernel Image
   Loading Device Tree to 8fff7000, end 8ffff4d7 ... OK

Starting kernel ...

[    0.000000] Booting Linux on physical CPU 0xf00
[    0.000000] Linux version 5.4.143 (andrei@HOMEPC) (gcc version 8.4.0 (OpenWrt GCC 8.4.0 r16279-5cc0535800)) #0 SMP Thu Dec 30 10:41:24 2021
[    0.000000] CPU: ARMv7 Processor [410fc075] revision 5 (ARMv7), cr=30c5387d
[    0.000000] CPU: div instructions available: patching division code
[    0.000000] CPU: PIPT / VIPT nonaliasing data cache, VIPT aliasing instruction cache
[    0.000000] OF: fdt: Machine model: LS1021A CUSTOM Board
[    0.000000] earlycon: uart8250 at MMIO 0x00000000021c0500 (options '')
[    0.000000] printk: bootconsole [uart8250] enabled
[    0.000000] Memory policy: Data cache writealloc
[    0.000000] cma: Failed to reserve 32 MiB
[    0.000000] psci: probing for conduit method from DT.
[    0.000000] psci: PSCIv1.0 detected in firmware.
[    0.000000] psci: Using standard PSCI v0.2 function IDs
[    0.000000] psci: MIGRATE_INFO_TYPE not supported.
[    0.000000] psci: SMC Calling Convention v1.0
[    0.000000] percpu: Embedded 15 pages/cpu s30924 r8192 d22324 u61440
[    0.000000] Built 1 zonelists, mobility grouping on.  Total pages: 130010
[    0.000000] Kernel command line: earlycon=uart8250,mmio,0x21c0500 ubi.mtd=ubi rootfstype=squashfs,ubifs root=/dev/ram0 rw console=ttyS0,115200 cma=32M@0x0-0x60000000 vmalloc=544M
[    0.000000] Dentry cache hash table entries: 65536 (order: 6, 262144 bytes, linear)
[    0.000000] Inode-cache hash table entries: 32768 (order: 5, 131072 bytes, linear)
[    0.000000] mem auto-init: stack:off, heap alloc:off, heap free:off
[    0.000000] software IO TLB: mapped [mem 0x992ec000-0x9d2ec000] (64MB)
[    0.000000] Memory: 409612K/524288K available (8192K kernel code, 243K rwdata, 1992K rodata, 2048K init, 267K bss, 114676K reserved, 0K cma-reserved, 40960K highmem)
[    0.000000] SLUB: HWalign=64, Order=0-3, MinObjects=0, CPUs=2, Nodes=1
[    0.000000] rcu: Hierarchical RCU implementation.
[    0.000000] rcu: RCU calculated value of scheduler-enlistment delay is 10 jiffies.
[    0.000000] NR_IRQS: 16, nr_irqs: 16, preallocated irqs: 16
[    0.000000] GIC: Using split EOI/Deactivate mode
[    0.000000] random: get_random_bytes called from start_kernel+0x2fc/0x4ac with crng_init=0
[    0.000000] arch_timer: cp15 timer(s) running at 12.50MHz (phys).
[    0.000000] clocksource: arch_sys_counter: mask: 0xffffffffffffff max_cycles: 0x2e2049cda, max_idle_ns: 440795202628 ns
[    0.000005] sched_clock: 56 bits at 12MHz, resolution 80ns, wraps every 4398046511080ns
[    0.008012] Switching to timer-based delay loop, resolution 80ns
[    0.014539] Console: colour dummy device 80x30
[    0.019017] Calibrating delay loop (skipped), value calculated using timer frequency.. 25.00 BogoMIPS (lpj=125000)
[    0.029384] pid_max: default: 32768 minimum: 301
[    0.034132] Mount-cache hash table entries: 1024 (order: 0, 4096 bytes, linear)
[    0.041458] Mountpoint-cache hash table entries: 1024 (order: 0, 4096 bytes, linear)
[    0.049882] CPU: Testing write buffer coherency: ok
[    0.055097] CPU0: update cpu_capacity 1024
[    0.059193] CPU0: thread -1, cpu 0, socket 15, mpidr 80000f00
[    0.065395] Setting up static identity map for 0x80200000 - 0x80200060
[    0.072011] rcu: Hierarchical SRCU implementation.
[    0.077422] smp: Bringing up secondary CPUs ...
[    0.082513] CPU1: update cpu_capacity 1024
[    0.082518] CPU1: thread -1, cpu 1, socket 15, mpidr 80000f01
[    0.082616] smp: Brought up 1 node, 2 CPUs
[    0.096571] SMP: Total of 2 processors activated (50.00 BogoMIPS).
[    0.102760] CPU: All CPU(s) started in HYP mode.
[    0.107375] CPU: Virtualization extensions available.
[    0.115999] VFP support v0.3: implementor 41 architecture 2 part 30 variant 7 rev 5
[    0.123850] clocksource: jiffies: mask: 0xffffffff max_cycles: 0xffffffff, max_idle_ns: 19112604462750000 ns
[    0.133712] futex hash table entries: 512 (order: 3, 32768 bytes, linear)
[    0.140619] pinctrl core: initialized pinctrl subsystem
[    0.146371] NET: Registered protocol family 16
[    0.151276] DMA: preallocated 256 KiB pool for atomic coherent allocations
[    0.159112] cpuidle: using governor menu
[    0.163141] No ATAGs?
[    0.165127] Machine: LS1021A CUSTOM Board
[    0.171433] SoC family: QorIQ LS1021A
[    0.175090] SoC ID: svr:0x87001120, Revision: 2.0
[    0.195642] SCSI subsystem initialized
[    0.199559] usbcore: registered new interface driver usbfs
[    0.205116] usbcore: registered new interface driver hub
[    0.210456] usbcore: registered new device driver usb
[    0.215815] imx-i2c 2180000.i2c: can't get pinctrl, bus recovery not supported
[    0.223233] i2c i2c-0: IMX I2C adapter registered
[    0.227984] i2c i2c-0: using dma0chan16 (tx) and dma0chan17 (rx) for DMA transfers
[    0.235707] imx-i2c 2190000.i2c: can't get pinctrl, bus recovery not supported
[    0.243207] pca953x 1-0020: using no AI
[    0.263691] i2c i2c-1: IMX I2C adapter registered
[    0.268419] i2c i2c-1: using dma0chan18 (tx) and dma0chan19 (rx) for DMA transfers
[    0.276159] pps_core: LinuxPPS API ver. 1 registered
[    0.281126] pps_core: Software ver. 5.3.6 - Copyright 2005-2007 Rodolfo Giometti <giometti@linux.it>
[    0.290292] PTP clock support registered
[    0.294545] fsl-ifc 1530000.ifc: Freescale Integrated Flash Controller
[    0.301107] fsl-ifc 1530000.ifc: IFC version 1.4, 8 banks
[    0.306752] workqueue: max_active 576 requested for napi_workq is out of range, clamping between 1 and 512
[    0.316904] Bluetooth: Core ver 2.22
[    0.320508] NET: Registered protocol family 31
[    0.324952] Bluetooth: HCI device and connection manager initialized
[    0.331330] Bluetooth: HCI socket layer initialized
[    0.336207] Bluetooth: L2CAP socket layer initialized
[    0.341267] Bluetooth: SCO socket layer initialized
[    0.346449] clocksource: Switched to clocksource arch_sys_counter
[    0.356332] thermal_sys: Registered thermal governor 'step_wise'
[    0.356693] NET: Registered protocol family 2
[    0.367215] IP idents hash table entries: 8192 (order: 4, 65536 bytes, linear)
[    0.374894] tcp_listen_portaddr_hash hash table entries: 512 (order: 0, 6144 bytes, linear)
[    0.383298] TCP established hash table entries: 4096 (order: 2, 16384 bytes, linear)
[    0.391091] TCP bind hash table entries: 4096 (order: 3, 32768 bytes, linear)
[    0.398288] TCP: Hash tables configured (established 4096 bind 4096)
[    0.404730] UDP hash table entries: 256 (order: 1, 8192 bytes, linear)
[    0.411290] UDP-Lite hash table entries: 256 (order: 1, 8192 bytes, linear)
[    0.418416] NET: Registered protocol family 1
[    0.422796] PCI: CLS 0 bytes, default 64
[    0.426998] Trying to unpack rootfs image as initramfs...
[    0.432587] rootfs image is not initramfs (invalid magic at start of compressed archive); looks like an initrd
[    0.538436] Freeing initrd memory: 28668K
[    0.543435] workingset: timestamp_bits=14 max_order=17 bucket_order=3
[    0.556181] squashfs: version 4.0 (2009/01/31) Phillip Lougher
[    0.562220] ntfs: driver 2.1.32 [Flags: R/O].
[    0.566758] jffs2: version 2.2 (NAND) (SUMMARY) (LZMA) (RTIME) (CMODE_PRIORITY) (c) 2001-2006 Red Hat, Inc.
[    0.576908] fuse: init (API version 7.31)
[    0.611801] bounce: pool size: 64 pages
[    0.617085] layerscape-pcie 3400000.pcie: host bridge /soc/pcie@3400000 ranges:
[    0.624424] layerscape-pcie 3400000.pcie:    IO 0x4000010000..0x400001ffff -> 0x00000000
[    0.632558] layerscape-pcie 3400000.pcie:   MEM 0x4040000000..0x407fffffff -> 0x40000000
[    0.640898] layerscape-pcie 3400000.pcie: PCI host bridge to bus 0000:00
[    0.647625] pci_bus 0000:00: root bus resource [bus 00-ff]
[    0.653112] pci_bus 0000:00: root bus resource [io  0x0000-0xffff]
[    0.659307] pci_bus 0000:00: root bus resource [mem 0x4040000000-0x407fffffff] (bus address [0x40000000-0x7fffffff])
[    0.669867] pci 0000:00:00.0: [1957:0e0b] type 01 class 0x060400
[    0.675945] pci 0000:00:00.0: supports D1 D2
[    0.680226] pci 0000:00:00.0: PME# supported from D0 D1 D2 D3hot
[    0.687374] PCI: bus0: Fast back to back transfers disabled
[    0.693942] PCI: bus1: Fast back to back transfers enabled
[    0.699471] pci 0000:00:00.0: PCI bridge to [bus 01-ff]
[    0.704967] pcieport 0000:00:00.0: PME: Signaling with IRQ 42
[    0.710976] pcieport 0000:00:00.0: AER: enabled with IRQ 43
[    0.716781] layerscape-pcie 3500000.pcie: host bridge /soc/pcie@3500000 ranges:
[    0.724114] layerscape-pcie 3500000.pcie:    IO 0x4800010000..0x480001ffff -> 0x00000000
[    0.732233] layerscape-pcie 3500000.pcie:   MEM 0x4840000000..0x487fffffff -> 0x40000000
[    0.740472] layerscape-pcie 3500000.pcie: PCI host bridge to bus 0001:00
[    0.747189] pci_bus 0001:00: root bus resource [bus 00-ff]
[    0.752677] pci_bus 0001:00: root bus resource [io  0x10000-0x1ffff] (bus address [0x0000-0xffff])
[    0.761652] pci_bus 0001:00: root bus resource [mem 0x4840000000-0x487fffffff] (bus address [0x40000000-0x7fffffff])
[    0.772206] pci 0001:00:00.0: [1957:0e0b] type 01 class 0x060400
[    0.778271] pci 0001:00:00.0: supports D1 D2
[    0.782540] pci 0001:00:00.0: PME# supported from D0 D1 D2 D3hot
[    0.789651] PCI: bus0: Fast back to back transfers disabled
[    0.795338] pci 0001:01:00.0: [1b4b:2b42] type 00 class 0x020000
[    0.801392] pci 0001:01:00.0: MSI quirk detected; MSI disabled
[    0.807292] pci 0001:01:00.0: reg 0x10: [mem 0x38000000-0x380fffff 64bit pref]
[    0.814552] pci 0001:01:00.0: reg 0x18: [mem 0x38100000-0x381fffff 64bit pref]
[    0.822043] pci 0001:01:00.0: supports D1 D2
[    0.826312] pci 0001:01:00.0: PME# supported from D0 D1 D3hot D3cold
[    0.857430] PCI: bus1: Fast back to back transfers disabled
[    0.863034] pci 0001:00:00.0: BAR 9: assigned [mem 0x4840000000-0x48401fffff 64bit pref]
[    0.871153] pci 0001:01:00.0: BAR 0: assigned [mem 0x4840000000-0x48400fffff 64bit pref]
[    0.879285] pci 0001:01:00.0: BAR 2: assigned [mem 0x4840100000-0x48401fffff 64bit pref]
[    0.887411] pci 0001:00:00.0: PCI bridge to [bus 01-ff]
[    0.892640] pci 0001:00:00.0:   bridge window [mem 0x4840000000-0x48401fffff 64bit pref]
[    0.900960] pcieport 0001:00:00.0: PME: Signaling with IRQ 44
[    0.907472] Serial: 8250/16550 driver, 16 ports, IRQ sharing enabled
[    0.915910] printk: console [ttyS0] disabled
[    0.920270] 21c0500.serial: ttyS0 at MMIO 0x21c0500 (irq = 31, base_baud = 9375000) is a 16550A
[    0.929009] printk: console [ttyS0] enabled
[    0.929009] printk: console [ttyS0] enabled
[    0.937353] printk: bootconsole [uart8250] disabled
[    0.937353] printk: bootconsole [uart8250] disabled
[    0.947407] 21c0600.serial: ttyS1 at MMIO 0x21c0600 (irq = 31, base_baud = 9375000) is a 16550A
[    0.956481] STMicroelectronics ASC driver initialized
[    0.968723] brd: module loaded
[    0.975112] loop: module loaded
[    1.009821] nand: device found, Manufacturer ID: 0xc8, Chip ID: 0xd1
[    1.016142] nand: ESMT NAND 128MiB 3,3V 8-bit
[    1.020507] nand: 128 MiB, SLC, erase size: 128 KiB, page size: 2048, OOB size: 64
[    1.028403] Bad block table found at page 65472, version 0x01
[    1.034701] Bad block table found at page 65408, version 0x01
[    1.041125] 2 fixed-partitions partitions found on MTD device 60000000.flash
[    1.048157] Creating 2 MTD partitions on "60000000.flash":
[    1.053616] 0x000000000000-0x000000200000 : "u-boot"
[    1.059247] 0x000000200000-0x000008000000 : "ubi"
[    1.064815] fsl,ifc-nand 60000000.nand: IFC NAND device at 0x60000000, bank 0
[    1.072614] libphy: Fixed MDIO Bus: probed
[    1.077203] Atheros(R) L2 Ethernet Driver - version 2.2.3
[    1.082569] Copyright (c) 2007 Atheros Corporation.
[    1.087859] libphy: Freescale PowerQUICC MII Bus: probed
[    1.094691] libphy: Freescale PowerQUICC MII Bus: probed
[    1.100882] fsl-gianfar soc:ethernet@2d10000: enabled errata workarounds, flags: 0x4
[    1.119273] fsl-gianfar soc:ethernet@2d10000 eth0: mac: 00:04:9f:03:5b:c1
[    1.126027] fsl-gianfar soc:ethernet@2d10000 eth0: Running with NAPI enabled
[    1.133056] fsl-gianfar soc:ethernet@2d10000 eth0: RX BD ring size for Q[0]: 256
[    1.140422] fsl-gianfar soc:ethernet@2d10000 eth0: RX BD ring size for Q[1]: 256
[    1.147787] fsl-gianfar soc:ethernet@2d10000 eth0: TX BD ring size for Q[0]: 256
[    1.155142] fsl-gianfar soc:ethernet@2d10000 eth0: TX BD ring size for Q[1]: 256
[    1.162855] fsl-gianfar soc:ethernet@2d50000: enabled errata workarounds, flags: 0x4
[    1.181146] fsl-gianfar soc:ethernet@2d50000 eth1: mac: 00:04:9f:03:5b:c2
[    1.187916] fsl-gianfar soc:ethernet@2d50000 eth1: Running with NAPI enabled
[    1.194927] fsl-gianfar soc:ethernet@2d50000 eth1: RX BD ring size for Q[0]: 256
[    1.202293] fsl-gianfar soc:ethernet@2d50000 eth1: RX BD ring size for Q[1]: 256
[    1.209665] fsl-gianfar soc:ethernet@2d50000 eth1: TX BD ring size for Q[0]: 256
[    1.217031] fsl-gianfar soc:ethernet@2d50000 eth1: TX BD ring size for Q[1]: 256
[    1.224571] usbcore: registered new interface driver cdc_acm
[    1.230213] cdc_acm: USB Abstract Control Model driver for USB modems and ISDN adapters
[    1.238258] usbcore: registered new interface driver usbserial_generic
[    1.244770] usbserial: USB Serial support registered for generic
[    1.250776] usbcore: registered new interface driver option
[    1.256330] usbserial: USB Serial support registered for GSM modem (1-port)
[    1.263951] ftm-alarm 29d0000.timer0: registered as rtc1
[    1.269359] i2c /dev entries driver
[    1.273514] pps pps0: new PPS source ptp0
[    1.278435] imx2-wdt 2ad0000.watchdog: timeout 60 sec (nowayout=0)
[    1.284637] Bluetooth: HCI UART driver ver 2.3
[    1.289075] Bluetooth: HCI UART protocol H4 registered
[    1.294181] Bluetooth: HCI UART protocol BCSP registered
[    1.299916] qoriq_cpufreq: Freescale QorIQ CPU frequency scaling driver
[    1.306699] sdhci: Secure Digital Host Controller Interface driver
[    1.312841] sdhci: Copyright(c) Pierre Ossman
[    1.317185] sdhci-pltfm: SDHCI platform and OF driver helper
[    1.346453] mmc0: SDHCI controller on 1560000.esdhc [1560000.esdhc] using ADMA 64-bit
[    1.354618] hidraw: raw HID events driver (C) Jiri Kosina
[    1.361340] NET: Registered protocol family 10
[    1.366967] Segment Routing with IPv6
[    1.370667] NET: Registered protocol family 17
[    1.375228] Bluetooth: RFCOMM TTY layer initialized
[    1.380118] Bluetooth: RFCOMM socket layer initialized
[    1.385241] Bluetooth: RFCOMM ver 1.11
[    1.388992] Bluetooth: BNEP (Ethernet Emulation) ver 1.3
[    1.394270] Bluetooth: BNEP filters: protocol multicast
[    1.399485] Bluetooth: BNEP socket layer initialized
[    1.404419] Bluetooth: HIDP (Human Interface Emulation) ver 1.2
[    1.410317] Bluetooth: HIDP socket layer initialized
[    1.415250] 8021q: 802.1Q VLAN Support v1.8
[    1.419548] ThumbEE CPU extension supported.
[    1.423793] Registering SWP/SWPB emulation handler
[    1.430561] ubi0: attaching mtd1
[    1.493734] random: fast init done
[    2.061984] ubi0: scanning is finished
[    2.075982] ubi0: attached mtd1 (name "ubi", size 126 MiB)
[    2.081502] ubi0: PEB size: 131072 bytes (128 KiB), LEB size: 126976 bytes
[    2.088365] ubi0: min./max. I/O unit sizes: 2048/2048, sub-page size 2048
[    2.095122] ubi0: VID header offset: 2048 (aligned 2048), data offset: 4096
[    2.102084] ubi0: good PEBs: 1004, bad PEBs: 4, corrupted PEBs: 0
[    2.108170] ubi0: user volume: 5, internal volumes: 1, max. volumes count: 128
[    2.115359] ubi0: max/mean erase counter: 2/0, WL threshold: 4096, image sequence number: 1640860884
[    2.124466] ubi0: available PEBs: 0, total reserved PEBs: 1004, PEBs reserved for bad PEB handling: 16
[    2.133771] ubi0: background thread "ubi_bgt0d" started, PID 73
[    2.138834] hctosys: unable to open rtc device (rtc0)
[    2.145416] RAMDISK: squashfs filesystem found at block 0
[    2.150833] RAMDISK: Loading 28661KiB [1 disk] into ram disk... /
[    2.230304] /
[    2.401158] /
[    2.572661] done.
[    2.934300] VFS: Mounted root (squashfs filesystem) readonly on device 1:0.
[    2.944087] Freeing unused kernel memory: 2048K
[    2.966665] Run /sbin/init as init process
[    3.168980] init: Console is alive
[    3.172517] init: - watchdog -
[    3.470753] kmodloader: loading kernel modules from /etc/modules-boot.d/*
[    3.521046] dwc3 3100000.usb3: Failed to get clk 'ref': -2
[    3.527994] xhci-hcd xhci-hcd.1.auto: xHCI Host Controller
[    3.533477] xhci-hcd xhci-hcd.1.auto: new USB bus registered, assigned bus number 1
[    3.541317] xhci-hcd xhci-hcd.1.auto: hcc params 0x0220f66c hci version 0x100 quirks 0x0000000002010810
[    3.550746] xhci-hcd xhci-hcd.1.auto: irq 41, io mem 0x03100000
[    3.557321] hub 1-0:1.0: USB hub found
[    3.561079] hub 1-0:1.0: 1 port detected
[    3.565384] xhci-hcd xhci-hcd.1.auto: xHCI Host Controller
[    3.570883] xhci-hcd xhci-hcd.1.auto: new USB bus registered, assigned bus number 2
[    3.578519] xhci-hcd xhci-hcd.1.auto: Host supports USB 3.0 SuperSpeed
[    3.586239] hub 2-0:1.0: USB hub found
[    3.590039] hub 2-0:1.0: 1 port detected
[    3.602552] input: gpio-keys as /devices/platform/gpio-keys/input/input0
[    3.609496] kmodloader: done loading kernel modules from /etc/modules-boot.d/*
[    3.627032] init: - preinit -
[    3.996967] random: jshn: uninitialized urandom read (4 bytes read)
[    4.024822] random: jshn: uninitialized urandom read (4 bytes read)
[    4.038546] random: jshn: uninitialized urandom read (4 bytes read)
Press the [f] key and hit [enter] to enter failsafe mode
Press the [1], [2], [3] or [4] key and hit [enter] to select the debug level
[    8.219631] mount_root: loading kmods from internal overlay
[    8.233360] kmodloader: loading kernel modules from //etc/modules-boot.d/*
[    8.241099] kmodloader: done loading kernel modules from //etc/modules-boot.d/*
[    8.637376] UBIFS (ubi0:4): default file-system created
[    8.643271] UBIFS (ubi0:4): Mounting in unauthenticated mode
[    8.649182] UBIFS (ubi0:4): background thread "ubifs_bgt0_4" started, PID 157
[    8.679299] urandom_read: 5 callbacks suppressed
[    8.679305] random: procd: uninitialized urandom read (4 bytes read)
[    8.715755] UBIFS (ubi0:4): UBIFS: mounted UBI device 0, volume 4, name "rootfs_data"
[    8.723581] UBIFS (ubi0:4): LEB size: 126976 bytes (124 KiB), min./max. I/O unit sizes: 2048 bytes/2048 bytes
[    8.733456] UBIFS (ubi0:4): FS size: 47742976 bytes (45 MiB, 376 LEBs), journal size 2412544 bytes (2 MiB, 19 LEBs)
[    8.743841] UBIFS (ubi0:4): reserved for root: 2255018 bytes (2202 KiB)
[    8.750428] UBIFS (ubi0:4): media format: w5/r0 (latest is w5/r0), UUID 0BA8113D-E580-45A8-B09D-BFDBF82CE114, small LPT model
[    8.762617] block: attempting to load /tmp/ubifs_cfg/upper/etc/config/fstab
[    8.769743] block: unable to load configuration (fstab: Entry not found)
[    8.776526] block: attempting to load /tmp/ubifs_cfg/etc/config/fstab
[    8.783044] block: unable to load configuration (fstab: Entry not found)
[    8.789822] block: attempting to load /etc/config/fstab
[    8.796496] block: unable to load configuration (fstab: Entry not found)
[    8.803190] block: no usable configuration
[    8.810822] UBIFS (ubi0:4): un-mount UBI device 0
[    8.815534] UBIFS (ubi0:4): background thread "ubifs_bgt0_4" stops
[    8.866894] mount_root: rootdisk overlay filesystem has not been formatted yet
[    8.985550] random: mkfs.f2fs: uninitialized urandom read (16 bytes read)
[    9.084306] F2FS-fs (loop0): Found nat_bits in checkpoint
[    9.102576] F2FS-fs (loop0): Mounted with checkpoint version = 351ed69f
[    9.336735] fsl-gianfar soc:ethernet@2d10000 eth0: Link is Up - 1Gbps/Full - flow control off
[    9.345270] IPv6: ADDRCONF(NETDEV_CHANGE): eth0: link becomes ready
[    9.389956] UBIFS (ubi0:4): Mounting in unauthenticated mode
[    9.395757] UBIFS (ubi0:4): background thread "ubifs_bgt0_4" started, PID 165
[    9.463641] UBIFS (ubi0:4): UBIFS: mounted UBI device 0, volume 4, name "rootfs_data"
[    9.471512] UBIFS (ubi0:4): LEB size: 126976 bytes (124 KiB), min./max. I/O unit sizes: 2048 bytes/2048 bytes
[    9.481409] UBIFS (ubi0:4): FS size: 47742976 bytes (45 MiB, 376 LEBs), journal size 2412544 bytes (2 MiB, 19 LEBs)
[    9.491815] UBIFS (ubi0:4): reserved for root: 2255018 bytes (2202 KiB)
[    9.498431] UBIFS (ubi0:4): media format: w5/r0 (latest is w5/r0), UUID 0BA8113D-E580-45A8-B09D-BFDBF82CE114, small LPT model
[    9.510501] block: attempting to load /tmp/ubifs_cfg/upper/etc/config/fstab
[    9.517577] block: unable to load configuration (fstab: Entry not found)
[    9.524275] block: attempting to load /tmp/ubifs_cfg/etc/config/fstab
[    9.530760] block: unable to load configuration (fstab: Entry not found)
[    9.537480] block: attempting to load /etc/config/fstab
[    9.542720] block: unable to load configuration (fstab: Entry not found)
[    9.549422] block: no usable configuration
[    9.556857] UBIFS (ubi0:4): un-mount UBI device 0
[    9.561576] UBIFS (ubi0:4): background thread "ubifs_bgt0_4" stops
[    9.570276] mount_root: overlay filesystem has not been fully initialized yet
[    9.577732] mount_root: switching to f2fs overlay
[    9.591890] urandom-seed: Seed file not found (/etc/urandom.seed)
[    9.648865] fsl-gianfar soc:ethernet@2d10000 eth0: Link is Down
[    9.659177] procd: - early -
[    9.662096] procd: - watchdog -
Failed to connect to ubus
[   10.235992] procd: - watchdog -
[   10.241735] procd: - ubus -
[   10.405044] procd: - init -
Please press Enter to activate this console.
[   10.741160] urngd: v1.0.2 started.
[   10.804555] kmodloader: loading kernel modules from /etc/modules.d/*
[   10.807432] random: crng init done
[   10.862978] usbcore: registered new interface driver btusb
[   10.869490] usbcore: registered new interface driver cdc_wdm
[   10.875750] Loading modules backported from Linux version v5.10.42-0-g65859eca4dff
[   10.883413] Backport generated by backports.git v5.10.42-1-0-gbee5c545
[   10.898137] lm75 1-0048: hwmon0: sensor 'lm75'
[   10.911598] xt_time: kernel timezone is -0000
[   10.916983] usbcore: registered new interface driver cdc_ncm
[   10.960227] mwifiex_pcie: PCI memory map Virt0: 096261fc PCI memory map Virt2: 6f6d4e5b
[   11.001377] PPP generic driver version 2.4.2
[   11.006258] NET: Registered protocol family 24
[   11.077656] usbcore: registered new interface driver qmi_wwan
[   11.097057] usbcore: registered new interface driver cdc_mbim
[   11.104848] kmodloader: done loading kernel modules from /etc/modules.d/*
[   12.231014] mwifiex_pcie 0001:01:00.0: info: FW download over, size 632240 bytes
[   13.116478] mwifiex_pcie 0001:01:00.0: WLAN FW is active
[   13.173787] mwifiex_pcie 0001:01:00.0: info: MWIFIEX VERSION: mwifiex 1.0 (16.68.1.p179)
[   13.181973] mwifiex_pcie 0001:01:00.0: driver_version = mwifiex 1.0 (16.68.1.p179)
crond[715]: crond (busybox 1.33.1) started, log level 5
[   26.367018] br-lan: port 1(eth1) entered blocking state
[   26.372226] br-lan: port 1(eth1) entered disabled state
[   26.377767] device eth1 entered promiscuous mode
[   28.138024] mwifiex_pcie 0001:01:00.0: CMD_RESP: cmd 0x20 error, result=0x1
[   28.163101] mwifiex_pcie 0001:01:00.0: CMD_RESP: cmd 0xd1 error, result=0x1
[   28.394042] br-lan: port 2(wlan0) entered blocking state
[   28.399379] br-lan: port 2(wlan0) entered disabled state
[   28.404917] device wlan0 entered promiscuous mode
[   30.046777] fsl-gianfar soc:ethernet@2d10000 eth0: Link is Up - 1Gbps/Full - flow control off
[   30.055299] IPv6: ADDRCONF(NETDEV_CHANGE): eth0: link becomes ready
[   30.533867] fsl-gianfar soc:ethernet@2d50000 eth1: Link is Up - 1Gbps/Full - flow control off
[   30.542473] br-lan: port 1(eth1) entered blocking state
[   30.547718] br-lan: port 1(eth1) entered forwarding state
[   30.563891] IPv6: ADDRCONF(NETDEV_CHANGE): br-lan: link becomes ready
[   32.891907] IPv6: ADDRCONF(NETDEV_CHANGE): wlan0: link becomes ready
[   32.898423] br-lan: port 2(wlan0) entered blocking state
[   32.903717] br-lan: port 2(wlan0) entered forwarding state
/etc/config/fstab

root@OpenWrt:/# cat /etc/config/fstab

config 'global'
        option  anon_swap       '0'
        option  anon_mount      '0'
        option  auto_swap       '1'
        option  auto_mount      '1'
        option  delay_root      '5'
        option  check_fs        '0'

config 'mount'
        option  target  '/overlay'
        option  uuid    '997a5632-7d0a-4ea5-8243-4d35208d56cc'
        option  enabled '0'

With OpenWrt, using initramfs will result in having tmpfs as rootfs as initramfs is intended for recovery and development purpose only. You can, however, include a squashfs as filesystem sub-image in your uImage.FIT and have Linux parse the FIT structure and create a partition to mount the filesystem.

Set CONFIG_FIT_PARTITION=y and see the Linksys E8450 (UBI) in target/linux/mediatek/image/mt7622.mk for an example of how to create FIT image with squashfs filesystem and have Linux mount it as rootfs.

Thank you for help, could you please help me one more time. I can't understand, how to start such image from u-boot?

Now I have FIT image over ubi volume rootfsa, boot sequence:

setenv bootargs "earlycon=uart8250,mmio,0x21c0500 ubi.mtd=ubi rootfstype=squashfs,ubifs root=/dev/ram0 rw console=ttyLP0,115200 cma=32M@0x0-0x60000000 vmalloc=544M"
ubi read 0x82000000 rootfsa
bootm 0x82000000

Image2 contains only squashfs rootfs

FIT image structure
## Checking Image at 82000000 ...
   FIT image found
   FIT description: U-Boot fitImage for 5.4.168 kernel
    Image 0 (kernel-0)
     Description:  Linux Kernel
     Type:         Kernel Image
     Compression:  gzip compressed
     Data Start:   0x820000d4
     Data Size:    5128365 Bytes = 4.9 MiB
     Architecture: ARM
     OS:           Linux
     Load Address: 0x81000000
     Entry Point:  0x81000000
     Hash algo:    sha1
     Hash value:   cf8aa43d5a899d5f5006b3d760945931929603e3
    Image 1 (fdt-0)
     Description:  Flattened Device Tree blob Glomex_LS1021A
     Type:         Flat Device Tree
     Compression:  uncompressed
     Data Start:   0x824e4288
     Data Size:    21720 Bytes = 21.2 KiB
     Architecture: ARM
     Load Address: 0x8f000000
     Hash algo:    sha1
     Hash value:   e7ac479784acd82715629ebe34c0fd33a17fc1fd
    Image 2 (ramdisk-0)
     Description:  ramdisk
     Type:         RAMDisk Image
     Compression:  uncompressed
     Data Start:   0x824e9820
     Data Size:    29373970 Bytes = 28 MiB
     Architecture: ARM
     OS:           Linux
     Load Address: unavailable
     Entry Point:  unavailable
     Hash algo:    sha1
     Hash value:   639c5f87c0ea2f85c2ec22b4660aec18168e025a
    Configuration 0 (conf-1)
     Description:  Boot Linux kernel with FDT blob + ramdisk
     Kernel:       kernel-0
     Init Ramdisk: ramdisk-0
     FDT:          fdt-0
     Hash algo:    sha1
     Hash value:   unavailable
## Checking hash(es) for FIT Image at 82000000 ...
   Hash(es) for Image 0 (kernel-0): sha1+
   Hash(es) for Image 1 (fdt-0): sha1+
   Hash(es) for Image 2 (ramdisk-0): sha1+

From U-Boot point of view it's the same, you use bootm to start the image and U-Boot will take care of loading kernel and dtb and validating rootfs.
The trick is to not use a boot filesystem (like on x86, but UBIFS in this case probably) to store the uImage.FIT there as a file but rather have a UBI volume containing the uImage.FIT (as well as extra space for rootfs_overlay).
Linux will then boot and recognize the uImage.FIT as partition table of the ubiblock device created for that volume (CONFIG_FIT_PARTITION=y enables that part) and map the filesystem/squashfs sub-image as partition to be used as rootfs.
If you want a dual-boot system, just have another UBI volume to store another uImage.FIT (ie. recovery image vs. production image).
As you are using a recent U-Boot built from source, take a look a package/boot/uboot-mediatek/patches/410-add-linksys-e8450.patch as an example of how things can be done.
(and the corresponding part building the uImage.FIT in target/linux/mediatek/image/mt7622.mk for Linksys E8450 UBI variant)

Thank you for help. I solve this issue. I made firmware image for the ubi volume:
rootfs(32 mb fixed) and then kernel+dtb FIT image
During the boot I read from ubi to RAM and start FIT image from the RAM address+32mb and connect emulated ubi block as rootfs.
And now I have two firmware (squashfs rootfs+kernel and dtb FIT image) ubi volumes. And I can update them with only 1 image and make safe upgrade.

You can do that, but then you have no fallback in case rootfs cannot be mounted due to corruption or what ever else may happen as the bootloader won't check the squashfs integrity before starting the kernel on a mission to mount that squashfs.
I kinda like the idea of the bootloader assessing the integrity of both kernel and rootfs before starting. If it was initramfs, it would do the same. Calculating a hash for 32MB also only takes a few milliseconds, so in practice it doesn't make a difference. And the lack of loadaddr makes U-Boot not memcpy the filesystem part, but only validate it. It also makes handling sysupgrade easier as there is really only a single image for all components (kernel+dtb+rootfs) in a single FIT file.

I use bootcount and if there is a problem with corrupted rootfs in first ubi volume it should reboot and start from the second ubi volume.

I hope you are storing the counter in RAM (and not anywhere in flash or even in the U-Boot environment...)

I use u-boot BOOTCOUNT_LIMIT feature and save it in the u-boot env (u-boot env is located in the ubi). Is there problems with this variant? I use mender update and have configured this part from their's manual.

I find this solution a lot in the wild and it certainly exhausts the flash more than needed. As you are storing the U-Boot environment in UBI it's not that bad, but it still adds 2 writes to the flash for every successful (re-)boot which could be avoided by using PSTORE/ramoops instead for the same purpose, because in that way the bootcount may limit the lifetime of the device. The severity of that impact depends on the math you do and for sure most devices won't be in use for 20 years (unfortunately). However, my ideal is to strictly avoid planned obsolescence, and 2 writes compared to 0 is a lot.

I have thought about flash erase cycles before. Vendor of installed nand flash writes in the datasheet about 100k cycles. I think that it is not problem for the router device. It should work without any reboot 24/7. But even if somebody want to power off it every minute it will take 2 months to make new bad data sector. And then ubi must use new sector and so on. I think that router board will die first =)
But we will test it before the production and maybe we will transfer counter to the RAM, thank you for your help and advises. Happy New Year :wink:

100k guaranteed write OPs? That's nice NAND then :slight_smile:

yes, SLC with CMOS floating gate technology.

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.