Skip to main content
Associate
December 19, 2024
Solved

STMCubeIDE won't include SPI HAL driver

  • December 19, 2024
  • 4 replies
  • 3369 views

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. 

Best answer by Mahmoud Ben Romdhane

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

4 replies

Technical Moderator
December 19, 2024

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.

To give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.
RModAuthor
Associate
December 19, 2024

Thanks for getting back to me.

I am using STMCubeIDE 1.17.0.

Attached is the .ioc file for this project.

Technical Moderator
December 19, 2024

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

 

To give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.
RModAuthor
Associate
December 19, 2024

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
Principal
December 20, 2024

@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?

 

 

 

 

 

If a reply has proven helpful, click on Accept as Solution so that it'll show at top of the post.CAN Jammer an open source CAN bus hacking toolCANableV3 Open Source
RModAuthor
Associate
December 20, 2024

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. . 

 

 

Technical Moderator
December 20, 2024

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

To give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.
Visitor II
January 14, 2025

I've been having this issue aswell, but on my STM32L4 board.
It turns out, that the necessary files weren't in the Drivers/STM32L4xx_HAL_Driver/Inc/ and Drivers/STM32L4xx_HAL_Driver/Src/ folders.

My solution was to go to the official STM32CubeL4 HAL Driver Github Page and download the required files and drop them into those directories:

  • stm32l4xx_hal_spi.c -> /Src/
  • stm32l4xx_hal_spi.h -> /Inc/
  • stm32l4xx_hal_spi_ex.c -> /Src/
  • stm32l4xx_hal_spi_3x.h -> /Inc/

Once I did this, I was able to generate a build with no issues.

Now as for your board (the STM32u0), you should be able to repeat the same process using the files on the STM32CubeU0 HAL Driver Github Page.

 

I hope this helps!