-1

I have a custom board (NXP iMX6UL) with Spansion Flash 25HS512TFANHI010 which I cant seem to get working.

My dtsi has the following

...
pinctrl_qspi: qspigrp {
                fsl,pins = <
                        MX6UL_PAD_NAND_WP_B__QSPI_A_SCLK        0x70a1
                        MX6UL_PAD_NAND_READY_B__QSPI_A_DATA00   0x70a1
                        MX6UL_PAD_NAND_CE0_B__QSPI_A_DATA01     0x70a1
                        MX6UL_PAD_NAND_CE1_B__QSPI_A_DATA02     0x70a1
                        MX6UL_PAD_NAND_CLE__QSPI_A_DATA03       0x70a1
                        MX6UL_PAD_NAND_DQS__QSPI_A_SS0_B        0x70a1
                >;
        };
...
&qspi {
        pinctrl-names = "default";
        pinctrl-0 = <&pinctrl_qspi>;
        status = "okay";
        //cs-gpios = <&gpio4 16 0>;

        flash0: 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>;
                spi-cpha;
                spi-cpol;
                m25p,fast-read;
                //wp-gpios = <&gpio4 14 0>;
                //hold-gpios = <&gpio4 15 0>;
                status = "okay";
         };
};

For u-boot my defconfig has the following

CONFIG_DM=y
CONFIG_SPI=y
CONFIG_SPI_FLASH=y
CONFIG_SPI_FLASH_SPANSION=y
CONFIG_DM_SPI=y
CONFIG_DM_SPI_FLASH=y
CONFIG_FSL_QSPI=y
CONFIG_SF_DEFAULT_MODE=0

for linux my defconfig has basically (among a lot of other stuff)

CONFIG_SPI_FSL_QUADSPI=y

so both u-boot and Linux doesn't seem to work well

u-boot Error

U-Boot 2021.10-rc2-00044-g4865db0716-dirty (Aug 24 2021 - 23:15:49 +0530)
...
=> sf probe
fsl_qspi spi@21e0000: spi_find_chip_select: plat=9ef61e10, cs=0
fsl_qspi spi@21e0000: spi_find_chip_select: plat=9ef61e10, cs=0
jedec_spi_nor s25hs512t@0: set_state_simple op missing
fsl_qspi spi@21e0000: CMD[9f] lutval[0:1c00049f          1:0     2:0     3:0]
Failed to initialize SPI flash at 0:0 (error -524)

DM Tree

=> dm tree 
 Class     Index  Probed  Driver                Name
