Hello, we have custom hardware board using Colibri IMX6ULL 512MB IT SoM.
We use latest stable Toradex BSP v5.7 with Toradex linux kernel 5.4.193 and Toradex u-boot v2020.07
I have implemented OTA updates using swupdate and A/B model.
When doing OTA update we update kernel, device tree and rootfs A or B ubi volumes. But sometimes in about 1 time from 50 random boards we get corrupted ubifs after doing reboot after update.
Kernel image and device tree binary is written by swupdate directly on ubi volumes replacing previous kernel image and device tree and rootfs is written as image of ubifs volume.
I do reboot immediately after swupdate finishes OTA update. Maybe that could be the issue?
The board during update is doing itâs usual work read/writes active rootfs and homefs ubi volumes.
What I have tried already to solve the ubifs corruption:
- Add sync command before rebooting
- Remove fastmap support from u-boot and kernel
But the same problem exists.
The usual problem is I canât read or access some directories on updated volumes. And in some cases there was even corruption on homefs ubi volume that is not touched by update.
Maybe you have experienced the same behaviour and could help with our case?
Kernel messages on corrupted fs
[ 265.291090] Hardware name: Freescale i.MX6 Ultralite (Device Tree)
[ 265.297312] [<8010ea38>] (unwind_backtrace) from [<8010bb90>] (show_stack+0x10/0x14)
[ 265.305088] [<8010bb90>] (show_stack) from [<8084e390>] (dump_stack+0x90/0xa4)
[ 265.312338] [<8084e390>] (dump_stack) from [<8038ea44>] (ubifs_read_node+0x260/0x2a8)
[ 265.320199] [<8038ea44>] (ubifs_read_node) from [<803ada50>] (ubifs_tnc_read_node+0x158/0x1ec)
[ 265.328839] [<803ada50>] (ubifs_tnc_read_node) from [<803903c0>] (tnc_read_hashed_node+0x98/0x1b8)
[ 265.337827] [<803903c0>] (tnc_read_hashed_node) from [<80393ea0>] (ubifs_tnc_next_ent+0x188/0x254)
[ 265.346816] [<80393ea0>] (ubifs_tnc_next_ent) from [<803852e0>] (ubifs_readdir+0x164/0x4e8)
[ 265.355201] [<803852e0>] (ubifs_readdir) from [<80251754>] (iterate_dir+0x74/0x15c)
[ 265.362889] [<80251754>] (iterate_dir) from [<80251ef4>] (ksys_getdents64+0x78/0x138)
[ 265.370748] [<80251ef4>] (ksys_getdents64) from [<80101000>] (ret_fast_syscall+0x0/0x54)
[ 265.378858] Exception stack(0x95235fa8 to 0x95235ff0)
[ 265.383929] 5fa0: 00000020 016afb08 00000003 016afb28 00008000 00000000
[ 265.392130] 5fc0: 00000020 016afb08 016afb0c 000000d9 00000000 016afb28 00000001 00000000
[ 265.400326] 5fe0: 000000d9 7e9bb3f4 76c8c313 76c33c26
[ 265.405490] UBIFS error (ubi0:5 pid 499): ubifs_readdir: cannot find next direntry, error -22
[ 268.371662] UBIFS error (ubi0:5 pid 501): ubifs_read_node: bad node type (255 but expected 2)
[ 268.380376] UBIFS error (ubi0:5 pid 501): ubifs_read_node: bad node at LEB 397:39928, LEB mapping status 1
[ 268.390122] Not a node, first 24 bytes:
[ 268.390138] 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
Our NAND layout is the following: mtdinfo -a
Count of MTD devices: 5
Present MTD devices: mtd0, mtd1, mtd2, mtd3, mtd4
Sysfs interface supported: yes
mtd0
Name: mx6ull-bcb
Type: nand
Eraseblock size: 131072 bytes, 128.0 KiB
Amount of eraseblocks: 4 (524288 bytes, 512.0 KiB)
Minimum input/output unit size: 2048 bytes
Sub-page size: 2048 bytes
OOB size: 112 bytes
Character device major/minor: 90:0
Bad blocks are allowed: true
Device is writable: true
mtd1
Name: u-boot1
Type: nand
Eraseblock size: 131072 bytes, 128.0 KiB
Amount of eraseblocks: 12 (1572864 bytes, 1.5 MiB)
Minimum input/output unit size: 2048 bytes
Sub-page size: 2048 bytes
OOB size: 112 bytes
Character device major/minor: 90:2
Bad blocks are allowed: true
Device is writable: true
mtd2
Name: u-boot2
Type: nand
Eraseblock size: 131072 bytes, 128.0 KiB
Amount of eraseblocks: 12 (1572864 bytes, 1.5 MiB)
Minimum input/output unit size: 2048 bytes
Sub-page size: 2048 bytes
OOB size: 112 bytes
Character device major/minor: 90:4
Bad blocks are allowed: true
Device is writable: true
mtd3
Name: u-boot-env
Type: nand
Eraseblock size: 131072 bytes, 128.0 KiB
Amount of eraseblocks: 4 (524288 bytes, 512.0 KiB)
Minimum input/output unit size: 2048 bytes
Sub-page size: 2048 bytes
OOB size: 112 bytes
Character device major/minor: 90:6
Bad blocks are allowed: true
Device is writable: true
mtd4
Name: ubi
Type: nand
Eraseblock size: 131072 bytes, 128.0 KiB
Amount of eraseblocks: 4064 (532676608 bytes, 508.0 MiB)
Minimum input/output unit size: 2048 bytes
Sub-page size: 2048 bytes
OOB size: 112 bytes
Character device major/minor: 90:8
Bad blocks are allowed: true
Device is writable: true
root@06883894:~# mtdinfo -u
Count of MTD devices: 5
Present MTD devices: mtd0, mtd1, mtd2, mtd3, mtd4
Sysfs interface supported: yes
UBI device layout on mtd4 is the following
UBI version: 1
Count of UBI devices: 1
UBI control device major/minor: 10:62
Present UBI devices: ubi0
root@06883894:~# ubinfo -a
UBI version: 1
Count of UBI devices: 1
UBI control device major/minor: 10:62
Present UBI devices: ubi0
ubi0
Volumes count: 8
Logical eraseblock size: 126976 bytes, 124.0 KiB
Total amount of logical eraseblocks: 4055 (514887680 bytes, 491.0 MiB)
Amount of available logical eraseblocks: 2 (253952 bytes, 248.0 KiB)
Maximum count of volumes 128
Count of bad physical eraseblocks: 9
Count of reserved physical eraseblocks: 71
Current maximum erase counter value: 140
Minimum input/output unit size: 2048 bytes
Character device major/minor: 244:0
Present volumes: 0, 1, 2, 3, 4, 5, 6, 7
Volume ID: 0 (on ubi0)
Type: static
Alignment: 1
Size: 100 LEBs (12697600 bytes, 12.1 MiB)
Data bytes: 6037168 bytes (5.7 MiB)
State: OK
Name: kernel_copy1
Character device major/minor: 244:1
-----------------------------------
Volume ID: 1 (on ubi0)
Type: static
Alignment: 1
Size: 100 LEBs (12697600 bytes, 12.1 MiB)
Data bytes: 6037168 bytes (5.7 MiB)
State: OK
Name: kernel_copy2
Character device major/minor: 244:2
-----------------------------------
Volume ID: 2 (on ubi0)
Type: static
Alignment: 1
Size: 2 LEBs (253952 bytes, 248.0 KiB)
Data bytes: 56163 bytes (54.8 KiB)
State: OK
Name: dtb_copy1
Character device major/minor: 244:3
-----------------------------------
Volume ID: 3 (on ubi0)
Type: static
Alignment: 1
Size: 2 LEBs (253952 bytes, 248.0 KiB)
Data bytes: 56163 bytes (54.8 KiB)
State: OK
Name: dtb_copy2
Character device major/minor: 244:4
-----------------------------------
Volume ID: 4 (on ubi0)
Type: static
Alignment: 1
Size: 8 LEBs (1015808 bytes, 992.0 KiB)
Data bytes: 0 bytes
State: OK
Name: m4firmware
Character device major/minor: 244:5
-----------------------------------
Volume ID: 5 (on ubi0)
Type: dynamic
Alignment: 1
Size: 1210 LEBs (153640960 bytes, 146.5 MiB)
State: OK
Name: rootfs_copy1
Character device major/minor: 244:6
-----------------------------------
Volume ID: 6 (on ubi0)
Type: dynamic
Alignment: 1
Size: 1210 LEBs (153640960 bytes, 146.5 MiB)
State: OK
Name: rootfs_copy2
Character device major/minor: 244:7
-----------------------------------
Volume ID: 7 (on ubi0)
Type: dynamic
Alignment: 1
Size: 1346 LEBs (170909696 bytes, 162.9 MiB)
State: OK
Name: homefs
Character device major/minor: 244:8