using nrf spi flash driver

I'm trying to use the nordic spi flash driver with a w25q64jvssiq SPI NOR device.

https://github.com/nrfconnect/sdk-zephyr/tree/main/samples/drivers/spi_flash

having problems adding the correct config and overlay

prj.conf ive added

CONFIG_FLASH=y
CONFIG_SPI=y
in app.overlay ive added
spi_flash0:&spi2
{
    compatible = "nordic,nrf-spim";
    pinctrl-0 = <&spi2_default_alt>;
    pinctrl-1 = <&spi2_sleep_alt>;
    pinctrl-names = "default", "sleep";
    status = "okay";
    // cs-gpios = <&gpio0 31 GPIO_ACTIVE_LOW>;
};
spi2_default_alt: spi2_default_alt {
    group1 {
        psels = <NRF_PSEL(SPIM_MOSI, 0, 9)>,
               <NRF_PSEL(SPIM_SCK, 0, 8)>,
                <NRF_PSEL(SPIM_MISO, 0, 10)>;
    };
};
spi2_sleep_alt: spi2_sleep_alt {
    group1 {
       psels = <NRF_PSEL(SPIM_MOSI, 0, 9)>,
               <NRF_PSEL(SPIM_SCK, 0, 8)>,
               <NRF_PSEL(SPIM_MISO, 0, 10)>;
       low-power-enable;
    };
};
group1 is complaining about "Node group1 should have "compatible" property"
What am i missing here ?
  • group1 is now ok has ive change the overlay to this

    &spi0 {
        compatible = "nordic,nrf-spim";
        status = "okay";
        pinctrl-0 = <&spi0_sleep>;
        pinctrl-1 = <&spi0_default>;
        cs-gpios = <&gpio0 12 GPIO_ACTIVE_LOW>;

        spi_flash0:spi_flash0@0 {
            compatible = "jedec,spi-nor";
            reg = <0>;
    //      irq-gpios = <&gpio0 21 0>;
            spi-max-frequency = <0x400000>;
            label = "W25Q64JV";
            jedec-id = [ 16 40 17 ];
            size = < 0x4000000 >;
        };
    };

    &pinctrl {
        spi0_sleep: spi0_sleep {
            group1 {
                psels = <NRF_PSEL(SPIM_SCL, 0, 19)>,
                        <NRF_PSEL(SPIM_MOSI, 0, 20)>,
                        <NRF_PSEL(SPIM_MISO, 0, 21)>;
       
    //          low-power-enable;
            };
        };
       
        spi0_default: spi0_default {
            group1 {
                psels = <NRF_PSEL(SPIM_SCL, 0, 19)>,
                        <NRF_PSEL(SPIM_MOSI, 0, 20)>,
                        <NRF_PSEL(SPIM_MISO, 0, 21)>;
            };  
        };  
    };
    the issue now is NRF_PSEL(SPIM_SCL019) has red squiggly line under it and is reporting  
    Unable to evaluate expression
    #define NRF_PSEL(SPIM_SCL, 0, 19) \
    ((((((0) * 32U) + (19)) & 0x7FU) << 0U) | ((NRF_FUN_SPIM_SCL & 0xFFFFU) << 16U))
     
    ????
  • Hi,

    How does it compile and run? VS Code produces a lot of squiggly line warnings that can be safely ignored if the project compiles and runs as expected.

    If you are having issues with that, could you tell me which version of the nRF Connect SDK you are using, so that I can try reproducing your issues?

  • using latest version v2.4.0 (VSC v2023.4.179)

    I know VC code can do this, but the project will not build ! See image 

    If i comment out the psel sections, it builds fine....... so it is something to do with them

  • Ive somehow fixed this. In the devicetree editor under pincrtl SPIM_SCK was not selected. So i reselected it and it cleared the issue.

    Note i manually edited the app.overlay to add them orginally..... So it must be something to do with this.

Related