-----------------------------------------------------------
 root          0  [ + ]   root_driver           root_driver
 thermal       0  [   ]   imx_thermal           |-- imx_thermal
 simple_bus    0  [ + ]   simple_bus            |-- soc
 simple_bus    1  [ + ]   simple_bus            |   |-- aips-bus@2000000
 simple_bus    2  [   ]   simple_bus            |   |   |-- spba-bus@2000000
 gpio          0  [   ]   gpio_mxc              |   |   |-- gpio@209c000
 gpio          1  [   ]   gpio_mxc              |   |   |-- gpio@20a0000
 gpio          2  [   ]   gpio_mxc              |   |   |-- gpio@20a4000
 gpio          3  [   ]   gpio_mxc              |   |   |-- gpio@20a8000
 gpio          4  [   ]   gpio_mxc              |   |   |-- gpio@20ac000
 simple_bus    3  [   ]   simple_bus            |   |   |-- anatop@20c8000
 simple_bus    4  [   ]   simple_bus            |   |   |-- snvs@20cc000
 pinctrl       0  [ + ]   fsl_imx6q_iomuxc      |   |   `-- iomuxc@20e0000
 pinconfig     0  [   ]   pinconfig             |   |       |-- i2c1grp
 pinconfig     1  [   ]   pinconfig             |   |       |-- i2c2grp
 pinconfig     2  [ + ]   pinconfig             |   |       |-- qspigrp
 pinconfig     3  [   ]   pinconfig             |   |       |-- tscgrp
 pinconfig     4  [   ]   pinconfig             |   |       |-- uart1grp
 pinconfig     5  [ + ]   pinconfig             |   |       |-- usdhc2grp
 pinconfig     6  [   ]   pinconfig             |   |       `-- wdoggrp
 simple_bus    5  [ + ]   simple_bus            |   `-- aips-bus@2100000
 mmc           0  [ + ]   fsl_esdhc             |       |-- usdhc@2194000
 blk           0  [   ]   mmc_blk               |       |   `-- usdhc@2194000.blk
 i2c           0  [   ]   i2c_mxc               |       |-- i2c@21a0000
 i2c           1  [   ]   i2c_mxc               |       |-- i2c@21a4000
 spi           0  [ + ]   fsl_qspi              |       `-- spi@21e0000
 spi_flash     0  [   ]   jedec_spi_nor         |           `-- s25hs512t@0
 regulator     0  [   ]   regulator_fixed       `-- regulator-sd2-vmmc

Linux Error

[    0.000000] Booting Linux on physical CPU 0x0
[    0.000000] Linux version 5.14.0-rc7-413454-gd5ae8d7f85b7 (harkirat@harkirat-devsys) (arm-linux-gnueabihf-gcc (Ubuntu 9.3.0-17ubuntu1~20.04) 9.3.0, GNU ld (GNU Binutils for Ubuntu) 2.34) #3 SMP Tue Aug 24 22:47:19 IST 2021
[    0.000000] CPU: ARMv7 Processor [410fc075] revision 5 (ARMv7), cr=10c5387d
...
[    2.639396] spi spi0.0: setup: unsupported mode bits 3
[    2.645215] fsl-quadspi 21e0000.spi: can't setup spi0.0, status -22
[    2.651590] spi_master spi0: spi_device register error /soc/bus@2100000/spi@21e0000/s25hs512t@0
[    2.660817] spi_master spi0: Failed to create SPI device for /soc/bus@2100000/spi@21e0000/s25hs512t@0
...

I have tried almost every iteration possible, but I can seem to get to the issue. I have a feeling its something to do with the dtsi. Any help will be appreciated, am at wits end.

PS: tried the cypress forums but they have been very non responsive. they have a u-boot patch from 2018.01 which is as such not compatible with 2021.10

Harkirat
  • 72
  • 8
  • 1
    It looks like the fsl-quadspi controller only supports SPI mode 0, but the combination of `spi-cpol` and `spi-cpha` corresponds to SPI mode 3. SPI NOR devices can usually work in either mode 0 or mode 3. Have you tried removing the `spi-cpol` and `spi-cpha` properties? – Ian Abbott Aug 26 '21 at 13:39
  • @IanAbbott - Thanks for the reply. I have tried that, but ineffective. I have also tried to manually probe using 'sf' command on u-boot console with different modes. None Work. I tried to read the driver code to understand what error is -524 (in u-boot) but couldn't get to anywhere. any other suggestions? – Harkirat Aug 26 '21 at 15:50
  • @IanAbbott So I might have misread your instruction. I had tried on u-boot only. it worked in the Linux Kernel (Thank you so much for that). I had to add the device IDs to drivers/mtd/spi/spi-nor-ids.c since the IDs for the HS/HL series of Spansion NOR devices are apparently not included. This solves problem number two (I think). Back to problem number one - uboot. I made the same changes to dtsi but since sf didn't work I think it may not be the problem. Any other suggestions where to look in uboot? – Harkirat Aug 26 '21 at 16:45
  • Sorry, I gave up on uboot as I find its source code structure too confusing. I use barebox instead. – Ian Abbott Aug 26 '21 at 22:13
  • @IanAbbott ... that will be a serious learning curve shifting to barebox. first to check if the device actually works there. and also the following - how is the integration with yocto? how mature is it for long developments? any walkthroughs for custom boards? – Harkirat Aug 27 '21 at 01:43
  • I'm not suggesting you switch to barebox, I'm just explaining why I can't help you much with u-boot! :-) – Ian Abbott Aug 27 '21 at 09:04
  • *"I have a custom board ..."* -- Then presumably you still have an untested board. Set aside Linux, and focus on U-Boot and testing your hardware. Add commands to access SPI devices (CONFIG_CMD_SPI) to your U-Boot. Do you have an oscilloscope? – sawdust Aug 30 '21 at 22:55
  • @sawdust custom = self designed and built. and yes to the latter two questions – Harkirat Sep 01 '21 at 02:31
  • @IanAbbott so despite your caution I went with Barebox. got it to boot and the system to detect the Flash (had to add the IDs to the driver file nevertheless). That left me with second problem erasing and writing to the Flash. Adding the link to the question if you have some time to take a look. https://stackoverflow.com/q/69007378/866664?sem=2 – Harkirat Sep 01 '21 at 03:15

1 Answers1

0

Support for S25HL/S25HS series has been added in u-boot 2021.10-rc3.

Ensure:

CONFIG_SPI_FLASH_SFDP_SUPPORT is set and
CONFIG_SPI_FLASH_BAR is not set

Thanks to Mr. Kuwano of Infineon for the support.

PS: Not tested on Linux. Not working on Barebox yet (getting detected but not writing).

ouflak
  • 2,458
  • 10
  • 44
  • 49
Harkirat
  • 72
  • 8