U-Boot执行mtdparts提示找不到nor0及dfu_alt_info配置咨询
问题背景
硬件:搭载S25HS512T闪存、i.MX6UL处理器的定制开发板
U-Boot版本:2021.10-rc3(已原生支持Spansion S25HS系列闪存)
DTS配置
&qspi { pinctrl-names = "default"; pinctrl-0 = <&pinctrl_qspi>; status = "okay"; flash: s25hs512t@0 { #address-cells = <1>; #size-cells = <1>; compatible = "spansion,s25hs512t", "jedec,spi-nor"; spi-max-frequency = <40000000>; spi-rx-bus-width = <4>; spi-tx-bus-width = <4>; reg = <0>; spi-mode = <0>; m25p,fast-read; status = "okay"; partition@uboot { label = "uboot"; reg = <0x00000000 0x00100000>; }; partition@uboot-env { label = "uboot-env"; reg = <0x00100000 0x00040000>; }; partition@kernel-dtb { label = "kernel-dtb"; reg = <0x00140000 0x00040000>; }; partition@kernel { label = "kernel"; reg = <0x00180000 0x00800000>; }; partition@root { label = "root"; reg = <0x00980000 0x03640000>; }; }; };
已验证正常的操作日志
sf probe闪存识别日志
=> sf probe drivers/core/uclass.c:325-uclass_find_device_by_seq() 0 drivers/core/uclass.c:333-uclass_find_device_by_seq() - 0 'spi@21e0000' drivers/core/uclass.c:336-uclass_find_device_by_seq() - found drivers/spi/spi-uclass.c:282-spi_find_chip_select() fsl_qspi spi@21e0000: spi_find_chip_select: plat=9ef2af60, cs=0 drivers/core/uclass.c:325-uclass_find_device_by_seq() 0 drivers/core/uclass.c:333-uclass_find_device_by_seq() - 0 'spi@21e0000' drivers/core/uclass.c:336-uclass_find_device_by_seq() - found drivers/spi/spi-uclass.c:282-spi_find_chip_select() fsl_qspi spi@21e0000: spi_find_chip_select: plat=9ef2af60, cs=0 drivers/core/uclass.c:325-uclass_find_device_by_seq() 0 drivers/core/uclass.c:333-uclass_find_device_by_seq() - 0 'iomuxc@20e0000' drivers/core/uclass.c:336-uclass_find_device_by_seq() - found drivers/pinctrl/pinctrl-uclass.c:300-pinctrl_select_state_simple() jedec_spi_nor m25p80@0: set_state_simple op missing drivers/spi/fsl_qspi.c:464-fsl_qspi_prepare_lut() fsl_qspi spi@21e0000: CMD[9f] lutval[0:1c00049f 1:0 2:0 3:0] drivers/spi/fsl_qspi.c:464-fsl_qspi_prepare_lut() fsl_qspi spi@21e0000: CMD[5a] lutval[0:818045a 1:1c000c08 2:0 3:0] drivers/spi/fsl_qspi.c:464-fsl_qspi_prepare_lut() fsl_qspi spi@21e0000: CMD[5a] lutval[0:818045a 1:1c000c08 2:0 3:0] drivers/spi/fsl_qspi.c:464-fsl_qspi_prepare_lut() fsl_qspi spi@21e0000: CMD[5a] lutval[0:818045a 1:1c000c08 2:0 3:0] drivers/spi/fsl_qspi.c:464-fsl_qspi_prepare_lut() fsl_qspi spi@21e0000: CMD[b7] lutval[0:4b7 1:0 2:0 3:0] drivers/spi/fsl_qspi.c:464-fsl_qspi_prepare_lut() fsl_qspi spi@21e0000: CMD[65] lutval[0:8200465 1:1c00 2:0 3:0] drivers/mtd/spi/spi-nor-core.c:2531- spi_nor_parse_sfdp() jedec_spi_nor m25p80@0: non-uniform erase sector maps are not supported yet. drivers/spi/fsl_qspi.c:464-fsl_qspi_prepare_lut() fsl_qspi spi@21e0000: CMD[65] lutval[0:8200465 1:1c00 2:0 3:0] drivers/spi/fsl_qspi.c:464-fsl_qspi_prepare_lut() fsl_qspi spi@21e0000: CMD[65] lutval[0:8200465 1:1c00 2:0 3:0] SF: Detected s25hs512t with page size 256 Bytes, erase size 256 KiB, total 64 MiB drivers/mtd/mtdcore.c:494- add_mtd_device() mtd: Giving out device 0 to s25hs512t <=== That works drivers/spi/spi-uclass.c:431- spi_get_bus_and_cs() spi_get_bus_and_cs: bus=9ef2ae80, slave=9ef2d248
mtd分区识别日志
=> env set mtdparts 's25hs512t:1024k(uboot),256k(uboot-env),256k(kernel-dtb),6656k(kernel),-(root)' => mtd list drivers/mtd/mtdcore.c:494- add_mtd_device() mtd: Giving out device 1 to uboot drivers/mtd/mtdcore.c:494- add_mtd_device() mtd: Giving out device 2 to uboot-env drivers/mtd/mtdcore.c:494- add_mtd_device() mtd: Giving out device 3 to kernel-dtb drivers/mtd/mtdcore.c:494- add_mtd_device() mtd: Giving out device 4 to kernel drivers/mtd/mtdcore.c:494- add_mtd_device() mtd: Giving out device 5 to root List of MTD devices: * s25hs512t - device: m25p80@0 - parent: spi@21e0000 - driver: jedec_spi_nor - path: /soc/aips-bus@2100000/spi@21e0000/m25p80@0 - type: NOR flash - block size: 0x40000 bytes - min I/O: 0x1 bytes - 0x000000000000-0x000004000000 : "s25hs512t" - 0x000000000000-0x000000100000 : "uboot" - 0x000000100000-0x000000140000 : "uboot-env" - 0x000000140000-0x000000180000 : "kernel-dtb" - 0x000000180000-0x000000800000 : "kernel" - 0x000000800000-0x000004000000 : "root"
异常现象
设置mtdids后执行mtdparts报错:
=> setenv mtdids 'nor0=s25hs512t' => mtdparts Device nor0 not found!
问题解答
1. mtdids配置错误说明与正确方案
错误原因
你配置的mtdids将nor0映射到了闪存设备s25hs512t,但同时你设置的mtdparts分区表是直接用s25hs512t作为设备前缀,两者不匹配,U-Boot的MTD子系统找不到nor0对应的分区表,所以报错。
正确配置流程
# 1. 先识别闪存,这一步是前置依赖 sf probe # 2. 设置mtdids,绑定别名和实际设备名 setenv mtdids 'nor0=s25hs512t' # 3. 设置mtdparts,前缀改为和mtdids里的别名nor0一致 setenv mtdparts 'mtdparts=nor0:1024k(uboot),256k(uboot-env),256k(kernel-dtb),6656k(kernel),-(root)' # 可选:保存环境变量到闪存,避免重启后重复配置 saveenv
配置完成后执行mtdparts即可正常输出分区列表。
2. dfu_alt_info正确配置
原有配置错误点
你写的root partubi 5里,partubi是UBI分区专属的类型标识,如果你的root分区没有做UBI格式化,直接用part即可。
正确配置
普通NOR分区场景:
setenv dfu_alt_info 'mtd nor0=uboot part 1;uboot-env part 2;kernel-dtb part 3;kernel part 4;root part 5;'
如果root分区确实规划为UBI分区,且U-Boot已经开启了CONFIG_MTD_UBI相关配置,可以保留partubi标识:
setenv dfu_alt_info 'mtd nor0=uboot part 1;uboot-env part 2;kernel-dtb part 3;kernel part 4;root partubi 5;'
内容的提问来源于stack exchange,提问作者Harkirat
相关产品推荐
相关产品推荐

