Skip to content

Commit

Permalink
MCU board support for Raspberry Pi Pico 2
Browse files Browse the repository at this point in the history
  • Loading branch information
burbokop authored and tronical committed Nov 26, 2024
1 parent 112608b commit 8bbaedb
Show file tree
Hide file tree
Showing 9 changed files with 1,629 additions and 0 deletions.
2 changes: 2 additions & 0 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -369,6 +369,8 @@ jobs:
include:
- feature: pico-st7789
target: thumbv6m-none-eabi
- feature: pico2-st7789
target: thumbv8m.main-none-eabihf
- feature: stm32h735g
target: thumbv7em-none-eabihf
steps:
Expand Down
2 changes: 2 additions & 0 deletions examples/mcu-board-support/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ path = "lib.rs"
[features]

pico-st7789 = ["slint/unsafe-single-threaded", "rp-pico", "embedded-hal", "embedded-hal-nb", "cortex-m-rt", "embedded-alloc", "fugit", "cortex-m", "display-interface", "display-interface-spi", "mipidsi", "defmt", "defmt-rtt", "slint/libm", "embedded-dma", "embedded-graphics", "euclid/libm"]
pico2-st7789 = ["slint/unsafe-single-threaded", "rp235x-hal/binary-info", "rp235x-hal/critical-section-impl", "rp235x-hal/rt", "rp235x-hal/defmt", "embedded-hal", "embedded-hal-nb", "cortex-m-rt", "embedded-alloc", "fugit", "cortex-m", "display-interface", "display-interface-spi", "mipidsi", "defmt", "defmt-rtt", "slint/libm", "embedded-dma", "embedded-graphics", "euclid/libm"]
stm32h735g = ["slint/unsafe-single-threaded", "cortex-m/critical-section-single-core", "cortex-m-rt","embedded-alloc", "embedded-time", "stm32h7xx-hal/stm32h735", "defmt", "defmt-rtt", "embedded-display-controller", "ft5336", "panic-probe", "slint/libm", "getrandom"]
esp32-s2-kaluga-1 = ["slint/unsafe-single-threaded", "esp-hal/esp32s2", "embedded-hal", "embedded-hal-bus", "esp-alloc", "esp-println/esp32s2", "display-interface", "display-interface-spi", "mipidsi", "embedded-graphics-core", "slint/libm"]
esp32-s3-box = ["slint/unsafe-single-threaded", "esp-hal/esp32s3", "embedded-hal", "embedded-hal-bus", "esp-alloc", "esp-println/esp32s3", "esp-backtrace/esp32s3", "display-interface", "display-interface-spi", "mipidsi", "embedded-graphics-core", "slint/libm", "tt21100"]
Expand All @@ -43,6 +44,7 @@ embedded-hal-nb = { version = "1.0.0", optional = true }
embedded-hal-bus = { version = "0.2", optional = true }
embedded-dma = { version = "0.2.0", optional = true }
rp-pico = { version = "0.9.0", optional = true }
rp235x-hal = { version = "0.2.0", default-features = false, optional = true }
fugit = { version = "0.3.6", optional = true }
euclid = { version = "0.22", default-features = false, optional = true }

Expand Down
22 changes: 22 additions & 0 deletions examples/mcu-board-support/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,28 @@ udisksctl mount -b /dev/sda1
elf2uf2-rs -d target/thumbv6m-none-eabi/release/printerdemo_mcu
```

### On the Raspberry Pi Pico2

Build the demo with:

```sh
cargo build -p printerdemo_mcu --no-default-features --features=mcu-board-support/pico2-st7789 --target=thumbv8m.main-none-eabihf --release
```

The resulting file can be flashed conveniently with [picotool](https://github.com/raspberrypi/picotool). You should build it from source.

Then upload the demo to the Raspberry Pi Pico: push the "bootsel" white button on the device while connecting the
micro-usb cable to the device, this connects some USB storage on your workstation where you can store the binary.

Or from the command on linux (connect the device while pressing the "bootsel" button):

```sh
# If you're on Linux: mount the device
udisksctl mount -b /dev/sda1
# upload
picotool load -u -v -x -t elf target/thumbv8m.main-none-eabihf/release/printerdemo_mcu
```

#### Using probe-rs

This requires [probe-rs](https://probe.rs) and to connect the pico via a probe
Expand Down
2 changes: 2 additions & 0 deletions examples/mcu-board-support/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ fn main() -> std::io::Result<()> {
cfg_if::cfg_if! {
if #[cfg(feature = "pico-st7789")] {
board_config_path = Some([env!("CARGO_MANIFEST_DIR"), "pico_st7789", "board_config.toml"].iter().collect());
} else if #[cfg(feature = "pico2-st7789")] {
board_config_path = Some([env!("CARGO_MANIFEST_DIR"), "pico2_st7789", "board_config.toml"].iter().collect());
} else if #[cfg(feature = "stm32h735g")] {
board_config_path = Some([env!("CARGO_MANIFEST_DIR"), "stm32h735g", "board_config.toml"].iter().collect());
}
Expand Down
7 changes: 7 additions & 0 deletions examples/mcu-board-support/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,11 @@ mod pico_st7789;
#[cfg(feature = "pico-st7789")]
pub use pico_st7789::*;

#[cfg(feature = "pico2-st7789")]
mod pico2_st7789;
#[cfg(feature = "pico2-st7789")]
pub use pico2_st7789::*;

#[cfg(feature = "stm32h735g")]
mod stm32h735g;
#[cfg(feature = "stm32h735g")]
Expand All @@ -31,6 +36,7 @@ pub use esp32_s3_box::*;

#[cfg(not(any(
feature = "pico-st7789",
feature = "pico2-st7789",
feature = "stm32h735g",
feature = "esp32-s2-kaluga-1",
feature = "esp32-s3-box"
Expand All @@ -39,6 +45,7 @@ pub use i_slint_core_macros::identity as entry;

#[cfg(not(any(
feature = "pico-st7789",
feature = "pico2-st7789",
feature = "stm32h735g",
feature = "esp32-s2-kaluga-1",
feature = "esp32-s3-box"
Expand Down
Loading

0 comments on commit 8bbaedb

Please sign in to comment.