PlatformIO Community

Forked mbed-os and platformio?

Hi all,
like several people on this list, we are working with a number of custom boards (STM F3 variants), so we have forked and extended the mbed repo with the board definitions we need.

Each time platformio updates silently, our additions are shredded and we have to move stuff over to the framework-mbed subdirs again. Is there a way to define a custom github repo instead of the mainline?

Platformio works nice otherwise, but this is really costing us devel time.

well, you can take advantage of the custom_script feature to make the changes to the specific files using bash scripts on linux.

Think diff but with the ability to make the changes instead of just highlighting them.

That way only the changes you make need to be static while the mbed os updates can continue.

Sure!

See example https://github.com/platformio/platform-espressif32/blob/feature/stage/platform.json#L48

Also, you can depend on the own dev/platform http://docs.platformio.org/en/latest/projectconf/section_env_general.html#platform

Thanks @ivankravets,

adding custom platforms looks easy (took me 1 minute to add our boards), but how could I add a custom framework (a forked mbed)? Simply using a git link in the framework= line does not do the trick.

Meanwhile, I’ll try the custom_script approach (thanks @Krishna_Chaitanya!) - linking to the .git followed by a ‘git checkout – . && cd platformio/ && LC_ALL=C tox’ should more or less do it :slight_smile:
Simon

Framework is a part of a development platform. Please specify dependency in platform.json file. I gave you example above.

Aye, overlooked that line - thanks!

Ok, I have a working setup now with my own ‘voxel-mbed’ framework defined; I had to add it in the compatibility list of the external libraries that I link my project against of course.

One odd thing though: I have a set of project-specific code in the lib/xxx/ directories which did not link any more, the builder complained about incompatible platform versions. I added a dummy library.json declaring compatible frameworks to make it compile again:
“frameworks”: [“mbed”, “voxel-mbed” ],

Hope this helps someone in the future :wink:

@ivankravets @svogl - This discussion helped me solve the problem of getting Arduino to compile for nucleo_f103rb under PlatformIO (I’ll create a pull request soon), so thanks for the tips.

The documentation for creating a custom platform is fairly comprehensive. But it is not so obvious that when you want a custom version of a framework, you should go about this by creating a custom platform. Is this documented anywhere?

One other problem I found, when cloning and renaming the ststm32 platform, was that I needed to edit platform.py and change the class name to match the name field of my custom platform.json file. Once I identified the problem this was a simple fix.

1 Like

@ivankravets, Is there an easy way to work with a development version of a platform? I have forked the stm32 platform in github, and cloned it to my local folder. Then I use the form platform=file://path/to/my_stm32_platform to refer to my local modified copy. I have not changed the platform name as I want to submit this as a pull request. The first time I do pio run it copies my folder into .platformio/platforms/ststm32-plus-random-characters and I can see my project using the modified platform. However, whenever I update my platform, this is not detected, and I need to manually delete this copied folder in order to update my changes.

What is the workflow that you use for developing and debugging platforms?

I use symlink on macOS. You can clone repo directly to ~/.platformio/platforms folder.

It depends on dev/platform. The only a few dev/platforms have platform.py file which configures “manifest” on-the-fly depending on a build environment.

Hi,
I’m trying to switch to fork of mbed.

Defining in platformio.ini

[env:nucleo_f429zi]
platform = ststm32
board = nucleo_f429zi

framework = mbed
platform_packages = framework-mbed @ https://github.com/EmbeddedPlanet/mbed-os.git#feature-hal-spec-sai

looks like solution. While Clean PIO pulls repository and trying to deal with custom framework.
image

But I have error while Build:

    > Executing task in folder nucleo-f429_adar: platformio run <

Processing nucleo_f429zi (platform: ststm32; board: nucleo_f429zi; framework: mbed)
------------------------------------------------------------------------------------------------
Verbose mode can be enabled via `-v, --verbose` option
CONFIGURATION: https://docs.platformio.org/page/boards/ststm32/nucleo_f429zi.html
PLATFORM: ST STM32 6.1.0 > ST Nucleo F429ZI
HARDWARE: STM32F429ZIT6 180MHz, 256KB RAM, 2MB Flash
DEBUG: Current (stlink) On-board (stlink) External (blackmagic, jlink)
PACKAGES: 
 - framework-mbed daf6b329 
 - toolchain-gccarmnoneeabi 1.70201.0 (7.2.1)

warning: Calling missing SConscript without error is deprecated.
Transition by adding must_exist=0 to SConscript calls.
Missing SConscript '/home/shtirlich/.platformio/packages/framework-mbed@src-289d2467bb098b61a3eff2311493280d/platformio/platformio-build.py'
File "/home/shtirlich/.platformio/platforms/ststm32/builder/frameworks/mbed.py", line 37, in <module>

I’v inspected “original” and pulled mbed folders and I see that first one have platformio sub-folder. Official mbed repo https://github.com/ARMmbed/mbed-os doesn’t , as fork I would like to use.
Manually copying it I’m able to build my project, but switching mbed commit will brake magic = )

So, what is a official way for switching to custom mbed os commits, @ivankravets ?

I’m not sure that this is possible. @valeros, please comment.

Hi @isaev-ni! PlatformIO build scripts for mbed are not part of the official repository. But you can do so in your fork, just create a submodule for PlatformIO build script from based on repository

https://github.com/platformio/builder-framework-mbed

Yep, was thinking about same hack. Will try soon.