Add CI and fix the rest of the readme
This commit is contained in:
+2
-1
@@ -14,7 +14,7 @@ rustflags = [
|
|||||||
# TODO(3) Adjust the compilation target.
|
# TODO(3) Adjust the compilation target.
|
||||||
# (`thumbv6m-*` is compatible with all ARM Cortex-M chips but using the right
|
# (`thumbv6m-*` is compatible with all ARM Cortex-M chips but using the right
|
||||||
# target improves performance)
|
# target improves performance)
|
||||||
target = "thumbv6m-none-eabi" # Cortex-M0 and Cortex-M0+
|
# target = "thumbv6m-none-eabi" # Cortex-M0 and Cortex-M0+
|
||||||
# target = "thumbv7m-none-eabi" # Cortex-M3
|
# target = "thumbv7m-none-eabi" # Cortex-M3
|
||||||
# target = "thumbv7em-none-eabi" # Cortex-M4 and Cortex-M7 (no FPU)
|
# target = "thumbv7em-none-eabi" # Cortex-M4 and Cortex-M7 (no FPU)
|
||||||
# target = "thumbv7em-none-eabihf" # Cortex-M4F and Cortex-M7F (with FPU)
|
# target = "thumbv7em-none-eabihf" # Cortex-M4F and Cortex-M7F (with FPU)
|
||||||
@@ -22,3 +22,4 @@ target = "thumbv6m-none-eabi" # Cortex-M0 and Cortex-M0+
|
|||||||
[alias]
|
[alias]
|
||||||
rb = "run --bin"
|
rb = "run --bin"
|
||||||
rrb = "run --release --bin"
|
rrb = "run --release --bin"
|
||||||
|
bbr = "build --release --bin"
|
||||||
|
|||||||
@@ -0,0 +1,32 @@
|
|||||||
|
name: Build
|
||||||
|
on:
|
||||||
|
pull_request:
|
||||||
|
push:
|
||||||
|
branches:
|
||||||
|
- master
|
||||||
|
|
||||||
|
env:
|
||||||
|
CARGO_TERM_COLOR: always
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
build:
|
||||||
|
name: Build the project according to the steps
|
||||||
|
runs-on: ubuntu:22.04
|
||||||
|
steps:
|
||||||
|
- name: Checkout
|
||||||
|
uses: actions/checkout@v3
|
||||||
|
|
||||||
|
- name: Install rust nightly
|
||||||
|
run: |
|
||||||
|
rustup override set nightly
|
||||||
|
|
||||||
|
- name: Configure rust target
|
||||||
|
run: |
|
||||||
|
rustup target add thumbv7em-none-eabihf
|
||||||
|
|
||||||
|
- name: Cache Dependencies
|
||||||
|
uses: Swatinem/rust-cache@v2
|
||||||
|
|
||||||
|
- name: Run steps
|
||||||
|
run: |
|
||||||
|
./run-steps.sh
|
||||||
+1
-1
@@ -1,2 +1,2 @@
|
|||||||
/target
|
/target
|
||||||
Cargo.lock
|
Cargo.lock
|
||||||
+2
-2
@@ -7,11 +7,11 @@ version = "0.1.0"
|
|||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
cortex-m = { version = "0.7", features = ["critical-section-single-core"] }
|
cortex-m = { version = "0.7", features = ["critical-section-single-core"] }
|
||||||
defmt = { version = "0.3", features = ["encoding-rzcobs"]
|
defmt = { version = "0.3", features = ["encoding-rzcobs"] }
|
||||||
defmt-brtt = { version = "0.1", default-features = false, features = ["rtt"] }
|
defmt-brtt = { version = "0.1", default-features = false, features = ["rtt"] }
|
||||||
panic-probe = { version = "0.3", features = ["print-defmt"] }
|
panic-probe = { version = "0.3", features = ["print-defmt"] }
|
||||||
# TODO select the correct rtic backend
|
# TODO select the correct rtic backend
|
||||||
rtic = { version = "2.0.0-alpha.1", features = [ "correct-rtic-backend" ] }
|
rtic = { version = "2.0.0-alpha.1", features = [ "$RTIC_BACKEND" ] }
|
||||||
# TODO enter your HAL here
|
# TODO enter your HAL here
|
||||||
# some-hal = "1.2.3"
|
# some-hal = "1.2.3"
|
||||||
# TODO add a monotonic if you use scheduling
|
# TODO add a monotonic if you use scheduling
|
||||||
|
|||||||
@@ -54,14 +54,14 @@ Let's walk through them together now.
|
|||||||
|
|
||||||
Pick a chip from `probe-run --list-chips` and enter it into `.cargo/config.toml`.
|
Pick a chip from `probe-run --list-chips` and enter it into `.cargo/config.toml`.
|
||||||
|
|
||||||
If, for example, you have a nRF52840 Development Kit from one of [our workshops], replace `{{chip}}` with `nRF52840_xxAA`.
|
If, for example, you have a nRF52840 Development Kit from one of [our workshops], replace `$CHIP` with `nRF52840_xxAA`.
|
||||||
|
|
||||||
[our workshops]: https://github.com/ferrous-systems/embedded-trainings-2020
|
[our workshops]: https://github.com/ferrous-systems/embedded-trainings-2020
|
||||||
|
|
||||||
``` diff
|
``` diff
|
||||||
# .cargo/config.toml
|
# .cargo/config.toml
|
||||||
[target.'cfg(all(target_arch = "arm", target_os = "none"))']
|
[target.'cfg(all(target_arch = "arm", target_os = "none"))']
|
||||||
-runner = "probe-run --chip {{chip}}"
|
-runner = "probe-run --chip $CHIP"
|
||||||
+runner = "probe-run --chip nRF52840_xxAA"
|
+runner = "probe-run --chip nRF52840_xxAA"
|
||||||
```
|
```
|
||||||
|
|
||||||
@@ -72,7 +72,7 @@ In `.cargo/config.toml`, pick the right compilation target for your board.
|
|||||||
``` diff
|
``` diff
|
||||||
# .cargo/config.toml
|
# .cargo/config.toml
|
||||||
[build]
|
[build]
|
||||||
-target = "thumbv6m-none-eabi" # Cortex-M0 and Cortex-M0+
|
-# target = "thumbv6m-none-eabi" # Cortex-M0 and Cortex-M0+
|
||||||
-# target = "thumbv7m-none-eabi" # Cortex-M3
|
-# target = "thumbv7m-none-eabi" # Cortex-M3
|
||||||
-# target = "thumbv7em-none-eabi" # Cortex-M4 and Cortex-M7 (no FPU)
|
-# target = "thumbv7em-none-eabi" # Cortex-M4 and Cortex-M7 (no FPU)
|
||||||
-# target = "thumbv7em-none-eabihf" # Cortex-M4F and Cortex-M7F (with FPU)
|
-# target = "thumbv7em-none-eabihf" # Cortex-M4F and Cortex-M7F (with FPU)
|
||||||
@@ -87,11 +87,11 @@ $ rustup +nightly target add thumbv7em-none-eabihf
|
|||||||
|
|
||||||
#### 4. Activate the correct `rtic` backend
|
#### 4. Activate the correct `rtic` backend
|
||||||
|
|
||||||
In `Cargo.toml`, activate the correct `rtic` backend for your target by replacing `correct-rtic-backend` with one of `thumbv6-backend`, `thumbv7-backend`, `thumbv8base-backend`, or `thumbv8main-backend`, depending on the target you are compiling for.
|
In `Cargo.toml`, activate the correct `rtic` backend for your target by replacing `$RTIC_BACKEND` with one of `thumbv6-backend`, `thumbv7-backend`, `thumbv8base-backend`, or `thumbv8main-backend`, depending on the target you are compiling for.
|
||||||
|
|
||||||
```diff
|
```diff
|
||||||
# Cargo.toml
|
# Cargo.toml
|
||||||
-rtic = { version = "2.0.0-alhpa.1", features = [ "correct-rtic-backend" ] }
|
-rtic = { version = "2.0.0-alhpa.1", features = [ "$RTIC_BACKEND" ] }
|
||||||
+rtic = { version = "2.0.0-alhpa.1", features = [ "thumbv7-backend" ] }
|
+rtic = { version = "2.0.0-alhpa.1", features = [ "thumbv7-backend" ] }
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|||||||
+1
-1
@@ -1,2 +1,2 @@
|
|||||||
[template]
|
[template]
|
||||||
ignore = ["README.md"]
|
ignore = ["README.md", "run-steps.sh"]
|
||||||
|
|||||||
Executable
+37
@@ -0,0 +1,37 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
set -ex
|
||||||
|
|
||||||
|
project="test-app"
|
||||||
|
|
||||||
|
echo "Installing necessary tools"
|
||||||
|
cargo install flip-link cargo-generate sd probe-run
|
||||||
|
|
||||||
|
echo "Cleaning up old project"
|
||||||
|
rm -rf "$project"
|
||||||
|
|
||||||
|
echo "Creating new project"
|
||||||
|
cargo generate -p . --name "$project"
|
||||||
|
|
||||||
|
echo "Storing current config so that the child project will compile."
|
||||||
|
mv Cargo.toml Cargo.toml.tmp
|
||||||
|
mv .cargo/config.toml .cargo/config.toml.tmp
|
||||||
|
|
||||||
|
cd "$project"
|
||||||
|
|
||||||
|
echo "Performing steps"
|
||||||
|
|
||||||
|
sd -s -- '--chip $CHIP' '--chip nRF52840_xxAA' .cargo/config.toml
|
||||||
|
sd -s '# target = "thumbv7em-none-eabihf" # Cortex-M4F and Cortex-M7F (with FPU)' 'target = "thumbv7em-none-eabihf"' .cargo/config.toml
|
||||||
|
sd -s '$RTIC_BACKEND' 'thumbv7-backend' Cargo.toml
|
||||||
|
sd -s '# some-hal = "1.2.3"' 'nrf52840-hal = "0.16.0"' Cargo.toml
|
||||||
|
sd -s '// use some_hal as _; // memory layout' 'use nrf52840_hal as _;' src/lib.rs
|
||||||
|
sd -s 'some_hal::pac' 'nrf52840_hal::pac' src/bin/minimal.rs
|
||||||
|
sd -s 'FreeInterrupt1, ...' 'SWI0_EGU0' src/bin/minimal.rs
|
||||||
|
|
||||||
|
cargo bbr minimal
|
||||||
|
|
||||||
|
cd ..
|
||||||
|
echo "Cleaning up"
|
||||||
|
mv Cargo.toml.tmp Cargo.toml
|
||||||
|
mv .cargo/config.toml.tmp .cargo/config.toml
|
||||||
Reference in New Issue
Block a user