Raspberry Pi Pico Gets supports for Rust, RT-Thread OS and FreeRTOS

In January end, we saw the launch of Raspberry Pi Pico equipped with an RP2040 dual-core Cortex-M0+ microcontroller working up to 133 MHz with official support for MicroPython and C.

In this feature, we will be discussing the Raspberry Pi Pico’s flexible software support compatible with RP2040 MCU, apart from the MicroPython, C/C++, and upcoming Arduino IDE software support. We will specifically be focusing on Rust, RT-Thread OS, and FreeRTOS support for Raspberry Pi Pico.

Raspberry Pi Pico Rust RT-Thread FreeRTOS

Rust Code Running on Raspberry Pi Pico

Rust language is considered fast, reliable, and secure when it comes to IoT gateways. It also opens up the option for writing extremely low-level code, such as operating system kernels or microcontroller applications.  Porting Rust with RP2040 for working with Raspberry Pi Pico was seen in Jonathan Pallant’s Twitter Feed.

The RP2040 comes with an external QSPI flash. The internal mask-ROM reads the programs from the external flash and uses it at top of SRAM (0x2004_lf00) using a bootloader. Hence, the programs are a 256-byte block for reconfiguration of the XIP_SSI interface with appropriate values of the QSPI flash. This configures the system for the QSPI flash starts from the address 0x1000_000 from upwards. For more information visit the GitHub repository.

Jonathan also explains how the code would have to be built:

Running of the “cargo build –release”, then using the elf2uf2 tool from the pico-sdk creates a UF2 file. This can then be copied to the emulated mass storage device created by the ROM bootloader. It should be ready for flashing out with an SWDv2 compatible probe (like a second Pico running picoprobe firmware).  Working with the regular Arm probe requires the SWDv2 support and something that understands how the dual M0+ cores are connected.

There might also be a  need to build a PAC with svd2rust or change the Cargo.toml to point to a copy of GitHub – there are several.

RT-Thread OS on Raspberry Pi Pico

RT-Thread OS is an open-source real-time operating system (RTOS) dedicated to embedded applications and IoT devices, and compatible with various architectures “ranging from x86 and Arm to RISC-V and Xtensa, is supported on the RP2040 — and, by extension, on RP2040-based development boards including the Raspberry Pi Pico.”

RT-Thread Studio IDE supports the Raspberry Pi Pico’s RP2040 MCU for the target projects and can be downloaded from the company website. The development steps involve the download of PICO BSP from the SDK Manager of the IDE. Users can then create a new RT-Thread project and select the PICO board to work with Raspberry Pi Pico.

For detailed information to get started with RT-Thread OS you can watch the tutorial video above, or read RT-Thread’s article on Medium with screenshots for getting started. You can also get support in the forum

FreeRTOS Example for Raspberry Pi Pico

FreeRTOS is a popular open-source real-time operating system (RTOS) for microcontrollers and small microprocessors distributed under the MIT open source license.

There are not many resources available online about the support of FreeRTOS for Raspberry Pi Pico. However, Reddit thread draws our attention to a FreeRTOS Example for Raspberry Pi Pico that is hosted on GitHub. The operating system can be used in a conventional way for raspberry pico projects with CMake. 

The discussion includes some insightful parts, including “the use of CM0 port for standard FreeRTOS kernel without modifications that solves the issue of dealing with portable parts”, and one person is also interested in porting Zephyr OS to Raspberry Pi Pico.

Share this:
FacebookTwitterHacker NewsSlashdotRedditLinkedInPinterestFlipboardMeWeLineEmailShare

Support CNX Software! Donate via cryptocurrencies, become a Patron on Patreon, or purchase goods on Amazon or Aliexpress

ROCK Pi 4C Plus

12 Replies to “Raspberry Pi Pico Gets supports for Rust, RT-Thread OS and FreeRTOS”

    1. Yes, I’ve seen this. That’s because Microsoft Visual Studio Code is used to program Raspberry Pi Pico from the Raspberry Pi SBC. I’m not even sure it’s installed by default, because Pico instructions still say VS Code must be installed manually.

  1. Has anyone used a final product with Rust? Normally the IoT people that i worked with was against using differenct languages other than Python or C. Hell, i worked in a project that the manager didnt even let me use C++

    1. Normally the IoT people that i worked with was against using differenct languages other than Python or C.

      Hum…. probably startups, with sub 30 old devs….
      C is perfectly good for embedded, you just need to know what you are doing..
      Rust is like training wheels, it’s cute, but after a couple of years in the industry, you should not need to use them…

      .

      1. >Rust is like training wheels, it’s cute, but after a couple of
        >years in the industry, you should not need to use them…

        This is anecdotal but I find that people that think they are better than tools written by many people to solve common issues that almost everyone makes are very often the source of the bugs that the tools are trying to avoid.

        Let’s say rust is “training wheels” that avoids common errors that happen in C. If rust didn’t need special runtime support, generated code with the same footprint, and was a supported language for what you’re working on.. Why would it’s hand holding even matter? Obviously you are a brilliant programmer and you never make mistakes but if the code getting loaded onto the device is almost identical to what would have been generated from C the only difference is that your ego is slightly hurt from not using C right?

        1. Embedded compiler writers enforce some of the benefits of Rust which lessens the benefits, but you are right that if Rust could match C then it would be the obvious choice.

      2. And after a decade or two in the industry one realises the sad truth. One sees many systems crash and burn through simple memory use errors, made by developers of all experience levels. One has spent countless hours on long and head scratching debugging sessions, long after the developer team has been disbanded. One has seen very expensive investigations into problems after products have been deployed.

        Eventually one realises that those training wheels are a very good idea. For all developers all the time. When they have zero impact on program size or execution speed to reject such help toward program correctness is professional negligence.

        I have no idea what you mean by “Rust is cute”. Hardly sounds like an objective assessment. On he contrary, if we want to be emotional about it, I would say Rust is brutal. Its compiler will endlessly remind you what a poor programmer you are with no compassion.

        I make no claim that Rust is the be all and end all, a silver bullet for the problems that plague the industry. But it shows what can be done. To ignore its to close ones eyes to the possibilities for improvement.

    2. I will have a look at RUST, But at the moment I am looking t ERLANG for RPi usage. Has anyone used ERLANG & RUST to be able to compare?

Leave a Reply

Your email address will not be published. Required fields are marked *

Khadas VIM4 SBC
Khadas VIM4 SBC