Hello Mike,

On 18.03.25 10:04, Mike Looijmans wrote:
I think I have everything set up to access MTD (and UBI) devices as "block", however, lsblk always ignores them, and refuses to list anything but the mmc. I can read ubifs and boot from it though, and since UBI runs on top of MTD block devices, MTD block device should be working, right?

Yes. I must admit, I have no device on which I have such a setup...

added Alexey (who introduced ubi block support), may he can give some hints.

I also have UBI_BLOCK enabled, so I would expect UBI volumes to appear in the 
"lsblk" as well.

good, that would have been my first question, if you have enabled "UBI_BLOCK"

Example U-boot session:

Zynq> mtd list
SF: Detected n25q256ax1 with page size 256 Bytes, erase size 64 KiB, total 32 
MiB
List of MTD devices:
* nor0
   - device: flash@0
   - parent: spi@e000d000
   - driver: jedec_spi_nor
   - path: /axi/spi@e000d000/flash@0
   - type: NOR flash
   - block size: 0x10000 bytes
   - min I/O: 0x1 bytes
   - 0x000000000000-0x000002000000 : "nor0"
           - 0x000000000000-0x000000100000 : "qspi-boot-bin"
           - 0x000000100000-0x000002000000 : "qspi-rootfs"

Aha, SPI NOR. I fear this is not supported yet.

Do you have somehow called ubi_part() ?

Can you try "ubi part...." and look if this helps?


Zynq> lsblk
Block Driver          Devices
-----------------------------
efi_blk             : <none>
mmc_blk             : mmc 0
mtd_blk             : <none>
ubi_blk             : <none>

Here (and for mtd) seems something missing!

usb_storage_blk     : <none>

Zynq> ubi part qspi-rootfs
Zynq> ubi list
0: qspi-rootfs
Zynq> lsblk
Block Driver          Devices
-----------------------------
efi_blk             : <none>
mmc_blk             : mmc 0
mtd_blk             : <none>
ubi_blk             : <none>
usb_storage_blk     : <none>


I would have expected the SPI NOR flash to appear in the "mtd_blk" devices, and would expect the UBI volumes to appear in the "ubi_blk" list.
What am I missing?

It seems to me, that you have to implement this like it is done for spi nand:

drivers/mtd/nand/spi/core.c
1180 static int spinand_bind(struct udevice *dev)
1181 {
1182         if (blk_enabled()) {
1183                 struct spinand_plat *plat = dev_get_plat(dev);
1184                 int ret;
1185
1186                 if (CONFIG_IS_ENABLED(MTD_BLOCK)) {
1187                         ret = mtd_bind(dev, &plat->mtd);
1188                         if (ret)
1189                                 return ret;
1190                 }
1191
1192                 if (CONFIG_IS_ENABLED(UBI_BLOCK))
1193                         return ubi_bind(dev);
1194         }
1195
1196         return 0;
1197 }

The only thing I just stumbled over is:

drivers/mtd/ubi/block.c
 35 static struct ubi_device *get_ubi_device(void)
 36 {
 37         return ubi_devices[0];
 38 }

may this is not perfect.

But as said, I cannot try out ...

What I'm aiming for here is to be able to:
- Read from squashfs in (raw) MTD partition (NOR flash is ideal for that)
- Read kernel/devicetree (fit) from UBI volume
- Read from squashfs inside UBI volume


I can read files from UBIFS (and boot into Linux using bootcmd_ubifs) just 
fine, e.g.:
Zynq> ubifsmount ubi0:qspi-rootfs
Zynq> ls ubi 0
<DIR>        5200  Fri Mar 09 12:34:56 2018  bin
<DIR>         160  Fri Mar 09 12:34:56 2018  dev
<DIR>        4984  Fri Mar 09 12:34:56 2018  etc
...



Good to hear that UBI/UBIFS setup is working!

So I fear there is some "add feature"/debug work ToDo to get this up and
working ...

bye,
Heiko
--
DENX Software Engineering GmbH,      Managing Director: Erika Unter
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: +49-8142-66989-52   Fax: +49-8142-66989-80   Email: h...@denx.de

Reply via email to