From 5f36108896d909ed990a587941d74e0488bcd190 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?xgroleau=F0=9F=90=A2?= Date: Tue, 6 Feb 2024 10:38:48 -0500 Subject: [PATCH 1/4] fix: rtos-usage time missing --- embassy-executor/Cargo.toml | 4 ++++ embassy-executor/src/raw/mod.rs | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/embassy-executor/Cargo.toml b/embassy-executor/Cargo.toml index 409df0d75..0762e2434 100644 --- a/embassy-executor/Cargo.toml +++ b/embassy-executor/Cargo.toml @@ -34,6 +34,7 @@ log = { version = "0.4.14", optional = true } rtos-trace = { version = "0.1.2", optional = true } embassy-executor-macros = { version = "0.4.0", path = "../embassy-executor-macros" } +embassy-time = { version = "0.3.0", path = "../embassy-time", optional = true } embassy-time-driver = { version = "0.1.0", path = "../embassy-time-driver", optional = true } embassy-time-queue-driver = { version = "0.1.0", path = "../embassy-time-queue-driver", optional = true } critical-section = "1.1" @@ -71,6 +72,9 @@ turbowakers = [] ## Use the executor-integrated `embassy-time` timer queue. integrated-timers = ["dep:embassy-time-driver", "dep:embassy-time-queue-driver"] +# Support for rtos trace require time +rtos-trace = ["dep:rtos-trace", "dep:embassy-time"] + #! ### Architecture _arch = [] # some arch was picked ## std diff --git a/embassy-executor/src/raw/mod.rs b/embassy-executor/src/raw/mod.rs index 3f00be4a8..fbc0481c2 100644 --- a/embassy-executor/src/raw/mod.rs +++ b/embassy-executor/src/raw/mod.rs @@ -588,7 +588,7 @@ impl rtos_trace::RtosTraceOSCallbacks for Executor { } #[cfg(feature = "integrated-timers")] fn time() -> u64 { - Instant::now().as_micros() + embassy_time::Instant::now().as_millis() } #[cfg(not(feature = "integrated-timers"))] fn time() -> u64 { From d48620d58f588936a5c74840063fe422764b749f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?xgroleau=F0=9F=90=A2?= Date: Tue, 6 Feb 2024 15:50:28 -0500 Subject: [PATCH 2/4] fix: compilation for rtos trace --- ci.sh | 2 ++ embassy-executor/Cargo.toml | 4 ---- embassy-executor/src/raw/mod.rs | 12 +++++++++++- 3 files changed, 13 insertions(+), 5 deletions(-) diff --git a/ci.sh b/ci.sh index df9e09848..4f28c5e92 100755 --- a/ci.sh +++ b/ci.sh @@ -23,6 +23,8 @@ cargo batch \ --- build --release --manifest-path embassy-executor/Cargo.toml --target thumbv6m-none-eabi --features defmt,arch-cortex-m,executor-thread,executor-interrupt,integrated-timers \ --- build --release --manifest-path embassy-executor/Cargo.toml --target thumbv7em-none-eabi --features arch-cortex-m \ --- build --release --manifest-path embassy-executor/Cargo.toml --target thumbv7em-none-eabi --features arch-cortex-m,integrated-timers \ + --- build --release --manifest-path embassy-executor/Cargo.toml --target thumbv7em-none-eabi --features arch-cortex-m,rtos-trace \ + --- build --release --manifest-path embassy-executor/Cargo.toml --target thumbv7em-none-eabi --features arch-cortex-m,integrated-timers,rtos-trace \ --- build --release --manifest-path embassy-executor/Cargo.toml --target thumbv7em-none-eabi --features arch-cortex-m,executor-thread \ --- build --release --manifest-path embassy-executor/Cargo.toml --target thumbv7em-none-eabi --features arch-cortex-m,executor-thread,integrated-timers \ --- build --release --manifest-path embassy-executor/Cargo.toml --target thumbv7em-none-eabi --features arch-cortex-m,executor-interrupt \ diff --git a/embassy-executor/Cargo.toml b/embassy-executor/Cargo.toml index 0762e2434..409df0d75 100644 --- a/embassy-executor/Cargo.toml +++ b/embassy-executor/Cargo.toml @@ -34,7 +34,6 @@ log = { version = "0.4.14", optional = true } rtos-trace = { version = "0.1.2", optional = true } embassy-executor-macros = { version = "0.4.0", path = "../embassy-executor-macros" } -embassy-time = { version = "0.3.0", path = "../embassy-time", optional = true } embassy-time-driver = { version = "0.1.0", path = "../embassy-time-driver", optional = true } embassy-time-queue-driver = { version = "0.1.0", path = "../embassy-time-queue-driver", optional = true } critical-section = "1.1" @@ -72,9 +71,6 @@ turbowakers = [] ## Use the executor-integrated `embassy-time` timer queue. integrated-timers = ["dep:embassy-time-driver", "dep:embassy-time-queue-driver"] -# Support for rtos trace require time -rtos-trace = ["dep:rtos-trace", "dep:embassy-time"] - #! ### Architecture _arch = [] # some arch was picked ## std diff --git a/embassy-executor/src/raw/mod.rs b/embassy-executor/src/raw/mod.rs index fbc0481c2..3d221c94b 100644 --- a/embassy-executor/src/raw/mod.rs +++ b/embassy-executor/src/raw/mod.rs @@ -581,6 +581,15 @@ impl embassy_time_queue_driver::TimerQueue for TimerQueue { #[cfg(feature = "integrated-timers")] embassy_time_queue_driver::timer_queue_impl!(static TIMER_QUEUE: TimerQueue = TimerQueue); +#[cfg(all(feature = "rtos-trace", feature = "integrated-timers"))] +const fn gcd(a: u64, b: u64) -> u64 { + if b == 0 { + a + } else { + gcd(b, a % b) + } +} + #[cfg(feature = "rtos-trace")] impl rtos_trace::RtosTraceOSCallbacks for Executor { fn task_list() { @@ -588,7 +597,8 @@ impl rtos_trace::RtosTraceOSCallbacks for Executor { } #[cfg(feature = "integrated-timers")] fn time() -> u64 { - embassy_time::Instant::now().as_millis() + const GCD_1M: u64 = gcd(embassy_time_driver::TICK_HZ, 1_000_000); + embassy_time_driver::now() * (1_000_00 / GCD_1M) / (embassy_time_driver::TICK_HZ / GCD_1M); } #[cfg(not(feature = "integrated-timers"))] fn time() -> u64 { From 09613e90de92ba43974796efec13e38adf4c3ac8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?xgroleau=F0=9F=90=A2?= Date: Thu, 8 Feb 2024 09:01:07 -0500 Subject: [PATCH 3/4] fix: missing 0 --- embassy-executor/src/raw/mod.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/embassy-executor/src/raw/mod.rs b/embassy-executor/src/raw/mod.rs index 3d221c94b..3c9407d39 100644 --- a/embassy-executor/src/raw/mod.rs +++ b/embassy-executor/src/raw/mod.rs @@ -598,7 +598,7 @@ impl rtos_trace::RtosTraceOSCallbacks for Executor { #[cfg(feature = "integrated-timers")] fn time() -> u64 { const GCD_1M: u64 = gcd(embassy_time_driver::TICK_HZ, 1_000_000); - embassy_time_driver::now() * (1_000_00 / GCD_1M) / (embassy_time_driver::TICK_HZ / GCD_1M); + embassy_time_driver::now() * (1_000_000 / GCD_1M) / (embassy_time_driver::TICK_HZ / GCD_1M); } #[cfg(not(feature = "integrated-timers"))] fn time() -> u64 { From 262518cfe5c303034f71393367914bec221c71be Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?xgroleau=F0=9F=90=A2?= Date: Thu, 8 Feb 2024 09:02:07 -0500 Subject: [PATCH 4/4] fix: removed trailing comma --- embassy-executor/src/raw/mod.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/embassy-executor/src/raw/mod.rs b/embassy-executor/src/raw/mod.rs index 3c9407d39..3d5e3ab9f 100644 --- a/embassy-executor/src/raw/mod.rs +++ b/embassy-executor/src/raw/mod.rs @@ -598,7 +598,7 @@ impl rtos_trace::RtosTraceOSCallbacks for Executor { #[cfg(feature = "integrated-timers")] fn time() -> u64 { const GCD_1M: u64 = gcd(embassy_time_driver::TICK_HZ, 1_000_000); - embassy_time_driver::now() * (1_000_000 / GCD_1M) / (embassy_time_driver::TICK_HZ / GCD_1M); + embassy_time_driver::now() * (1_000_000 / GCD_1M) / (embassy_time_driver::TICK_HZ / GCD_1M) } #[cfg(not(feature = "integrated-timers"))] fn time() -> u64 {