error: 'DT_N_S_soc_S_spi_40004000_S_sst26vf032b_0' undeclared (first use in this function); did you mean 'DT_N_S_soc_S_spi_40004000_S_sst26vf032b_0_BUS'?

Im a bit stuck here.

I have the following code, trying to communicate with a flash memory:

Overlay:

&spi1 {
compatible = "nordic,nrf-spi";
status = "okay";
pinctrl-0 = <&spi1_default>;
pinctrl-1 = <&spi1_sleep>;
pinctrl-names = "default", "sleep";
cs-gpios = <&gpio0 21 GPIO_ACTIVE_LOW>;

SST26VF032B: SST26VF032B@0 {
compatible = "jedec,spi-nor";
reg = <0>;
spi-max-frequency = <8000000>;
requires-ulbpr;
label = "SST26VF032B";
jedec-id = [BF 26 42];
size = <16777216>;
//size = <67108864>;
has-dpd;
// t-enter-dpd = <10000>;
// t-exit-dpd = <35000>;
};

};

code:

#include "flash_memory.h"
#include <zephyr/kernel.h>
#include <zephyr/drivers/flash.h>



typedef struct {
    uint8_t code[8];
    uint8_t card[8];
    uint8_t other[16];
} Slot;

#define SLOTS_IN_PAGE 128

typedef struct {
    Slot slot[SLOTS_IN_PAGE];
} Page;

#define ARRAY_SIZE 1024
#define FLASH_SLOT_ADDRESS 0x0000
#define SLOT_SIZE 32
#define MEMORY_PAGE_SIZE 4096
#define PAGE_SIZE SLOT_SIZE*SLOTS_IN_PAGE

Slot arrayOfCodes[ARRAY_SIZE];

void test_flash_memory() {
     const struct device *flash_dev;
     flash_dev = device_get_binding(DT_LABEL(DT_INST(0, jedec_spi_nor)));

    if(!flash_dev) {
        printk("Failed to get flash dev\r\n");
    }

    printk("Testing memory\r\n");

    static Page toMemory;
    int page = 0;
    int position = 40960 + (PAGE_SIZE*page);
    int offset = 0 + (SLOTS_IN_PAGE * page);

    int err = flash_read(flash_dev, position, &toMemory, PAGE_SIZE);
    if(err) {
        printk("failed writing flash memory:");
    } else {
        printk("Success reading memory");
    }
    
}

I get the following error message:

error: 'DT_N_S_soc_S_spi_40004000_S_sst26vf032b_0' undeclared (first use in this function); did you mean 'DT_N_S_soc_S_spi_40004000_S_sst26vf032b_0_BUS'?

Am I missing something in the overlay file, im using version 2.7.0 of the toolchain.

Related