Mbed OS on Raspberry Pi Pico anyone?

I just started experimenting with the Pi Pico.
What is its status of mbed os support? The linked git issue is still marked as a draft.

Beginners question: Is mbed os the library which is used in the arduino mbed os core for the rpi pico?

Hello,

Mbed team usually not adding any targets, that is done by Mbed partners (ST, NXP and so on) or some else who want it. In this case It was done by Arduino team for Arduino world not for us.
If you want use it without any workaround or finding how, use Arduino tools and not Mbed tools.

Yes, but Arduino team took Mbed OS and wrapped it with some patches, so it is not 1:1.
Mbed OS Tech Forum - Arduino Special - YouTube

Br, Jan

1 Like

You can definitely use MbedOS via the Arduino IDE. The benefit of this is that once your code has compiled, the Arduino IDE will upload your sketch via USB for you (otherwise you have to use swdio and swclk pins for debugging and/or also manually upload your compiled application). There is no need to even use the BootSEL button (well ok you do need to use it occasionally as it’s not perfect).

You can even include PicoSDK code in your Arduino Sketch. So the Arduino IDE is quite flexible.

For example, you can use Arduino code:

#include "mbed.h"

void setup() {
  // put your setup code here, to run once:
  Serial.begin(115200);
  while (!Serial) {;;}

  Serial.print("Mbed OS version ");
  Serial.print(String(MBED_MAJOR_VERSION)+".");
  Serial.print(String(MBED_MINOR_VERSION)+".");
  Serial.println(MBED_PATCH_VERSION);
  
}

void loop() {
  // put your main code here, to run repeatedly:

}

which will return Mbed OS version 6.15.1

or you can use Mbed code, with a small mod (need to add mbed:: as a qualifier for Mbed specific functions or use using namespace mbed;

/*
 * Copyright (c) 2020 Arm Limited and affiliates.
 * SPDX-License-Identifier: Apache-2.0
 */

#include "mbed.h"

// Specify different pins to test printing on UART other than the console UART.
#define TARGET_TX_PIN   (Add Specific Pin Number here)
#define TARGET_RX_PIN   (Add Specific Pin Number here)

// Create a BufferedSerial object to be used by the system I/O retarget code.
static mbed::BufferedSerial serial_port(TARGET_TX_PIN, TARGET_RX_PIN, 115200);

mbed::FileHandle *mbed::mbed_override_console(int fd)
{
    return &serial_port;
}

int main(void)
{
    // print to the console using the `serial_port` object.
    printf(
        "Mbed OS version %d.%d.%d\n",
        MBED_MAJOR_VERSION,
        MBED_MINOR_VERSION,
        MBED_PATCH_VERSION
    );
}
4 Likes