This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

using spi_nor driver with nrf sdk connect / zephyr - driver not found

hello Nordic

i am working with nrf52832, ncs 1.7.1

i am trying to work with external flash driver (25lp128)

so my dts looks like this:

...

chosen {
		zephyr,sram = &sram0;
		zephyr,flash = &flash0;
		zephyr,code-partition = &slot0_partition;
		nordic,pm-ext-flash = &flash_25lp128;
	};
	
....

&spi2 {
		status = "okay";
		sck-pin = <5>; // gpio 0 pin 5
		mosi-pin = <4>; // gpio 0 pin 4
		miso-pin = <2>; // gpio 0 pin 2
		compatible = "nordic,nrf-spim";
		cs-gpios = <&gpio0 3 (GPIO_PULL_UP | GPIO_ACTIVE_LOW)>;
		flash_25lp128: flash_25lp128@0 {
			compatible = "issi,is25lp128", "jedec,spi-nor";
			reg = <0>;
			label = "FLASH_25LP128";
			// power_resources = <&flash_on>;
			spi-max-frequency = <133000000>;
			jedec-id = [9d 60 18];
			size = <134217728>;
		};
	};
	&flash0 {
		partitions {
			compatible = "fixed-partitions";
			#address-cells = <1>;
			#size-cells = <1>;

			mbr_partition: partition@0 {
				label = "mbr";
				reg = <0x00000000 0x00001000>;
			};
			boot_partition: partition@1000 {
				label = "mcuboot";
				reg = <0x1000 0xc000>;
			};
			slot0_partition: partition@d000 {
				label = "image-0";
				reg = <0xd000 0x6c800>;
			};
			slot1_partition: partition@79800 {
				label = "image-1";
				reg = <0x79800 0x800>;
			};
			storage_partition: partition@7a000 {
				label = "storage";
				reg = <0x7a000 0x6000>;
			};
		};
	};

my configs are this:

myboard.conf:

# SPI Flash
CONFIG_SPI=y
CONFIG_SPI_NOR=y
CONFIG_SPI_NOR_FLASH_LAYOUT_PAGE_SIZE=4096

# Enable flash operations.
CONFIG_FLASH_MAP=y
CONFIG_FLASH_TESTS=y
CONFIG_FLASH_PAGE_LAYOUT=y
CONFIG_FLASH_25LP128=y

CONFIG_SYSTEM_WORKQUEUE_STACK_SIZE=2048
CONFIG_BT_RX_STACK_SIZE=1024

# CONFIG_MAIN_STACK_SIZE=1024
CONFIG_MPSL_SIGNAL_STACK_SIZE=640

CONFIG_IDLE_STACK_SIZE=128
CONFIG_ISR_STACK_SIZE=1024
# keep CONFIG_HEAP_MEM_POOL_SIZE=16384 because this is needed by usb /nrfx modules
# CONFIG_HEAP_MEM_POOL_SIZE=16384
# CONFIG_HEAP_MEM_POOL_SIZE=10240
# CONFIG_HEAP_MEM_POOL_SIZE=8192
# CONFIG_HEAP_MEM_POOL_SIZE=4096
# CONFIG_HEAP_MEM_POOL_SIZE=3600
# CONFIG_HEAP_MEM_POOL_SIZE=2048
CONFIG_HEAP_MEM_POOL_SIZE=1024

CONFIG_NRFX_SPIM=y
CONFIG_NRFX_SPIM1=y

CONFIG_SOC_NRF52832_ALLOW_SPIM_DESPITE_PAN_58=y

# CONFIG_SERIAL=n

# Configurations set based on thread analyzer output.
# CONFIG_SDC_RX_STACK_SIZE=324
CONFIG_BT_HCI_TX_STACK_SIZE_WITH_PROMPT=y
CONFIG_BT_HCI_TX_STACK_SIZE=640


# Disable features not needed
# CONFIG_TIMESLICING=n
# CONFIG_MINIMAL_LIBC_MALLOC=n

# Disable Bluetooth features not needed
# CONFIG_BT_DEBUG_NONE=y
# CONFIG_BT_ASSERT=n
# CONFIG_BT_DATA_LEN_UPDATE=n
CONFIG_BT_PHY_UPDATE=n
# CONFIG_BT_GATT_CACHING=n
# CONFIG_BT_GATT_SERVICE_CHANGED=n
# CONFIG_BT_GAP_PERIPHERAL_PREF_PARAMS=n
# CONFIG_BT_SETTINGS_CCC_LAZY_LOADING=y
# CONFIG_BT_HCI_VS_EXT=n


# Disable Bluetooth controller features not needed
CONFIG_BT_CTLR_PRIVACY=n
CONFIG_BT_CTLR_PHY_2M=n
# Reduce Bluetooth buffers
CONFIG_BT_BUF_EVT_DISCARDABLE_COUNT=1
CONFIG_BT_BUF_EVT_DISCARDABLE_SIZE=43
CONFIG_BT_BUF_EVT_RX_COUNT=2

CONFIG_BT_CONN_TX_MAX=2
CONFIG_BT_L2CAP_TX_BUF_COUNT=2
CONFIG_BT_CTLR_RX_BUFFERS=1
CONFIG_BT_BUF_ACL_TX_COUNT=3
CONFIG_BT_BUF_ACL_TX_SIZE=27

in myboard dir - Kconfig.defconfig:

config FLASH_25LP128
   bool "enables flash device"
   default y
 

when i call on device_get_binding like this:

const struct device *dev = device_get_binding("FLASH_25LP128");
	if (!dev) {
		LOG_ERR("FLASH_25LP128 not found in zephyr\n");
		return;
	}

also tried with - device_get_binding("FLASH_25LP128");  

and got the same result

i added a print in the ncs in the spi_nor.c file (lines 352-354) in the 'spi_nor_access' static function for debugging:

	int res = spi_transceive_dt(&driver_cfg->spi, &tx_set, &rx_set);
	LOG_ERR("spi_transceive_dt ret - %d\n", res);
	return res; //spi_transceive_dt(&driver_cfg->spi, &tx_set, &rx_set);
}

and i get this logs before the app :

[00000020] <err> spi_nor: JEDEC ID device acquired
[00000021] <wrn> spi_nrfx_spim: Transaction aborted since it would trigger nRF52832 PAN 58
[00000021] <err> spi_nor: spi_transceive_dt ret - -5

[00000022] <err> spi_nor: JEDEC ID read failed: -5
*** Booting Zephyr OS build v2.6.99-ncs1-1  ***

and after obviously the driver bind returns null

any ideas what i am doing wrong ?

hope to read from you soon

best regards

Ziv

Parents Reply Children
Related