[U-Boot] UBI / UBIFS booting from NAND support

Ladislav Michl ladis at linux-mips.org
Mon Nov 27 11:31:50 UTC 2017


Dear Jose Miguel,

On Mon, Nov 27, 2017 at 11:45:11AM +0100, Jose Miguel Sanchez Sanabria wrote:
> Hi everyone.
> 
> I was testing the booting process from NAND using an UBI/UBIFS image in an
> igepv2 board.

I'm happy to see someone from ISEE being interested in mainline support
for their own product.

> However MLO tries to boot first kernel (falcon mode activated) and then
> falls back to u-boot (as expected anyway I just wanted to load u-boot from
> ubi) trying to load volume 0, but fails.

Due to size restrictions, MLO does contain only limited UBI functionality,
just enough to load image from static UBI volume.

> U-Boot SPL 2017.11-dirty (Nov 24 2017 - 14:29:26)
> Trying to boot from NAND
> UBI warning: LEB 0 of 1 is missing
> UBI warning: Failed to load volume 3
> UBI warning: LEB 0 of 1 is missing
> UBI warning: Failed to load volume 3
> UBI warning: Failed
> Loading Linux failed, falling back to U-Boot.
> UBI warning: LEB 0 of 1 is missing
> UBI warning: Failed to load volume 0
> UBI warning: LEB 0 of 1 is missing
> UBI warning: Failed to load volume 0
> UBI warning: Failed
> SPL: failed to boot from all boot devices
> ### ERROR ### Please RESET the board ###

As noted above, ubispl loader is rather limited and identifies volumes
by volume id. u-boot.img is expected to be found in vol_id=0, while linux
zImage in vol_id=3. Log above indicates there are no such volumes.
What does u-boot's command 'ubi info l' show?

> I can however mount the ubi image but suspicious log appear:
> 
> u-boot:> ubifsmount ubi0:ubirootfs

Now you are in u-boot, where different UBI implementation is used, so
you can identify volumes also by name.

> 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
> 
> This has to do with the discussion about ubifs null deference so I suppose
> it should not affect much to write operation.

Well, I do not use UBIFS in U-Boot at all. Just UBI to read and write volumes.

> I would finally like to know if the ubi/ubifs support is functional; which
> would mean I did not use the ubi tools correctly to create the ubi image.

You will find script I'm using to bring board up at the end of this mail.
But note, that 'fdt memory' is hacked a bit and proper implementaion is welcome:
https://lists.denx.de/pipermail/u-boot/2017-January/279823.html

Also note 'setenv fdtfile "${soc_family}-${board_name}.dtb"' line. That's also
not in mainline as it needs also board revision too and the way it is currently
done, we cannot distinguish rev B. and rev F. Unfortunately this article
http://labs.isee.biz/index.php/IGEP_Technology_devices_revisions#IGEP0020_revisions
does not explain, how all those numbers map to board revisions ISEE is using
in vendor code.

That said, I enabled UBIFS for IGEPv2 only localy to verify my ubifs_finddir
reimplementation, but as I was even unable to mount ubifs, original reporter
did not confirm that at least mount works for him and I run out of the time,
ubifs issue is still unresolved.

Best regards,
	ladis

echo "*** starting u-boot instalation script ***"
nandecc hw hamming
setenv has_onenand $?
# MLO ...
fatload mmc 0:1 $loadaddr MLO
if test $has_onenand -eq 0
then
	nand erase.part SPL
	nand write $fileaddr 0 $filesize
	nand write $fileaddr 20000 $filesize
	nand write $fileaddr 40000 $filesize
	nand write $fileaddr 60000 $filesize
	nandecc sw bch8
	nand read $loadaddr UBI 20000
	if test $? != 0
	then
		ubi detach
		nand erase.part UBI
	fi
else
	ubi part UBI
	ubi check loader
	if test $? != 0
	then
		ubi detach
		onenand erase
	else
		onenand erase 0 80000
	fi
	onenand write $fileaddr 0 20000
	onenand write $fileaddr 20000 20000
	onenand write $fileaddr 40000 20000
	onenand write $fileaddr 60000 20000
fi

# UBI volumes
ubi part UBI

echo "Creating UBI volumes..."
ubi check loader
if test $? != 0
then
	ubi createvol loader 100000 static 0
fi
ubi check config
if test $? != 0
then
	ubi createvol config 8000 static 1
fi
ubi check config_r
if test $? != 0
then
	ubi createvol config_r 8000 static 2
fi
ubi check kernel
if test $? != 0
then
	ubi createvol kernel 400000 static 3
fi
ubi check dtb
if test $? != 0
then
	ubi createvol dtb 40000 static 4
fi
ubi check rootfs
if test $? != 0
then
	ubi createvol rootfs
fi

setenv fdtfile "${soc_family}-${board_name}.dtb"

# U-Boot ...
fatload mmc 0:1 $loadaddr u-boot.img
ubi write $fileaddr loader $filesize
# ... and root filesystem first
fatload mmc 0:1 $loadaddr root.ubifs
ubi write $fileaddr rootfs $filesize
# now load FDT blob ...
fatload mmc 0:1 $fdtaddr $fdtfile
# and fix it...
setenv bootargs "console=ttyO2,115200n8 root=ubi0:rootfs ubi.mtd=1 rootfstype=ubifs rw quiet"
fdt addr $fdtaddr
fdt resize 1000
fdt memory
fdt boardsetup
fdt chosen
fdt set /chosen bootargs "${bootargs}"
# store FDT blob
ubi write $fileaddr dtb 40000
# ... and finaly kernel image
fatload mmc 0:1 $loadaddr zImage
ubi write $fileaddr kernel $filesize
# boot into shinny new system
bootz $loadaddr - $fdtaddr


More information about the U-Boot mailing list