diff options
-rw-r--r-- | .github/workflows/on-target.yml | 4 | ||||
-rw-r--r-- | cortex-m-rt/examples/device.rs | 1 | ||||
-rw-r--r-- | cortex-m-rt/examples/warnings.rs | 1 | ||||
-rw-r--r-- | cortex-m-rt/link.x.in | 13 | ||||
-rw-r--r-- | cortex-m-rt/src/lib.rs | 1 | ||||
-rw-r--r-- | cortex-m-semihosting/src/debug.rs | 16 | ||||
-rw-r--r-- | cortex-m-semihosting/src/hio.rs | 3 | ||||
-rw-r--r-- | cortex-m-semihosting/src/lib.rs | 11 | ||||
-rw-r--r-- | cortex-m/Cargo.toml | 2 | ||||
-rw-r--r-- | cortex-m/src/peripheral/scb.rs | 10 | ||||
-rw-r--r-- | xtask/tests/ci.rs | 10 |
11 files changed, 44 insertions, 28 deletions
diff --git a/.github/workflows/on-target.yml b/.github/workflows/on-target.yml index beb0e7d..8371da1 100644 --- a/.github/workflows/on-target.yml +++ b/.github/workflows/on-target.yml @@ -66,7 +66,9 @@ jobs: run: probe-run --version - name: List probes run: probe-run --list-probes - - uses: actions/download-artifact@v3 + # TODO: replace with actions/download-artifact when they update to node20 + # https://github.com/actions/download-artifact/issues/230 + - uses: newAM/download-artifact@4202241ccada6f83f838525a8af979a4ec900a49 with: name: testsuite-bin path: testsuite-bin diff --git a/cortex-m-rt/examples/device.rs b/cortex-m-rt/examples/device.rs index c18b569..02a60c8 100644 --- a/cortex-m-rt/examples/device.rs +++ b/cortex-m-rt/examples/device.rs @@ -16,6 +16,7 @@ fn main() -> ! { } // interrupts portion of the vector table +#[repr(C)] pub union Vector { handler: unsafe extern "C" fn(), reserved: usize, diff --git a/cortex-m-rt/examples/warnings.rs b/cortex-m-rt/examples/warnings.rs index 3372003..abf4a2f 100644 --- a/cortex-m-rt/examples/warnings.rs +++ b/cortex-m-rt/examples/warnings.rs @@ -22,6 +22,7 @@ extern "C" { fn INT(); } +#[repr(C)] union Vector { #[allow(dead_code)] handler: unsafe extern "C" fn(), diff --git a/cortex-m-rt/link.x.in b/cortex-m-rt/link.x.in index 01bef98..5b13bef 100644 --- a/cortex-m-rt/link.x.in +++ b/cortex-m-rt/link.x.in @@ -79,11 +79,11 @@ SECTIONS /* Reset vector */ KEEP(*(.vector_table.reset_vector)); /* this is the `__RESET_VECTOR` symbol */ - __reset_vector = .; /* Exceptions */ + __exceptions = .; /* start of exceptions */ KEEP(*(.vector_table.exceptions)); /* this is the `__EXCEPTIONS` symbol */ - __eexceptions = .; + __eexceptions = .; /* end of exceptions */ /* Device specific interrupts */ KEEP(*(.vector_table.interrupts)); /* this is the `__INTERRUPTS` symbol */ @@ -231,8 +231,13 @@ origin and length are set to multiples of 8 in the `memory.x` file."); /* # Position checks */ -/* ## .vector_table */ -ASSERT(__reset_vector == ADDR(.vector_table) + 0x8, " +/* ## .vector_table + * + * If the *start* of exception vectors is not 8 bytes past the start of the + * vector table, then we somehow did not place the reset vector, which should + * live 4 bytes past the start of the vector table. + */ +ASSERT(__exceptions == ADDR(.vector_table) + 0x8, " BUG(cortex-m-rt): the reset vector is missing"); ASSERT(__eexceptions == ADDR(.vector_table) + 0x40, " diff --git a/cortex-m-rt/src/lib.rs b/cortex-m-rt/src/lib.rs index 920c989..27bb1bd 100644 --- a/cortex-m-rt/src/lib.rs +++ b/cortex-m-rt/src/lib.rs @@ -1128,6 +1128,7 @@ extern "C" { } #[doc(hidden)] +#[repr(C)] pub union Vector { handler: unsafe extern "C" fn(), reserved: usize, diff --git a/cortex-m-semihosting/src/debug.rs b/cortex-m-semihosting/src/debug.rs index a4fa6d8..7c7ff9d 100644 --- a/cortex-m-semihosting/src/debug.rs +++ b/cortex-m-semihosting/src/debug.rs @@ -11,16 +11,14 @@ //! ```no_run //! use cortex_m_semihosting::debug::{self, EXIT_SUCCESS, EXIT_FAILURE}; //! -//! fn main() { -//! if 2 == 2 { -//! // report success -//! debug::exit(EXIT_SUCCESS); -//! } else { -//! // report failure -//! debug::exit(EXIT_FAILURE); -//! } +//! if 2 == 2 { +//! // report success +//! debug::exit(EXIT_SUCCESS); +//! } else { +//! // report failure +//! debug::exit(EXIT_FAILURE); //! } -//! +//! ``` /// This values are taken from section 5.5.2 of /// ADS Debug Target Guide (DUI0058). diff --git a/cortex-m-semihosting/src/hio.rs b/cortex-m-semihosting/src/hio.rs index b6b6c7b..e0614ad 100644 --- a/cortex-m-semihosting/src/hio.rs +++ b/cortex-m-semihosting/src/hio.rs @@ -1,5 +1,8 @@ //! Host I/O +// Fixing this lint requires a breaking change that does not add much value +#![allow(clippy::result_unit_err)] + use crate::nr; use core::{fmt, slice}; diff --git a/cortex-m-semihosting/src/lib.rs b/cortex-m-semihosting/src/lib.rs index 8306307..e72dbe6 100644 --- a/cortex-m-semihosting/src/lib.rs +++ b/cortex-m-semihosting/src/lib.rs @@ -184,12 +184,23 @@ pub mod hio; pub mod nr; /// Performs a semihosting operation, takes a pointer to an argument block +/// +/// # Safety +/// +/// The syscall number must be a valid [semihosting operation], +/// and the arguments must be valid for the associated operation. +/// +/// [semihosting operation]: https://developer.arm.com/documentation/dui0471/i/semihosting/semihosting-operations?lang=en #[inline(always)] pub unsafe fn syscall<T>(nr: usize, arg: &T) -> usize { syscall1(nr, arg as *const T as usize) } /// Performs a semihosting operation, takes one integer as an argument +/// +/// # Safety +/// +/// Same as [`syscall`]. #[inline(always)] pub unsafe fn syscall1(_nr: usize, _arg: usize) -> usize { match () { diff --git a/cortex-m/Cargo.toml b/cortex-m/Cargo.toml index cdd63bd..03a1ca1 100644 --- a/cortex-m/Cargo.toml +++ b/cortex-m/Cargo.toml @@ -18,7 +18,7 @@ links = "cortex-m" # prevent multiple versions of this crate to be linked toget [dependencies] critical-section = "1.0.0" -volatile-register = "0.2.0" +volatile-register = "0.2.2" bitfield = "0.13.2" embedded-hal = "0.2.4" diff --git a/cortex-m/src/peripheral/scb.rs b/cortex-m/src/peripheral/scb.rs index b9cf0e4..b10f9d2 100644 --- a/cortex-m/src/peripheral/scb.rs +++ b/cortex-m/src/peripheral/scb.rs @@ -664,10 +664,7 @@ impl SCB { /// a runtime-dependent `panic!()` call. #[inline] pub unsafe fn invalidate_dcache_by_slice<T>(&mut self, slice: &mut [T]) { - self.invalidate_dcache_by_address( - slice.as_ptr() as usize, - slice.len() * core::mem::size_of::<T>(), - ); + self.invalidate_dcache_by_address(slice.as_ptr() as usize, core::mem::size_of_val(slice)); } /// Cleans D-cache by address. @@ -750,10 +747,7 @@ impl SCB { /// to main memory, overwriting whatever was in main memory. #[inline] pub fn clean_dcache_by_slice<T>(&mut self, slice: &[T]) { - self.clean_dcache_by_address( - slice.as_ptr() as usize, - slice.len() * core::mem::size_of::<T>(), - ); + self.clean_dcache_by_address(slice.as_ptr() as usize, core::mem::size_of_val(slice)); } /// Cleans and invalidates D-cache by address. diff --git a/xtask/tests/ci.rs b/xtask/tests/ci.rs index 1dc4754..3c3ef99 100644 --- a/xtask/tests/ci.rs +++ b/xtask/tests/ci.rs @@ -27,16 +27,16 @@ static NON_BASE_TARGETS: &[&str] = &[ fn build(package: &str, target: &str, features: &[&str]) { println!("building {} for {} {:?}", package, target, features); let mut cargo = Command::new("cargo"); - cargo.args(&["build", "-p", package, "--target", target]); + cargo.args(["build", "-p", package, "--target", target]); for feat in features { - cargo.args(&["--features", *feat]); + cargo.args(["--features", *feat]); } // A `critical_section` implementation is always needed. if package == "cortex-m" { - cargo.args(&["--features", "critical-section-single-core"]); + cargo.args(["--features", "critical-section-single-core"]); } else { - cargo.args(&["--features", "cortex-m/critical-section-single-core"]); + cargo.args(["--features", "cortex-m/critical-section-single-core"]); } // Cargo features don't work right when invoked from the workspace root, so change to the @@ -77,7 +77,7 @@ fn check_crates_build(_is_nightly: bool) { let used_features = &*all_features .iter() .copied() - .filter(|feat| should_use_feature(*feat)) + .filter(|feat| should_use_feature(feat)) .collect::<Vec<_>>(); // (note: we don't test with default features disabled, since we don't use them yet) |