Table of content

What is this :grey_question:

The rules of the game are explained in my original.

53rd Challenge

Challenge

Run hello world on a pi pico using rust.

Solution :white_check_mark:

Start from a template

cargo generate \
--git https://github.com/rp-rs/rp2040-project-template \
--branch main \
--name pi-pico-helloworld

The template, looks like this, when running tree -L 3

.
├── CODE_OF_CONDUCT.md
├── Cargo.lock
├── Cargo.toml
├── Embed.toml
├── README.md
├── build.rs
├── debug_probes.md
├── memory.x
├── src
│   └── main.rs
└── target
    ├── CACHEDIR.TAG
    ├── release
    │   ├── build
    │   ├── deps
    │   ├── examples
    │   └── incremental
    └── thumbv6m-none-eabi
        ├── CACHEDIR.TAG
        └── release

There are a number of runners described in the example. Lets keep it simple and use UF2. We hold the reset button on the pico and plug it into the computer so it is in boot mode. Then we change our .cargo/config so the runner says runner = "elf2uf2-rs -d. Its already in the file, just need to uncomment it. We will reduce the blinky example even more, to just “hello world”.

    #![no_std]
    #![no_main]

    use bsp::entry;
    use defmt::*;
    use defmt_rtt as _;
    use panic_probe as _;
    use rp_pico as bsp;

    #[entry]
    fn main() -> ! {
        info!("Hello World!");
        loop {}
    }
    

Thats it, with cargo run --release the program is flashed :). See the repo on github