From 0d801478ac2e2bc8b2a6c07a3e5bda0497ea89d8 Mon Sep 17 00:00:00 2001 From: Priit Laes Date: Tue, 24 Sep 2024 16:38:45 +0300 Subject: [PATCH 1/2] examples: Add support for different devices for nrf-sdc --- examples/nrf-sdc/.cargo/config.toml | 4 +++- examples/nrf-sdc/Cargo.lock | 1 + examples/nrf-sdc/Cargo.toml | 18 +++++++++++++++--- examples/nrf-sdc/build.rs | 9 ++++++++- examples/nrf-sdc/memory-nrf52832.x | 6 ++++++ .../nrf-sdc/{memory.x => memory-nrf52840.x} | 0 6 files changed, 33 insertions(+), 5 deletions(-) create mode 100644 examples/nrf-sdc/memory-nrf52832.x rename examples/nrf-sdc/{memory.x => memory-nrf52840.x} (100%) diff --git a/examples/nrf-sdc/.cargo/config.toml b/examples/nrf-sdc/.cargo/config.toml index c3f9240..da2300b 100644 --- a/examples/nrf-sdc/.cargo/config.toml +++ b/examples/nrf-sdc/.cargo/config.toml @@ -1,5 +1,7 @@ [target.'cfg(all(target_arch = "arm", target_os = "none"))'] -runner = "probe-rs run --chip nRF52833_xxAA" +#runner = "probe-rs run --chip nRF52832_xxAA" +#runner = "probe-rs run --chip nRF52833_xxAA" +runner = "probe-rs run --chip nRF52840_xxAA" [build] # Pick ONE of these compilation targets diff --git a/examples/nrf-sdc/Cargo.lock b/examples/nrf-sdc/Cargo.lock index 6756e7d..4ec7071 100644 --- a/examples/nrf-sdc/Cargo.lock +++ b/examples/nrf-sdc/Cargo.lock @@ -759,6 +759,7 @@ dependencies = [ "embedded-storage", "embedded-storage-async", "nrf-mpsl-sys", + "nrf52832-pac", "nrf52840-pac", ] diff --git a/examples/nrf-sdc/Cargo.toml b/examples/nrf-sdc/Cargo.toml index 3fe1a71..c7ef45d 100644 --- a/examples/nrf-sdc/Cargo.toml +++ b/examples/nrf-sdc/Cargo.toml @@ -5,14 +5,14 @@ edition = "2021" resolver = "2" [dependencies] -embassy-executor = { version = "0.6", default-features = false, features = ["task-arena-size-65536", "arch-cortex-m", "executor-thread", "defmt", "integrated-timers", "executor-interrupt"] } +embassy-executor = { version = "0.6", default-features = false, features = ["arch-cortex-m", "executor-thread", "defmt", "integrated-timers", "executor-interrupt"] } embassy-time = { version = "0.3", default-features = false, features = ["defmt", "defmt-timestamp-uptime"] } -embassy-nrf = { version = "0.2", default-features = false, features = ["defmt", "nrf52840", "time-driver-rtc1", "gpiote", "unstable-pac", "rt"] } +embassy-nrf = { version = "0.2", default-features = false, features = ["defmt", "time-driver-rtc1", "gpiote", "unstable-pac", "rt"] } embassy-futures = "0.1.1" embassy-sync = { version = "0.6", features = ["defmt"] } futures = { version = "0.3", default-features = false, features = ["async-await"]} -nrf-sdc = { version = "0.1.0", default-features = false, features = ["defmt", "nrf52840", "peripheral", "central"] } +nrf-sdc = { version = "0.1.0", default-features = false, features = ["defmt", "peripheral", "central"] } nrf-mpsl = { version = "0.1.0", default-features = false, features = ["defmt", "critical-section-impl"] } bt-hci = { version = "0.1.1", default-features = false, features = ["defmt"] } trouble-host = { version = "0.1.0", path = "../../host", features = ["defmt"] } @@ -51,3 +51,15 @@ nrf-mpsl = { git = "https://github.com/alexmoon/nrf-sdc.git", rev = "3702af909d3 #nrf-sdc = { path = "../../../nrf-sdc/nrf-sdc" } #nrf-mpsl = { path = "../../../nrf-sdc/nrf-mpsl" } #bt-hci = { path = "../../../bt-hci" } + +[features] +nrf52832 = [ + "embassy-executor/task-arena-size-32768", + "embassy-nrf/nrf52832", + "nrf-sdc/nrf52832", +] +nrf52840 = [ + "embassy-executor/task-arena-size-65536", + "embassy-nrf/nrf52840", + "nrf-sdc/nrf52840", +] diff --git a/examples/nrf-sdc/build.rs b/examples/nrf-sdc/build.rs index 30691aa..c1afc70 100644 --- a/examples/nrf-sdc/build.rs +++ b/examples/nrf-sdc/build.rs @@ -13,13 +13,20 @@ use std::fs::File; use std::io::Write; use std::path::PathBuf; +fn linker_data() -> &'static [u8] { + #[cfg(feature = "nrf52832")] + return include_bytes!("memory-nrf52832.x"); + #[cfg(feature = "nrf52840")] + return include_bytes!("memory-nrf52840.x"); +} + fn main() { // Put `memory.x` in our output directory and ensure it's // on the linker search path. let out = &PathBuf::from(env::var_os("OUT_DIR").unwrap()); File::create(out.join("memory.x")) .unwrap() - .write_all(include_bytes!("memory.x")) + .write_all(linker_data()) .unwrap(); println!("cargo:rustc-link-search={}", out.display()); diff --git a/examples/nrf-sdc/memory-nrf52832.x b/examples/nrf-sdc/memory-nrf52832.x new file mode 100644 index 0000000..982023e --- /dev/null +++ b/examples/nrf-sdc/memory-nrf52832.x @@ -0,0 +1,6 @@ +MEMORY +{ + /* NOTE 1 K = 1 KiBi = 1024 bytes */ + FLASH : ORIGIN = 0x00000000, LENGTH = 512K + RAM : ORIGIN = 0x20000000, LENGTH = 64K +} diff --git a/examples/nrf-sdc/memory.x b/examples/nrf-sdc/memory-nrf52840.x similarity index 100% rename from examples/nrf-sdc/memory.x rename to examples/nrf-sdc/memory-nrf52840.x From 7ff8f0172185db5412e16677b4cc9f4e763efcf4 Mon Sep 17 00:00:00 2001 From: Priit Laes Date: Tue, 24 Sep 2024 22:10:33 +0300 Subject: [PATCH 2/2] workflows: Split out nrf-sdc examples into their own job --- .github/workflows/ci.yaml | 25 +++++++++++++++++++++++-- 1 file changed, 23 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index b526a99..e749fbb 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -31,12 +31,13 @@ jobs: needs: build strategy: matrix: - example: [nrf-sdc, serial-hci, esp32] #, apache-nimble] + # nrf-sdc examples are handled within nrf-sdc job matrix + example: [serial-hci, esp32] #, apache-nimble] steps: - uses: actions/checkout@v4 - name: Add dependencies run: | - sudo apt-get install libudev-dev + sudo apt-get install --no-install-recommends libudev-dev - name: Build example ${{ matrix.example }} working-directory: examples/${{ matrix.example }} @@ -46,3 +47,23 @@ jobs: cargo fmt --check cargo clippy --locked cargo build --release --locked + nrf-sdc: + runs-on: ubuntu-latest + needs: build + strategy: + matrix: + target: ["nrf52832", "nrf52840"] + steps: + - uses: actions/checkout@v4 + - name: Add dependencies + run: | + sudo apt-get install --no-install-recommends libudev-dev + + - name: Build nrf-sdc example for ${{ matrix.target}} + working-directory: examples/nrf-sdc + env: + CARGO_NET_GIT_FETCH_WITH_CLI: "true" + run: | + cargo fmt --check + cargo clippy --locked --features ${{ matrix.target }} + cargo build --release --locked --features ${{ matrix.target }}