U Boot how to make SPI Flash configuration

cancel
Showing results for 
Search instead for 
Did you mean: 

U Boot how to make SPI Flash configuration

1,584 Views
berkayercann1
Contributor I

Hi guys,

I'm working on i.MX6UL custom board. Trying to configure SPI Flash (Model = Winbond W25Q128JV),
Here's the changes that I've made and the parts that I've added;

## arch/arm/dts/imx6ul-14x14-evk.dts;

+spi4 {
+        compatible = "spi-gpio";
+        pinctrl-names = "default";
+        pinctrl-0 = <&pinctrl_spi4>;
+        pinctrl-assert-gpios = <&gpio1 10 GPIO_ACTIVE_LOW>;
+        num-chipselects = <1>;
+        #address-cells = <1>;
+        #size-cells = <0>;
+        status = "okay";
+            flash: m25p80@0 {
+                #address-cells = <1>;
+                #size-cells = <1>;
+                compatible = "spansion,m25p80";
+                reg = <0>;
+                spi-max-frequency = <133000000>;
+    };

## board/freescale/imx6ul_14x14_evk.c;

+#define SPI_PAD_CTRL (PAD_CTL_HYS |                \
+    PAD_CTL_SPEED_MED |        \
+    PAD_CTL_DSE_40ohm | PAD_CTL_SRE_FAST)

-----------------------------------------------------------------------------------------------------------------------------

+#ifdef CONFIG_SPINOR
+/* pin conflicts with eim nor */
+static iomux_v3_cfg_t const ecspi1_pads[] = {
+    MX6_PAD_ENET2_TX_EN__ECSPI4_MOSI| MUX_PAD_CTRL(SPI_PAD_CTRL),
+    MX6_PAD_ENET2_TX_DATA1__ECSPI4_SCLK | MUX_PAD_CTRL(SPI_PAD_CTRL),
+    MX6_PAD_ENET2_TX_CLK__ECSPI4_MISO | MUX_PAD_CTRL(SPI_PAD_CTRL),

+  /* CS Pin */
+  MX6_PAD_JTAG_MOD__GPIO1_IO10  | MUX_PAD_CTRL(NO_PAD_CTRL),
+};

+static void setup_spinor(void)
+{
+ imx_iomux_v3_setup_multiple_pads(ecspi1_pads, ARRAY_SIZE(ecspi1_pads));
+  gpio_request(IMX_GPIO_NR(1, 10), "escpi cs");
+   gpio_direction_output(IMX_GPIO_NR(1, 0), 0);
+}

+int board_spi_cs_gpio(unsigned bus, unsigned cs)
+{
+   return (bus == 0 && cs == 0) ? (IMX_GPIO_NR(1, 10)) : -1;
+}
+#endif

-----------------------------------------------------------------------------------------------------------------------------

+#ifdef CONFIG_SPINOR
+   setup_spinor();
+#endif

-----------------------------------------------------------------------------------------------------------------------------

##configs/mx6ul_14x14_evk_defconfig

+CONFIG_DM_SPI=y
+CONFIG_DM_SPI_FLASH=y
+CONFIG_SPINOR=y
+CONFIG_WINBOND=y
+CONFIG_SPI_FLASH=y
+CONFIG_SPI_FLASH_BAR=y
+CONFIG_CMD_SPI=y

-----------------------------------------------------------------------------------------------------------------------------

##drivers/mtd/spi/spi_flash_ids.c

#ifdef CONFIG_SPI_FLASH_WINBOND        /* WINBOND */

   + {"w25q128jv",       INFO(0xef7018, 0x0,    64 * 1024,   256, RD_FULL | WR_QPP | SECT_4K) },

-----------------------------------------------------------------------------------------------------------------------------

##include/configs/mx6ul_14x14_evk.h

+#ifdef CONFIG_SPINOR
+#define CONFIG_CMD_SF
+#define CONFIG_SPI_FLASH
+#define CONFIG_SPI_FLASH_WINBOND
+#define CONFIG_SF_DEFAULT_BUS 4
+#define CONFIG_SF_DEFAULT_CS 0
+#define CONFIG_SF_DEFAULT_SPEED 133000000
+#define CONFIG_SF_DEFAULT_MODE SPI_MODE_0
+#endif

But I can't even open the SPI bus. Here's the terminal output when I try to 'sf probe'

=>sf probe

Invalid bus 0 (err=-19)

Failed to initialize SPI flash at 0:0 (error -19)

=>sf probe 4:0

Invalid bus 4 (err=-19)

Failed to initialize SPI flash at 4:0(error -19)

.

.

.

I dont know what I'm missing , I could use some help.

Thank you.

0 Kudos
6 Replies

899 Views
igorpadykov
NXP TechSupport
NXP TechSupport

Hi berkay

one can recheck LUT, example can be found on

https://community.nxp.com/thread/446470 

Best regards
igor
-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------

0 Kudos

899 Views
berkayercann1
Contributor I

Hi Igor,
I've checked the links but we're not sure that we need to use LUT and have to deal with registers . Also we're not using MFG so that answer will be so hard for us . Is there another way to probe an SPI flash?

Thanks for the answer.

0 Kudos

899 Views
igorpadykov
NXP TechSupport
NXP TechSupport

Hi berkay

one can look at spi-nor n25q032 example:

flash: n25q032@0

https://source.codeaurora.org/external/imx/linux-imx/tree/arch/arm/boot/dts/imx6ul-14x14-ddr3-arm2.d... 

uboot/board/freescale/mx6ul_14x14_ddr3_arm2/mx6ul_14x14_ddr3_arm2.c

mx6ul_14x14_ddr3_arm2.c\mx6ul_14x14_ddr3_arm2\freescale\board - uboot-imx - i.MX U-Boot 

Best regards
igor

0 Kudos

899 Views
berkayercann1
Contributor I

I did exactly the same configurations from the links but still getting the same errors , Invalid bus 4 (err = -19)
Also got the activated SPI conf scripts from the defconfig and configured the board header file from your link . Still missing something :/

0 Kudos

899 Views
igorpadykov
NXP TechSupport
NXP TechSupport

one can try to check spi signals using oscilloscope.

Best regards
igor

0 Kudos

899 Views
berkayercann1
Contributor I

Hi Igor ,
I've checked the SPI signals , they're not correct .

Thanks for the answer again .

0 Kudos