[U-Boot] mtd partitions go away

Hello all,
just see with current HEAD of u-boot on an imx6ull based board with SPI NOR and NAND following behaviour:
=> 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?
bye, Heiko

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?
bye, Heiko

On Thu, 15 Nov 2018 14:48:49 +0100 Marek Vasut marek.vasut@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#L...

Hi Heiko,
On Thu, 15 Nov 2018 15:21:31 +0100 Boris Brezillon boris.brezillon@bootlin.com wrote:
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#L...
Can you try with the following diff applied?
--->8--- diff --git a/drivers/mtd/spi/sf_internal.h b/drivers/mtd/spi/sf_internal.h index 26f5c7c995e5..799056d97d0a 100644 --- a/drivers/mtd/spi/sf_internal.h +++ b/drivers/mtd/spi/sf_internal.h @@ -223,7 +223,7 @@ int spi_flash_cmd_read_ops(struct spi_flash *flash, u32 offset,
#ifdef CONFIG_SPI_FLASH_MTD int spi_flash_mtd_register(struct spi_flash *flash); -void spi_flash_mtd_unregister(void); +void spi_flash_mtd_unregister(struct spi_flash *flash); #endif
/** diff --git a/drivers/mtd/spi/sf_mtd.c b/drivers/mtd/spi/sf_mtd.c index 58d7e4439903..c4fda82b4a36 100644 --- a/drivers/mtd/spi/sf_mtd.c +++ b/drivers/mtd/spi/sf_mtd.c @@ -9,8 +9,7 @@ #include <linux/mtd/mtd.h> #include <spi_flash.h>
-static struct mtd_info sf_mtd_info; -static char sf_mtd_name[8]; +#define SF_MTD_MAX_NAME_SIZE 8
static int spi_flash_mtd_erase(struct mtd_info *mtd, struct erase_info *instr) { @@ -71,33 +70,81 @@ static int spi_flash_mtd_number(void) #endif }
-int spi_flash_mtd_register(struct spi_flash *flash) +static int spi_flash_mtd_init_and_add(struct spi_flash *flash, + struct mtd_info *mtd) { - memset(&sf_mtd_info, 0, sizeof(sf_mtd_info)); - sprintf(sf_mtd_name, "nor%d", spi_flash_mtd_number()); + snprintf(mtd->name, SF_MTD_MAX_NAME_SIZE, "nor%d", + spi_flash_mtd_number());
- sf_mtd_info.name = sf_mtd_name; - sf_mtd_info.type = MTD_NORFLASH; - sf_mtd_info.flags = MTD_CAP_NORFLASH; - sf_mtd_info.writesize = 1; - sf_mtd_info.writebufsize = flash->page_size; + mtd->type = MTD_NORFLASH; + mtd->flags = MTD_CAP_NORFLASH; + mtd->writesize = 1; + mtd->writebufsize = flash->page_size;
- sf_mtd_info._erase = spi_flash_mtd_erase; - sf_mtd_info._read = spi_flash_mtd_read; - sf_mtd_info._write = spi_flash_mtd_write; - sf_mtd_info._sync = spi_flash_mtd_sync; + mtd->_erase = spi_flash_mtd_erase; + mtd->_read = spi_flash_mtd_read; + mtd->_write = spi_flash_mtd_write; + mtd->_sync = spi_flash_mtd_sync;
- sf_mtd_info.size = flash->size; - sf_mtd_info.priv = flash; + mtd->size = flash->size; + mtd->priv = flash;
/* Only uniform flash devices for now */ - sf_mtd_info.numeraseregions = 0; - sf_mtd_info.erasesize = flash->sector_size; + mtd->numeraseregions = 0; + mtd->erasesize = flash->sector_size; + + return add_mtd_device(mtd); +} + +#ifdef CONFIG_DM_SPI_FLASH +int spi_flash_mtd_register(struct spi_flash *flash) +{ + struct mtd_info *mtd = dev_get_uclass_priv(flash->dev); + int ret; + + /* MTD object already registered, return directly. */ + if (mtd->name) + return 0; + + mtd->name = malloc(SF_MTD_MAX_NAME_SIZE); + if (!mtd->name) + return -ENOMEM; + + mtd->dev = flash->dev; + ret = spi_flash_mtd_init_and_add(flash, mtd); + if (ret) { + free(mtd->name); + mtd->name = NULL; + } + + return ret; +} + +void spi_flash_mtd_unregister(struct spi_flash *flash) +{ + struct mtd_info *mtd = dev_get_uclass_priv(flash->dev); + + if (!mtd->name) + return; + + del_mtd_device(mtd); + free(mtd->name); + mtd->name = NULL; +} +#else +static struct mtd_info sf_mtd_info; +static char sf_mtd_name[SF_MTD_MAX_NAME_SIZE]; + +int spi_flash_mtd_register(struct spi_flash *flash) +{ + memset(&sf_mtd_info, 0, sizeof(sf_mtd_info)); + sf_mtd_info.name = sf_mtd_name;
- return add_mtd_device(&sf_mtd_info); + return spi_flash_mtd_init_and_add(flash, &sf_mtd_info); }
-void spi_flash_mtd_unregister(void) +void spi_flash_mtd_unregister(struct spi_flash *flash) { del_mtd_device(&sf_mtd_info); } +#endif /* CONFIG_DM_SPI_FLASH */ diff --git a/drivers/mtd/spi/sf_probe.c b/drivers/mtd/spi/sf_probe.c index 94fde2ae7a36..b8ee6da8ae9f 100644 --- a/drivers/mtd/spi/sf_probe.c +++ b/drivers/mtd/spi/sf_probe.c @@ -84,7 +84,7 @@ struct spi_flash *spi_flash_probe(unsigned int busnum, unsigned int cs, void spi_flash_free(struct spi_flash *flash) { #ifdef CONFIG_SPI_FLASH_MTD - spi_flash_mtd_unregister(); + spi_flash_mtd_unregister(flash); #endif spi_free_slave(flash->spi); free(flash);

