aboutsummaryrefslogtreecommitdiff
path: root/examples
diff options
context:
space:
mode:
authorQuentin Smith <[email protected]>2022-08-18 01:38:58 -0400
committerQuentin Smith <[email protected]>2022-08-18 01:38:58 -0400
commit2edf532f8d8ce048137990bf74b07759428ed7c1 (patch)
tree116b1401bb040c3f60fcd2e9c6e591e05f7272b0 /examples
parent7dfe119fe0c7b99d7a6d73af6ac3fc6f7cef9d12 (diff)
Move rtos-trace example to a separate project to simplify Cargo.toml
Diffstat (limited to 'examples')
-rw-r--r--examples/nrf-rtos-trace/.cargo/config.toml9
-rw-r--r--examples/nrf-rtos-trace/Cargo.toml51
-rw-r--r--examples/nrf-rtos-trace/build.rs36
-rw-r--r--examples/nrf-rtos-trace/memory.x7
-rw-r--r--examples/nrf-rtos-trace/src/bin/rtos_trace.rs (renamed from examples/nrf/src/bin/rtos_trace.rs)0
-rw-r--r--examples/nrf/Cargo.toml67
-rw-r--r--examples/nrf/build.rs1
7 files changed, 115 insertions, 56 deletions
diff --git a/examples/nrf-rtos-trace/.cargo/config.toml b/examples/nrf-rtos-trace/.cargo/config.toml
new file mode 100644
index 000000000..8ca28df39
--- /dev/null
+++ b/examples/nrf-rtos-trace/.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-run --list-chips`
3runner = "probe-run --chip nRF52840_xxAA"
4
5[build]
6target = "thumbv7em-none-eabi"
7
8[env]
9DEFMT_LOG = "trace"
diff --git a/examples/nrf-rtos-trace/Cargo.toml b/examples/nrf-rtos-trace/Cargo.toml
new file mode 100644
index 000000000..9c749a388
--- /dev/null
+++ b/examples/nrf-rtos-trace/Cargo.toml
@@ -0,0 +1,51 @@
1[package]
2edition = "2021"
3name = "embassy-nrf-examples"
4version = "0.1.0"
5
6[features]
7default = ["log", "nightly"]
8nightly = ["embassy-executor/nightly", "embassy-nrf/nightly", "embassy-nrf/unstable-traits", "embassy-usb", "embassy-usb-serial", "embassy-usb-hid", "embassy-usb-ncm", "embedded-io/async", "embassy-net"]
9log = [
10 "dep:log",
11 "embassy-util/log",
12 "embassy-executor/log",
13 "embassy-nrf/log",
14 "embassy-net/log",
15 "embassy-usb-ncm/log",
16 # Currently broken:
17 # "embassy-usb/log",
18 # "embassy-usb-serial/log",
19 # "embassy-usb-hid/log",
20]
21
22[dependencies]
23embassy-util = { version = "0.1.0", path = "../../embassy-util" }
24embassy-executor = { version = "0.1.0", path = "../../embassy-executor", features=["rtos-trace", "rtos-trace-interrupt"] }
25embassy-nrf = { version = "0.1.0", path = "../../embassy-nrf", features = ["nrf52840", "time-driver-rtc1", "gpiote", "unstable-pac"] }
26embassy-net = { version = "0.1.0", path = "../../embassy-net", features = ["tcp", "dhcpv4", "medium-ethernet", "pool-16"], optional = true }
27embassy-usb = { version = "0.1.0", path = "../../embassy-usb", optional = true }
28embassy-usb-serial = { version = "0.1.0", path = "../../embassy-usb-serial", optional = true }
29embassy-usb-hid = { version = "0.1.0", path = "../../embassy-usb-hid", optional = true }
30embassy-usb-ncm = { version = "0.1.0", path = "../../embassy-usb-ncm", optional = true }
31embedded-io = "0.3.0"
32
33cortex-m = "0.7.3"
34cortex-m-rt = "0.7.0"
35panic-probe = { version = "0.3" }
36futures = { version = "0.3.17", default-features = false, features = ["async-await"] }
37rand = { version = "0.8.4", default-features = false }
38embedded-storage = "0.3.0"
39usbd-hid = "0.5.2"
40serde = { version = "1.0.136", default-features = false }
41rtos-trace = "0.1.3"
42systemview-target = { version = "0.1.1", features = ["callbacks-app", "callbacks-os", "log", "cortex-m"] }
43log = { version = "0.4.17", optional = true }
44
45[[bin]]
46name = "rtos_trace"
47required-features = ["nightly"]
48
49[patch.crates-io]
50rtos-trace = { git = "https://gitlab.com/quentinmit/rtos-trace.git", branch = "build-fix" }
51systemview-target = { git = "https://gitlab.com/quentinmit/rtos-trace.git", branch = "build-fix" }
diff --git a/examples/nrf-rtos-trace/build.rs b/examples/nrf-rtos-trace/build.rs
new file mode 100644
index 000000000..36cdb65a8
--- /dev/null
+++ b/examples/nrf-rtos-trace/build.rs
@@ -0,0 +1,36 @@
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 #[cfg(feature = "defmt")]
35 println!("cargo:rustc-link-arg-bins=-Tdefmt.x");
36}
diff --git a/examples/nrf-rtos-trace/memory.x b/examples/nrf-rtos-trace/memory.x
new file mode 100644
index 000000000..9b04edec0
--- /dev/null
+++ b/examples/nrf-rtos-trace/memory.x
@@ -0,0 +1,7 @@
1MEMORY
2{
3 /* NOTE 1 K = 1 KiBi = 1024 bytes */
4 /* These values correspond to the NRF52840 with Softdevices S140 7.0.1 */
5 FLASH : ORIGIN = 0x00000000, LENGTH = 1024K
6 RAM : ORIGIN = 0x20000000, LENGTH = 256K
7}
diff --git a/examples/nrf/src/bin/rtos_trace.rs b/examples/nrf-rtos-trace/src/bin/rtos_trace.rs
index 5699fe8e2..5699fe8e2 100644
--- a/examples/nrf/src/bin/rtos_trace.rs
+++ b/examples/nrf-rtos-trace/src/bin/rtos_trace.rs
diff --git a/examples/nrf/Cargo.toml b/examples/nrf/Cargo.toml
index 8704f27c3..91edbd36d 100644
--- a/examples/nrf/Cargo.toml
+++ b/examples/nrf/Cargo.toml
@@ -4,71 +4,28 @@ name = "embassy-nrf-examples"
4version = "0.1.0" 4version = "0.1.0"
5 5
6[features] 6[features]
7default = ["defmt", "nightly"] 7default = ["nightly"]
8nightly = ["embassy-executor/nightly", "embassy-nrf/nightly", "embassy-nrf/unstable-traits", "embassy-usb", "embassy-usb-serial", "embassy-usb-hid", "embassy-usb-ncm", "embedded-io/async", "embassy-net"] 8nightly = ["embassy-executor/nightly", "embassy-nrf/nightly", "embassy-nrf/unstable-traits", "embassy-usb", "embassy-usb-serial", "embassy-usb-hid", "embassy-usb-ncm", "embedded-io/async", "embassy-net"]
9defmt = [
10 "dep:defmt",
11 "dep:defmt-rtt",
12 "embassy-util/defmt",
13 "embassy-executor/defmt",
14 "embassy-executor/defmt-timestamp-uptime",
15 "embassy-nrf/defmt",
16 "embassy-net/defmt",
17 "embassy-usb/defmt",
18 "embassy-usb-serial/defmt",
19 "embassy-usb-hid/defmt",
20 "embassy-usb-ncm/defmt",
21 "panic-probe/print-defmt",
22]
23log = [
24 "dep:log",
25 "embassy-util/log",
26 "embassy-executor/log",
27 "embassy-nrf/log",
28 "embassy-net/log",
29 "embassy-usb-ncm/log",
30 # Currently broken:
31 # "embassy-usb/log",
32 # "embassy-usb-serial/log",
33 # "embassy-usb-hid/log",
34]
35rtos-trace = [
36 "dep:rtos-trace",
37 "dep:systemview-target",
38 "embassy-executor/rtos-trace",
39 "embassy-executor/rtos-trace-interrupt",
40]
41 9
42[dependencies] 10[dependencies]
43embassy-util = { version = "0.1.0", path = "../../embassy-util" } 11embassy-util = { version = "0.1.0", path = "../../embassy-util", features = ["defmt"] }
44embassy-executor = { version = "0.1.0", path = "../../embassy-executor" } 12embassy-executor = { version = "0.1.0", path = "../../embassy-executor", features = ["defmt", "defmt-timestamp-uptime"] }
45embassy-nrf = { version = "0.1.0", path = "../../embassy-nrf", features = ["nrf52840", "time-driver-rtc1", "gpiote", "unstable-pac"] } 13embassy-nrf = { version = "0.1.0", path = "../../embassy-nrf", features = ["defmt", "nrf52840", "time-driver-rtc1", "gpiote", "unstable-pac"] }
46embassy-net = { version = "0.1.0", path = "../../embassy-net", features = ["tcp", "dhcpv4", "medium-ethernet", "pool-16"], optional = true } 14embassy-net = { version = "0.1.0", path = "../../embassy-net", features = ["defmt", "tcp", "dhcpv4", "medium-ethernet", "pool-16"], optional = true }
47embassy-usb = { version = "0.1.0", path = "../../embassy-usb", optional = true } 15embassy-usb = { version = "0.1.0", path = "../../embassy-usb", features = ["defmt"], optional = true }
48embassy-usb-serial = { version = "0.1.0", path = "../../embassy-usb-serial", optional = true } 16embassy-usb-serial = { version = "0.1.0", path = "../../embassy-usb-serial", features = ["defmt"], optional = true }
49embassy-usb-hid = { version = "0.1.0", path = "../../embassy-usb-hid", optional = true } 17embassy-usb-hid = { version = "0.1.0", path = "../../embassy-usb-hid", features = ["defmt"], optional = true }
50embassy-usb-ncm = { version = "0.1.0", path = "../../embassy-usb-ncm", optional = true } 18embassy-usb-ncm = { version = "0.1.0", path = "../../embassy-usb-ncm", features = ["defmt"], optional = true }
51embedded-io = "0.3.0" 19embedded-io = "0.3.0"
52 20
53defmt = { version = "0.3", optional = true } 21defmt = "0.3"
54defmt-rtt = { version = "0.3", optional = true } 22defmt-rtt = "0.3"
55 23
56cortex-m = "0.7.3" 24cortex-m = "0.7.3"
57cortex-m-rt = "0.7.0" 25cortex-m-rt = "0.7.0"
58panic-probe = { version = "0.3" } 26panic-probe = { version = "0.3", features = ["print-defmt"] }
59futures = { version = "0.3.17", default-features = false, features = ["async-await"] } 27futures = { version = "0.3.17", default-features = false, features = ["async-await"] }
60rand = { version = "0.8.4", default-features = false } 28rand = { version = "0.8.4", default-features = false }
61embedded-storage = "0.3.0" 29embedded-storage = "0.3.0"
62usbd-hid = "0.5.2" 30usbd-hid = "0.5.2"
63serde = { version = "1.0.136", default-features = false } 31serde = { version = "1.0.136", default-features = false }
64rtos-trace = { version = "0.1.3", optional = true }
65systemview-target = { version = "0.1.1", optional = true, features = ["callbacks-app", "callbacks-os", "log", "cortex-m"] }
66log = { version = "0.4.17", optional = true }
67
68[[bin]]
69name = "rtos_trace"
70required-features = ["nightly", "rtos-trace"]
71
72[patch.crates-io]
73rtos-trace = { git = "https://gitlab.com/quentinmit/rtos-trace.git", branch = "build-fix" }
74systemview-target = { git = "https://gitlab.com/quentinmit/rtos-trace.git", branch = "build-fix" }
diff --git a/examples/nrf/build.rs b/examples/nrf/build.rs
index 36cdb65a8..30691aa97 100644
--- a/examples/nrf/build.rs
+++ b/examples/nrf/build.rs
@@ -31,6 +31,5 @@ fn main() {
31 31
32 println!("cargo:rustc-link-arg-bins=--nmagic"); 32 println!("cargo:rustc-link-arg-bins=--nmagic");
33 println!("cargo:rustc-link-arg-bins=-Tlink.x"); 33 println!("cargo:rustc-link-arg-bins=-Tlink.x");
34 #[cfg(feature = "defmt")]
35 println!("cargo:rustc-link-arg-bins=-Tdefmt.x"); 34 println!("cargo:rustc-link-arg-bins=-Tdefmt.x");
36} 35}