Skip to content

Commit

Permalink
Deletes the top-level workspace and moves the examples.
Browse files Browse the repository at this point in the history
RP2350 stuff is coming, and you can't build rp2040-hal for Armv8-M and you can't build rp235x-hal for Armv6-M, and so they cannot be in the same workspace. Ergo, if the rp2350-hal is coming to this repo (and it is), we cannot have a workspace any more.

I also moved the examples into their own package, because that's much neater than having to deal with memory.x being in magically the right place, or a bunch of dev-dependencies that are not relevant to most crate users.
  • Loading branch information
thejpster committed Aug 16, 2024
1 parent 23a68bc commit 826cb98
Show file tree
Hide file tree
Showing 53 changed files with 186 additions and 238 deletions.
43 changes: 28 additions & 15 deletions .github/workflows/build_and_test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,14 @@ jobs:
- name: Install cargo-hack
run: |
curl -sSL https://github.com/taiki-e/cargo-hack/releases/download/v0.6.17/cargo-hack-x86_64-unknown-linux-gnu.tar.gz | tar xvzf - -C ~/.cargo/bin
- name: Build rp2040-hal's workspace (without the examples)
run: cargo hack build --optional-deps --each-feature
- run: cargo clean
- name: Build rp2040-hal's workspace (with the examples)
run: cargo hack build --examples --optional-deps --each-feature
- name: Build rp2040-hal
run: cd rp2040-hal && cargo hack build --optional-deps --each-feature --target=thumbv6m-none-eabi
- name: Build rp2040-hal-macros
run: cd rp2040-hal-macros && cargo hack build --optional-deps --each-feature
- name: Build on-target-tests
run: cd on-target-tests && cargo hack build --optional-deps --each-feature
- name: Build rp2040-hal-examples
run: cd rp2040-hal-examples && cargo hack build --optional-deps --each-feature
tests:
name: Execute host-runable tests
runs-on: ubuntu-20.04
Expand All @@ -29,15 +32,13 @@ jobs:
run: |
curl -sSL https://github.com/taiki-e/cargo-hack/releases/download/v0.6.17/cargo-hack-x86_64-unknown-linux-gnu.tar.gz | tar xvzf - -C ~/.cargo/bin
- name: Test
run: cargo hack test -p rp2040-hal --target x86_64-unknown-linux-gnu --optional-deps --each-feature --tests --features critical-section-impl
run: cd rp2040-hal && cargo hack test --optional-deps --each-feature --tests --features critical-section-impl
- name: Test docs
run: cargo hack test -p rp2040-hal --target x86_64-unknown-linux-gnu --optional-deps --each-feature --doc --features critical-section-impl
run: cd rp2040-hal && cargo hack test --optional-deps --each-feature --doc --features critical-section-impl
- name: Test macros
run: cargo hack test -p rp2040-hal-macros --target x86_64-unknown-linux-gnu --optional-deps --tests --each-feature
run: cd rp2040-hal-macros && cargo hack test --optional-deps --tests --each-feature
- name: Test macro docs
run: cargo hack test -p rp2040-hal-macros --target x86_64-unknown-linux-gnu --optional-deps --doc --each-feature
- name: Clean
run: cargo clean
run: cd rp2040-hal-macros && cargo hack test --optional-deps --doc --each-feature
udeps:
name: Check rp2040-hal for unused dependencies
runs-on: ubuntu-20.04
Expand All @@ -53,8 +54,14 @@ jobs:
- name: Install cargo-udeps
run: |
curl -sSL https://github.com/est31/cargo-udeps/releases/download/v0.1.45/cargo-udeps-v0.1.45-x86_64-unknown-linux-gnu.tar.gz | tar xvzf - --strip-components=2 -C ~/.cargo/bin ./cargo-udeps-v0.1.45-x86_64-unknown-linux-gnu/cargo-udeps
- name: Check unused deps
run: cargo hack udeps --optional-deps --each-feature
- name: Check unused deps in rp2040-hal
run: cd rp2040-hal && cargo hack udeps --optional-deps --each-feature --target=thumbv6m-none-eabi
- name: Check unused deps in rp2040-hal-macros
run: cd rp2040-hal-macros && cargo hack udeps --optional-deps --each-feature
- name: Check unused deps in rp2040-hal-examples
run: cd rp2040-hal-examples && cargo hack udeps --optional-deps --each-feature
- name: Check unused deps in on-target-tests
run: cd on-target-tests && cargo hack udeps --optional-deps --each-feature
msrv:
name: Verify build on MSRV
runs-on: ubuntu-20.04
Expand All @@ -69,5 +76,11 @@ jobs:
curl -sSL https://github.com/taiki-e/cargo-hack/releases/download/v0.6.17/cargo-hack-x86_64-unknown-linux-gnu.tar.gz | tar xvzf - -C ~/.cargo/bin
- name: Use older version of regex
run: cargo update -p regex --precise 1.9.3
- name: Verify MSRV
run: cargo hack build --examples --optional-deps --each-feature
- name: Build rp2040-hal (on MSRV)
run: cd rp2040-hal && cargo hack build --optional-deps --each-feature --target=thumbv6m-none-eabi
- name: Build rp2040-hal-macros (on MSRV)
run: cd rp2040-hal-macros && cargo hack build --optional-deps --each-feature
- name: Build on-target-tests (on MSRV)
run: cd on-target-tests && cargo hack build --optional-deps --each-feature
- name: Build rp2040-hal-examples (on MSRV)
run: cd rp2040-hal-examples && cargo hack build --optional-deps --each-feature
12 changes: 10 additions & 2 deletions .github/workflows/clippy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,13 @@ jobs:
with:
target: thumbv6m-none-eabi
components: clippy
- run: cargo clippy --workspace --examples
- run: cargo clippy --workspace --examples --all-features
- name: Build rp2040-hal
run: cd rp2040-hal && cargo clippy --target=thumbv6m-none-eabi
- name: Build rp2040-hal (with all features)
run: cd rp2040-hal && cargo clippy --target=thumbv6m-none-eabi --all-features
- name: Build rp2040-hal-macros
run: cd rp2040-hal-macros && cargo clippy
- name: Build on-target-tests
run: cd on-target-tests && cargo clippy
- name: Build rp2040-hal-examples
run: cd rp2040-hal-examples && cargo clippy
9 changes: 8 additions & 1 deletion .github/workflows/rustfmt.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,11 @@ jobs:
with:
target: thumbv6m-none-eabi
components: rustfmt
- run: cargo fmt -- --check
- name: Check format of rp2040-hal
run: cd rp2040-hal && cargo fmt -- --check
- name: Check format of rp2040-hal-macros
run: cd rp2040-hal-macros && cargo fmt -- --check
- name: Check format of on-target-tests
run: cd on-target-tests && cargo fmt -- --check
- name: Check format of rp2040-hal-examples
run: cd rp2040-hal-examples && cargo fmt -- --check
23 changes: 0 additions & 23 deletions Cargo.toml

