1

I am working on an embedded Linux (kernel-5.24), where UBIFS is used as filesystem for both rootfs and user configuration data.

Now I am trying to generate one single UBI image to burn the NAND FLASH (128MB) directly from within factory.

As I said, there are 2 UBI volumes in my system, one is rootfs (rootfs.ubifs), the other is for user configuration (usrconf.ubifs), and the ubinize.cfg is as follows,

[ubifs_volume]
mode=ubi
image=rootfs.ubifs
vol_id=0
vol_size=56MiB
vol_type=dynamic
vol_alignment=1
vol_name=rootfs

[usrconf_volume]
mode=ubi
image=usrconf.ubifs
vol_id=1
vol_size=56MiB
vol_type=dynamic
vol_alignment=1
vol_name=usrconf
vol_flags=autoresize

Now my question is how to combine the rootfs.ubifs file and usrconf.ubifs file into one rawubi.img to burn the FLASH? Where should I put the 2 files into the final rawubi.img?

== Updated with more tests ==
I changed the ubinize.cfg as follows (set usrconf volume to static and vol_id=0, rootfs volume as vol_id=1)

[usrconf_volume]
mode=ubi
image=usrconf.ubifs
vol_id=0
vol_size=56MiB
vol_type=static
vol_alignment=1
vol_name=usrconf

[ubifs_volume]
mode=ubi
image=rootfs.ubifs
vol_id=1
vol_size=56MiB
vol_type=dynamic
vol_alignment=1
vol_name=rootfs
vol_flags=autoresize

ubinize -m 2048 -p 128KiB -s 512 -O 2048 ./ubinize.cfg -v -o rawubi.img

After burned the generated rawubi.img to NAND FLASH, I booted the Linux with root=ubi0:rootfs rootfstype=ubifs, and hit following error,

[    2.671151] UBIFS (ubi0:1): Mounting in unauthenticated mode
[    2.677163] UBIFS (ubi0:1): background thread "ubifs_bgt0_1" started, PID 70
[    2.706562] UBIFS error (ubi0:1 pid 1): ubifs_read_node: bad node type (255 but expected 9)
[    2.715237] UBIFS error (ubi0:1 pid 1): ubifs_read_node: bad node at LEB 187:115776, LEB mapping status 0
[    2.725139] Not a node, first 24 bytes:
[    2.725148] 00000000: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff

It seemed that the FLASH is NOT populated with the data of rootfs.ubifs when rootfs volume is changed to vol_id=1.

1 Answer 1

1

I found there is a mistake in my operation of burning rawubi.img, where only a part of rawubi.img (first volume) is written to NAND FLASH, the data of 2nd volume is NOT being written, that is why the error occurred in my 2nd tests (with data of 0xFF).

So with fixes to the operation of burning the whole rawubi.img, I can mount the usrconf volume with read-only mode (it is set to static volume) as follows,

# mount -t ubifs ubi0:usrconf /mnt/
[   20.695088] UBIFS (ubi0:1): static UBI volume - read-only mode
[   20.701180] UBIFS error (ubi0:1 pid 175): ubifs_mount: cannot mount read-write - read-only media
[   20.710798] UBIFS (ubi0:1): static UBI volume - read-only mode
[   20.717229] UBIFS (ubi0:1): Mounting in unauthenticated mode
[   20.762993] UBIFS (ubi0:1): UBIFS: mounted UBI device 0, volume 1, name "usrdata", R/O mode
[   20.771664] UBIFS (ubi0:1): LEB size: 126976 bytes (124 KiB), min./max. I/O unit sizes: 2048 bytes/2048 bytes
[   20.781928] UBIFS (ubi0:1): FS size: 57393152 bytes (54 MiB, 452 LEBs), journal size 9023488 bytes (8 MiB, 72 LEBs)
[   20.792741] UBIFS (ubi0:1): reserved for root: 0 bytes (0 KiB)
[   20.798776] UBIFS (ubi0:1): media format: w4/r0 (latest is w5/r0), UUID 2CA863C1-5D80-4069-AC4D-DE831E343103, small LPT model
[   20.810928] UBIFS (ubi0:1): full atime support is enabled.

The final working ubinize.cfg is as follows,

[ubifs_volume]
mode=ubi
image=rootfs.ubifs
vol_id=0
vol_size=56MiB
vol_type=dynamic
vol_alignment=1
vol_name=rootfs

[usrconf_volume]
mode=ubi
image=usrconf.ubifs
vol_id=1
vol_size=56MiB
vol_type=static
vol_alignment=1
vol_name=usrconf

And the command I used is,

ubinize -m 2048 -p 128KiB -s 512 -O 2048 ./ubinize.cfg -v -o rawubi.img

The generated rawubi.img could be used to programing the FLASH chip directly.

2
  • In my answer, I mentioned that the burning operation only writes the data of first volume to the FLASH, this is what I did before I added 2nd volume. After adding a 2nd volume to the ubinize.cfg, the burning script has NOT been updated to write the whole new and bigger rawubi.img to FLASH, that is why the error occurred on setting rootfs to vol_id=1 (2nd volume) (no data is deployed from rawubi.img to NAND FLASH). Hope this provides more details on the fix.
    – wangt13
    Oct 4, 2023 at 9:49
  • Sure, the answer is updated with the final command and ubinize.cfg. Look forward to your upvoting.... :-)
    – wangt13
    Oct 5, 2023 at 7:56

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .