Interfacing FLASH with SPI instead of QSPI

Hi

I am working with nrf52840dk- nrf52840 board to interface the  flash(mx25r64) using spi_flash example code. I wants to use  SPI instead of QSPI in nrf connect sdk .
But I am facing error.

Below I have attached the overlay file I created for SPI flash pin mapping. I haven't changed anything in the main.c and I didn't changed anything in the prj.confg file also.

In the main.c there is if condition

if (!device_is_ready(flash_dev)) {
printk("%s: device not ready.\n", flash_dev->name);
return;
}

When I buid my code and try to debug the code it is coming into this if condition and shows device is not ready.  Can Someone help me with this.

Note:I didn't changed anything in the main.c

OVERLAY FILE:

&qspi {
    status ="disabled";
};

arduino_i2c: &i2c0 {
    status ="disabled";
};

/{
    aliases{
        spi-flash0 = &mx25r641;
    };
};

&spi0 {
    compatible = "nordic,nrf-spi";
    /* Cannot be used together with i2c0. */
    status = "okay";
    pinctrl-0 = <&spi0_default>;
    pinctrl-1 = <&spi0_sleep>;
    pinctrl-names = "default", "sleep";
    cs-gpios = < &gpio0 16 GPIO_ACTIVE_LOW >;
    mx25r641: mx25r641@0{
        compatible = "jedec,spi-nor";
        reg =<0x0>;
        spi-max-frequency = < 100000 >;
        label = "mx25r64";
        jedec-id = [c2 28 17];
        sfdp-bfp = [
            e5 20 f1 ff  ff ff ff 03  44 eb 08 6b  08 3b 04 bb
            ee ff ff ff  ff ff 00 ff  ff ff 00 ff  0c 20 0f 52
            10 d8 00 ff  23 72 f5 00  82 ed 04 cc  44 83 68 44
            30 b0 30 b0  f7 c4 d5 5c  00 be 29 ff  f0 d0 ff ff
        ];
        size = <67108864>;
        has-dpd;
        t-enter-dpd = <10000>;
        t-exit-dpd = <35000>;
    };
};

&pinctrl {
    spi0_default: spi0_default {
        group1 {
            psels = <NRF_PSEL(SPIM_SCK, 0, 15)>,
                    <NRF_PSEL(SPIM_MOSI, 0, 14)>,
                    <NRF_PSEL(SPIM_MISO, 0, 13)>;
        };
    };

    spi0_sleep: spi0_sleep {
        group1 {
            psels = <NRF_PSEL(SPIM_SCK, 0, 15)>,
                    <NRF_PSEL(SPIM_MOSI, 0, 14)>,
                    <NRF_PSEL(SPIM_MISO, 0, 13)>;
            low-power-enable;
        };
    };
};
In nrf52840dk_nrf52840.dts there is a node for qspi when I use spi-flash0 = &mx25r64 aliases it is redirecting to the qspi but I want the flash in spi so created above node in the overlay file 
mx25r641: mx25r641@0{
        compatible = "jedec,spi-nor";
        reg =<0x0>;
        spi-max-frequency = < 100000 >;
        label = "mx25r64";
        jedec-id = [c2 28 17];
        sfdp-bfp = [
            e5 20 f1 ff  ff ff ff 03  44 eb 08 6b  08 3b 04 bb
            ee ff ff ff  ff ff 00 ff  ff ff 00 ff  0c 20 0f 52
            10 d8 00 ff  23 72 f5 00  82 ed 04 cc  44 83 68 44
            30 b0 30 b0  f7 c4 d5 5c  00 be 29 ff  f0 d0 ff ff
        ];
        size = <67108864>;
        has-dpd;
        t-enter-dpd = <10000>;
        t-exit-dpd = <35000>;
    };
by changing the label name from mx25r64 to mx25r641 and compatible to jedec,spi-nor.
 
When I change 
CONFIG_NORDIC_QSPI_NOR=y this to 
CONFIG_NORDIC_QSPI_NOR=n and adds CONFIG_SPI_NOR =y in nrf52840dk_nrf52840.conf file It is throwing error like this "Aborting the code due to kconfig".
If someone finds the  process what I am doing wrong please correct me with the right process and help to interface the flash with spi.
Related