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!

  • Sorry, but I don't see a better step forward other than start connecting a logic analyzer for debugging.

    Kenneth

  • I am able to read and write to external flash using NVS. However, when I enable SB_CONFIG_PM_EXTERNAL_FLASH_MCUBOOT_SECONDARY=y, the device does not start. If I use simple DFU, it works fine.

  • NVS is working properly in external flash, but when I add SB_CONFIG_PM_EXTERNAL_FLASH_MCUBOOT_SECONDARY=y (which is for the MCUboot secondary slot in external flash), nothing works. The project does not start, and no logs are received.

    I used the following example:

    https://devzone.nordicsemi.com/f/nordic-q-a/118825/fota-over-ble-using-external-flash-nrf-connect-sdk-2-9-0---upload-to-device-stuck/522530

    8054.peripheral_lbs_fota_spi.zip


    I am using the Adafruit Feather nRF52840 Sense board along with the 

    nrf21540dk_nrf52840.overlay
    For external flash, I am using the W25Q32 module :https://robu.in/product/w25q32-large-capacity-flash-storage-module/

  •    

    I hope you're both doing well. If you have any suggestions or advice on this, I would really appreciate it. Please let me know if there's anything you recommend.

    Thank you for your time!

    Best regards,
    Anil Dalvadi

  • I kind of bailed when you went from a standard Nordic product (nrf21540) and immediately started saying you were testing with the Adafruit Feather. Have you reached out to Adafruit resources on how to work with their parts? 

    Did you attempt a simple check of accessing the spi device directly?
    \v2.9.0\zephyr\samples\drivers\spi_flash\ might help with testing the general setup, before committing to more complex things like booting from it.

Reply
  • I kind of bailed when you went from a standard Nordic product (nrf21540) and immediately started saying you were testing with the Adafruit Feather. Have you reached out to Adafruit resources on how to work with their parts? 

    Did you attempt a simple check of accessing the spi device directly?
    \v2.9.0\zephyr\samples\drivers\spi_flash\ might help with testing the general setup, before committing to more complex things like booting from it.

Children
Related