cancel
Showing results for 
Search instead for 
Did you mean: 

Missing <include "spi.h"> in STM32CubeMX V. 6.4.0. / HAL 1.9.1 (STM32H7)

GS1
Senior III

After migrating a project to STM32CubeMX Version 6.4.0 / HAL 1.9.1

or after creation of a new project using the latest version of STM32CubeMX 6.4.0. / HAL 1.9.1. an include for spi.h is missing, which produces a compiler error! In the previous version all was fine.

Processor: STM32H7A3ZITx

activated port: SPI3

and some Timers, USART, CAN, etc.

After Code Creation with the new release, a line is missing in main.h:

#include "spi.h"

Please forward this to your responsibles. Thank you.

BR GS

1 ACCEPTED SOLUTION

Accepted Solutions
Sara BEN HADJ YAHYA
ST Employee

Hello @GS@S​ ,

This issue is fixed in STM32CubeMX latest release.

V6.5.0 is now available under this Link.

Thanks for your contribution.

Sara.

View solution in original post

10 REPLIES 10
Peter BENSCH
ST Employee

I can't confirm that because spi.h should only be created if you set in CubeMX:

Project Manager > Code Generator > Generate peripheral initialization as a pair of...

If you do not activate this point, spi.h will not be created either and an #include "spi.h" should not appear in any of the created .c/.h files.

Could it be that this is a left-over from a previous project version?

Regards

/Peter

@Sara BEN HADJ YAHYA​ 

@Imen DAHMEN​ 

In order 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.
Sara BEN HADJ YAHYA
ST Employee

Hello @GS@S​ ,

Thanks for your feedback,

As @Peter BENSCH​  mentioned in his comment, the spi.h file is only generated when Project Manager > Code Generator > Generate peripheral initialization as a pair of... field is checked. When it is generated, the include of this file will be called in main.c.

I tried to generate a project with the Project Manager > Code Generator > Generate peripheral initialization as a pair of... is checked and I didn't face any issue.

If this isn't your issue could you please share your .ioc file and provide us with the exact scenario to reproduce it.

If you issue is solved, please close this post by clicking the "Select as Best" button. This will help other members of the community find this response more quickly :)

Sara.

Hello Sara and Peter,

I checked my project and the option of generating pairs of.. is activated!

I send you my .IOC file so you can check by yourself.

After generating code the main file includes part looks like this:

/* USER CODE END Header */

/* Includes ------------------------------------------------------------------*/

#include "main.h"

#include "adc.h"

#include "dma.h"

#include "fatfs.h"

#include "fdcan.h"

#include "i2c.h"

#include "mdma.h"

#include "octospi.h"

#include "sdmmc.h"

#include "tim.h"

#include "usart.h"

#include "usb_device.h"

#include "gpio.h"

/* Private includes ----------------------------------------------------------*/

...

As said before: the missing spi.h also is coming up after I migrated another project, which before the migration was ok.

BR GS

I tried to reproduce the effect with a new project and the error appeared once I activated mdma. and octospi.:

/* Includes ------------------------------------------------------------------*/

#include "main.h"

#include "adc.h"

#include "dma.h"

#include "fatfs.h"

#include "fdcan.h"

#include "i2c.h"

#include "mdma.h"

#include "octospi.h"

#include "sdmmc.h"

#include "tim.h"

#include "usart.h"

#include "usb_device.h"

#include "gpio.h"

May be this information helps?

I checked my migrated project and that one also uses octospi, but no mdma.

I just assume the generator thinks: I included "... spi.h" and then skips the include for "spi.h".

Please check and let me know if I am right?

Sara BEN HADJ YAHYA
ST Employee

Hello @GS@S​ ,

You are right and I confirm the issue, it seems that the spi.h header file is not included in main.c only when OCTOSPI is enabled.

To make sure that the #include "spi.h" will not disappear from main.c after code regeneration, please make sure to add it in the user section code.

/* Private includes ----------------------------------------------------------*/

/* USER CODE BEGIN Includes */

#include "spi.h"

/* USER CODE END Includes */

With this being said, the issue is reported to the dev team to be fixed. I will keep you posted with the updates.

If your issue is solved or reported, please close this post by clicking the "Select as Best" button. This will help other members of the community find this response more quickly :)

Thanks for your contribution,

Sara.

Bertrand1
Senior

Hello,

Seems have a similar issue. I opened a project in MX6.3/FW1.9.0 for a STM32H747, inside CubeIDE 1.8.

I accept a migration because MX6.4 & FW 1.9.1. Too bad.

After the code regeneration, I was unable to compile.

It seems it change some include path for USB device drivers files & all HAL files moved .

Crazy.

I backup source file with git, but not .project file, so I was unable to retrieve immediatly.

I loose a lot of time.

Regards

Bertrand

So you got an important learning effect:

1) NEVER do an upgrade of a project before copying ALL Files of your project to a separte safe-directory. I even use this to see the changes afterwards. I want to know whats going on.

2) Activate the checkbox in the project Manager properties of CubeMX: "Backup previously genterated files when re-generating"

BR GS

I do it normally but I believed I was backup by my repo....

I forgot "eclipse" file.

But, Yes, it confirmes ( it is not the first time :( ) I am feel partly guilty

GS1
Senior III

My experience with CubeMX updates is not the best over the years. I had several problems after migration. So I am really careful with migrating projects. Especially if they are already "life" and actually working.