Skip to main content
KHarb.1
Senior
June 30, 2026
Question

After upgrade to CubeIDE 2.0.0, HAL objects are being treated as the wrong TypeDef with STM32G4

  • June 30, 2026
  • 5 replies
  • 117 views

I just upgraded to Cube 2.0.0 components. I did my first build in CubeIDE 2.0.0 with a previously working project and I got strange errors.  It appears the HAL objects for the peripherals are getting garbled.  When pointers to the objects are passed to functions, the compiler says that the pointer is of another peripheral type.  In the output below, the pointers to ADCs are treated like they are of the timer typedef.

What could cause this?

 

arm-none-eabi-gcc "../Core/Src/main.c" -mcpu=cortex-m4 -std=gnu11 -g3 -DDEBUG -DUSE_HAL_DRIVER -DSTM32G473xx -c -I../Core/Inc -I../Drivers/STM32G4xx_HAL_Driver/Inc -I../Drivers/STM32G4xx_HAL_Driver/Inc/Legacy -I../Drivers/CMSIS/Device/ST/STM32G4xx/Include -I../Drivers/CMSIS/Include -I../USB_Device/App -I../USB_Device/Target -I../Middlewares/ST/STM32_USB_Device_Library/Core/Inc -I../Middlewares/ST/STM32_USB_Device_Library/Class/CDC/Inc -O0 -ffunction-sections -fdata-sections -Wall -fstack-usage -fcyclomatic-complexity -MMD -MP -MF"Core/Src/main.d" -MT"Core/Src/main.o" --specs=nano.specs -mfpu=fpv4-sp-d16 -mfloat-abi=hard -mthumb -o "Core/Src/main.o"

arm-none-eabi-gcc "../Core/Src/stm32g4xx_it.c" -mcpu=cortex-m4 -std=gnu11 -g3 -DDEBUG -DUSE_HAL_DRIVER -DSTM32G473xx -c -I../Core/Inc -I../Drivers/STM32G4xx_HAL_Driver/Inc -I../Drivers/STM32G4xx_HAL_Driver/Inc/Legacy -I../Drivers/CMSIS/Device/ST/STM32G4xx/Include -I../Drivers/CMSIS/Include -I../USB_Device/App -I../USB_Device/Target -I../Middlewares/ST/STM32_USB_Device_Library/Core/Inc -I../Middlewares/ST/STM32_USB_Device_Library/Class/CDC/Inc -O0 -ffunction-sections -fdata-sections -Wall -fstack-usage -fcyclomatic-complexity -MMD -MP -MF"Core/Src/stm32g4xx_it.d" -MT"Core/Src/stm32g4xx_it.o" --specs=nano.specs -mfpu=fpv4-sp-d16 -mfloat-abi=hard -mthumb -o "Core/Src/stm32g4xx_it.o"

../Core/Src/stm32g4xx_it.c: In function 'TIM2_IRQHandler':

../Core/Src/stm32g4xx_it.c:282:47: error: passing argument 1 of 'HAL_ADC_GetValue' from incompatible pointer type [-Wincompatible-pointer-types]

282 | opt_val[0] = HAL_ADC_GetValue(&hadc1);

| ^~~~~~

| |

| TIM_HandleTypeDef *

In file included from ../Core/Inc/stm32g4xx_hal_conf.h:228,

from ../Drivers/STM32G4xx_HAL_Driver/Inc/stm32g4xx_hal.h:29,

from ../Core/Inc/main.h:30,

from ../Core/Src/stm32g4xx_it.c:21:

../Drivers/STM32G4xx_HAL_Driver/Inc/stm32g4xx_hal_adc.h:2246:67: note: expected 'const ADC_HandleTypeDef *' but argument is of type 'TIM_HandleTypeDef *'

2246 | uint32_t HAL_ADC_GetValue(const ADC_HandleTypeDef *hadc);

| ~~~~~~~~~~~~~~~~~~~~~~~~~^~~~

../Core/Src/stm32g4xx_it.c:285:47: error: passing argument 1 of 'HAL_ADC_GetValue' from incompatible pointer type [-Wincompatible-pointer-types]

285 | opt_val[1] = HAL_ADC_GetValue(&hadc2);

| ^~~~~~

| |

| TIM_HandleTypeDef *

../Drivers/STM32G4xx_HAL_Driver/Inc/stm32g4xx_hal_adc.h:2246:67: note: expected 'const ADC_HandleTypeDef *' but argument is of type 'TIM_HandleTypeDef *'

2246 | uint32_t HAL_ADC_GetValue(const ADC_HandleTypeDef *hadc);

