From 406e39a0d5a9d5fbfb6da091beefddabbf89b780 Mon Sep 17 00:00:00 2001 From: bunnie Date: Sat, 1 Nov 2025 20:09:12 +0800 Subject: [PATCH] fix timebase of delays in loader should be tied to the system clock frequency --- loader/src/lib.rs | 2 +- loader/src/platform/bao1x/bao1x.rs | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/loader/src/lib.rs b/loader/src/lib.rs index 1ff422382..15a41f17d 100644 --- a/loader/src/lib.rs +++ b/loader/src/lib.rs @@ -54,4 +54,4 @@ pub const GUARD_MEMORY_BYTES: usize = 8 * crate::PAGE_SIZE; // 1 extra page for pub const SWAPPER_PID: u8 = 2; #[cfg(feature = "bao1x")] -pub const SYSTEM_CLOCK_FREQUENCY: u32 = 800_000_000; +pub const SYSTEM_CLOCK_FREQUENCY: u32 = bao1x_hal::board::DEFAULT_FCLK_FREQUENCY / 2; diff --git a/loader/src/platform/bao1x/bao1x.rs b/loader/src/platform/bao1x/bao1x.rs index 3db9516ad..a93ee4063 100644 --- a/loader/src/platform/bao1x/bao1x.rs +++ b/loader/src/platform/bao1x/bao1x.rs @@ -36,7 +36,8 @@ pub fn delay(quantum: usize) { use utralib::{CSR, utra}; // abuse the d11ctime timer to create some time-out like thing let mut d11c = CSR::new(utra::d11ctime::HW_D11CTIME_BASE as *mut u32); - d11c.wfo(utra::d11ctime::CONTROL_COUNT, 333_333); // 1.0ms per interval + // 1.0ms per interval + d11c.wfo(utra::d11ctime::CONTROL_COUNT, crate::SYSTEM_CLOCK_FREQUENCY / 1000); let mut polarity = d11c.rf(utra::d11ctime::HEARTBEAT_BEAT); for _ in 0..quantum { while polarity == d11c.rf(utra::d11ctime::HEARTBEAT_BEAT) {}