Reading Flash MX25L32 on BL653

Hello,

I'm working with nRF52840, BL653-DK board (Laird), and I'm trying to bind and read from the flash memory of the device (MX25L32, SPI NOR).

I've added this node to the board's .dts file, as a child node to the spi1 node:

...

&spi1 {
    compatible = "nordic,nrf-spi";
    status = "okay";
    sck-pin = <41>;
    mosi-pin = <40>;
    miso-pin = <4>;
    cs-gpios = <&gpio1 23 0>;
    mx25l32: mx25l3235f@0 {
        compatible = "nordic,qspi-nor";
        reg = <0>;
        spi-max-frequency = <80000000>;
        label = "MX25L32";
        jedec-id = [c2 28 17];
        size = <67108864>;
        wp-gpios = <&gpio0 22 0>;
        hold-gpios = <&gpio0 23 0>;
    };
};

When trying to bind to this flash from my project it does not seem to identify the drive and I get NULL from the device_get_binding() func:

#include <zephyr.h>
#include <device.h>
#include <drivers/flash.h>
#include <devicetree.h>
 
#if (CONFIG_NORDIC_QSPI_NOR - 0) || \
    DT_NODE_HAS_STATUS(DT_INST(0, nordic_qspi_nor), okay)
#define FLASH_DEVICE DT_LABEL(DT_INST(0, nordic_qspi_nor))
#endif
...
const struct device *flash_dev = device_get_binding(FLASH_DEVICE);
Can you please assist me in figuring out why this doesn't work so I can read from the flash?
Thanks in advance,
Dagan
  • Finally it worked with this configuration:

    &pinctrl {
        spi1_default: spi1_default {
    		group1 {
    			psels = <41 40 4>;
    		};
    	};
    
    	spi1_sleep: spi1_sleep {
    		group1 {
    			psels = <41 40 4>;
    			low-power-enable;
    		};
    	};
    };
    
    &spi1 {
    	compatible = "nordic,nrf-spi";
    	/* Cannot be used together with i2c0. */
        status = "okay";
    	sck-pin = <41>;
    	mosi-pin = <40>;
    	miso-pin = <4>;
    	pinctrl-0 = <&spi1_default>;
    	pinctrl-1 = <&spi1_sleep>;
    	pinctrl-names = "default", "sleep";
    	cs-gpios = <&gpio1 23 GPIO_ACTIVE_LOW>;
    	mx25l32: mx25l3256@0 {
    		compatible = "jedec,spi-nor";
    		reg = <0>;
    		spi-max-frequency = <80000000>;
    		label = "MX25L32";
    		jedec-id = [c2 20 16];
    		size = <33554432>;
    		has-dpd;
    		t-enter-dpd = <10000>;
    		t-exit-dpd = <100000>;
    		wp-gpios = <&gpio0 22 0>;
            hold-gpios = <&gpio0 23 0>;
    	};
    };

    Thanks a lot!
    Dagan

  • I'm glad to hear you've got it up and running, though there seems to be an issue with the pinctrl driver as you had to add the pins to the &spi1 node :/ 

Related