SPIM00 Failed to initialize nrfx driver: 0bad0004 on NRF54L15-DK

Hey folks, I'm trying to use SPI00 instead of SPI20 to achieve higher frequencies and driver fails to initialize no matter what I've tried to do on NRF54L15-DK.

Here are relevant parts:

overlay:

 

&spi00 {
    status = "okay";
    compatible = "nordic,nrf-spim";
    pinctrl-0 = <&spi00_default>;
    pinctrl-1 = <&spi00_sleep>;
    pinctrl-names = "default", "sleep";
    cs-gpios = <&gpio2 6 GPIO_ACTIVE_LOW>;
    sdhc0: sdhc@0 {
        compatible = "zephyr,sdhc-spi-slot";
        reg = <0>;
        status = "okay";
        mmc {
            compatible = "zephyr,sdmmc-disk";
            disk-name = "SD";
            status = "okay";
        };
        spi-max-frequency = <8000000>;
    };
};

&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;
        };
    };

};

prj.conf

CONFIG_DISK_ACCESS=y
CONFIG_FILE_SYSTEM=y
CONFIG_FAT_FILESYSTEM_ELM=y
CONFIG_FS_FATFS_LFN=y
CONFIG_FS_FATFS_EXFAT=y
CONFIG_DISK_DRIVER_SDMMC=y
CONFIG_SD_LOG_LEVEL_DBG=y
CONFIG_SDHC_LOG_LEVEL_DBG=y

Thread for SD card init

int thread0(void)
{
	// spi_pins_high_drive_init();
	k_msleep(3000);

	// tree
	// -----------------------------------------------------------------------------
	// Data reading/decoding
	// -----------------------------------------------------------------------------
		static const char *disk_pdrv = DISK_DRIVE_NAME;
		uint64_t memory_size_mb;
		uint32_t block_count;
		uint32_t block_size;

		if (disk_access_ioctl(disk_pdrv, DISK_IOCTL_CTRL_INIT, NULL) != 0)
		{
			LOG_ERR("Storage init ERROR!");
			break;
		}
}

What I get during init attempt:

[00:00:03.002,124] <err> spi_nrfx_spim: Failed to initialize nrfx driver: 0bad0004
[00:00:03.002,130] <err> sdhc_spi: Card SCLK init sequence failed
[00:00:03.002,135] <err> sd: Could not disable card power via SDHC
[00:00:03.002,141] <err> main: Storage init ERROR!

I've also tried to set drive level to high using the following (but not sure if that's the correct way)

#include "hal/nrf_gpio.h"
#include "nrf.h"

#define NRF_GPIO_PIN_DRIVE_EXTRA_HIGH NRF_GPIO_PIN_E0E1

void spi_pins_high_drive_init(void)
{
	// --- Configure P2.1 (e.g., SCK) ---
	nrf_gpio_cfg(NRF_GPIO_PIN_MAP(2, 1), // Pin number 1
							 NRF_GPIO_PIN_DIR_OUTPUT, NRF_GPIO_PIN_INPUT_DISCONNECT,
							 NRF_GPIO_PIN_NOPULL,
							 NRF_GPIO_PIN_DRIVE_EXTRA_HIGH, // This is the E0/E1 setting
							 NRF_GPIO_PIN_NOSENSE);

	// --- Configure P2.2 (e.g., MOSI) ---
	nrf_gpio_cfg(NRF_GPIO_PIN_MAP(2, 2), // Pin number 2
							 NRF_GPIO_PIN_DIR_OUTPUT, NRF_GPIO_PIN_INPUT_DISCONNECT,
							 NRF_GPIO_PIN_NOPULL,
							 NRF_GPIO_PIN_DRIVE_EXTRA_HIGH, // This is the E0/E1 setting
							 NRF_GPIO_PIN_NOSENSE);

	// --- Configure P2.4 (e.g., CSN) ---
	nrf_gpio_cfg(NRF_GPIO_PIN_MAP(2, 4), // Pin number 4
							 NRF_GPIO_PIN_DIR_OUTPUT, NRF_GPIO_PIN_INPUT_DISCONNECT,
							 NRF_GPIO_PIN_NOPULL,
							 NRF_GPIO_PIN_DRIVE_EXTRA_HIGH, // This is the E0/E1 setting
							 NRF_GPIO_PIN_NOSENSE);
}

I also have 47 set to off to disable onboard external flash in nrf connect board configurator.

Using SPI20 works without any issues, so SD card itself and the rest of the code should be working fine.

DK version is 0.9.3 and I did re-solder the bridges to connect P2 to GPIO instead of flash.

Any ideas?

Parents
  • Hi,

    SPIM00 has to be used with dedicated pins, but that seems to be in order here. another point is to enable the correct drive strength (E0/E1) in the device tree with "nordic,drive-mode = <NRF_DRIVE_E0E1>;" as shown here, then the driver will configure the drive strength properly.

    Another issue is that SD cards should start with a low clock frequency first, and then move to a higher frequency. However, the SPI00 clock cannot go lower than  1 MHz (or rather 128 MHz / 126). So it will not be possible to initiate communication with a SD card in a complient way using SPIM00. It coudl work though and most likely this is not an issue, but you should be ware of it (particularily if the end user could potentially insert an old/low performing SD card that cannot handle higher frequencies).

  • Unfortunately that did not change much - I still have "spi_nrfx_spim: Failed to initialize nrfx driver: 0bad0004" which I believe happens even before any messages are sent to the card, which means likely a driver software problem  

  • Hi,

    That is a good point. The error code 0x0bad0004 is NRFX_ERROR_INVALID_PARAM and comes from this call to nrfx_spim_init(). I expect the check that fails is the frequency check here? Which frequency are you configuring now? Note the limitation of SPIM00 frequency due to the prescaler. I also see that I rounded off the frequency in my previous reply to 1 MHz, but the minimum is slightly higher (or rather 128 MHz / 126). See the Configuration in the SPIM chapter in the datasheet for details.

Reply
  • Hi,

    That is a good point. The error code 0x0bad0004 is NRFX_ERROR_INVALID_PARAM and comes from this call to nrfx_spim_init(). I expect the check that fails is the frequency check here? Which frequency are you configuring now? Note the limitation of SPIM00 frequency due to the prescaler. I also see that I rounded off the frequency in my previous reply to 1 MHz, but the minimum is slightly higher (or rather 128 MHz / 126). See the Configuration in the SPIM chapter in the datasheet for details.

Children
Related