I tried attaching the file, but .patch is not an allowed file extension in this forum.
I hope including it like so in this post is okay (otherwise, please advise how to send this):
Code: Select all
From d942e1fae2f3f9df6ece5752d3345bbddff999ac Mon Sep 17 00:00:00 2001
From: Michael Stapelberg <stapelberg@google.com>
Date: Thu, 11 Jun 2020 19:17:45 +0200
Subject: [PATCH] ARMCMx: rules_code.ld: align .vectors to 256
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
See the comment in the commit for more details.
Alignment generally doesn’t matter when the .vectors section is the first one
placed on the flash, ending up at address 0.
The Teensy 4.1, however, requires flashconfig to come first (more on that in
another commit to ChibiOS-Contrib), and isn’t happy with un-aligned vector
tables. In my case, it rebooted after enabling the SysTick_Handler interrupt.
---
.../ARMCMx/compilers/GCC/ld/rules_code.ld | 19 ++++++++++++++++++-
1 file changed, 18 insertions(+), 1 deletion(-)
diff --git a/os/common/startup/ARMCMx/compilers/GCC/ld/rules_code.ld b/os/common/startup/ARMCMx/compilers/GCC/ld/rules_code.ld
index 888cc712e..a175986f6 100644
--- a/os/common/startup/ARMCMx/compilers/GCC/ld/rules_code.ld
+++ b/os/common/startup/ARMCMx/compilers/GCC/ld/rules_code.ld
@@ -18,7 +18,24 @@ ENTRY(Reset_Handler)
SECTIONS
{
- .vectors : ALIGN(16)
+/*
+
+The Teensy 4.1 has an ARM Cortex M7 with 160+16 interrupts, so we need to align
+256, the nearest power of two, as per:
+http://infocenter.arm.com/help/topic/com.arm.doc.dui0646c/DUI0646C_cortex_m7_dgug.pdf section 4.3.4:
+
+When setting TBLOFF, you must align the offset to the number of exception
+entries in the vector table. The minimum alignment is 32 words, enough for up to
+16 interrupts. For more interrupts, adjust the alignment by rounding up to the
+next power of two. For example, if you require 21 interrupts, the alignment must
+be on a 64-word boundary because the required table size is 37 words, and the
+next power of two is 64.
+
+Note: Table alignment requirements mean that bits[6:0] of the table offset are
+always zero.
+
+*/
+ .vectors : ALIGN(256)
{
KEEP(*(.vectors))
} > VECTORS_FLASH AT > VECTORS_FLASH_LMA
--
2.27.0
Thank you,