Harkirat
Harkirat

Reputation: 92

u-boot : cmd mdtparts cannot finding nor0

I have a custom board using s25hs512t and imx6ul. Currently I am using u-boot 2021.10-rc3 which has support for Spansion S25HS series.

My dtsi has

&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>;
                };

        };
};

u-boot is detecting it fine

=> 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

setting mtdparts works fine

=> 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"

Problem is when setting mtdids

=> setenv mtdids 'nor0=s25hs512t'    
=> mtdparts 
Device nor0 not found!

Questions

  1. What am I doing wrong in setting mtdids? what's supposed to be the right thing
  2. what's the correct dfu_alt_info to be set. What I tried and didn't work was
env set dfu_alt_info 'mtd nor0=uboot part 1;uboot-env part 2;kernel-dtb part 3;kernel part 4;root partubi 5;'

Upvotes: 0

Views: 1242

Answers (1)

Harkirat
Harkirat

Reputation: 92

So it seems that the recent patch on u-boot 2021.10-rc3 for including Serial Flash Discoverable Parameters picked up the name from the parameters itself.

In drivers/mtd/spi/spi-nor-core.c

int spi_nor_scan(struct spi_nor *nor)
{
        ...
        if (!mtd->name)
                mtd->name = info->name;
        mtd->dev = nor->dev;
        ...
}

Though a good idea it breaks mtdparts and dfu (maybe others, not sure) on u-boot because it expects the old naming convention - nor, nand, etc with suffix dev digit

If I statically code the name to

        if (!mtd->name)
                mtd->name = "nor0";

I have managed to make it work

=> 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 nor0 with page size 256 Bytes, erase size 256 KiB, total 64 MiB
drivers/spi/spi-uclass.c:431-  spi_get_bus_and_cs() spi_get_bus_and_cs: bus=9ef2ae80, slave=9ef2b9c8

=> env set mtdparts 'nor0:1024k(uboot),256k(uboot-env),256k(kernel-dtb),6656k(kernel),-(root)'

=> setenv mtdids 'nor0=nor0'         

=> mtdparts                 

device nor0 <nor0>, # parts = 5
 #: name                size            offset          mask_flags
 0: uboot               0x00100000      0x00000000      0
 1: uboot-env           0x00040000      0x00100000      0
 2: kernel-dtb          0x00040000      0x00140000      0
 3: kernel              0x00680000      0x00180000      0
 4: root                0x03800000      0x00800000      0

active partition: nor0,0 - (uboot) 0x00100000 @ 0x00000000

defaults:
mtdids  : 
mtdparts: 

=> env set dfu_alt_info 'mtd nor0=uboot part 1;uboot-env part 2;kernel-dtb part 3;kernel part 4;root partubi 5' 

=> dfu 0 list  
using id 'nor0,0'
using id 'nor0,1'
using id 'nor0,2'
using id 'nor0,3'                                                                                                
using id 'nor0,4'
DFU alt settings list:
dev: MTD alt: 0 name: uboot layout: RAW_ADDR
dev: MTD alt: 1 name: uboot-env layout: RAW_ADDR
dev: MTD alt: 2 name: kernel-dtb layout: RAW_ADDR
dev: MTD alt: 3 name: kernel layout: RAW_ADDR
dev: MTD alt: 4 name: root layout: RAW_ADDR

This solution is NOT suitable for production, but at least it won't break your development till u-boot guys fix it

Upvotes: 1

Related Questions