While the official SDKs by Raspberry Pi Ltd only support C, C++ and python, it is also possible to develop a firmware using your favourite language, Rust.
As the RP2040 is based on a popular architecture, ARM Cortex-M, many drivers and other supporting infrastructure from the general Embedded Rust ecosystem can be used.
The easiest way to get startet is by using rp2040-hal, a hardware abstraction layer which hides the details of configuring the RP2040's registers behind a higher-level Rust API.
Alternatively, Embassy has support for the RP2040 and provides a modern async API.
It is easiest to start with one of the supported boards. Other boards based on the RP2040 should work as well, provided that you have some hardware documentation for that board.
Technically, it is possible to program the RP2040 using the integrated USB boot loader, so if you have a board like the Raspberry Pi Pico, you only need a USB cable to get started.
In practice, firmware development is much easier if you have a debug probe. This is a little device connecting the RP2040 to your computer, which allows direct access to the RP2040's memory, and provides means to show debug output generated by the firmware you are developing.
If you have a second Raspberry Pi Pico, it can be used as a debug probe, as described in the getting started document. There's no need to buy a more expensive debug probe, they provide little advantage (if at all) when starting to develop for the RP2040.
For building rust binaries for the rp2040, you need to install the rustc target thumbv6m-none-eabi
:
rustup target add thumbv6m-none-eabi
To upload a firmware using the integrated USB boot loader, the binary file must be converted to UF2 format. This can be accomplished using the elf2uf2 tool from the C SDK, or the rust port, elf2uf2-rs.
This conversion is not needed when using a debug probe for firmware upload. Instead, you need some software to talk to the debug probe. One good tool for that is probe-run.
A good place to start is the rp2040-project-template. It contains a simple firmware which just blinks a LED, wrapped in all the usual tooling.
If you have questions, need help, or want to share your creations, join us Matrix: #rp-rs:matrix.org.
Licensed under the terms of both the MIT license and the Apache License (Version 2.0), at your option.