How to Interface W25Q32 External Flash with nRF21540DK/nRF52840 in nRF Connect SDK 2.9.0?

I am using nRF Connect SDK 2.9.0 with Toolchain 2.9.0 and trying to interface Winbond W25Q32 SPI flash memory with nRF21540DK (nRF52840). I need help with the following:

  1. Device Tree Overlay – Proper setup for enabling W25Q32 in Zephyr.
  2. Driver Support – Recommended drivers, APIs, or sample projects for working with SPI flash.

If anyone has successfully integrated external SPI flash with nRF52840 in nRF Connect SDK 2.9.0, please share your insights or example configurations.

Thanks in advance!

Parents
  • Also, the core .dtsi file that is included into the nrf52840 device tree is stored here \zephyr\dts\arm\nordic\nrf52840.dtsi .
    This shows the base of spi1 which I think you will need to connect to for flash.

    For an example of how to add the flash to the device tree (but to a different spi since it's a different board, sorry I couldn't find one specific to the nrf21540/nrf52840)  zephyr\boards\sparkfun\thing_plus\sparkfun_thing_plus_nrf9160_common.dtsi . This shows a w25q32 attached to a spi3. You need to create an overlay for the nrf21540 and copy this into spi1. 

    I haven't had to use an external flash, but this looks like some pieces to start from.

    I am assuming you understand the device tree layout system. 

    Also, IF you haven't run through them, I suggest you go through the Nordic courses on how to use their tools. 

  • I am using the Adafruit Feather nRF52840 Sense board with an external SPI NOR flash (Winbond W25Q32JV) in nRF Connect SDK 2.9.0. However, the flash is not being recognized, and I get the following error:

    E: Device id 00 00 00 does not match config ef 40 16
    Flash device w25q32jv@0 is not ready

    Here is my overlay file:

     &spi1 {
    	compatible = "nordic,nrf-spim";
    	status = "okay";
    	cs-gpios = <&gpio0 8 GPIO_ACTIVE_LOW>;
    	pinctrl-0 = <&spi1_default>;
    	pinctrl-1 = <&spi1_sleep>;
    	pinctrl-names = "default", "sleep";
    	w25q32jv: w25q32jv@0 {
    		compatible = "jedec,spi-nor";
    		reg = <0>;
    		spi-max-frequency = <40000000>;
    		size = <0x2000000>;
    		has-dpd;
    		t-enter-dpd = <3000>;
    		t-exit-dpd = <30000>;
    		jedec-id = [ ef 40 16 ];
    	};
    };  
    / {
        chosen {
            nordic,pm-ext-flash = &w25q32jv;
        };
    };

    Here is my prj.conf file:

    CONFIG_NCS_SAMPLES_DEFAULTS=y
    CONFIG_SERIAL=y
    CONFIG_CONSOLE=y
    CONFIG_UART_CONSOLE=y
    CONFIG_UART_ASYNC_API=y
    CONFIG_LOG_BACKEND_UART=y
    CONFIG_BT=y
    CONFIG_BT_PERIPHERAL=y
    CONFIG_BT_DEVICE_NAME="Nordic_LBS"
    
    # Enable the LBS service
    CONFIG_BT_LBS=y
    CONFIG_BT_LBS_POLL_BUTTON=y
    CONFIG_DK_LIBRARY=y
    CONFIG_CLOCK_CONTROL_NRF_K32SRC_RC=y
    CONFIG_SYSTEM_WORKQUEUE_STACK_SIZE=2048
    
    CONFIG_GPIO=y
    CONFIG_SPI=y
    CONFIG_SPI_NOR=y
    CONFIG_SPI_NOR_SFDP_DEVICETREE=y
    CONFIG_SPI_NOR_FLASH_LAYOUT_PAGE_SIZE=4096
    CONFIG_NORDIC_QSPI_NOR=n  # Explicitly disable QSPI if using SPI
    CONFIG_SPI_NOR_SFDP_MINIMAL=y
    CONFIG_PM_OVERRIDE_EXTERNAL_DRIVER_CHECK=y
    CONFIG_PM_PARTITION_REGION_NVS_STORAGE_EXTERNAL=y
    CONFIG_PM_PARTITION_SIZE_NVS_STORAGE=0x8000
    CONFIG_FLASH=y
    CONFIG_FLASH_MAP=y
    CONFIG_NVS=y
    CONFIG_MPU_ALLOW_FLASH_WRITE=y
    

    What could be causing this issue, and how can I fix it? Any suggestions would be appreciated!

Reply
  • I am using the Adafruit Feather nRF52840 Sense board with an external SPI NOR flash (Winbond W25Q32JV) in nRF Connect SDK 2.9.0. However, the flash is not being recognized, and I get the following error:

    E: Device id 00 00 00 does not match config ef 40 16
    Flash device w25q32jv@0 is not ready

    Here is my overlay file:

     &spi1 {
    	compatible = "nordic,nrf-spim";
    	status = "okay";
    	cs-gpios = <&gpio0 8 GPIO_ACTIVE_LOW>;
    	pinctrl-0 = <&spi1_default>;
    	pinctrl-1 = <&spi1_sleep>;
    	pinctrl-names = "default", "sleep";
    	w25q32jv: w25q32jv@0 {
    		compatible = "jedec,spi-nor";
    		reg = <0>;
    		spi-max-frequency = <40000000>;
    		size = <0x2000000>;
    		has-dpd;
    		t-enter-dpd = <3000>;
    		t-exit-dpd = <30000>;
    		jedec-id = [ ef 40 16 ];
    	};
    };  
    / {
        chosen {
            nordic,pm-ext-flash = &w25q32jv;
        };
    };

    Here is my prj.conf file:

    CONFIG_NCS_SAMPLES_DEFAULTS=y
    CONFIG_SERIAL=y
    CONFIG_CONSOLE=y
    CONFIG_UART_CONSOLE=y
    CONFIG_UART_ASYNC_API=y
    CONFIG_LOG_BACKEND_UART=y
    CONFIG_BT=y
    CONFIG_BT_PERIPHERAL=y
    CONFIG_BT_DEVICE_NAME="Nordic_LBS"
    
    # Enable the LBS service
    CONFIG_BT_LBS=y
    CONFIG_BT_LBS_POLL_BUTTON=y
    CONFIG_DK_LIBRARY=y
    CONFIG_CLOCK_CONTROL_NRF_K32SRC_RC=y
    CONFIG_SYSTEM_WORKQUEUE_STACK_SIZE=2048
    
    CONFIG_GPIO=y
    CONFIG_SPI=y
    CONFIG_SPI_NOR=y
    CONFIG_SPI_NOR_SFDP_DEVICETREE=y
    CONFIG_SPI_NOR_FLASH_LAYOUT_PAGE_SIZE=4096
    CONFIG_NORDIC_QSPI_NOR=n  # Explicitly disable QSPI if using SPI
    CONFIG_SPI_NOR_SFDP_MINIMAL=y
    CONFIG_PM_OVERRIDE_EXTERNAL_DRIVER_CHECK=y
    CONFIG_PM_PARTITION_REGION_NVS_STORAGE_EXTERNAL=y
    CONFIG_PM_PARTITION_SIZE_NVS_STORAGE=0x8000
    CONFIG_FLASH=y
    CONFIG_FLASH_MAP=y
    CONFIG_NVS=y
    CONFIG_MPU_ALLOW_FLASH_WRITE=y
    

    What could be causing this issue, and how can I fix it? Any suggestions would be appreciated!

Children
Related