STM32L Errors Building samples/drivers/spi_fujitsu_fram with Ninja


@kiwironnie
 

New to Zephyr, no problem with building and running the hello world example for an STM32L433, nucleo_l433rc_p board
Trying to build samples/drivers/spi_fujitsu_fram as an example of SPI use. From a created build directly cmake -GNinja -DBOARD=nucleo_l433rc_p .. runs through ok, but Ninja fails with:

/media/fred/zephyrdev/stm-testbed/zephyr/include/devicetree.h:208:32: error: 'DT_N_ALIAS_spi_1_P_label' undeclared (first use in this function)
  208 | #define DT_ALIAS(alias) DT_CAT(DT_N_ALIAS_, alias)
      |                                ^~~~~~~~~~~
/media/fred/zephyrdev/stm-testbed/zephyr/include/devicetree.h:2176:24: note: in definition of macro 'DT_CAT'
 2176 | #define DT_CAT(a1, a2) a1 ## a2
      |                        ^~
/media/fred/zephyrdev/stm-testbed/zephyr/include/devicetree.h:584:27: note: in expansion of macro 'DT_PROP'
  584 | #define DT_LABEL(node_id) DT_PROP(node_id, label)
      |                           ^~~~~~~
../src/main.c:148:27: note: in expansion of macro 'DT_LABEL'
  148 |  spi = device_get_binding(DT_LABEL(DT_ALIAS(spi_1)));
      |                           ^~~~~~~~

and other similar errors.
Have checked that SPI1 is enabled for the board in the .dts file.  Also tried building for other STM32 boards but getting similar errors running Ninja.
Some guidance would be appreciated.


Erwan Gouriou
 

Hi Ron,

First question: do you have the matching FRAM that is described on  the sample ?

If  yes, I'd suggest adding "spi_1 = &spi1;" in your board aliases, and hopefully this should work.

BR

Erwan


On Mon, 15 Feb 2021 at 18:39, <ron@...> wrote:
New to Zephyr, no problem with building and running the hello world example for an STM32L433, nucleo_l433rc_p board
Trying to build samples/drivers/spi_fujitsu_fram as an example of SPI use. From a created build directly cmake -GNinja -DBOARD=nucleo_l433rc_p .. runs through ok, but Ninja fails with:

/media/fred/zephyrdev/stm-testbed/zephyr/include/devicetree.h:208:32: error: 'DT_N_ALIAS_spi_1_P_label' undeclared (first use in this function)
  208 | #define DT_ALIAS(alias) DT_CAT(DT_N_ALIAS_, alias)
      |                                ^~~~~~~~~~~
/media/fred/zephyrdev/stm-testbed/zephyr/include/devicetree.h:2176:24: note: in definition of macro 'DT_CAT'
 2176 | #define DT_CAT(a1, a2) a1 ## a2
      |                        ^~
/media/fred/zephyrdev/stm-testbed/zephyr/include/devicetree.h:584:27: note: in expansion of macro 'DT_PROP'
  584 | #define DT_LABEL(node_id) DT_PROP(node_id, label)
      |                           ^~~~~~~
../src/main.c:148:27: note: in expansion of macro 'DT_LABEL'
  148 |  spi = device_get_binding(DT_LABEL(DT_ALIAS(spi_1)));
      |                           ^~~~~~~~

and other similar errors.
Have checked that SPI1 is enabled for the board in the .dts file.  Also tried building for other STM32 boards but getting similar errors running Ninja.
Some guidance would be appreciated.


@kiwironnie
 

Thanks Erwan, brilliant, solved!

When the board alias "spi-1 = &spi1;" was added the executable built ok, no errors!

Note that an underscore in "spi_1 = &spi1;" threw an error: dtlib.DTError: /aliases: alias property name 'spi_1' should include only characters from [0-9a-z-]

But then it's clear from the documentation that dashes in the .dts become underscores in the source.

Am not bothered about the actual hardware at this stage, as the idea is to be able to use an example that builds ok as a template to be modified.

Cheers

Ron