From 37435f17390b35d00de267f1d167976dd1fee419 Mon Sep 17 00:00:00 2001 From: Andelf Date: Thu, 3 Oct 2024 13:39:10 +0800 Subject: [PATCH] Fix build errors and missing v3 feature (#5) * fix: missing v3 feature in rt crate * fix(build): feature flags * fix(build): rt cfg flags warning * fixup! ci: create rust.yml --- .github/workflows/rust.yml | 2 ++ qingke-rt/Cargo.toml | 4 ++-- qingke-rt/build.rs | 4 ++++ src/pfic.rs | 1 + 4 files changed, 9 insertions(+), 2 deletions(-) diff --git a/.github/workflows/rust.yml b/.github/workflows/rust.yml index bda4a7b..533dc35 100644 --- a/.github/workflows/rust.yml +++ b/.github/workflows/rust.yml @@ -16,5 +16,7 @@ jobs: steps: - uses: actions/checkout@v4 + - name: Prepare Rust Target + run: rustup target add riscv32imac-unknown-none-elf - name: Build run: cargo build --all --target riscv32imac-unknown-none-elf diff --git a/qingke-rt/Cargo.toml b/qingke-rt/Cargo.toml index e71972c..d058a5e 100644 --- a/qingke-rt/Cargo.toml +++ b/qingke-rt/Cargo.toml @@ -15,7 +15,7 @@ readme = "README.md" [features] v2 = [] -v3 = [] +v3 = ["qingke/v3"] v4 = [] # v5 is not released yet # v5 = [] @@ -24,7 +24,7 @@ highcode = [] [dependencies] qingke-rt-macros = { path = "./macros", version = "0.3" } -qingke = { path = "../", version = "0.3" } +qingke = { path = "../", version = "0.3", features = ["critical-section-impl"] } [package.metadata.docs.rs] targets = ["riscv32imac-unknown-none-elf"] diff --git a/qingke-rt/build.rs b/qingke-rt/build.rs index 803f70f..278f92c 100644 --- a/qingke-rt/build.rs +++ b/qingke-rt/build.rs @@ -76,6 +76,10 @@ fn main() { let target = env::var("TARGET").unwrap(); let cargo_flags = env::var("CARGO_ENCODED_RUSTFLAGS").unwrap(); // set configuration flags depending on the target + + println!("cargo::rustc-check-cfg=cfg(riscvf)"); + println!("cargo::rustc-check-cfg=cfg(riscvd)"); + if target.starts_with("riscv") { println!("cargo:rustc-cfg=riscv"); diff --git a/src/pfic.rs b/src/pfic.rs index b0dff45..9b94932 100644 --- a/src/pfic.rs +++ b/src/pfic.rs @@ -168,6 +168,7 @@ pub unsafe fn disable_vtf(channel: u8) { ptr::write_volatile(PFIC_VTFADDRR0.offset(channel as isize), val & 0xFFFF_FFFE); } +#[cfg(feature = "critical-section-impl")] pub unsafe fn wfi_to_wfe(v: bool) { critical_section::with(|_| { let mut val = ptr::read_volatile(PFIC_SCTLR);