Make error: SPI Driver test program

Hi All,

As a beginner's level task, I'm working on Spansion NOR flash memory (S25FL127S) interfacing with STM32F072 (ARM Cortex M0 based SOC). I've a custom board which has Spansion Flash memory connected to STM32F072 over SPI bus.

I've a work-in-progress driver under: ~/RIOT/drivers/s25127s/s25127s.c driver header: ~/RIOT/drivers/include/s25fl127s.h and the driver test program: ~/RIOT/tests/driver_s25fl127s/main.c

However, As of now an attempt to build the test program failed. So I tried to build driver test program for nvram-spi (since, this is the driver that I'm referring to) instead and that too failed.

<snip> [amit@discworld driver_nvram_spi]$ make There are unsatisfied feature requirements: periph_gpio periph_spi


Building application "driver_nvram_spi" for "native" with MCU "native".

In file included from main.c:28:0: ../../drivers/include/nvram-spi.h:40:5: error: unknown type name ‘spi_t’      spi_t spi;      ^ main.c: In function ‘main’: main.c:116:16: error: ‘SPI_0’ undeclared (first use in this function)          .spi = TEST_NVRAM_SPI_DEV,                 ^ main.c:116:16: note: each undeclared identifier is reported only once for each function it appears in main.c:125:9: error: implicit declaration of function ‘spi_init_master’ [-Werror=implicit-function-declaration]      if (spi_init_master(TEST_NVRAM_SPI_DEV, SPI_CONF, SPI_SPEED_10MHZ) == 0) {          ^ main.c:125:33: error: ‘SPI_CONF_FIRST_RISING’ undeclared (first use in this function)      if (spi_init_master(TEST_NVRAM_SPI_DEV, SPI_CONF, SPI_SPEED_10MHZ) == 0) {                                  ^ main.c:125:57: error: ‘SPI_SPEED_10MHZ’ undeclared (first use in this function)      if (spi_init_master(TEST_NVRAM_SPI_DEV, SPI_CONF, SPI_SPEED_10MHZ) == 0) {                                                          ^ cc1: all warnings being treated as errors /home/amit/Documents/tut/sem4/sem5/projects/riot-os/RIOT/Makefile.base:60: recipe for target '/home/amit/Documents/tut/sem4/sem5/projects/riot-os/RIOT/tests/driver_nvram_spi/bin/native/driver_nvram_spi/main.o' failed make[1]: *** [/home/amit/Documents/tut/sem4/sem5/projects/riot-os/RIOT/tests/driver_nvram_spi/bin/native/driver_nvram_spi/main.o] Error 1 /home/amit/Documents/tut/sem4/sem5/projects/riot-os/RIOT/tests/driver_nvram_spi/../../Makefile.include:215: recipe for target 'all' failed make: *** [all] Error 2 <snip>

Seems that, I may have to export some environment variables or update some Makefiles for building my driver test application. I'm wondering, if there is any document on writing and testing drivers for RIOT ?

My setup environment: Host: Linux, x86_64

Thanks, #!/Kumar/Amit/Mehta


It seems you are not building for your target board but for native. Native has no SPI support (as indicated by the error message). If you export BOARD for your target hardware (which has to support SPI), things should go better.

Cheers, Ludwig

Thank you. That worked, however, I need to fix some other compilation errors and do some testing, before I send this PR.

Thanks, #!/Kumar/Amit/Mehta