Skip to content

Commit

Permalink
cargo: use nightly and force target build
Browse files Browse the repository at this point in the history
  • Loading branch information
philiplinden committed Dec 18, 2024
1 parent 00f49ff commit 66cc945
Show file tree
Hide file tree
Showing 6 changed files with 47 additions and 10 deletions.
22 changes: 16 additions & 6 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,16 @@ jobs:
- name: Checkout sources
uses: actions/checkout@v2

- name: Install stable toolchain
- name: Install nightly toolchain
uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: stable
toolchain: nightly
override: true

- name: Add Cortex-M build target toolchain
run: rustup target add thumbv7em-none-eabihf

- name: Run cargo check
uses: actions-rs/cargo@v1
continue-on-error: true # WARNING: only for this example, remove it!
Expand All @@ -31,13 +34,16 @@ jobs:
- name: Checkout sources
uses: actions/checkout@v2

- name: Install stable toolchain
- name: Install nightly toolchain
uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: stable
toolchain: nightly
override: true

- name: Add Cortex-M build target toolchain
run: rustup target add thumbv7em-none-eabihf

- name: Run cargo build
uses: actions-rs/cargo@v1
with:
Expand All @@ -50,13 +56,17 @@ jobs:
- name: Checkout sources
uses: actions/checkout@v2

- name: Install stable toolchain
- name: Install nightly toolchain
uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: stable
toolchain: nightly
override: true

- name: Add Cortex-M build target toolchain
run: rustup target add thumbv7em-none-eabihf


- name: Run cargo test
uses: actions-rs/cargo@v1
with:
Expand Down
5 changes: 5 additions & 0 deletions crates/ahab_stm32f11ve/.cargo/config.toml
Original file line number Diff line number Diff line change
@@ -1,2 +1,7 @@
[target.'cfg(all(target_arch = "arm", target_os = "none"))']
rustflags = [
"-C", "link-arg=-Tlink.x",
]

[build]
target = "thumbv7em-none-eabihf" # Cortex-M4F and Cortex-M7F (with FPU)
5 changes: 4 additions & 1 deletion crates/ahab_stm32f11ve/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,15 +1,18 @@
cargo-features = ["per-package-target"]

[package]
authors = ["Philip Linden <[email protected]>"]
edition = "2021"
readme = "README.md"
name = "ahab_stm32f11ve"
version = "0.1.0"
forced-target = "thumbv7em-none-eabihf"

[dependencies]
cortex-m = { version = "0.7.6", features = ["critical-section-single-core"] }
cortex-m-rt = { workspace = true }
panic-halt = { workspace = true }
rtt-target = { version = "0.6.1", features = ["log"] }
rtt-target = { workspace = true }

[[bin]]
name = "ahab_stm32f11ve"
Expand Down
6 changes: 4 additions & 2 deletions docs/SUMMARY.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,11 @@

# STM32F411VE

- [getting started](docs/stm32/getting-started.md)
- [debugging](docs/stm32/debugging.md)
- [getting started](docs/stm32f411ve/getting-started.md)
- [debugging](docs/stm32f411ve/debugging.md)

---

# Development

- [captain's log](captains-log.md)
14 changes: 13 additions & 1 deletion docs/captains-log.md
Original file line number Diff line number Diff line change
Expand Up @@ -96,4 +96,16 @@ re-use the template code if I need it, but building up from scratch is great
practice to learn what all of these files do and how they fit together.

Woohoo! I got a (dummy) program to compile for the STM32F411E board! Now to
flash it...
flash it... Nice, it worked!

There is one hang up though. When I `cargo build` from the root, it tries to
compile the embedded crates for the host arch. I want to edit `Cargo.toml` at
the root to effectively do the same thing as specifying the target arch in
`.cargo/config.toml` for each crate.

https://doc.rust-lang.org/cargo/reference/unstable.html#per-package-target

https://nnarain.github.io/2021/08/02/Setting-up-per-package-targets-in-Rust.html

I had to add `cargo-features = ["per-package-target"]` to the `Cargo.toml` file,
which is an unstable `nightly` feature.
5 changes: 5 additions & 0 deletions rust-toolchain.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
[toolchain]
channel = "nightly" # required for per-package-target

[feature]
per-package-target = ["true"]

0 comments on commit 66cc945

Please sign in to comment.