aboutsummaryrefslogtreecommitdiff
path: root/examples/nrf9151/s
diff options
context:
space:
mode:
authornerwalt <[email protected]>2024-06-27 14:07:26 -0600
committernerwalt <[email protected]>2024-06-27 14:07:26 -0600
commit8a6b71b0bba450687c48b36c60273f825c3f6d4b (patch)
tree2e41e1c1c21cc1f23665cdf1534bbaebbdad4f80 /examples/nrf9151/s
parent26e660722cca9151e5a9331c328421145509ab20 (diff)
Adding initial support for nrf9151 s and ns
Adding s and ns examples, including a reference TFM
Diffstat (limited to 'examples/nrf9151/s')
-rw-r--r--examples/nrf9151/s/.cargo/config.toml9
-rw-r--r--examples/nrf9151/s/Cargo.toml20
-rw-r--r--examples/nrf9151/s/build.rs35
-rw-r--r--examples/nrf9151/s/memory.x5
-rw-r--r--examples/nrf9151/s/src/bin/blinky.rs24
5 files changed, 93 insertions, 0 deletions
diff --git a/examples/nrf9151/s/.cargo/config.toml b/examples/nrf9151/s/.cargo/config.toml
new file mode 100644
index 000000000..1444b0cd1
--- /dev/null
+++ b/examples/nrf9151/s/.cargo/config.toml
@@ -0,0 +1,9 @@
1[target.'cfg(all(target_arch = "arm", target_os = "none"))']
2# replace nRF82840_xxAA with your chip as listed in `probe-rs chip list`
3runner = "probe-rs run --chip nRF9160_xxAA"
4
5[build]
6target = "thumbv8m.main-none-eabihf"
7
8[env]
9DEFMT_LOG = "trace"
diff --git a/examples/nrf9151/s/Cargo.toml b/examples/nrf9151/s/Cargo.toml
new file mode 100644
index 000000000..0299002a0
--- /dev/null
+++ b/examples/nrf9151/s/Cargo.toml
@@ -0,0 +1,20 @@
1[package]
2edition = "2021"
3name = "embassy-nrf9151-secure-examples"
4version = "0.1.0"
5license = "MIT OR Apache-2.0"
6
7[dependencies]
8embassy-executor = { version = "0.5.0", path = "../../../embassy-executor", features = ["task-arena-size-32768", "arch-cortex-m", "executor-thread", "executor-interrupt", "defmt", "integrated-timers"] }
9embassy-time = { version = "0.3.1", path = "../../../embassy-time", features = ["defmt", "defmt-timestamp-uptime"] }
10embassy-nrf = { version = "0.1.0", path = "../../../embassy-nrf", features = ["defmt", "nrf9151-s", "time-driver-rtc1", "gpiote", "unstable-pac", "time"] }
11
12defmt = "0.3"
13defmt-rtt = "0.4"
14
15cortex-m = { version = "0.7.6", features = ["inline-asm", "critical-section-single-core"] }
16cortex-m-rt = "0.7.0"
17panic-probe = { version = "0.3", features = ["print-defmt"] }
18
19[profile.release]
20debug = 2
diff --git a/examples/nrf9151/s/build.rs b/examples/nrf9151/s/build.rs
new file mode 100644
index 000000000..30691aa97
--- /dev/null
+++ b/examples/nrf9151/s/build.rs
@@ -0,0 +1,35 @@
1//! This build script copies the `memory.x` file from the crate root into
2//! a directory where the linker can always find it at build time.
3//! For many projects this is optional, as the linker always searches the
4//! project root directory -- wherever `Cargo.toml` is. However, if you
5//! are using a workspace or have a more complicated build setup, this
6//! build script becomes required. Additionally, by requesting that
7//! Cargo re-run the build script whenever `memory.x` is changed,
8//! updating `memory.x` ensures a rebuild of the application with the
9//! new memory settings.
10
11use std::env;
12use std::fs::File;
13use std::io::Write;
14use std::path::PathBuf;
15
16fn main() {
17 // Put `memory.x` in our output directory and ensure it's
18 // on the linker search path.
19 let out = &PathBuf::from(env::var_os("OUT_DIR").unwrap());
20 File::create(out.join("memory.x"))
21 .unwrap()
22 .write_all(include_bytes!("memory.x"))
23 .unwrap();
24 println!("cargo:rustc-link-search={}", out.display());
25
26 // By default, Cargo will re-run a build script whenever
27 // any file in the project changes. By specifying `memory.x`
28 // here, we ensure the build script is only re-run when
29 // `memory.x` is changed.
30 println!("cargo:rerun-if-changed=memory.x");
31
32 println!("cargo:rustc-link-arg-bins=--nmagic");
33 println!("cargo:rustc-link-arg-bins=-Tlink.x");
34 println!("cargo:rustc-link-arg-bins=-Tdefmt.x");
35}
diff --git a/examples/nrf9151/s/memory.x b/examples/nrf9151/s/memory.x
new file mode 100644
index 000000000..4c7d4ebf0
--- /dev/null
+++ b/examples/nrf9151/s/memory.x
@@ -0,0 +1,5 @@
1MEMORY
2{
3 FLASH : ORIGIN = 0x00000000, LENGTH = 1024K
4 RAM : ORIGIN = 0x20018000, LENGTH = 160K
5}
diff --git a/examples/nrf9151/s/src/bin/blinky.rs b/examples/nrf9151/s/src/bin/blinky.rs
new file mode 100644
index 000000000..5e3cc8ac0
--- /dev/null
+++ b/examples/nrf9151/s/src/bin/blinky.rs
@@ -0,0 +1,24 @@
1#![no_std]
2#![no_main]
3
4use embassy_executor::Spawner;
5use embassy_nrf::gpio::{Level, Output, OutputDrive};
6use embassy_time::Timer;
7use {defmt_rtt as _, panic_probe as _};
8
9use defmt;
10
11#[embassy_executor::main]
12async fn main(_spawner: Spawner) {
13 let p = embassy_nrf::init(Default::default());
14 let mut led = Output::new(p.P0_00, Level::Low, OutputDrive::Standard);
15
16 loop {
17 led.set_high();
18 defmt::info!("high");
19 Timer::after_millis(500).await;
20 led.set_low();
21 defmt::info!("low");
22 Timer::after_millis(1000).await;
23 }
24}