On Thu, 15 Nov 2018 16:15:51 +0100 Boris Brezillon boris.brezillon@bootlin.com wrote:
Hi Heiko,
On Thu, 15 Nov 2018 15:21:31 +0100 Boris Brezillon boris.brezillon@bootlin.com wrote:
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#L...
Can you try with the following diff applied?
If the previous diff did not fix your problem, you can try this one
--->8--- diff --git a/drivers/mtd/mtd_uboot.c b/drivers/mtd/mtd_uboot.c index 5ca560c96879..af5ad25cc37a 100644 --- a/drivers/mtd/mtd_uboot.c +++ b/drivers/mtd/mtd_uboot.c @@ -164,6 +164,7 @@ int mtd_probe_devices(void) /* Check if mtdparts/mtdids changed since last call, otherwise: exit */ if ((!mtdparts && !old_mtdparts && !mtdids && !old_mtdids) || (mtdparts && old_mtdparts && mtdids && old_mtdids && + !mtd_dev_list_updated() && !strcmp(mtdparts, old_mtdparts) && !strcmp(mtdids, old_mtdids))) return 0; diff --git a/drivers/mtd/mtdcore.c b/drivers/mtd/mtdcore.c index fb6c779abbfe..7a15ded8c883 100644 --- a/drivers/mtd/mtdcore.c +++ b/drivers/mtd/mtdcore.c @@ -87,14 +87,17 @@ struct idr_layer {
struct idr { struct idr_layer id[MAX_IDR_ID]; + bool updated; };
#define DEFINE_IDR(name) struct idr name;
void idr_remove(struct idr *idp, int id) { - if (idp->id[id].used) + if (idp->id[id].used) { idp->id[id].used = 0; + idp->updated = true; + }
return; } @@ -134,6 +137,7 @@ int idr_alloc(struct idr *idp, void *ptr, int start, int end, gfp_t gfp_mask) if (idl->used == 0) { idl->used = 1; idl->ptr = ptr; + idp->updated = true; return i; } i++; @@ -155,6 +159,16 @@ struct mtd_info *__mtd_next_device(int i) } EXPORT_SYMBOL_GPL(__mtd_next_device);
+bool mtd_dev_list_updated(void) +{ + if (mtd_idr.updated) { + mtd_idr.updated = false; + return true; + } + + return false; +} + #ifndef __UBOOT__ static LIST_HEAD(mtd_notifiers);
diff --git a/include/linux/mtd/mtd.h b/include/linux/mtd/mtd.h index 68e591532492..d20ebd820289 100644 --- a/include/linux/mtd/mtd.h +++ b/include/linux/mtd/mtd.h @@ -581,6 +581,7 @@ int mtd_arg_off_size(int argc, char *const argv[], int *idx, loff_t *off, void mtd_get_len_incl_bad(struct mtd_info *mtd, uint64_t offset, const uint64_t length, uint64_t *len_incl_bad, int *truncated); +bool mtd_dev_list_updated(void);
/* drivers/mtd/mtd_uboot.c */ int mtd_search_alternate_name(const char *mtdname, char *altname,

Hello Boris,
Am 15.11.2018 um 17:47 schrieb Boris Brezillon:
On Thu, 15 Nov 2018 16:15:51 +0100 Boris Brezillon boris.brezillon@bootlin.com wrote:
Hi Heiko,
On Thu, 15 Nov 2018 15:21:31 +0100 Boris Brezillon boris.brezillon@bootlin.com wrote:
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#L...
Can you try with the following diff applied?
If the previous diff did not fix your problem, you can try this one
--->8--- diff --git a/drivers/mtd/mtd_uboot.c b/drivers/mtd/mtd_uboot.c index 5ca560c96879..af5ad25cc37a 100644 --- a/drivers/mtd/mtd_uboot.c +++ b/drivers/mtd/mtd_uboot.c @@ -164,6 +164,7 @@ int mtd_probe_devices(void) /* Check if mtdparts/mtdids changed since last call, otherwise: exit */ if ((!mtdparts && !old_mtdparts && !mtdids && !old_mtdids) || (mtdparts && old_mtdparts && mtdids && old_mtdids &&
!mtd_dev_list_updated() && !strcmp(mtdparts, old_mtdparts) && !strcmp(mtdids, old_mtdids))) return 0;
diff --git a/drivers/mtd/mtdcore.c b/drivers/mtd/mtdcore.c index fb6c779abbfe..7a15ded8c883 100644 --- a/drivers/mtd/mtdcore.c +++ b/drivers/mtd/mtdcore.c @@ -87,14 +87,17 @@ struct idr_layer {
struct idr { struct idr_layer id[MAX_IDR_ID];
bool updated;
};
#define DEFINE_IDR(name) struct idr name;
void idr_remove(struct idr *idp, int id) {
if (idp->id[id].used)
if (idp->id[id].used) { idp->id[id].used = 0;
idp->updated = true;
} return;
}
@@ -134,6 +137,7 @@ int idr_alloc(struct idr *idp, void *ptr, int start, int end, gfp_t gfp_mask) if (idl->used == 0) { idl->used = 1; idl->ptr = ptr;
idp->updated = true; return i; } i++;
@@ -155,6 +159,16 @@ struct mtd_info *__mtd_next_device(int i) } EXPORT_SYMBOL_GPL(__mtd_next_device);
+bool mtd_dev_list_updated(void) +{
if (mtd_idr.updated) {
mtd_idr.updated = false;
return true;
}
return false;
+}
- #ifndef __UBOOT__ static LIST_HEAD(mtd_notifiers);
diff --git a/include/linux/mtd/mtd.h b/include/linux/mtd/mtd.h index 68e591532492..d20ebd820289 100644 --- a/include/linux/mtd/mtd.h +++ b/include/linux/mtd/mtd.h @@ -581,6 +581,7 @@ int mtd_arg_off_size(int argc, char *const argv[], int *idx, loff_t *off, void mtd_get_len_incl_bad(struct mtd_info *mtd, uint64_t offset, const uint64_t length, uint64_t *len_incl_bad, int *truncated); +bool mtd_dev_list_updated(void);
/* drivers/mtd/mtd_uboot.c */ int mtd_search_alternate_name(const char *mtdname, char *altname,
This does fix "mtd list" => 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" => 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" - 0x000000000000-0x000000010000 : "spl" - 0x000000010000-0x0000000d0000 : "u-boot" - 0x0000000d0000-0x0000000e0000 : "env" - 0x0000000e0000-0x0000000f0000 : "env-red" - 0x0000000f0000-0x000000800000 : "rescue"
But problem with "ubi part" remains:
=> ubi part ubi Partition ubi not found! =>
Thanks for your help. I try to find time, to dig also into it, but may only next week ...
bye, Heiko

Hello Boris,
thanks for the fast response.
Am 15.11.2018 um 16:15 schrieb Boris Brezillon:
Hi Heiko,
On Thu, 15 Nov 2018 15:21:31 +0100 Boris Brezillon boris.brezillon@bootlin.com wrote:
Looks like spi_flash_mtd_register() is doing something really bad here
Yes!
[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.
Yep...
[1]https://elixir.bootlin.com/u-boot/v2018.11/source/drivers/mtd/spi/sf_mtd.c#L...
Can you try with the following diff applied?
The patch do not apply for me, so I added it from hand.
But it crashes for me (output with some debug printfs) and U-Boot Environment in SPI NOR:
U-Boot 2018.11-00042-g48b013532c-dirty (Nov 16 2018 - 06:31:16 +0000)
CPU: Freescale i.MX6ULL rev1.0 528 MHz (running at 396 MHz) CPU: Industrial temperature grade (-40C to 105C) at 45C Reset cause: WDOG [...] DRAM: 128 MiB NAND: 128 MiB Loading Environment from SPI Flash... SF: Detected s25f064l with page size 256 Bytes, erase size 64 KiB, total 8 MiB spi_flash_mtd_register === start: 749000 spi_flash_mtd_register === name : <NULL> spi_flash_mtd_register === start spi_flash_mtd_register === ret: 0 spi_flash_read_dm === reloc_offset: 749000 dev:00000c00 off: d0000 len: 16384 data abort pc : [<87f69226>] lr : [<87f69223>] reloc pc : [<87820226>] lr : [<87820223>] sp : 86f44e50 ip : 00000000 fp : 00000017 r10: 878006cc r9 : 86f44ee0 r8 : 86f50600 r7 : 87fdb78c r6 : 00004000 r5 : 000d0000 r4 : 00000c00 r3 : 49e2e00d r2 : 00004000 r1 : 86f44c24 r0 : 0000004e Flags: Nzcv IRQs off FIQs off Mode SVC_32 Code: e9cd4603 48081600 f02c4908 6823fa66 (6bdb4632) Resetting CPU ...
It crashes in:
8782018c T board_nand_init 87820200 t spi_flash_post_bind 87820204 T spi_flash_read_dm <- 87820244 T spi_flash_write_dm 87820252 T spi_flash_erase_dm
dev pointer seems bogus to me ...
I try to find out more, but may I have only next week time for it... sorry.
bye, Heiko
participants (3)
-
Boris Brezillon
-
Heiko Schocher
-
Marek Vasut