This file was deleted.

6 changes: 6 additions & 0 deletions format.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
rem Formats all the files in the repo

cargo fmt --manifest-path rp2040-hal\Cargo.toml -- --check
cargo fmt --manifest-path rp2040-hal-macros\Cargo.toml -- --check
cargo fmt --manifest-path rp2040-hal-examples\Cargo.toml -- --check
cargo fmt --manifest-path on-target-tests\Cargo.toml -- --check
8 changes: 8 additions & 0 deletions format.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#!/bin/sh

# Formats all the files in the repo

cargo fmt --manifest-path rp2040-hal/Cargo.toml -- --check
cargo fmt --manifest-path rp2040-hal-macros/Cargo.toml -- --check
cargo fmt --manifest-path rp2040-hal-examples/Cargo.toml -- --check
cargo fmt --manifest-path on-target-tests/Cargo.toml -- --check
File renamed without changes.
12 changes: 12 additions & 0 deletions on-target-tests/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -77,3 +77,15 @@ futures = { version = "0.3.30", default-features = false, features = [
] }
i2c-write-iter = { version = "1.0.0", features = ["async"] }
itertools = { version = "0.12.0", default-features = false }

[profile.dev]
codegen-units = 1
incremental = false
lto = 'fat'
opt-level = 's'

[profile.test]
codegen-units = 1
incremental = false
lto = 'fat'
opt-level = 's'
2 changes: 2 additions & 0 deletions on-target-tests/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,12 @@ Adding a test:
Running all tests:
Linux (and any other Unix-likes where probe-rs are supported):
```system
cd on-target-tests
./run_tests.sh
```
Windows
```system
cd on-target-tests
run_tests.bat
```

Expand Down
2 changes: 1 addition & 1 deletion run_tests.bat → on-target-tests/run_tests.bat
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@

@SET "CARGO_TARGET_THUMBV6M_NONE_EABI_RUNNER=probe-rs run"

cargo test -p on-target-tests --no-fail-fast -- --chip rp2040
cargo test --no-fail-fast -- --chip rp2040
2 changes: 1 addition & 1 deletion run_tests.sh → on-target-tests/run_tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@
# Keep running tests even if one of them fails
# We need to specify probe-rs as our runner via environment variables here
# to control build since we aren't able to override them in config.toml
CARGO_TARGET_THUMBV6M_NONE_EABI_RUNNER="probe-rs run" cargo test -p on-target-tests --no-fail-fast -- --chip rp2040
CARGO_TARGET_THUMBV6M_NONE_EABI_RUNNER="probe-rs run" cargo test --no-fail-fast -- --chip rp2040
41 changes: 41 additions & 0 deletions rp2040-hal-examples/.cargo/config.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
#
# Cargo Configuration for the https://github.com/rp-rs/rp-hal.git repository.
#
# Copyright (c) The RP-RS Developers, 2021
#
# You might want to make a similar file in your own repository if you are
# writing programs for Raspberry Silicon microcontrollers.
#
# This file is MIT or Apache-2.0 as per the repository README.md file
#

