Imx6ull UBI setting mount fail

Hi Team,

I have integrated my imx6ull for NAND boot in which we are using mender code. Yocto build is successfull . But when booted we get the below error. we are not able to figure out what is the issue. Since i have not tested with mender before.

U-Boot 2018.03-4.14.98-2.2.0+g73af2fca69 (Feb 25 2020 - 07:39:36 +0000)

CPU: Freescale i.MX6ULL rev1.1 792 MHz (running at 396 MHz)
CPU: Industrial temperature grade (-40C to 105C) at 41C
Reset cause: POR
Model: Freescale i.MX6 ULL 14x14 EVK Board
Board: MX6ULL 14x14 EVK
I2C: ready
DRAM: 256 MiB
NAND: 512 MiB
MMC: FSL_SDHC: 0
Loading Environment from … ubi0: attaching mtd1
ubi0 error: validate_ec_hdr: bad VID header offset 2048, expected 4096
ubi0 error: validate_ec_hdr: bad EC header
Erase counter header dump:
magic 0x55424923
version 1
ec 0
vid_hdr_offset 2048
data_offset 4096
image_seq 1848161125
hdr_crc 0xbb8791a9
erase counter header hexdump:
ubi0 error: ubi_io_read_ec_hdr: validation failed for PEB 0
ubi0 error: ubi_attach_mtd_dev: failed to attach mtd1, error -22
UBI error: cannot attach mtd1UBI error: cannot initialize UBI, error -22UBI init error 22

** Cannot find mtd partition “ubi”
Failed (-5)
In: serial
Out: serial
Err: serial
Net: No ethernet found.
Normal Boot
Hit any key to stop autoboot: 0
Saving Environment to … ubi0: attaching mtd1
ubi0 error: validate_ec_hdr: bad VID header offset 2048, expected 4096
ubi0 error: validate_ec_hdr: bad EC header
Erase counter header dump:
magic 0x55424923
version 1
ec 0
vid_hdr_offset 2048
data_offset 4096
image_seq 1848161125
hdr_crc 0xbb8791a9
erase counter header hexdump:
ubi0 error: ubi_io_read_ec_hdr: validation failed for PEB 0
ubi0 error: ubi_attach_mtd_dev: failed to attach mtd1, error -22
UBI error: cannot attach mtd1UBI error: cannot initialize UBI, error -22UBI init error 22

** Cannot find mtd partition “ubi”
Failed (1)
ubi0: attaching mtd1
ubi0 error: validate_ec_hdr: bad VID header offset 2048, expected 4096
ubi0 error: validate_ec_hdr: bad EC header
Erase counter header dump:
magic 0x55424923
version 1
ec 0
vid_hdr_offset 2048
data_offset 4096
image_seq 1848161125
hdr_crc 0xbb8791a9
erase counter header hexdump:
ubi0 error: ubi_io_read_ec_hdr: validation failed for PEB 0
ubi0 error: ubi_attach_mtd_dev: failed to attach mtd1, error -22
UBI error: cannot attach mtd1UBI error: cannot initialize UBI, error -22UBI init error 22
UBIFS error (pid: 1): cannot open “ubi0:rootfsa”, error -19Error reading superblock on volume ‘ubi0:rootfsa’ errno=-19!
ubifsmount - mount UBIFS volume

I am using the .ubimg image.
Also my boot env is as below

