Created
August 15, 2023 09:40
-
-
Save iUltimateLP/637ed22e1940ecacd93d30cdf7a01cf9 to your computer and use it in GitHub Desktop.
Kickstart example to get PlatformIO to work with a STM32CubeMX generated project.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
; STM32 PlatformIO configuration file | |
; | |
; This is a kickstart example to get PlatformIO to work with a STM32CubeMX generated project, which eliminates the need of | |
; of the STM32CubeIDE. It also exclusively uses the driver files provided by CubeMX, rather than the outdated ones PlatformIO uses. | |
; | |
; The following steps get you started: | |
; 1. Open the STM32CubeMX tool, find your board/MCU, and create a new project. | |
; 2. Go to the "Project Manager" tab and set the following: | |
; | |
; Project > Toolchain / IDE : "Makefile" | |
; Code Generator > STM32Cube MCU packages and embedded software packs : "Copy only the necessary library files" | |
; Code Generator > Generated files : "Generate peripheral initilization as a pair of '.c/.h' files per peripheral" | |
; | |
; 3. Configure your STM32 project to your likings and when done, click "Generate Code" to kick off the code generation. | |
; 4. STM32CubeMX will generate a couple of files, most importantly the .ioc, .s and .ld files. | |
; It will also copy the necessary library files into "Drivers/" and user code into "Core/" | |
; 5. Enter this directory with the VSCode PlatformIO terminal and run the following command: | |
; | |
; PS C:\Path\To\CubeMX\Project> pio init | |
; | |
; 6. PlatformIO will generate an empty project structure inside the existing folder. You can delete the include/, lib/ and src/ folders since CubeMX | |
; has it's own way of naming these. | |
; | |
; 7. Open the "platformio.ini" file and paste the contents of this file. You can then alter this configuration template by your likings, such as the | |
; board you are using. | |
; | |
; More documentation on the PlatformIO .ini syntax can be found here: https://docs.platformio.org/page/projectconf.html | |
; Common PlatformIO configuration | |
[platformio] | |
include_dir = Core/Inc ; Directory that contains the user include files (more are defined in build_flags) | |
src_dir = . ; Directory that contains source files. Needs to be "." (current dir) so it takes the "startup_stm32xxxx.s" assembler file into account | |
; Common environment configuration | |
[env] | |
platform = ststm32 ; STM32 platform (https://registry.platformio.org/platforms/platformio/ststm32) | |
; Board-specific configuration | |
; IMPORTANT: do not include a "framework" here, otherwise it'll use PlatformIO's libraries instead of the ones copied by CubeMX (or you'll have duplicates) | |
[env:nucleo_l432kc] | |
board = nucleo_l432kc ; Which board to use | |
board_build.ldscript = STM32L432KCUx_FLASH.ld ; Path to the linker script generated by STM32CubeMX, necessary for linking the binary | |
; Additional build flags to pass to the compiler | |
; -I<dir> adds the given directory to the include paths. Add any STM32 driver include paths here | |
build_flags = | |
-IDrivers/CMSIS/Include | |
-IDrivers/CMSIS/Device/ST/STM32L4xx/Include | |
-IDrivers/STM32L4xx_HAL_Driver/Inc |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment