Skip to content

Commit 77449e5

Browse files
committedFeb 12, 2025
cortex-m-rt: Fix max_int_handlers on armv8m
Fixed interrupt count for Cortex-M23 (ARMv8-M Baseline, 240) and Cortex-M33 (ARMv8-M Mainline, 480) based on the technical reference manual. The original value of 496 referred to the entire vector table length, with exceptions length already included in the assert check.
1 parent b188019 commit 77449e5

File tree

2 files changed

+9
-8
lines changed

2 files changed

+9
-8
lines changed
 

‎cortex-m-rt/build.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -68,12 +68,12 @@ INCLUDE device.x"#
6868
println!("cargo:rustc-cfg=cortex_m");
6969
println!("cargo:rustc-cfg=armv8m");
7070
println!("cargo:rustc-cfg=armv8m_base");
71-
496
71+
240
7272
} else if target.starts_with("thumbv8m.main") {
7373
println!("cargo:rustc-cfg=cortex_m");
7474
println!("cargo:rustc-cfg=armv8m");
7575
println!("cargo:rustc-cfg=armv8m_main");
76-
496
76+
480
7777
} else {
7878
// Non ARM target. We assume you're just testing the syntax.
7979
// This value seems as good as any.

‎cortex-m-rt/src/lib.rs

+7-6
Original file line numberDiff line numberDiff line change
@@ -273,7 +273,8 @@
273273
//!
274274
//! - `__INTERRUPTS`. This is the device specific interrupt portion of the vector table; its exact
275275
//! size depends on the target device but if the `"device"` feature has not been enabled it will
276-
//! have a size of 32 vectors (on ARMv6-M), 240 vectors (on ARMv7-M) or 496 vectors (on ARMv8-M).
276+
//! have a size of 32 vectors (on ARMv6-M), 240 vectors (on ARMv7-M, ARMv8-M Baseline) or 480
277+
//! vectors (on ARMv8-M Mainline).
277278
//! This array is located after `__EXCEPTIONS` in the `.vector_table` section.
278279
//!
279280
//! - `__pre_init`. This is a function to be run before RAM is initialized. It defaults to an empty
@@ -1259,7 +1260,7 @@ pub static __EXCEPTIONS: [Vector; 14] = [
12591260

12601261
// If we are not targeting a specific device we bind all the potential device specific interrupts
12611262
// to the default handler
1262-
#[cfg(all(any(not(feature = "device"), test), not(armv6m), not(armv8m)))]
1263+
#[cfg(all(any(not(feature = "device"), test), not(armv6m), not(armv8m_main)))]
12631264
#[doc(hidden)]
12641265
#[cfg_attr(cortex_m, link_section = ".vector_table.interrupts")]
12651266
#[no_mangle]
@@ -1271,18 +1272,18 @@ pub static __INTERRUPTS: [unsafe extern "C" fn(); 240] = [{
12711272
DefaultHandler
12721273
}; 240];
12731274

1274-
// ARMv8-M can have up to 496 device specific interrupts
1275-
#[cfg(all(not(feature = "device"), armv8m))]
1275+
// ARMv8-M Mainline can have up to 480 device specific interrupts
1276+
#[cfg(all(not(feature = "device"), armv8m_main))]
12761277
#[doc(hidden)]
12771278
#[cfg_attr(cortex_m, link_section = ".vector_table.interrupts")]
12781279
#[no_mangle]
1279-
pub static __INTERRUPTS: [unsafe extern "C" fn(); 496] = [{
1280+
pub static __INTERRUPTS: [unsafe extern "C" fn(); 480] = [{
12801281
extern "C" {
12811282
fn DefaultHandler();
12821283
}
12831284

12841285
DefaultHandler
1285-
}; 496];
1286+
}; 480];
12861287

12871288
// ARMv6-M can only have a maximum of 32 device specific interrupts
12881289
#[cfg(all(not(feature = "device"), armv6m))]

0 commit comments

Comments
 (0)
Failed to load comments.