altbootcmd=run mender_altbootcmd; run bootcmd
baudrate=115200
board_name=EVK
board_rev=14X14
bootargs=root=ubi0_0 mtdparts=01806000.flash:10m(u-boot),-(ubi) ubi.mtd=ubi rootfstype=ubifs console=ttymxc4,115200 ubi.mtd=3 rootfstype=ubifs coherent_)
bootcmd=run mender_setup; setenv bootargs root={mender_kernel_root} {mtdparts} ubi.mtd={mender_mtd_ubi_dev_name} rootfstype=ubifs {bootargs}; ubi par
bootcmd_mfg=run mfgtool_args;bootz {loadaddr} {initrd_addr} {fdt_addr}; bootcount=1 bootdelay=3 bootlimit=1 console=ttymxc4 ethaddr=00:01:02:03:04:FF ethprime=eth1 fdt_addr_r=0x83000000 fdt_file=imx6ull-iwg18m-sm.dtb fdt_high=0xffffffff fdtcontroladdr=8eef4330 initrd_addr=0x83800000 initrd_high=0xffffffff loadaddr=0x80800000 mender_altbootcmd=if test {mender_boot_part} = 0; then setenv mender_boot_part 1; setenv mender_boot_part_hex 1; else setenv mender_boot_part 0; setenvp
mender_boot_kernel_type=bootz
mender_boot_part=0
mender_boot_part_hex=0
mender_boot_part_name=ubi0:rootfsa
mender_check_saveenv_canary=1
mender_dtb_name=imx6ull-iwg18m-sm-nand.dtb
mender_kernel_name=zImage
mender_kernel_root=ubi0_0
mender_kernel_root_name=ubi0:rootfsa
mender_mtd_ubi_dev_name=ubi
mender_saveenv_canary=1
mender_setup=if test “{mender_saveenv_canary}" != "1"; then setenv mender_saveenv_canary 1; saveenv; fi; if test "{mender_pre_setup_commands}” != “”; i
mender_try_to_recover=if test {upgrade_available} = 1; then reset; fi mender_uboot_boot=dummy dummy: mender_uboot_dev=dummy mender_uboot_if=dummy mender_uboot_root=dummy dummy:0 mender_uboot_root_name=ubi0:rootfsa mfgtool_args=setenv bootargs console={console},${baudrate} rdinit=/linuxrc g_mass_storage.stall=0 g_mass_storage.removable=1 g_mass_storage.file=/fat g
mtddevname=u-boot
mtddevnum=0
mtdids=nand0=01806000.flash
mtdparts=mtdparts=01806000.flash:10m(u-boot),-(ubi)
partition=nand0,0
stderr=serial
stdin=serial
stdout=serial
tee=no
upgrade_available=0

Environment size: 3376/131067 bytes

As far as I can recall, this means that your MTDPARAMS are incorrect for the flash parts on your device.

I’m not sure how to troubleshoot that though.

Below are my configuration for MTD

Partitions

MENDER_MTDIDS = “nand0=01806000.flash”
MENDER_MTDPARTS = “01806000.flash:10m(u-boot),-(ubi)”
MENDER_NAND_FLASH_PAGE_SIZE = “4096”
MENDER_PARTITION_ALIGNMENT = “4194304”
MENDER_STORAGE_PEB_SIZE = “131072”
MENDER_STORAGE_TOTAL_SIZE_MB = “512”
MENDER_BOOT_PART_SIZE_MB = “0”
MENDER_DATA_PART_SIZE_MB = “10”

MENDER_PARTITION_ALIGNMENT is almost certainly wrong, since it is not supposed to be a power of two when using UBI. Just unset it, it should be automatically set from the other variables. The rest looks ok to me from a generic viewpoint, but I don’t know the board well, so it’s hard for me to say.

ERROR: u-boot-iwg18m-2018.03-r0 do_provide_mender_defines: BOOTENV_SIZE (0x20000) is too big to fit two copies inside MENDER_RESERVED_SPACE_BOOTLOADER_DATA (245760) with proper alignment. Please either: 1. Increase MENDER_RESERVED_SPACE_BOOTLOADER_DATA manually and make sure it is an even multiple of MENDER_PARTITION_ALIGNMENT (122880). -or- 2. Decrease BOOTENV_SIZE in the U-Boot recipe so that it can fit two copies inside MENDER_RESERVED_SPACE_BOOTLOADER_DATA. Please see https://docs.mender.io/troubleshooting/yocto-project-build for more information.

I would try option 1 in this case.

UBIFS assert failed in ubifs_change_lp at 540
UBIFS assert failed in ubifs_release_lprops at 278
UBIFS assert failed in ubifs_change_lp at 540
UBIFS assert failed in ubifs_release_lprops at 278
UBIFS error (ubi0:0 pid 0): ubifs_read_node: bad node type (255 but expected 9)
UBIFS error (ubi0:0 pid 0): ubifs_read_node: bad node at LEB 125:249352, LEB mapping status 0
Not a node, first 24 bytes:UBIFS error (ubi0:0 pid 0): ubifs_iget: failed to read inode 1, error -22
Error reading superblock on volume ‘ubi0:rootfsa’ errno=-22!

Can you post the output from:

