Hi all,
I’m using VScode and PlatformIO plugin to develop STM32. Actually, I’m trying to replace STM32CubeIDE with the above solution.
In most IDEs(such as MDK, CubeIDE), there is a settings page to include head files and source files.
STM32CubdeIDE
Now I generate a Cube project with STM32CubeMX and wanna to build & compile with PlatformIO. I’m trying to add build flags in file ‘platformio.ini’ to include HAL libraries & other .h files. But failed.
[platformio]
; include_dir = ./Core/Inc
src_dir = ./
[env:disco_f429zi]
platform = ststm32
board = disco_f429zi
framework = stm32cube
build_flags =
-O0
-D STM32F429xx
-D USE_HAL_DRIVER
-I Core/Inc
-I Drivers/STM32F4xx_HAL_Driver/Inc
-I Drivers/STM32F4xx_HAL_Driver/Inc/Legacy
-I Drivers/CMSIS/Device/ST/STM32F4xx/Include
-I Drivers/CMSIS/Include
; build_src_filter =
; +<startup_stm32f429bitx.s>
; +<Drivers/>
; +<Core/Src>
board_build.ldscript = ./STM32F429BITX_FLASH.ld
upload_protocol = stlink
debug_tool = stlink
Error message like this:
Compiling .pio\build\disco_f429zi\FrameworkHALDriver\Src\stm32f4xx_hal_tim_ex.o
C:\Users\***\.platformio\packages\framework-stm32cubef4\Drivers\STM32F4xx_HAL_Driver\Src\stm32f4xx_hal_rtc_ex.c:940:10: error: conflicting types for 'HAL_RTCEx_DeactivateWakeUpTimer'
uint32_t HAL_RTCEx_DeactivateWakeUpTimer(RTC_HandleTypeDef *hrtc)
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from Drivers\STM32F4xx_HAL_Driver\Inc/stm32f4xx_hal_rtc.h:683:0,
from Core\Inc/stm32f4xx_hal_conf.h:391,
from Drivers\STM32F4xx_HAL_Driver\Inc/stm32f4xx_hal.h:29,
from C:\Users\***\.platformio\packages\framework-stm32cubef4\Drivers\STM32F4xx_HAL_Driver\Src\stm32f4xx_hal_rtc_ex.c:82:
Drivers\STM32F4xx_HAL_Driver\Inc/stm32f4xx_hal_rtc_ex.h:873:19: note: previous declaration of 'HAL_RTCEx_DeactivateWakeUpTimer' was here
HAL_StatusTypeDef HAL_RTCEx_DeactivateWakeUpTimer(RTC_HandleTypeDef *hrtc);
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
*** [.pio\build\disco_f429zi\FrameworkHALDriver\Src\stm32f4xx_hal_rtc_ex.o] Error 1
C:\Users\***\.platformio\packages\framework-stm32cubef4\Drivers\STM32F4xx_HAL_Driver\Src\stm32f4xx_hal_tim.c:525:19: error: conflicting types for 'HAL_TIM_Base_Start_DMA'
HAL_StatusTypeDef HAL_TIM_Base_Start_DMA(TIM_HandleTypeDef *htim, uint32_t *pData, uint16_t Length)
^~~~~~~~~~~~~~~~~~~~~~
In file included from Core\Inc/stm32f4xx_hal_conf.h:407:0,
from Drivers\STM32F4xx_HAL_Driver\Inc/stm32f4xx_hal.h:29,
from C:\Users\***\.platformio\packages\framework-stm32cubef4\Drivers\STM32F4xx_HAL_Driver\Src\stm32f4xx_hal_tim.c:186:
Drivers\STM32F4xx_HAL_Driver\Inc/stm32f4xx_hal_tim.h:1901:19: note: previous declaration of 'HAL_TIM_Base_Start_DMA' was here
HAL_StatusTypeDef HAL_TIM_Base_Start_DMA(TIM_HandleTypeDef *htim, const uint32_t *pData, uint16_t Length);
^~~~~~~~~~~~~~~~~~~~~~
When I add ‘include_dir’ below [platformio]
[platformio]
include_dir = ./Core/Inc ;new added
src_dir = ./
[env:disco_f429zi]
platform = ststm32
board = disco_f429zi
framework = stm32cube
build_flags =
-O0
-D STM32F429xx
-D USE_HAL_DRIVER
-I Core/Inc
-I Drivers/STM32F4xx_HAL_Driver/Inc
-I Drivers/STM32F4xx_HAL_Driver/Inc/Legacy
-I Drivers/CMSIS/Device/ST/STM32F4xx/Include
-I Drivers/CMSIS/Include
; build_src_filter =
; +<startup_stm32f429bitx.s>
; +<Drivers/>
; +<Core/Src>
board_build.ldscript = ./STM32F429BITX_FLASH.ld
upload_protocol = stlink
debug_tool = stlink
A simmilar error is still there:
Compiling .pio\build\disco_f429zi\FrameworkHALDriver\Src\stm32f4xx_hal_smartcard.o
C:\Users\***\.platformio\packages\framework-stm32cubef4\Drivers\STM32F4xx_HAL_Driver\Src\stm32f4xx_hal_rtc_ex.c:940:10: error: conflicting types for 'HAL_RTCEx_DeactivateWakeUpTimer'
uint32_t HAL_RTCEx_DeactivateWakeUpTimer(RTC_HandleTypeDef *hrtc)
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from Drivers\STM32F4xx_HAL_Driver\Inc/stm32f4xx_hal_rtc.h:683:0,
from Core\Inc/stm32f4xx_hal_conf.h:391,
from Drivers\STM32F4xx_HAL_Driver\Inc/stm32f4xx_hal.h:29,
from C:\Users\***\.platformio\packages\framework-stm32cubef4\Drivers\STM32F4xx_HAL_Driver\Src\stm32f4xx_hal_rtc_ex.c:82:
Drivers\STM32F4xx_HAL_Driver\Inc/stm32f4xx_hal_rtc_ex.h:873:19: note: previous declaration of 'HAL_RTCEx_DeactivateWakeUpTimer' was here
HAL_StatusTypeDef HAL_RTCEx_DeactivateWakeUpTimer(RTC_HandleTypeDef *hrtc);
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Compiling .pio\build\disco_f429zi\FrameworkHALDriver\Src\stm32f4xx_hal_smbus.o
*** [.pio\build\disco_f429zi\FrameworkHALDriver\Src\stm32f4xx_hal_rtc_ex.o] Error 1
===================================================================== [FAILED] Took 9.42 seconds =====================================================================
I’m wandering what the correct writing should look like. I’ve read the platformio docunment and searched with google, bing and github, but no solution yet. Any ideas?