cancel
Showing results for 
Search instead for 
Did you mean: 

GENERATE CODE error, unknown type name 'HAL_StatusTypeDef'

Snowcone_engineer
Associate II

Eval board used: Nucleo-U385RG-Q 
Software tools:
STM32CubeIDE Version: 2.0.0 Build: 26820_20251114_1348 (UTC)
STM32CubeMX Version: 6.15.0

The provided project for the eval board builds without errors.
But when I modify the MCU to add a GPIO or I2C using STM32CubeMX,
multiple build errors are generated after using "GENERATE CODE" command.

These errors are:

unknown type name 'HAL_StatusTypeDef'
unknown type name 'HAL_LockTypeDef'

Although these definitions are defined in the following *.h file:
stm32u3xx_hal_def.h

/**
* @brief HAL Status structures definition
*/
typedef enum
{
 HAL_OK = 0x00,
 HAL_ERROR = 0x01,
 HAL_BUSY = 0x02,
 HAL_TIMEOUT = 0x03
} HAL_StatusTypeDef;

/**
* @brief HAL Lock structures definition
*/
typedef enum
{
 HAL_UNLOCKED = 0x00,
 HAL_LOCKED = 0x01
} HAL_LockTypeDef;



Apparently, the errors are created from define guards not allowing other files
to access and use the “typedef enum HAL_StatusTypeDef and HAL_LockTypeDef in stm32u3xx_hal_def.h.

To correct the problem:
I had to move HAL_StatusTypeDef and HAL_LockTypeDef defines To: stm32u3xx_hal_conf.h

Unfortunately, each to I modify the MCU pin definition or add a pin assignment with STM32CubeMX
and regenerate the code using "GENERATE CODE", the same errors are created after a build is started.

It seems there is a bug in the STM32CubeMX when using the "GENERATE CODE".

 

5 REPLIES 5
TDK
Super User

Please provide the IOC file and project code you used to generate the issue.

 

I'm able to add a I2C peripheral and GPIO pin and generate code without issue.

Finished building target: test_u385_nucleo_i2c_gpio.elf
 
arm-none-eabi-size  test_u385_nucleo_i2c_gpio.elf 
arm-none-eabi-objdump -h -S test_u385_nucleo_i2c_gpio.elf  > "test_u385_nucleo_i2c_gpio.list"
   text	   data	    bss	    dec	    hex	filename
  15516	     32	   1832	  17380	   43e4	test_u385_nucleo_i2c_gpio.elf
Finished building: default.size.stdout
 
Finished building: test_u385_nucleo_i2c_gpio.list

 

If you feel a post has answered your question, please click "Accept as Solution".
FBL
ST Employee

Hi @Snowcone_engineer 

Would you mention which Cube firmware version are you using as well? Is it V1.2.1?

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.




Best regards,
FBL

I'm not sure what you mean by "Cube firmware version". The following are the tool versions that I used.

STM32CubeIDE Version: 2.0.0 Build: 26820_20251114_1348 (UTC)
STM32CubeMX Version: 6.15.0

Thanks.

Thanks for trying to reproduce my issue.

Attached is the IOC file used in the project and build. I hope this will help alone.

Sorry about not including the whole project, it's a bit large and include some proprietary data.

If this isn't enough to solve the problem, I'll just use the work around for now. It may not be a problem when I change the project from the U385 eval board to my own PCB design. 

TDK
Super User

This IOC files generates code that compiles with no errors.

You're not on the latest versions, it's possible that could be an issue.

> Sorry about not including the whole project, it's a bit large and include some proprietary data.

The problem about not showing the project is that the error can't be reproduced. If you can generate a toy problem that gives the same error, try that. Otherwise it's difficult to debug code without seeing the code.

My crystal ball says your include files are wrong or out of order.

 

You should only ever include "stm32u3xx_hal.h"

 

If you feel a post has answered your question, please click "Accept as Solution".