ubireader_display_info -i UBIMG

where UBIMG is the image ending in .ubimg.

(If you don’t have the tool, you can install with with sudo pip3 install python-lzo ubi-reader)

Please find the output of ubireader_display_info

UBI File

Min I/O: 4096
LEB Size: 253952
PEB Size: 262144
Total Block Count: 269
Data Block Count: 267
Layout Block Count: 2
Internal Volume Block Count: 0
Unknown Block Count: 0
First UBI PEB Number: 0

Image: 1201317210
---------------------
	Image Sequence Num: 1201317210
	Volume Name:u-boot-env-2
	Volume Name:data
	Volume Name:rootfsa
	Volume Name:rootfsb
	Volume Name:u-boot-env-1
	PEB Range: 0 - 268

	Volume: u-boot-env-2
	---------------------
		Vol ID: 4
		Name: u-boot-env-2
		Block Count: 1

		Volume Record
		---------------------
			alignment: 1
			crc: '0xf6617426'
			data_pad: 0
			errors: ''
			flags: 0
			name: u'u-boot-env-2'
			name_len: 12
			padding: u'\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00'
			rec_index: 4
			reserved_pebs: 1
			upd_marker: 0
			vol_type: 'dynamic'


	Volume: data
	---------------------
		Vol ID: 2
		Name: data
		Block Count: 13

		Volume Record
		---------------------
			alignment: 1
			crc: '0x893aff54'
			data_pad: 0
			errors: ''
			flags: 0
			name: u'data'
			name_len: 4
			padding: u'\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00'
			rec_index: 2
			reserved_pebs: 42
			upd_marker: 0
			vol_type: 'dynamic'


	Volume: rootfsa
	---------------------
		Vol ID: 0
		Name: rootfsa
		Block Count: 126

		Volume Record
		---------------------
			alignment: 1
			crc: '0xa297a27b'
			data_pad: 0
			errors: ''
			flags: 0
			name: u'rootfsa'
			name_len: 7
			padding: u'\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00'
			rec_index: 0
			reserved_pebs: 947
			upd_marker: 0
			vol_type: 'dynamic'


	Volume: rootfsb
	---------------------
		Vol ID: 1
		Name: rootfsb
		Block Count: 126

		Volume Record
		---------------------
			alignment: 1
			crc: '0x775c41d'
			data_pad: 0
			errors: ''
			flags: 0
			name: u'rootfsb'
			name_len: 7
			padding: u'\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00'
			rec_index: 1
			reserved_pebs: 947
			upd_marker: 0
			vol_type: 'dynamic'


	Volume: u-boot-env-1
	---------------------
		Vol ID: 3
		Name: u-boot-env-1
		Block Count: 1

		Volume Record
		---------------------
			alignment: 1
			crc: '0x2cb7a4fb'
			data_pad: 0
			errors: ''
			flags: 0
			name: u'u-boot-env-1'
			name_len: 12
			padding: u'\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00'
			rec_index: 3
			reserved_pebs: 1
			upd_marker: 0
			vol_type: 'dynamic'

Actually i am flashing u-boot and my .ubimg only onto my board. Is it required to flash any other component

It looks correct as far as I can see, and yes, flashing u-boot and ubimg is what you need. But how are you flashing exactly? Is the flashing tool aware of the mtdparts string 01806000.flash:10m(u-boot),-(ubi)?

Yes, @kacf the Flashing tool firmware we have made the same changes. But we are getting the below:

UBIFS assert failed in ubifs_change_lp at 540
UBIFS assert failed in ubifs_release_lprops at 278
UBIFS assert failed in ubifs_change_lp at 540
UBIFS assert failed in ubifs_release_lprops at 278
UBIFS error (ubi0:0 pid 0): ubifs_read_node: bad node type (255 but expected 9)
UBIFS error (ubi0:0 pid 0): ubifs_read_node: bad node at LEB 125:249352, LEB mapping status 0
Not a node, first 24 bytes:UBIFS error (ubi0:0 pid 0): ubifs_iget: failed to read inode 1, error -22
Error reading superblock on volume ‘ubi0:rootfsa’ errno=-22!

Sorry, then I’m out of ideas. Maybe you can experiment with IMAGE_CMD_ubimg and tweak the settings until you get something that works.

Is UBIFS supported in MLC NAND ?