On 1/20/26 13:10, Quentin Schulz wrote: > Hi Mikhail, > > On 1/19/26 11:33 PM, Mikhail Kshevetskiy wrote: >> mtdpart internally enumerate partitions starting from zero, but >> partition >> driver API enumerate partitions starting from 1, so wrong partition will >> be queried. This is wrong. >> > > Are you sure this is the only place we need to fix that? > > Do mtd_parse_partitions, mtd_add_partition, mtd_del_partitions, > add_mtd_partitions work as intended? They seem to also be using > 0-starting indices... There's probably some mixing up between a device > index (0-starting?) and a partition index (1-starting) I guess?
Yes, I am pretty sure. The functions mtd_parse_partitions(), add_mtd_partitions() and mtd_free_parsed_partitions() are sused to parse mtd_parts string only and not used in other places. They operates with temporary array, removed by mtd_free_parsed_partitions() after the parsing was finished. So no need to worry about them. The functions mtd_add_partition() and mtd_del_partition() are linux only defined. They are placed under #ifndef __UBOOT__ <https://elixir.bootlin.com/u-boot/v2026.01/C/ident/__UBOOT__> #endif condition, so does not compiles during U-Boot building. > > Would be nice if we could have some tests in test/ so that 1) we know > it works as expected, 2) we avoid regressions in the future? Do you mean generic U_BOOT_PART_TYPE interface test or generic interface test + special test for every available interface? > > Also in v2 you said not many devices do have both MTD_PARTITIONS and > MTD_BLOCK enabled but I don't understand where MTD_BLOCK is required. > Are we missing a symbol dependency somewhere? > I think U_BOOT_PART_TYPE(mtd) interface should be conditionally compiled if CONFIG_MTD_BLOCK is defined. As I can see this interface is needed for commands like "part" and "read" , "write". Without CONFIG_MTD_BLOCK we have => mtd list List of MTD devices: * spi-nand0 ... - 0x000000000000-0x000010000000 : "spi-nand0" - 0x000000000000-0x000000100000 : "bl2" - 0x000000100000-0x000010000000 : "ubi" so we have 2 MTD partitions: "bl2" and "ubi", but => part list mtd 0 => read mtd 0#bl2 $loadaddr 0 2 ** Bad device specification mtd 0#bl2 ** ** Bad device specification mtd 0#bl2 ** Couldn't find partition mtd 0#bl2 means no MTD partition information can be used. > Cheers, > Quentin

