Run Arduino libraries and sketches on Mbed OS

Is it possible to implement this in Platformio?
http://blog.janjongboom.com/2019/08/01/arduino-mbed.html

This should work on Linux & Mac but not on Windows at the moment due to a limitation with the filepath length. See Issue ARM mbed: Compilation of project with long file paths not possible · Issue #2877 · platformio/platformio-core · GitHub. Also on Windows, you must execute git config --system core.longpaths true before cloning because otherwise you will get an error about the filepath being to long. (Or, manually download the repo below and extract it into the lib/ folder).

Otherwise, it’s just a mbed-os library with a mbed_lib.json. You can try:

platformio.ini

[env:nucleo_l152re]
platform = ststm32
board = nucleo_l152re
framework = mbed
build_flags = -D PIO_FRAMEWORK_MBED_RTOS_PRESENT
lib_deps = https://github.com/arduino/ArduinoCore-nRF528x-mbedos.git

src/main.cpp

// Arduino code
#include "Arduino.h"

void setup() {
    pinMode(LED_BUILTIN, OUTPUT);
    Serial.begin(115200);
    Serial.println("Welcome to Arduino on Mbed OS");
}

void loop() {
    digitalWrite(LED_BUILTIN, HIGH);
    Serial.println("LED is now on!");
    delay(1000);
    digitalWrite(LED_BUILTIN, LOW);
    Serial.println("LED is now off!");
    delay(1000);
}

// Mbed OS code
int main() {
    setup();
    while (1) loop();
}
2 Likes

@maxgerhardt wow! :slight_smile: Does it work? :slight_smile: Can we use this case for Support for Arduino Nano 33 BLE (Sense) · Issue #53 · platformio/platform-nordicnrf52 · GitHub ?

Right now it doesn’t compile due to long filepaths and every header (also for completely different targts) being included by the library. Does need additional work to teach it to not spam 255 Kilobytes of include paths.