| ~~~~~~~~~~~~~~~~~~~~~~~~~^~~~

../Core/Src/stm32g4xx_it.c:286:31: error: passing argument 1 of 'HAL_ADC_Start' from incompatible pointer type [-Wincompatible-pointer-types]

286 | HAL_ADC_Start(&hadc2);

| ^~~~~~

| |

| TIM_HandleTypeDef *

../Drivers/STM32G4xx_HAL_Driver/Inc/stm32g4xx_hal_adc.h:2232:58: note: expected 'ADC_HandleTypeDef *' but argument is of type 'TIM_HandleTypeDef *'

2232 | HAL_StatusTypeDef HAL_ADC_Start(ADC_HandleTypeDef *hadc);

| ~~~~~~~~~~~~~~~~~~~^~~~

make[1]: *** [Core/Src/subdir.mk:31: Core/Src/stm32g4xx_it.o] Error 1

make[1]: *** Waiting for unfinished jobs....

../Core/Src/main.c: In function 'main':

../Core/Src/main.c:321:23: error: assignment to 'uint32_t' {aka 'long unsigned int'} from 'uint32_t *' {aka 'long unsigned int *'} makes integer from pointer without a cast [-Wint-conversion]

321 | DMA2_Channel2->CPAR = (uint32_t*)&DAC1->DHR12R2;

| ^

../Core/Src/main.c:324:23: error: assignment to 'uint32_t' {aka 'long unsigned int'} from 'uint32_t *' {aka 'long unsigned int *'} makes integer from pointer without a cast [-Wint-conversion]

324 | DMA1_Channel2->CPAR = (uint32_t*)&DAC1->DHR12R2;

| ^

../Core/Src/main.c:328:23: error: assignment to 'uint32_t' {aka 'long unsigned int'} from 'uint32_t *' {aka 'long unsigned int *'} makes integer from pointer without a cast [-Wint-conversion]

328 | DMA1_Channel3->CPAR = (uint32_t*)&DAC1->DHR12R1;

| ^

../Core/Src/main.c:331:23: error: assignment to 'uint32_t' {aka 'long unsigned int'} from 'uint32_t *' {aka 'long unsigned int *'} makes integer from pointer without a cast [-Wint-conversion]

331 | DMA1_Channel4->CPAR = (uint32_t*)&DAC1->DHR12R1;

| ^

../Core/Src/main.c:354:25: error: assignment to 'uint32_t' {aka 'long unsigned int'} from 'volatile uint32_t *' {aka 'volatile long unsigned int *'} makes integer from pointer without a cast [-Wint-conversion]

354 | DMA2_Channel5->CMAR = &TIM4->CNT;

| ^

../Core/Src/main.c:366:13: warning: variable 'hs' set but not used [-Wunused-but-set-variable]

366 | uint8_t hs;

| ^~

../Core/Src/main.c: At top level:

../Core/Src/main.c:1873:6: warning: 'fence_check' defined but not used [-Wunused-function]

1873 | void fence_check(void){

| ^~~~~~~~~~~

make[1]: *** [Core/Src/subdir.mk:31: Core/Src/main.o] Error 1

make: *** [makefile:62: all] Error 2

"make -j8 all" terminated with exit code 2. Build might be incomplete.

 

21:31:56 Build Failed. 12 errors, 2 warnings. (took 1s.197ms)

5 replies

mƎALLEm
ST Technical Moderator
June 30, 2026

Hello,

Such kind of questions need to be posted in STM32 Embedded Software forum board. Noting to do with the silicon behavior. I’m moving the post then..

To give better visibility on the answered topics, please click "Best answer" on the reply which solved your issue or answered your question.
T_Hamdi
ST Employee
June 30, 2026

Hello ​@KHarb.1 

Could you please share your initial project or the steps you followed to open it in the new CubeIDE version? The more details you provide, the better.

 

"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.Hamdi Teyeb"
Pavel A.
June 30, 2026

> What could cause this?

The different (updated) compiler. You can use your previous toolchain with CubeIDE 2.x and avoid all these issues.

 

KHarb.1
KHarb.1Author
Senior
July 1, 2026

This was a from a change in compiler settings. I had a misconfigured pointer, but in previous versions it was a warning and luckily everything still worked. The latest version makes it a hard fault.

T_Hamdi
ST Employee
July 1, 2026

hello ​@KHarb.1 

Yes, between different versions of CubeIDE, the compiler may change. Some warnings in one version can become errors in a later compiler version. I suggest checking the latest compilation flags and compiler settings.

 

"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.Hamdi Teyeb"