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
  • 1 reply
  • 4 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)

1 reply

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.