PlatformIO Community

How to add a different arduino core


#1

I’ve been working on adding an STM32L0 arduino core from https://github.com/GrumpyOldPizza/ArduinoCore-stm32l0 to platformio. I have it working but am wondering what the best way to integrate is. It lives in a separate framework-arduinostm32l0 package but I need to insert it somehow into the ststm32 platform. What I did was to add to platform.json, add a build script into builder/frameworks/arduino and then extend the hokey matching at the end of stm32duino.py:

from SCons.Script import DefaultEnvironment

env = DefaultEnvironment()

if "stm32f1" in env.BoardConfig().get("build.variant"):
    env.SConscript('maple/stm32f1.py', exports="env")
if "stm32l0" in env.BoardConfig().get("build.mcu"):
    env.SConscript('stm32l0/stm32l0.py', exports="env")

Notice the last two lines, which I added.
Questions:

  • is there no cleaner way to do this?
  • how do I do this in my environment such that it doesn’t get wiped the next time I upgrade platformio?

#2

One thing I tried is to create a different framework, e.g. arduino-stm32l0 in order to avoid having the hokey if "stm32l0" in env.BoardConfig().get("build.mcu"): condition, but there are a number of things that are hard-coded in platformio for a framework called arduino. Is there a way to “enable” these special things for a framework that is called differently?


#3

Hi, I am trying to do the same…did you find a better / automatic solution?


#4

We work on the bug update for ST STM32 dev/platform which will allow switching between cores. See

You can try upstream version https://docs.platformio.org/en/latest/platforms/ststm32.html#stable-and-upstream-versions


#5

Can you share some more detailed information about how you got it working in PlatformIO? I don’t mind a complicated solution, as long as it works.


#6

This was released today as stable 5.2.0. Update your platforms (pio platform update) and try the instructions from the documentation linked above.


#7

I think there is a little miscommunication here. I was referring to the STM32L0 core mentioned at the beginning of this thread. The updated platforms and docs you are referring to, are all about two different cores: STM32duino and STM32Duino and Arduino STM32 (maple).

To be more specific: I want to be able to use the STM32L0 arduino core from https://github.com/GrumpyOldPizza/ArduinoCore-stm32l0 .


#8

Ah, now that’s a different thing. For that you’d need to update the platform-ststm32 again with new builder scripts for your core and the new core itself of course. I can’t give you a step-by-step explanation out of my head but if you want to start working, then you’d look into the arduino.py builder script, specifically the code which distinguishes the cores, and the invoked sub-scripts (e.g. framework-arduinoststm32-maple\tools\platformio-build-stm32f1.py)


#9

Thanks for our prompt answers! Maybe topic starter tve will return to this topic with some more detailed information, or I will dive into this myself later.