2021-06-15 10:16 PM
I tried this tutorial - https://www.carminenoviello.com/2015/06/04/stm32-applications-eclipse-gcc-stcube/ - Build STM32 applications with Eclipse, GCC and STM32Cube
. In the last,it was said:
we have to declare which MCU we are using defining a global macro inside the project configuration. For Nucleo-F401RE the macro is STM32F401xE. Go inside the project properties (on the main Eclipse menu go to Project->Properties), then C/C++ Build->Settings. Click on Tool Settings and go in Cross ARM C Compiler->Preprocessor. Click on the Add icon () and add the macro STM32F401xE.
I added STM32G474xE as macro, and there were more than 300 errors after built. So I guess maybe the macro was wrong? What is it?
This is the first error:
#error "Please select first the target STM32G4xx device used in your application (in stm32g4xx.h file)"
now, it has only 12 errors:
Building file: ../system/src/stm32g4xx/stm32g4xx_hal_timebase_tim_template.c
Invoking: GNU Arm Cross C Compiler
arm-none-eabi-gcc -mcpu=cortex-m4 -mthumb -Og -fmessage-length=0 -fsigned-char -ffunction-sections -fdata-sections -ffreestanding -fno-move-loop-invariants -Wall -Wextra -g3 -DDEBUG -D STM32G474xE -DTRACE -I"../include" -I"../system/include" -I"../system/include/cmsis" -I"../system/include/stm32g4xx" -std=gnu11 -MMD -MP -MF"system/src/stm32g4xx/stm32g4xx_hal_timebase_tim_template.d" -MT"system/src/stm32g4xx/stm32g4xx_hal_timebase_tim_template.o" -c -o "system/src/stm32g4xx/stm32g4xx_hal_timebase_tim_template.o" "../system/src/stm32g4xx/stm32g4xx_hal_timebase_tim_template.c"
../system/src/stm32g4xx/stm32g4xx_hal_timebase_tim_template.c:56:1: error: unknown type name 'TIM_HandleTypeDef'; did you mean 'EXTI_HandleTypeDef'?
TIM_HandleTypeDef TimHandle;
^~~~~~~~~~~~~~~~~
EXTI_HandleTypeDef
../system/src/stm32g4xx/stm32g4xx_hal_timebase_tim_template.c: In function 'HAL_InitTick':
../system/src/stm32g4xx/stm32g4xx_hal_timebase_tim_template.c:108:12: error: request for member 'Instance' in something not a structure or union
TimHandle.Instance = TIM6;
^
../system/src/stm32g4xx/stm32g4xx_hal_timebase_tim_template.c:116:12: error: request for member 'Init' in something not a structure or union
TimHandle.Init.Period = (1000000U / 1000U) - 1U;
^
../system/src/stm32g4xx/stm32g4xx_hal_timebase_tim_template.c:117:12: error: request for member 'Init' in something not a structure or union
TimHandle.Init.Prescaler = uwPrescalerValue;
^
../system/src/stm32g4xx/stm32g4xx_hal_timebase_tim_template.c:118:12: error: request for member 'Init' in something not a structure or union
TimHandle.Init.ClockDivision = 0;
^
../system/src/stm32g4xx/stm32g4xx_hal_timebase_tim_template.c:119:12: error: request for member 'Init' in something not a structure or union
TimHandle.Init.CounterMode = TIM_COUNTERMODE_UP;
^
../system/src/stm32g4xx/stm32g4xx_hal_timebase_tim_template.c:119:32: error: 'TIM_COUNTERMODE_UP' undeclared (first use in this function); did you mean '__COUNTER__'?
TimHandle.Init.CounterMode = TIM_COUNTERMODE_UP;
^~~~~~~~~~~~~~~~~~
__COUNTER__
../system/src/stm32g4xx/stm32g4xx_hal_timebase_tim_template.c:119:32: note: each undeclared identifier is reported only once for each function it appears in
../system/src/stm32g4xx/stm32g4xx_hal_timebase_tim_template.c:120:12: warning: implicit declaration of function 'HAL_TIM_Base_Init'; did you mean 'HAL_MspDeInit'? [-Wimplicit-function-declaration]
status = HAL_TIM_Base_Init(&TimHandle);
^~~~~~~~~~~~~~~~~
HAL_MspDeInit
../system/src/stm32g4xx/stm32g4xx_hal_timebase_tim_template.c:124:14: warning: implicit declaration of function 'HAL_TIM_Base_Start_IT'; did you mean 'HAL_DMA_Start_IT'? [-Wimplicit-function-declaration]
status = HAL_TIM_Base_Start_IT(&TimHandle);
^~~~~~~~~~~~~~~~~~~~~
HAL_DMA_Start_IT
../system/src/stm32g4xx/stm32g4xx_hal_timebase_tim_template.c: In function 'HAL_SuspendTick':
../system/src/stm32g4xx/stm32g4xx_hal_timebase_tim_template.c:154:3: warning: implicit declaration of function '__HAL_TIM_DISABLE_IT'; did you mean 'DMA_MINC_DISABLE'? [-Wimplicit-function-declaration]
__HAL_TIM_DISABLE_IT(&TimHandle, TIM_IT_UPDATE);
^~~~~~~~~~~~~~~~~~~~
DMA_MINC_DISABLE
../system/src/stm32g4xx/stm32g4xx_hal_timebase_tim_template.c:154:36: error: 'TIM_IT_UPDATE' undeclared (first use in this function); did you mean 'HRTIM_RSTR_UPDATE'?
__HAL_TIM_DISABLE_IT(&TimHandle, TIM_IT_UPDATE);
^~~~~~~~~~~~~
HRTIM_RSTR_UPDATE
../system/src/stm32g4xx/stm32g4xx_hal_timebase_tim_template.c: In function 'HAL_ResumeTick':
../system/src/stm32g4xx/stm32g4xx_hal_timebase_tim_template.c:166:3: warning: implicit declaration of function '__HAL_TIM_ENABLE_IT' [-Wimplicit-function-declaration]
__HAL_TIM_ENABLE_IT(&TimHandle, TIM_IT_UPDATE);
^~~~~~~~~~~~~~~~~~~
../system/src/stm32g4xx/stm32g4xx_hal_timebase_tim_template.c:166:35: error: 'TIM_IT_UPDATE' undeclared (first use in this function); did you mean 'HRTIM_RSTR_UPDATE'?
__HAL_TIM_ENABLE_IT(&TimHandle, TIM_IT_UPDATE);
^~~~~~~~~~~~~
HRTIM_RSTR_UPDATE
../system/src/stm32g4xx/stm32g4xx_hal_timebase_tim_template.c: At top level:
../system/src/stm32g4xx/stm32g4xx_hal_timebase_tim_template.c:177:36: error: unknown type name 'TIM_HandleTypeDef'; did you mean 'EXTI_HandleTypeDef'?
void HAL_TIM_PeriodElapsedCallback(TIM_HandleTypeDef *htim)
^~~~~~~~~~~~~~~~~
EXTI_HandleTypeDef
../system/src/stm32g4xx/stm32g4xx_hal_timebase_tim_template.c: In function 'TIM6_DAC_IRQHandler':
../system/src/stm32g4xx/stm32g4xx_hal_timebase_tim_template.c:189:3: warning: implicit declaration of function 'HAL_TIM_IRQHandler'; did you mean 'HAL_EXTI_IRQHandler'? [-Wimplicit-function-declaration]
HAL_TIM_IRQHandler(&TimHandle);
^~~~~~~~~~~~~~~~~~
HAL_EXTI_IRQHandler
system/src/stm32g4xx/subdir.mk:273: recipe for target 'system/src/stm32g4xx/stm32g4xx_hal_timebase_tim_template.o' failed
make: *** [system/src/stm32g4xx/stm32g4xx_hal_timebase_tim_template.o] Error 1
"make all" terminated with exit code 2. Build might be incomplete.
13:25:44 Build Failed. 12 errors, 5 warnings. (took 19s.356ms)
2021-06-20 06:49 AM
Try to define: STM32G474xx
Look at the file stm32g4xx.h to know what to define for every MCU.
Also exclude all "template" files from the build. These are useless for a first work.