NRF54L15 spi00 not working

Hello team,

I am using SPI00 of NRF54L15 to communicate with w25q32fv (spi Flash). Below is the configuration I set in .overlay file

&pinctrl {
    spi00_default: spi00_default {
        group1 {
            psels = <NRF_PSEL(SPIM_SCK, 2, 1)>,
                    <NRF_PSEL(SPIM_MOSI, 2, 2)>,
                    <NRF_PSEL(SPIM_MISO, 2, 4)>;
        };
    };
    spi00_sleep: spi00_sleep {
        group1 {
            psels = <NRF_PSEL(SPIM_SCK, 2, 1)>,
                    <NRF_PSEL(SPIM_MOSI, 2, 2)>,
                    <NRF_PSEL(SPIM_MISO, 2, 4)>;
					
            low-power-enable;
        };
    };
};

&spi00 {
	compatible = "nordic,nrf-spim";
	status = "okay";
    pinctrl-0 = <&spi00_default>;
    pinctrl-1 = <&spi00_sleep>;
    pinctrl-names = "default", "sleep";
	cs-gpios = <&gpio2 5 GPIO_ACTIVE_LOW>;
	w25q32fv: w25q32fv@0 {
		compatible = "jedec,spi-nor";
		reg = <0>;
		spi-max-frequency = <8000000>;
		label = "W25Q32FV";
		status = "okay";
		jedec-id = [ef 40 16];   /* optional but helpful */
		size = <0x400000>;       /* 4 MByte = 32 Mbit */
	};
};

And below is the code I am using to read the ID of the flash

void data_write_spi()
{
    if (!device_is_ready(spi_dev)) {
        printf("SPI device not ready");
        return;
    }
    
    uint8_t cmd[4];
    uint8_t rx[5];

    cmd[0] = 0x9F;

    struct spi_buf tx_bufs = {.buf = cmd, .len = 1};
    struct spi_buf rx_bufs = {.buf = rx, .len = 5};

    struct spi_buf_set tx = {.buffers = &tx_bufs, .count = 1};    
    struct spi_buf_set rx_set = {.buffers = &rx_bufs, .count = 1};

    k_msleep(5);
    int ret = spi_transceive(spi_dev, &spi_cfg, &tx, &rx_set);


    if (ret == 0) {
        printf("JEDEC ID: %02X %02X %02X %02x %02x", rx[0], rx[1], rx[2], rx[3], rx[4]);
    } else {
        printf("SPI transfer failed: %d", ret);
    }
}

I am getting the following error.

SPI transfer failed: -5

How can I fix this issue so I can use spi00 appropriately? Any help would be greatly appreciated.

Thanks,

Payal

  • Hi, 

    Now I am using SPI00 on a custom board. And I am observing the same error SPI transfer failed: -5, on the custom board as well

  • Hi,

    Please share your custom board and overlay files, and the generated .dts and .config and I'll have a look

    Kind regards,
    Andreas

  • Hi, 

    Now we have changed the flash part to AT45DB641E

    The following are the settings in .overlay

     
    &pinctrl {
        spi00_default: spi00_default {
            group1 {
                psels = <NRF_PSEL(SPIM_SCK, 2, 1)>,
                        <NRF_PSEL(SPIM_MOSI, 2, 2)>,
                        <NRF_PSEL(SPIM_MISO, 2, 4)>;
    			nordic,drive-mode = <NRF_DRIVE_E0E1>;
            };
        };
        spi00_sleep: spi00_sleep {
            group1 {
                psels = <NRF_PSEL(SPIM_SCK, 2, 1)>,
                        <NRF_PSEL(SPIM_MOSI, 2, 2)>,
                        <NRF_PSEL(SPIM_MISO, 2, 4)>;
    			nordic,drive-mode = <NRF_DRIVE_E0E1>;
                low-power-enable;
            };
        };
    };
    
    &spi00 {
    	compatible = "nordic,nrf-spim";
    	status = "okay";
        pinctrl-0 = <&spi00_default>;
        pinctrl-1 = <&spi00_sleep>;
        pinctrl-names = "default", "sleep";
    	cs-gpios = <&gpio2 5 GPIO_ACTIVE_LOW>;
    	at45db641e: at45db641e@0 {
    		compatible = "atmel,at45";//"zephyr,spi-device";
    		reg = <0>;
    		spi-max-frequency = <8000000>;
    		label = "AT45DB641E";
    		status = "okay";
    		jedec-id = [1f 28 00];   /* optional but helpful */
    		size = <0x800000>;       /* 4 MByte = 32 Mbit */
    		sector-size = <262144>;
            block-size = <2048>;
            page-size = <256>;
    	};
    };
    

    Attaching the .dts and .config file

    reference_files.zip

  • Hi,

    Thank you for sending this. It will unfortunately take longer time than I initially expected before I will be able to have a look, but I will get back to you in the upcoming week

    Kind regards,
    Andreas

  • Hi,

    I think I need more info to be able to determine what might be wrong. You had a setup on your DK with an externally connected external flash that worked. The pin config is fine, and there's some changes done since you're now on a custom board

    1. How do you initialize the device in the app?
    2. I've not checked this myself, but does the driver for the device exist in NCS
    3. Verify if you see the same in https://github.com/nrfconnect/sdk-nrf/tree/main/samples/zephyr/drivers/jesd216 
    4. Add a small test that does
      const struct device *bus = DEVICE_DT_GET(DT_NODELABEL(spi00));
      printk("spi00 ready: %d\n", device_is_ready(bus));
      const struct device *flash = DEVICE_DT_GET(DT_NODELABEL(at45db641e));
      printk("flash ready: %d\n", device_is_ready(flash));

    5. If both are ready, call a single spi_transceive() with a trivial buffer and log the return value.
    6. Use a logic analyzer on P2.1/2/4/5 to confirm SCK/MOSI/CS activity and whether MISO responds.
    7. If you can share the exact API call that returns -5 (e.g. spi_transceive() vs. a flash driver call) and how you reference the devicetree node in code, that might help us determining the root cause as well

    Kind regards,
    Andreas

Related