Announcing First-Class Support for the Nano 33 BLE in Mbed OS CE

Hello! I'm Jamie, one of the developers of Mbed OS Community Edition. As of today, we are proud to announce that we have an Mbed OS build that's able to run directly on an Arduino Nano 33 BLE board, with no additional configuration or patches needed.

You may not have heard of Mbed OS, but it's already running on every Nano 33 BLE board, as the lower layer that connects the Arduino framework and the hardware. Until now, you haven't been able to use it by itself without getting into nasty linker script and build system hacking, because not everything needed for this board made it into the upstream Mbed OS repo. As of now, this changes! Mbed can now be used without restriction on the Nano 33 BLE, and can be leveraged to provide a capable and powerful software framework to those who want it.

What is Mbed OS?

Mbed OS is an operating system created by ARM to aid development of code for its microprocessors, especially for networked and Internet of Things applications. Mbed OS provides a high-level C++ API that is concise and easy to use, but also provides access to many advanced features of ARM chips such as wireless communication and asynchronous operations. Thanks to its high-level API, Mbed helps you write code that can be used across of wide variety of processors without needing significant changes.

What does Mbed OS code look like?

  • See a hello world example here
  • See an I2C communication example here (scroll down a bit)
  • See an Internet communication example here

What is Mbed CE?

Unfortunately, Mbed OS was put into maintenance mode in January 2022, after which development of new features and bugfixes by ARM stopped. Community bugfixes are still being accepted, but that's it.

To keep development on Mbed OS running, and to fix some of the idiosyncrasies created by years of ARM constantly changing direction on the project, I and several other community members created Mbed OS Community Edition (CE). To summarize, we are working on fixing longstanding bugs, improving the build system, creating better documentation, and expanding Mbed OS to support an even wider number of targets. Being blunt, we've still got a long way to go, but we are making good progress!

Why use Mbed over Arduino?

To be honest, if you are a casual Arduino user, and you have found everything you need in the Arduino ecosystem, Mbed may not be for you -- Arduino does an excellent job of making the basics well-documented and easy to use. Mbed does require some prerequisite knowledge -- you will need to be comfortable working with git, using the command line, and installing the ARM toolchain. We have a guide for this, but experience is recommended.

However, Mbed should be very useful to those of you who are working with more complex systems and are starting to push against the limits of the Arduino framework. Need to create multiple SPI, I2C, or UART peripherals and use them on arbitrary pins? We got you. Want to send or receive UART serial data in the background, without slowing down your code? Mbed does that automatically with BufferedSerial. Need to create multiple threads that time-share the processor, and then exchange data between them? This is what Mbed's RTOS and EventQueue libraries are designed for. Basically, if you want to create more complex applications that squeeze all the features out of the Nano 33 BLE's processor, Mbed may be what you need.

The other big benefit of Mbed OS is its build system. Gone is Mbed's obtuse and finicky build system of the past -- it has been replaced by a sleek, logically structured CMake-based build system. CMake is highly expandable, allowing you to structure your project any way that you wish. Want to create multiple executables and libraries in a single project and link them together? Have source files that are auto-generated by a script or external tool? Want to set up unit tests that run on real hardware and report results back to your computer? All of these, and more, are possible with Mbed's build system plus a little bit of CMake script written by you.

Furthermore, the build system has been optimized at every turn for rapid and convenient development. There will be no inefficiencies like waiting for full rebuilds or manually copying/flashing programs to your board. We have out-of-the-box support for two IDEs, CLion and VS Code. If you use either of these, IntelliSense works straightaway and you can build and flash code with a single click. Command-line building is also straightforward. Since CMake is using its efficient Ninja backend, builds are multicore and code is only recompiled when strictly needed. Debugging is also supported out-of-the-box on most targets (though on the Nano 33 BLE it requires a separate adapter). And since the Mbed source gets added as a submodule, instead of an opaque binary, it's easy for you to view or debug the lower layers when needed.

Using Mbed on Arduino Nano 33 BLE

First of all, go and read the doc page I wrote that explains how this board works with Mbed OS. At minimum, make sure to read and follow the "Selecting Bootloader or SWD" section, and decide whether to use the bootloader or a debug probe.

Next, you must install the toolchain per the guide here.

Now, you're ready to work on an actual project:

Hopefully this is enough to get you started! Feel free to post here if you have any feedback or questions. Also, the Mbed CE project is still looking for additional members, so let me know if you're interested in helping to keep things going.

One last thing: Don't forget that the Arduino core and bluetooth libraries for the Nano 33 BLE are built on top of Mbed. So if your project has existing code built on the Arduino API, or if you just like using the Arduino stuff better, you can actually import all or parts of these repos into your Mbed project. It might take a little hacking, but it definitely is possible.

1 Like

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.