Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

examples: Add support for different devices for nrf-sdc #121

Merged
merged 2 commits into from
Sep 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 23 additions & 2 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}
Expand All @@ -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 }}
4 changes: 3 additions & 1 deletion examples/nrf-sdc/.cargo/config.toml
Original file line number Diff line number Diff line change
@@ -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
Expand Down
1 change: 1 addition & 0 deletions examples/nrf-sdc/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

18 changes: 15 additions & 3 deletions examples/nrf-sdc/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"] }
Expand Down Expand Up @@ -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",
]
9 changes: 8 additions & 1 deletion examples/nrf-sdc/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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());

Expand Down
6 changes: 6 additions & 0 deletions examples/nrf-sdc/memory-nrf52832.x
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
MEMORY
{
/* NOTE 1 K = 1 KiBi = 1024 bytes */
FLASH : ORIGIN = 0x00000000, LENGTH = 512K
RAM : ORIGIN = 0x20000000, LENGTH = 64K
}
File renamed without changes.