diff options
| -rw-r--r-- | CHANGELOG.md | 4 | ||||
| -rw-r--r-- | src/host.rs | 19 | ||||
| -rw-r--r-- | tests/inspect_elf.rs | 2 |
3 files changed, 20 insertions, 5 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md index a43b8e5..7e59f3a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,10 @@ ## [Unreleased] +Establish a 32 byte reservation at the start of ITCM where instructions are +never placed. This reduces the total capacity of ITCM by 32 bytes on nearly +all MCUs, except the 1180. + ## [0.1.7] 2025-06-14 Introduce `RuntimeBuilder::in_flash` for creating images that can be launched diff --git a/src/host.rs b/src/host.rs index 43472fe..ba299dd 100644 --- a/src/host.rs +++ b/src/host.rs @@ -946,7 +946,7 @@ impl Family { /// Returns the start and size of the ITCM memory region. const fn itcm_start_size(self, itcm_banks: u32) -> (u32, u32) { - let itcm_size = itcm_banks * self.flexram_bank_size(); + let mut itcm_size = itcm_banks * self.flexram_bank_size(); let itcm_start = match self { Family::Imxrt1010 | Family::Imxrt1015 @@ -956,7 +956,13 @@ impl Family { | Family::Imxrt1060 | Family::Imxrt1064 | Family::Imxrt1160 - | Family::Imxrt1170 => 0x00000000, + | Family::Imxrt1170 => { + // Establish a reservation for null pointers. + // Note that this reservation is the minimum + // size of an MPU region. + itcm_size = itcm_size.saturating_sub(32); + 32 + } Family::Imxrt1180 => 0x10000000 - itcm_size, }; (itcm_start, itcm_size) @@ -1252,11 +1258,16 @@ mod tests { #[test] fn itcm_start_size() { // Most parts have an ITCM that could touch address 0. + // However, the implementation reserves an MPU region + // at address 0. for family in MOST_FAMILIES { for itcm_banks in 0..=family.flexram_bank_count() { let (start, size) = family.itcm_start_size(itcm_banks); - assert_eq!(start, 0); - assert_eq!(size, family.flexram_bank_size() * itcm_banks); + assert_eq!(start, 32); + assert_eq!( + size, + (family.flexram_bank_size() * itcm_banks).saturating_sub(32) + ); } } diff --git a/tests/inspect_elf.rs b/tests/inspect_elf.rs index 8108f3f..e9a8f73 100644 --- a/tests/inspect_elf.rs +++ b/tests/inspect_elf.rs @@ -198,7 +198,7 @@ struct Section { } const DTCM: u64 = 0x2000_0000; -const ITCM: u64 = 0x0000_0000; +const ITCM: u64 = 0x0000_0020; const fn aligned(value: u64, alignment: u64) -> u64 { (value + (alignment - 1)) & !(alignment - 1) |
