SRUG 2024.02 Meetup
https://slides.com/u007d
Personal Introduction:
Brad G.
- Online: U007D ("Curly")
- Started tech back in the 1980's
- Hold a B.Sc. in Computer Science
- Started in BASIC
- Historically gravitated to low-level languages
- MOS 6502/6510 Assembly
- Motorola 68k Assembly
- K&R C, ANSI C, Pascal/Object Pascal, C++
An Introduction to Bare-Metal Embedded Systems Programming in Rust
On a Raspberry Pi Pico
Prerequisites:
Install Rust
1. https://www.rust-lang.org/tools/install
2. `rustup target add thumbv6m-none-eabi`
Install Tooling (git)
Mac: `brew install git` (see https://brew.sh/) or
https://github.com/git-guides/install-git
Ubuntu: `apt install git`
Windows: https://github.com/git-guides/install-git
Install Tooling (Other)
- `cargo install elf2uf2-rs svd2rust form`
- (Optional) Visual Studio Code Editor:
https://code.visualstudio.com
- (Optional) Mac: `brew install binutils`
Ubuntu: `apt install binutils`
Setting up the Board

1. Wire pin 1 (GPIO 0) to an empty row
2. Add resistor from wire end row to new empty row
3. Add LED (long leg) from resistor end row to new empty row
4. Wire from LED (short leg) to - rail
5. Wire - rail to pin 38 (Ground)
Setting up the Board

Setting up the Board

Running on the Pi
The Raspberry Pi Pico has a different CPU then your computer.
Your computer has to compile your source code to machine language for a processor it can't run. This is called cross-compiling.
Your cross-compiled program then needs to be transferred to the Pi and run there.
Running on the Pi (2)
To do this:
1. Unplug your RPi Pico USB cable (either end) if it is plugged in.
2. Hold down the white button on the RPi Pico.
3. Re-connect your RPi Pico with the white button held down.
(Your RPi Pico is now ready to receive your cross-compiled program.)
4. `cargo run`. (Your program is now running on your RPi Pico.)
5. Repeat the above procedure to send and run a new version of your code to your RPi Pico.
Bare-Metal Programming Like It's 1972
https://github.com/dougsummerville/Bare-Metal-Raspberry-PI-Pico/blob/main/baremetal/include/rp2040/pll.h
Bare-Metal Programming Like It's 2024
Let's Get Started
- git clone https://github.com/u007d/blinky
- cd blinky
- code . # or start your editor/IDE pointing here
Bonus: Making our own PAC
(We are in a new Golden Age for programming!)
- Silicon Vendor Description files
- https://github.com/raspberrypi/pico-sdk/blob/master/src/rp2040/hardware_regs/rp2040.svd
- `svd2rust -i rp2040.svd -o . --pascal-enum-values`
- `form -i rp2040/lib.rs -o src`
Thank you!
SRUG 2024.02: An Introduction to Bare-Metal Embedded Systems Programming in Rust
By u007d
SRUG 2024.02: An Introduction to Bare-Metal Embedded Systems Programming in Rust
- 221