cancel
Showing results for 
Search instead for 
Did you mean: 

Compiler errors: unknown type name 'HAL_LockTypeDef' and 'HAL_StatusTypeDef' using CubeMX and Atollic TrueSTUDIO 7.1

joseph23
Associate II
Posted on August 11, 2017 at 17:36

I'm attempting to compile a STM32F303RE project using the Cube MX generated HAL drivers for Atollic TrueStudio 7.1. I'm getting 39 errors on stm32f3xx_hal_dma.h, stm32f3xx_hal_uart.h, and

stm32f3xx_hal_uart_ex.h wherever a HAL_StatusTypeDef or HAL_LockTypeDef type is referenced.

>:(

Each header file that has these errors has a #include 'stm32f3xx_hal_def.h' where the type is defined at the top of the file.

This seems to be related to using the HAL drivers in source files other than main.c. I've created a bare bones blinky project using CubeMX and I initially had the same errors, until Iincludedstm32f3xx_hal.h in the external source file that I created that calls the HAL driver functions. Unfortunately this solution didn't work with my more complicated project.

If the header file defining the type is right there, why in the world would the compiler not see it? I feel like I'm missing something really basic, but I can't figure this out. Any help would be greatly appreciated!

Note: this post was migrated and contained many threaded conversations, some content may be missing.
21 REPLIES 21
Posted on August 11, 2017 at 17:42

Check module import settings in project's 

stm32f3xx_hal_conf.h file

Tips, buy me a coffee, or three.. PayPal Venmo Up vote any posts that you find helpful, it shows what's working..
joseph23
Associate II
Posted on August 11, 2017 at 19:10

Ok, so I'm using a UART, GPIO, and a timer in this project.  Currently the stm32f3xx_hal_conf.h file shows the following:

#define HAL_MODULE_ENABLED

/*#define HAL_ADC_MODULE_ENABLED */

/*#define HAL_CAN_MODULE_ENABLED */

/*#define HAL_CEC_MODULE_ENABLED */

/*#define HAL_NAND_MODULE_ENABLED */

/*#define HAL_NOR_MODULE_ENABLED */

/*#define HAL_PCCARD_MODULE_ENABLED */

/*#define HAL_SRAM_MODULE_ENABLED */

/*#define HAL_HRTIM_MODULE_ENABLED */

/*#define HAL_OPAMP_MODULE_ENABLED */

/*#define HAL_SDADC_MODULE_ENABLED */

/*#define HAL_TSC_MODULE_ENABLED */

/*#define HAL_COMP_MODULE_ENABLED */

/*#define HAL_CRC_MODULE_ENABLED */

/*#define HAL_CRYP_MODULE_ENABLED */

/*#define HAL_DAC_MODULE_ENABLED */

/*#define HAL_I2S_MODULE_ENABLED */

#define HAL_IWDG_MODULE_ENABLED

/*#define HAL_LCD_MODULE_ENABLED */

/*#define HAL_LPTIM_MODULE_ENABLED */

/*#define HAL_RNG_MODULE_ENABLED */

/*#define HAL_RTC_MODULE_ENABLED */

/*#define HAL_SPI_MODULE_ENABLED */

#define HAL_TIM_MODULE_ENABLED

#define HAL_UART_MODULE_ENABLED

//#define HAL_USART_MODULE_ENABLED

/*#define HAL_IRDA_MODULE_ENABLED */

/*#define HAL_SMARTCARD_MODULE_ENABLED */

/*#define HAL_SMBUS_MODULE_ENABLED */

/*#define HAL_WWDG_MODULE_ENABLED */

/*#define HAL_PCD_MODULE_ENABLED */

#define HAL_GPIO_MODULE_ENABLED

#define HAL_DMA_MODULE_ENABLED

#define HAL_RCC_MODULE_ENABLED

#define HAL_FLASH_MODULE_ENABLED

#define HAL_PWR_MODULE_ENABLED

#define HAL_CORTEX_MODULE_ENABLED

//#define HAL_I2C_MODULE_ENABLED

And in the System Configuration section:

#define VDD_VALUE ((uint32_t)3300) /*!< Value of VDD in mv */

#define TICK_INT_PRIORITY ((uint32_t)0) /*!< tick interrupt priority (lowest by default) */

#define USE_RTOS 0

#define PREFETCH_ENABLE 1

#define INSTRUCTION_CACHE_ENABLE 0

#define DATA_CACHE_ENABLE 0

I'm not using any extended UART or USART functionality.  Just a vanilla 115200 8N1 UART.

I don't see anything that is off here, but it's very possible that I'm missing something.

Thanks for the quick response!

Posted on August 14, 2017 at 16:34

To use a HAL driver is there anything that needs to be done other than to include the header for that file?  If there are other headers to include, does the order of inclusion matter?

Posted on August 14, 2017 at 17:07

The compiler needs a command line define USE_HAL_DRIVER so that the ♯ include 'stm32f3xx.h' pulls in the conf.h file.

You should review the sample/example/template projects under the Cube install, and look at the project metadata, and project specific files.

Tips, buy me a coffee, or three.. PayPal Venmo Up vote any posts that you find helpful, it shows what's working..
Posted on August 14, 2017 at 18:15

I just checked the Properties for the project and USE_HAL_DRIVER is in there in C/C++ Build | Settings | C Compiler | Symbols | Defined Symbols.  Any other ideas?

Thanks

Posted on August 14, 2017 at 18:39

I don't use Atollic. Browse the dependency trees, grep the source, and try and understand where the definition are that you want, and why they wouldn't be pulled in.

Tips, buy me a coffee, or three.. PayPal Venmo Up vote any posts that you find helpful, it shows what's working..
Morty Morty
Associate III
Posted on August 31, 2017 at 11:21

This is a bug in stm32f3xx_hal_def.h. It defines HAL_StatusTypeDef and HAL_LockTypeDef, yet only after(!) including stm32f3xx.h, which in turn includes files that require HAL_StatusTypeDef and HAL_LockTypeDef. Thus if you move the include behind those definitions it compiles fine.

Amel NASRI
ST Employee
Posted on September 11, 2017 at 17:34

Hi

moritz.struebe

‌,

Please share your .ioc file allowing to reproduce issue.

-Amel

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.

Posted on September 11, 2017 at 16:09

Could someone from ST confirm that is is/is not a bug?