block devices on MTD and UBI
Oskar Nilsson
onilsson at rums.se
Wed Mar 26 10:33:26 CET 2025
Hello Heiko,
On Wednesday, 26 March 2025 at 06:21:35 +01:00, Heiko Schocher <hs at denx.de> wrote:
> Hello Oskar,
>
> Hmm... yep, so the theory ... but let me first look if this is used in mainline:
>
> hs at threadripper:u-boot [master] $ grep -lr UBI_BLOCK configs/
> hs at threadripper:u-boot [master] $
>
> So no users at all currently? That explains, why it is may buggy.
>
> hs at threadripper:u-boot [master] $ grep -lr UBI_BLOCK .
> ./drivers/mtd/nand/spi/core.c
> ./drivers/mtd/ubi/ubi.h
> ./drivers/mtd/ubi/Makefile
> ./drivers/mtd/ubi/Kconfig
> ./include/ubi_uboot.h
>
> And option is not selected through any Kconfig ... so yes, expect bugs
> here... and I have no hardware for that to dig into ... I am sorry.
>
No problem, I'll continue to try to get it working on my board.
>
>
> > Note that I'm on u-boot-imx 2024.04 and have back ported the ubi and mtd block
> > patches, so there may be differences to latest.
> > Looking at the driver model, a .blk has been added:
> > => dm tree
> > Class Index Probed Driver Name
> > -----------------------------------------------------------
> > root 0 [ + ] root_driver root_driver
> > thermal 0 [ ] imx_thermal |-- imx_thermal
> > simple_bus 0 [ + ] simple_bus |-- soc
> > mtd 0 [ + ] mxs-nand-dt | |-- nand-controller at 1806000
> > blk 0 [ ] ubi_blk | | `-- <<nand-controller at 1806000.blk>>
> > ...
> > Calling sqfsls, seems to find the right volume (rootfs0):
> > => sqfsls mtd 0 /
> > FS: Setting up block device: ifname='mtd', dev_part_str='0', fstype=6
> > Read 512 bytes from volume rootfs0 to 9ef2cb80
> > Disk <<nand-controller at 1806000.blk>> not ready
> > ** Bad device specification mtd 0 **
> > Couldn't find partition mtd 0
> > FS: Failed to get partition info (err=-19)
> > Interestingly after each command that uses a blk device, I get 128 blk_partitions
> >
> Do I see it correct that your patch:
>
> <https://patchwork.ozlabs.org/project/uboot/patch/20250325174708.426459-1-onilsson@rums.se/>
>
> fixes this problem?
> Yes, that's my patch, I've sent V2. Returning -ENOENT is definitely better.
> > => dm tree
> > Class Index Probed Driver Name
> > -----------------------------------------------------------
> > root 0 [ + ] root_driver root_driver
> > thermal 0 [ ] imx_thermal |-- imx_thermal
> > simple_bus 0 [ + ] simple_bus |-- soc
> > mtd 0 [ + ] mxs-nand-dt | |-- nand-controller at 1806000
> > blk 0 [ ] ubi_blk | | `-- <<nand-controller at 1806000.blk>>
> > partition 0 [ ] blk_partition | | |-- <<nand-controller at 1806000.blk>>:1
> > partition 1 [ ] blk_partition | | |-- <<nand-controller at 1806000.blk>>:2
> > partition 2 [ ] blk_partition | | |-- <<nand-controller at 1806000.blk>>:3
> > partition 3 [ ] blk_partition | | |-- <<nand-controller at 1806000.blk>>:4
> > partition 4 [ ] blk_partition | | |-- <<nand-controller at 1806000.blk>>:5
> > ...
> > At first I also got the error "UBIFS not mounted, use ubifsmount to mount volume first!"
> > To fix that I added this small patch:
> > diff --git a/disk/part.c b/disk/part.c
> > index 8982ef3bae..f168311e9a 100644
> > --- a/disk/part.c
> > +++ b/disk/part.c
> > @@ -524,7 +524,7 @@ int blk_get_device_part_str(const char *ifname, const char *dev_part_str,
> > }
> > #endif
> > -#if IS_ENABLED(CONFIG_CMD_UBIFS) && !IS_ENABLED(CONFIG_SPL_BUILD)
> > +#if IS_ENABLED(CONFIG_CMD_UBIFS) && !IS_ENABLED(CONFIG_SPL_BUILD) && !IS_ENABLED(CONFIG_UBI_BLOCK)
> > /*
> > * Special-case ubi, ubi goes through a mtd, rather than through
> > * a regular block device.
> >
>
> Please send a formal patch for this, so I can pick it up, thanks!
>
OK, I'll test more to see if there is anything that breaks when adding this extra check.
Regards,
Oskar
More information about the U-Boot
mailing list