This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

nRF9160 and SD card example

Dear All,

I want to create a simple example, where the nRF9160 will create a file in an SD card, read it, write to it etc.

I found an example in ncs/zephyr/samples/subsys/fs/fat_fs. In this example the device will mount the SD card and read out the files in it, so it seems to be the perfect starting point for me.

In the Zephyr documentation (here) it is suggested that I need to implement an overlay. But when I make that overlay file the project won't be loaded on the SES, giving me this error:

My overlay file looks like this:

CONFIG_SPI=y
CONFIG_SPI_1=y
CONFIG_DISK_ACCESS=y
CONFIG_DISK_ACCESS_SDHC=y
CONFIG_DISK_ACCESS_SPI_SDHC=y
CONFIG_DISK_SDHC_VOLUME_NAME="SD"
CONFIG_LOG=y
CONFIG_FILE_SYSTEM=y
CONFIG_FAT_FILESYSTEM_ELM=y
CONFIG_PRINTK=y

From what I understand the overlay file is somehow messing the project up, but I don't see how that happens.

If I do not add the overlay file, the project loads normally, but I am getting this error when I try to compile:

Building ‘zephyr/drivers/spi/libdrivers__spi.a’ from solution ‘build’ in configuration ‘Common’
1> Archiving ‘libdrivers__gpio.a’
2> Compiling ‘spi_nrfx_spim.c’
2> In file included from C:/ncs/zephyr/include/arch/arm/arch.h:26:0,
2>                  from C:/ncs/zephyr/include/arch/cpu.h:17,
2>                  from C:/ncs/zephyr/include/kernel_includes.h:34,
2>                  from C:/ncs/zephyr/include/kernel.h:17,
2>                  from C:/ncs/zephyr/include/device.h:11,
2>                  from C:/ncs/zephyr/include/drivers/spi.h:24,
2>                  from C:/ncs/zephyr/drivers/spi/spi_nrfx_spim.c:7:
2> C:/ncs/zephyr/drivers/spi/spi_nrfx_spim.c:374:8: error: 'DT_NORDIC_NRF_SPIM_SPI_1_IRQ_0_PRIORITY' undeclared (first use in this function); did you mean 'DT_NORDIC_NRF_SPIM_SPI_3_IRQ_0_PRIORITY'?
2> C:/ncs/zephyr/include/arch/arm/irq.h:82:32: note: in definition of macro 'Z_ARCH_IRQ_CONNECT'
2> C:/ncs/zephyr/drivers/spi/spi_nrfx_spim.c:373:3: note: in expansion of macro 'IRQ_CONNECT'
2> C:/ncs/zephyr/drivers/spi/spi_nrfx_spim.c:412:1: note: in expansion of macro 'SPI_NRFX_SPIM_DEVICE'
2> C:/ncs/zephyr/drivers/spi/spi_nrfx_spim.c:374:8: note: each undeclared identifier is reported only once for each function it appears in
2> C:/ncs/zephyr/include/arch/arm/irq.h:82:32: note: in definition of macro 'Z_ARCH_IRQ_CONNECT'
2> C:/ncs/zephyr/drivers/spi/spi_nrfx_spim.c:373:3: note: in expansion of macro 'IRQ_CONNECT'
2> C:/ncs/zephyr/drivers/spi/spi_nrfx_spim.c:412:1: note: in expansion of macro 'SPI_NRFX_SPIM_DEVICE'
2> C:/ncs/zephyr/drivers/spi/spi_nrfx_spim.c:387:17: error: 'DT_NORDIC_NRF_SPIM_SPI_1_SCK_PIN' undeclared here (not in a function); did you mean 'DT_NORDIC_NRF_SPIM_SPI_3_SCK_PIN'?
2> C:/ncs/zephyr/drivers/spi/spi_nrfx_spim.c:412:1: note: in expansion of macro 'SPI_NRFX_SPIM_DEVICE'
2> C:/ncs/zephyr/drivers/spi/spi_nrfx_spim.c:388:17: error: 'DT_NORDIC_NRF_SPIM_SPI_1_MOSI_PIN' undeclared here (not in a function); did you mean 'DT_NORDIC_NRF_SPIM_SPI_3_MOSI_PIN'?
2> C:/ncs/zephyr/drivers/spi/spi_nrfx_spim.c:412:1: note: in expansion of macro 'SPI_NRFX_SPIM_DEVICE'
2> C:/ncs/zephyr/drivers/spi/spi_nrfx_spim.c:389:17: error: 'DT_NORDIC_NRF_SPIM_SPI_1_MISO_PIN' undeclared here (not in a function); did you mean 'DT_NORDIC_NRF_SPIM_SPI_3_MISO_PIN'?
2> C:/ncs/zephyr/drivers/spi/spi_nrfx_spim.c:412:1: note: in expansion of macro 'SPI_NRFX_SPIM_DEVICE'
2> In file included from C:/ncs/zephyr/include/drivers/spi.h:24:0,
2>                  from C:/ncs/zephyr/drivers/spi/spi_nrfx_spim.c:7:
2> C:/ncs/zephyr/drivers/spi/spi_nrfx_spim.c:399:9: error: 'DT_NORDIC_NRF_SPIM_SPI_1_LABEL' undeclared here (not in a function); did you mean 'DT_NORDIC_NRF_SPIM_SPI_3_LABEL'?
2> C:/ncs/zephyr/include/device.h:107:11: note: in definition of macro 'DEVICE_AND_API_INIT'
2> C:/ncs/zephyr/drivers/spi/spi_nrfx_spim.c:398:2: note: in expansion of macro 'DEVICE_DEFINE'
2> C:/ncs/zephyr/drivers/spi/spi_nrfx_spim.c:412:1: note: in expansion of macro 'SPI_NRFX_SPIM_DEVICE'
Build failed


which obviously comes from the fact that spi1 is not correctly initialized.

So what is the proper form of the overlay file?

Parents Reply
  • Hello Hakon,

    I am trying to do the same thing as Giannis. The files you have shown are olimexino_stm32.dts and nrf52840_blip.overlay. But we are working on nrf9160dk and not on nrf52840 blip board. So I will need to add nrf9160_pca10090ns.overlay file and do changes what you have told for nrf52840_blip.overlay file. But instead of olimexino_stm32.dts file, which file I should edit?

Children
Related