STM32F415VG Support


I have a board with an STM32F415VG I’d like to program using PlatformIO. It looks like PlatformIO only has the STM32F415RG supported right now. They are functionally the same, except the VG version has 100 pins instead of 64, and an extra port which I don’t intend to use. I’m assuming I can’t just put the RG version and flash using that in PlatformIO? Am I shit out of luck here? Or is there some sort of hack I can do to program this using PlatformIO?


Primarily, board support requests are to be made through opening an issue in platformio/platform-ststm32. But there’s a shortcut here.

The STM32 HAL code does not differentiate between an F415RG and F415VG. It’s of the same STM32F415xx device class – this not always true for all devices. E.g., it differentiates a STM32F401xC and a STM32F401xE.

So, since the base STM32 HAL framework (on which pretty much every other framework is built) doesn’t differentiate between these two chips, the produced code for them will be the same. It’s just that for some chips you don’t have access to some pins because of the package (e.g., LQFP64 vs LQFP144).

While that means that you can use the existing genericSTM32F415RG.json board definition in your project, it doesn’t hurt to correct the meta-info used in it. This can be done with dynamic changes through the platformio.ini.

platform = ststm32
; base definition: RG.
board = genericSTM32F415RG
; correct sub-attributes
board_build.mcu = stm32f415vgt6
; use correct Arduino variant (aka, limit the pinout compared to a RG..)
board_build.variant = STM32F4xx/F405VGT_F415VGT
board_debug.jlink_device = STM32F415VG
; optional compiler flags for Arduino
build_flags = -DARDUINO_GENERIC_F415VGTX
; select target framework.
; example
framework = arduino

You can alternatively create a corrected board definition file. This would enable you to just say board = genericSTM32F415VG with the appropriate genericSTM32F415VG.json file – which can be created by duplicating the genericSTM32F415RG.json file into the boards/genericSTM32F415VG.json (folder can be created in the project) and changing up the attributes as referenced above. This is generally also documented in the documentation, and adding such a file into the boards/ folder of the platform is also exactly how the PlatformIO maintainers would create support for the board.

Note that if you use the Arduino framework with the board, you should implement the clock initialization function in your firmware.

extern "C" void SystemClock_Config(void) {
   //code here

STM32CubeMX is capable of auto-generating this function if you create a project for that microcontroller and set up the clock tree according to your hardware (external crystal / internal oscillator etc.).