[build]
# Set the default target to match the Cortex-M0+ in the RP2040
target = "thumbv6m-none-eabi"

# Target specific options
[target.thumbv6m-none-eabi]
# Pass some extra options to rustc, some of which get passed on to the linker.
#
# * linker argument --nmagic turns off page alignment of sections (which saves
# flash space)
# * linker argument -Tlink.x tells the linker to use link.x as the linker
# script. This is usually provided by the cortex-m-rt crate, and by default
# the version in that crate will include a file called `memory.x` which
# describes the particular memory layout for your specific chip.
# * no-vectorize-loops turns off the loop vectorizer (seeing as the M0+ doesn't
# have SIMD)
rustflags = [
"-C", "link-arg=--nmagic",
"-C", "link-arg=-Tlink.x",
"-C", "link-arg=-Tdefmt.x",
"-C", "no-vectorize-loops",
]

# This runner will make a UF2 file and then copy it to a mounted RP2040 in USB
# Bootloader mode:
runner = "elf2uf2-rs -d"

# This runner will find a supported SWD debug probe and flash your RP2040 over
# SWD:
# runner = "probe-rs run --chip RP2040"
37 changes: 37 additions & 0 deletions rp2040-hal-examples/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
[package]
name = "rp2040-hal-examples"
version = "0.1.0"
edition = "2021"
authors = ["The rp-rs Developers"]
homepage = "https://github.com/rp-rs/rp-hal"
description = "Examples for the rp2040-hal crate"
license = "MIT OR Apache-2.0"
rust-version = "1.77"
repository = "https://github.com/rp-rs/rp-hal"
categories = ["embedded", "hardware-support", "no-std", "no-std::no-alloc"]
keywords = ["embedded", "hal", "raspberry-pi", "rp2040", "embedded-hal"]

[dependencies]
cortex-m = "0.7.2"
cortex-m-rt = "0.7"
cortex-m-rtic = "1.1.4"
critical-section = { version = "1.0.0" }
defmt = "0.3"
defmt-rtt = "0.4.0"
dht-sensor = "0.2.1"
embedded_hal_0_2 = { package = "embedded-hal", version = "0.2.5", features = ["unproven"] }
embedded-alloc = "0.5.1"
embedded-hal = "1.0.0"
embedded-hal-async = "1.0.0"
fugit = "0.3.6"
futures = { version = "0.3.30", default-features = false, features = ["async-await"] }
hd44780-driver = "0.4.0"
nb = "1.0"
nostd_async = { version = "0.6.1", features = ["cortex_m"] }
panic-halt = "0.2.0"
panic-probe = { version = "0.3.1", features = ["print-defmt"] }
pio = "0.2.0"
pio-proc = "0.2.0"
rand = { version = "0.8.5", default-features = false }
rp2040-boot2 = "0.3.0"
rp2040-hal = { path = "../rp2040-hal", version = "0.10.0", features = ["binary-info", "critical-section-impl", "rt", "defmt"] }
14 changes: 14 additions & 0 deletions rp2040-hal-examples/build.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
use std::fs::File;
use std::io::Write;
use std::path::PathBuf;

fn main() {
// Put the linker script somewhere the linker can find it
let out = PathBuf::from(std::env::var_os("OUT_DIR").unwrap());
let memory_x = include_bytes!("memory.x");
let mut f = File::create(out.join("memory.x")).unwrap();
f.write_all(memory_x).unwrap();
println!("cargo:rustc-link-search={}", out.display());
println!("cargo:rerun-if-changed=build.rs");
println!("cargo:rerun-if-changed=memory.x");
}
7 changes: 6 additions & 1 deletion memory.x → rp2040-hal-examples/memory.x
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
MEMORY {
BOOT2 : ORIGIN = 0x10000000, LENGTH = 0x100
/*
* Here we assume you have 2048 KiB of Flash. This is what the Pi Pico
* has, but your board may have more or less Flash and you should adjust
* this value to suit.
*/
FLASH : ORIGIN = 0x10000100, LENGTH = 2048K - 0x100
/*
* RAM consists of 4 banks, SRAM0-SRAM3, with a striped mapping.
Expand Down Expand Up @@ -75,4 +80,4 @@ SECTIONS {
/* We put this in the header */
__bi_entries_end = .;
} > FLASH
} INSERT AFTER .text;
} INSERT AFTER .text;
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Loading

0 comments on commit 826cb98

Please sign in to comment.