Page 1 of 2

Compile error - STM32F412VE

Posted: Sat Apr 03, 2021 3:06 pm
by somanshraj
The following STM32F412VE Arduino board is not available, hence I added the variant by copying the closest variant Generic_F412Rx and doing the necessary changes to files in it. On compiling the error I'm stuck at is :

/Library/Arduino15/packages/STM32/tools/xpack-arm-none-eabi-gcc/9.2.1-1.1/bin/../lib/gcc/arm-none-eabi/9.2.1/../../../../arm-none-eabi/bin/ld: libraries/SrcWrapper/stm32/PortNames.c.o: in function set_GPIO_Port_Clock': PortNames.c:(.text.set_GPIO_Port_Clock+0xa2): undefined reference to __HAL_RCC_GPIOF_CLK_ENABLE'

/Library/Arduino15/packages/STM32/tools/xpack-arm-none-eabi-gcc/9.2.1-1.1/bin/../lib/gcc/arm-none-eabi/9.2.1/../../../../arm-none-eabi/bin/ld: PortNames.c:(.text.set_GPIO_Port_Clock+0xaa): undefined reference to `__HAL_RCC_GPIOG_CLK_ENABLE'

collect2: error: ld returned 1 exit status
exit status 1
Error compiling for board Generic STM32F4 series.

Any idea or hint will be helpful ?

Re: Compile error - STM32F412VE

Posted: Sat Apr 03, 2021 4:31 pm
by fpiSTM
First check the product_line entry in the boards.txt.
I guess you kept: STM32F412Rx while it should be STM32F412Vx

Re: Compile error - STM32F412VE

Posted: Sat Apr 03, 2021 5:58 pm
by somanshraj
Okay. This is what I added. Maybe I am missing something ?

# Generic F412VE
GenF4.menu.pnum.Generic_F412VE=Generic F412VE
GenF4.menu.pnum.Generic_F412VE.upload.maximum_size=524288
GenF4.menu.pnum.Generic_F412VE.upload.maximum_data_size=262144
GenF4.menu.pnum.Generic_F412VE.build.board=GENERIC_F412VE
GenF4.menu.pnum.Generic_F412VE.build.product_line=STM32F412Vx
GenF4.menu.pnum.Generic_F412VE.build.variant=Generic_F412Vx

Re: Compile error - STM32F412VE

Posted: Sat Apr 03, 2021 6:10 pm
by somanshraj
Update : On removing the following code below from PortNames.c fixed the compile error.

#if defined GPIOF_BASE
case PortF:
gpioPort = (GPIO_TypeDef *)GPIOF_BASE;
__HAL_RCC_GPIOF_CLK_ENABLE();
break;
#endif
#if defined GPIOG_BASE
case PortG:
#if defined(PWR_CR2_IOSV)
// Enable VDDIO2 supply for 14 I/Os (Port G[15:2])
HAL_PWREx_EnableVddIO2();
#endif
gpioPort = (GPIO_TypeDef *)GPIOG_BASE;
__HAL_RCC_GPIOG_CLK_ENABLE();
break;
#endif

Re: Compile error - STM32F412VE

Posted: Sat Apr 03, 2021 8:39 pm
by fpiSTM
Yes removing that solved your issue but this is not correct as it is common and under preprocessing.

Re: Compile error - STM32F412VE

Posted: Sun Apr 04, 2021 9:49 am
by fpiSTM
In fact it seems there is a mismatch between the CMSIS device drivers definition of the mcu:
https://raw.githubusercontent.com/stm32 ... 32f412vx.h

and the HAL RCC:
https://github.com/stm32duino/Arduino_C ... l_rcc_ex.h

That would be fine to open an issue in the STM32CubeF4 GitHub repository.
https://github.com/STMicroelectronics/STM32CubeF4

Re: Compile error - STM32F412VE

Posted: Sun Apr 04, 2021 9:52 am
by mlundin
Variants of STM32F412Vx with 100 pins or less dont have ports F and G according to datasheet, still GPIOF_BASE and GPIOG_BASE are defined in the stm32f412vx.h header file.

Since PortNames.c only checks if GPIOF_BASE is defined that will fail since __HAL_RCC_GPIOF_CLK_ENABLE() is not defined, see "stm32f4xx_hal_rcc_ex.h:4726" and above. Perhaps the code should check if the clock enable macro is defined.

EDIT: There is also a macro IS_GPIO_ALL_INSTANCE(GPIOx) that could be used to check if the port is present according to HAL code.

Re: Compile error - STM32F412VE

Posted: Sun Apr 04, 2021 1:22 pm
by fpiSTM
mlundin wrote: Sun Apr 04, 2021 9:52 am Variants of STM32F412Vx with 100 pins or less dont have ports F and G according to datasheet, still GPIOF_BASE and GPIOG_BASE are defined in the stm32f412vx.h header file.

Since PortNames.c only checks if GPIOF_BASE is defined that will fail since __HAL_RCC_GPIOF_CLK_ENABLE() is not defined, see "stm32f4xx_hal_rcc_ex.h:4726" and above. Perhaps the code should check if the clock enable macro is defined.

EDIT: There is also a macro IS_GPIO_ALL_INSTANCE(GPIOx) that could be used to check if the port is present according to HAL code.
I've just check the datasheet and even if some PF/PG are mentioned for UFBGA144 and LQFP144 they are not available for the sales F412V version. Only 81 pins.
So the cmsis device should be fixed.

Code: Select all

IS_GPIO_ALL_INSTANCE 
is not useful in that case as it is fixed. In any case even testing with it or testing the HAL RCC macro exists will simply hide the issue as you think enable the GPIO clock while it will not.

Re: Compile error - STM32F412VE

Posted: Sun Apr 04, 2021 2:11 pm
by fpiSTM

Re: Compile error - STM32F412VE

Posted: Mon Apr 05, 2021 3:04 am
by somanshraj
mlundin wrote: Sun Apr 04, 2021 9:52 am Variants of STM32F412Vx with 100 pins or less dont have ports F and G according to datasheet, still GPIOF_BASE and GPIOG_BASE are defined in the stm32f412vx.h header file.

Since PortNames.c only checks if GPIOF_BASE is defined that will fail since __HAL_RCC_GPIOF_CLK_ENABLE() is not defined, see "stm32f4xx_hal_rcc_ex.h:4726" and above. Perhaps the code should check if the clock enable macro is defined.

EDIT: There is also a macro IS_GPIO_ALL_INSTANCE(GPIOx) that could be used to check if the port is present according to HAL code.
Exactly!