[U-Boot] mtd partitions go away

Boris Brezillon boris.brezillon at bootlin.com
Thu Nov 15 14:21:31 UTC 2018


On Thu, 15 Nov 2018 14:48:49 +0100
Marek Vasut <marek.vasut at gmail.com> wrote:

> On 11/15/2018 11:14 AM, Heiko Schocher wrote:
> > Hello all,
> > 
> > just see with current HEAD of u-boot on an imx6ull based board with SPI NOR
> > and NAND following behaviour:  
> 
> +CC Boris, since he was recently looking into this stuff.
> 
> > => mtdparts  
> > 
> > device nand0 <gpmi-nand>, # parts = 1
> >  #: name                size            offset          mask_flags
> >  0: ubi                 0x08000000      0x00000000      0
> > 
> > device nor0 <spi1.0>, # parts = 5
> >  #: name                size            offset          mask_flags
> >  0: spl                 0x00010000      0x00000000      0
> >  1: u-boot              0x000c0000      0x00010000      0
> >  2: env                 0x00010000      0x000d0000      0
> >  3: env-red             0x00010000      0x000e0000      0
> >  4: rescue              0x00710000      0x000f0000      0
> > 
> > active partition: nand0,0 - (ubi) 0x08000000 @ 0x00000000
> > 
> > defaults:
> > mtdids  : nand0=gpmi-nand,nor0=spi1.0
> > mtdparts:
> > mtdparts=gpmi-nand:-(ubi);spi1.0:64k(spl),768k(u-boot),64k(env),64k(env-red),-(rescue)
> >   
> > =>  
> >   
> > => mtd list  
> > List of MTD devices:
> > * nand0
> >   - type: NAND flash
> >   - block size: 0x20000 bytes
> >   - min I/O: 0x800 bytes
> >   - OOB size: 64 bytes
> >   - OOB available: 0 bytes
> >   - ECC strength: 8 bits
> >   - ECC step size: 512 bytes
> >   - bitflip threshold: 6 bits
> >   - 0x000000000000-0x000008000000 : "nand0"
> >           - 0x000000000000-0x000008000000 : "ubi"
> > * nor0
> >   - type: NOR flash
> >   - block size: 0x10000 bytes
> >   - min I/O: 0x1 bytes
> >   - 0x000000000000-0x000000800000 : "nor0"
> >           - 0x000000000000-0x000000010000 : "spl"
> >           - 0x000000010000-0x0000000d0000 : "u-boot"
> >           - 0x0000000d0000-0x0000000e0000 : "env"
> >           - 0x0000000e0000-0x0000000f0000 : "env-red"
> >           - 0x0000000f0000-0x000000800000 : "rescue"
> > 
> > until here all is fine, for example an "ubi part ubi" works as
> > expected ... also doing this command n times, no problems.
> > 
> > Now:
> >   
> > => sf probe  
> > SF: Detected s25f064l with page size 256 Bytes, erase size 64 KiB, total
> > 8 MiB  
> > => mtd list  
> > List of MTD devices:
> > * nand0
> >   - type: NAND flash
> >   - block size: 0x20000 bytes
> >   - min I/O: 0x800 bytes
> >   - OOB size: 64 bytes
> >   - OOB available: 0 bytes
> >   - ECC strength: 8 bits
> >   - ECC step size: 512 bytes
> >   - bitflip threshold: 6 bits
> >   - 0x000000000000-0x000008000000 : "nand0"
> >           - 0x000000000000-0x000008000000 : "ubi"
> > * nor0
> >   - type: NOR flash
> >   - block size: 0x10000 bytes
> >   - min I/O: 0x1 bytes
> >   - 0x000000000000-0x000000800000 : "nor0"  
> > =>  
> > 
> > All MTD devices on nor0 are gone ... also the previous working
> > "ubi part ubi" fails ...
> > 
> > Adding debug code:
> > 
> > mtd_for_each_device(other)
> >     printf("%s ===== %s\n", __func__, other->name);
> > 
> > shows only:
> > 
> > get_mtd_device_nm ===== nand0
> > get_mtd_device_nm ===== nor0
> > 
> > ?
> > 
> > Anyone sees this behaviour too?
> > 
> > Any hints?

Looks like spi_flash_mtd_register() is doing something really bad here
[1]: memsetting the global sf_mtd_info object without testing if
this object has already been registered, and then registering it again
to the MTD layer. So any partition that had been attached to the mtd
object through mtd_probe_devices() are lost, and mtdparts/mtdids are not
parsed again because they haven't changed since the last time
mtd_probe_devices() was called.

[1]https://elixir.bootlin.com/u-boot/v2018.11/source/drivers/mtd/spi/sf_mtd.c#L76


More information about the U-Boot mailing list