Skip to content

Examples for RP2040-Zero Microcontroller #186

@Vaishnav-Sabari-Girish

Description

@Vaishnav-Sabari-Girish

Hey @orhun
I recently started working with Rust on the RP2040-Zero microcontroller and I noticed that there were no examples for this board in the examples/ directory.

I have a minimal example ready with me. It displays text using ratatui on the 1.54 inch E-Paper Display by Waveshare.

For the user's convenience I have added a Justfile which does the jobs of mounting, copying and umounting the drive.

It contains sudo commands. I did try alternatives without sudo but it was not as smooth as the one I have right now.

For your reference I am dropping the Justfile here

# Match the exact binary name from Cargo.toml
BIN_NAME := "rp2040-1in54-epd-example"

# Go up two directories to reach the workspace root target folder
TARGET_DIR := "../../target/thumbv6m-none-eabi/release"

build:
    @cargo build --release

run: build
    @echo "Converting ELF to UF2..."
    @elf2uf2-rs convert {{TARGET_DIR}}/{{BIN_NAME}} flash.uf2
    @echo "Mounting RP2040 synchronously (requires sudo)..."
    @sudo mount -t vfat -o sync /dev/sda1 /mnt/rp2
    @echo "Flashing memory..."
    @sudo cp flash.uf2 /mnt/rp2/
    @echo "Done! Program has been flashed"
    @sudo umount /mnt/rp2/ || true


nuke:
    @echo "Nuking RP2040 flash memory..."
    @if mountpoint -q /mnt/rp2; then \
        echo "✓ Drive already mounted at /mnt/rp2"; \
    else \
        echo "Mounting RP2040..."; \
        sudo mount -t vfat -o sync /dev/sda1 /mnt/rp2; \
    fi
    @echo "Copying flash_nuke.uf2..."
    @sudo cp flash_nuke.uf2 /mnt/rp2/
    @echo "Waiting for flash erase to complete..."
    @sleep 2
    @sudo umount /mnt/rp2/ || true
    @echo "Flash memory nuked! Board will reboot."

clean:
    @cargo clean
    @rm -f flash.uf2

If you prefer the commands to be without sudo please let me know and I shall make the required changes.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions