I am relatively new to PlatformIO (have successfully flashed some STM32s with mbed and arduino through the IDE) and some of the internal workings are a bit nebulous to me despite reading a bunch of documentation and searching through github.
thanks for the pointers. It sounds like you are suggesting to add a new arduino core as well as board definitions for the 4 boards?
If I start modifying those github repos you linked to how do I test my local branches? Check it all out locally and compile myself? Just modify my local install in ~/.platformio and then submit the changes as a diff? How do you work on this?
Well it’s hard to convey multiple years of development experience in a single post; there’s a lot of background knowledge in play here, but let me try anyways by showing how I developed it…
I’m assuming you have completely read the linked documentation and know what a platform, framework, package, board definition etc. is and how e.g. a platform and package is described and configured by its JSON files.
these two criticial files dictate what flags ( -D .. -m .. -f ..) the compiler gets, how all available boards / variants are defined (with their name, configuration options which feed into compiler options, variant-specific source code folder, …) and how the code is uploaded (here: either openocd or dfu)
can also run Arduino IDE in verbose mode to see all compiler invocations if unsure
Replicate board JSON definitions (mostly templated from existing board definition, plus boards.txt, plus what options you need in there accessible from the build script, here e.g. I put hwids, usb_product etc)
Redirect platform to the forked version of ststm32 by pointing it to the new git as shown per docs
Add new Arduino core package. I chose the simpler platform_packages way here to make PIO download and “know” the package. The proper way would be to modify the platform.json. Since PIO 5.0.0 has introduced a new package repository system, and I don’t yet know how to reference my own published packages in there…
As you can see one needs a quite good understanding of PlatformIO internals, terminology and python scripting to integrate it here. Usually the core team adds integration for new cores, platforms etc.
The way I develop is to clone all my forked repos but modify my local files in e.g. C:\Users\.platformio\packages and C:\Users\.platformio\platforms, then copy them back and commit. Only at the last stage I redirect the packages / platforms of the project to the forked sources, remove my previous packages and platforms and see if it correctly uses the redirected packages.
On another note, I would be happy for feedback on https://github.com/maxgerhardt/pio-stm32l4core-example. You should be able to download this project, set default_envs = .. for your board (follow documentation links for supported boards and configs) and see if compilation, uploading and e.g. a basic blinky or serial output works.
I can succesfully compile for all environments; however I don’t have a board for testing.