How do i compile my code against Mbed 2 C/C++ SDK

How do i compile my code against Mbed 2 C/C++ SDK (and preferably a revision from the repository found at https://os.mbed.com/users/mbed_official/code/mbed/

The repository is behaving very badly with lots of timeouts and 404’s but I managed to recreate most of it as a (local) git repo.

I can’t upgrade to mbed os 5/6 bare metal due some 3rd party lib’s used that have never updates after 2013 or so.

In PlatformIO, build support for any framework / SDK is achieved by implement a “builder script”, which is a Python script using the underlying PlatformIO and SCons build system APIs to teach PlatformIO/SCons exactly what files to compile, how they’re compiled, and finally linked together and postprocessed.

That builder script is called from the platform (e.g., platform-ststm32, platform-nordicnrf52, …). For the mbed-os 5/6 framework, as is present at https://github.com/platformio/builder-framework-mbed, that’s currently about 800 lines of Python. That is quite a lot, something like the Arduino AVR builder script is only 190 lines. The mbed os build script does quite some work adapting it to PlatformIO, and that is with the help of importing the native mbed-os Python build packages.

Given that mbed 2 is so much older and 3 or 4 major versions behind the curent one, you will likely need a completely new builder script. Realistically, you can only write that if you have both superb knowledge of the PlatformIO / SCons internal (e.g., here) and the build system for mbed-os 2.

At which point one may also say, why do all this work and not directly use mbed-os’s native build system, or do the work and get it “up to date” on mbed os 6.

In any case, the mbed-os project was halted, killed by ARM almost a year ago.

So it’s quite a complex job (was hoping just unzipping the right commit’s sources would do). I know it’s going open source and yes mbed2 is old (but so is the application I build on it).

I will give mbed-os6 bare metal another go.

To my surprise, mbed-os6 in bare metal mode works (at least it’s testable on the device) after some not to big changes to my sources. Some serial port stuff. One major issue was getting *printf(0 functions to handle floats.

build_flags = -Wl,-u,_printf_float,-u,_scanf_float

in the patformio.ini and it worked. Most fixes I found where for mbed-os’es mbed_app.json file which platformio mostly ignores (at least for the float/printf fixes).

Next up is getting debugging with cmis-dap to work.

Actually that should still be a respected file, it’s also used in reference projects to e.g. set it to baremetal mode or enable the network stack

So if there’s issues with that, the developers would appreciate an issue opened at the platform-xxx repo that your project is using.