cancel
Showing results for 
Search instead for 
Did you mean: 

STMCubeIDE won't include SPI HAL driver

RMod
Associate II

I am putting together a project for the U031 Nucleo board based on the DAC signal generation example project. From the configuration page I have added SPI, as well as TIM2 and the other required drivers (DAC, DMA, EXTI, TIM1). When it generates code, it looks like everything is there in way of configuration but stm32u0xx_hal_spi.c is not included in the drivers to be compiled. When I try to build the project the HAL_SPI_INT function cannot be found. It seems to find all the correct header files and the configuration in stm32u0xx_hal_config.h is correct and SPI is defined but it is not included in the make. It shows all the other required drivers in the driver directory but not spi.  The stm32u0xx_hal_spi.c and stm32u0xx_hal_spi_ex.c files are both in the same project folder with all the other drivers. I have checked the auto generated submake files and spi is not listed.

 If I build an example with just SPI then the driver is included. 

Originally I had the project compiling and working correctly without SPI but when I tried to add SPI no luck. I have tried building a new project with all the needed drivers but I see the same result, no SPI.

It looks like the project does not get correct configured by the IDE configuration tool. The project settings need to be edited but I can't find the right place to modify.

Any suggestions on how to get the SPI driver to be included in the build would be much appreciated. 

16 REPLIES 16
Mahmoud Ben Romdhane
ST Employee

Hello @RMod ,

First let me thank you for posting and welcome to the ST Community.

For more investigation, I suggest that you provide your Ioc.File and the STM32CubeIDE version.

Thanks.

Mahmoud.

Thanks for getting back to me.

I am using STMCubeIDE 1.17.0.

Attached is the .ioc file for this project.

Hello @RMod ,

Further to your reply, I made a new project with STM32U031C6Tx and I activated the SPI2.

You can notice through the attachment that stm32u0xx_hal_spi.c and stm32u0xx_hal_spi_ex.c are well generated.

MahmoudBenRomdhane_0-1734615421738.png

The build of your project was finished also successfully on MDK-ARM.

Thanks.

Mahmoud

 

Thanks for checking it on your system but that does not fix the issue.

Can you try this with the NUCLEO-U031 board. The NUCLEO uses the 64K version of U031. The device you targeted the project to  is the 32K version. Not that I would think that it would make a difference but there is some reason for this problem and it may be a strange bug in the tool.. 

Any suggestions on how to get this working on my system?

Is there any other way to add the SPI HAL driver that does not use the configuration page?

I am also noticing that you did not start from an example project for you test. Could you retest by starting from the DAC signal generation example project and see if you get a different result when you add SPI and TIM2. Since the example was written by STM I would think this should work correctly but maybe there is an issue with the example project. 

RMod
Associate II

I looked in the .project file and stm32u0xx_hal_spi.c is not listed as a linked resource. 

How do I add SPI as a linked resource?

There does not seem to be a way to do this through the project properties. 

RMod_0-1734660317523.png

I can edit but not add.

Karl Yamashita
Lead III

@RMod wrote:

When I try to build the project the HAL_SPI_INT function cannot be found.


You must be talking about HAL_SPI_IRQHandler?

 

Importing the example project DAC_SignalsGeneration, I was able to produce your issue where in the SPI1_IRQHandler function, It calls HAL_SPI_IRQHandler, but can't be found.

 

As you've mentioned, it seems that the HAL_SPI_MODULE_ENABLED is enabled, but ALL the functions in the stm32u0xx_hal_spi.c are commented out.

 

KarlYamashita_1-1734659674995.png

KarlYamashita_0-1734659437185.png

 

If you had took a screen shot to show the issue, then @Mahmoud Ben Romdhane could have looked into it more.

 

 

A temporary workaround until ST figures out the issue, is to include the define as a symbol. Then all the functions are no longer grayed out. 

KarlYamashita_3-1734660508478.png

 

I did notice that after removing the symbol, it still worked. Even after removing the SPI peripheral and adding it back, the functions were not commented out.

 

It's too late for me to try, as I can't re-create the issue, but maybe you can try Cleaning Project and build again?

 

 

 

 

 

Tips and Tricks with TimerCallback https://www.youtube.com/@eebykarl
If you find my solution useful, please click the Accept as Solution so others see the solution.

Hi @Karl Yamashita ,

Thanks for looking into this and reproducing my problem. I am not using SPI interrupts and did not enable that in the configuration tool. The code created by the configuration tool creates an initialization function MX_SPI1_Init. This is where the error occurs.  I tried adding the symbol to enable SPI just as you did but no change. As can be seen, stm32u0xx_hal_spi.c is not listed in the included drivers. It is also not listed as linked resource in the project settings.

I think this is the root cause of my issue. Do think that is correct?

Are there more screenshots you would like to see to help diagnosis this problem?

RMod_0-1734672659254.png

Do you know how to add linked resources outside of the configuration tool?

Thanks for the tip about including screenshots for @Mahmoud Ben Romdhane . I will include more details in future posts. . 

 

 

Hello @RMod ,

 

Further to your comment, I want to thank you for reporting this issue and I confirm that stm32u0xx_hal_spi.c and stm32u0xx_hal_spi_ex.c are not generated and included on driver while using STM32CubeIDE.

The issue will be investigated by the STM32cubeMX team (Internal ticket number: 199216).

 

Best Regards.

Mahmoud

Hi @Mahmoud Ben Romdhane ,

Thanks for confirming this issue. Do you have thoughts on possible workarounds?

Can a linked resource be added to an STM32CubeIDE project?

If so, how can this be done?