diff --git a/arch/stm32f429/isr.c b/arch/stm32f429/isr.c index 01f75f3a3..b4391df4a 100644 --- a/arch/stm32f429/isr.c +++ b/arch/stm32f429/isr.c @@ -13,6 +13,8 @@ typedef void(*ISR)(void); #define INITIALISATION_VECTOR_SIZE 0x6B +void _start(); + ISR InitialisationVector[INITIALISATION_VECTOR_SIZE] __attribute__((section(".isr_vector_table"))) = { @@ -22,11 +24,29 @@ ISR InitialisationVector[INITIALISATION_VECTOR_SIZE] _HardFaultServiceRoutine, _MemManageServiceRoutine, _BusFaultServiceRoutine, - 0, // UsageFault - 0, // Reserved + _UsageFaultServiceRoutine, + 0, 0, 0, 0, // Reserved _SVCallServiceRoutine, - 0, // Debug Monitor + _DebugMonitorServiceRoutine, + 0, // Reserved _PendSVServiceRoutine, _SysTickServiceRoutine, - 0 + _WWDGServiceRoutine, + _PVDServiceRoutine, + _TampStampServiceRoutine, + _RtcWakeupServiceRoutine, + _FlashServiceRoutine, + _RCCServiceRoutine, + _EXTI0ServiceRoutine, + _EXTI1ServiceRoutine, + _EXTI2ServiceRoutine, + _EXTI3ServiceRoutine, + _EXTI4ServiceRoutine, + _DMA1Stream0ServiceRoutine, + _DMA1Stream1ServiceRoutine, + _DMA1Stream2ServiceRoutine, + _DMA1Stream3ServiceRoutine, + _DMA1Stream4ServiceRoutine, + _DMA1Stream5ServiceRoutine, + _DMA1Stream6ServiceRoutine }; diff --git a/arch/stm32f429/isr.h b/arch/stm32f429/isr.h index bbe49b6bd..185805362 100644 --- a/arch/stm32f429/isr.h +++ b/arch/stm32f429/isr.h @@ -1,8 +1,28 @@ -void _ResetServiceRoutine(void); -void _NMIServiceRoutine(void); -void _HardFaultServiceRoutine(void); -void _MemManageServiceRoutine(void); -void _BusFaultServiceRoutine(void); -void _SVCallServiceRoutine(void); -void _PendSVServiceRoutine(void); -void _SysTickServiceRoutine(void); +void _ResetServiceRoutine(); +void _NMIServiceRoutine(); +void _HardFaultServiceRoutine(); +void _MemManageServiceRoutine(); +void _BusFaultServiceRoutine(); +void _UsageFaultServiceRoutine(); +void _SVCallServiceRoutine(); +void _DebugMonitorServiceRoutine(); +void _PendSVServiceRoutine(); +void _SysTickServiceRoutine(); +void _WWDGServiceRoutine(); +void _PVDServiceRoutine(); +void _TampStampServiceRoutine(); +void _RtcWakeupServiceRoutine(); +void _FlashServiceRoutine(); +void _RCCServiceRoutine(); +void _EXTI0ServiceRoutine(); +void _EXTI1ServiceRoutine(); +void _EXTI2ServiceRoutine(); +void _EXTI3ServiceRoutine(); +void _EXTI4ServiceRoutine(); +void _DMA1Stream0ServiceRoutine(); +void _DMA1Stream1ServiceRoutine(); +void _DMA1Stream2ServiceRoutine(); +void _DMA1Stream3ServiceRoutine(); +void _DMA1Stream4ServiceRoutine(); +void _DMA1Stream5ServiceRoutine(); +void _DMA1Stream6ServiceRoutine(); diff --git a/boot/stm32f429.ld b/boot/stm32f429.ld index 5a2e674c1..768f89f0f 100644 --- a/boot/stm32f429.ld +++ b/boot/stm32f429.ld @@ -19,6 +19,42 @@ MEMORY { SECTIONS { + /* The ISR vector table (explained below) contains pointer to functions that + * we may want to override depending on the binary we want to produce. + * The C implementation uses _NameServiceRoutine symbols. If those symbols are + * defined elsewhere, want to use that version. If they aren't defined, we + * want to provide a default value. We'll define here the default value that + * we want to be "absolute zero" (outside of any section). + * provide here a default implementation (namely, calling crt0's _start on + * reset, and an infinite loop on HardFault). */ + + PROVIDE(_NMIServiceRoutine = 0); + PROVIDE(_MemManageServiceRoutine = 0); + PROVIDE(_BusFaultServiceRoutine = 0); + PROVIDE(_UsageFaultServiceRoutine = 0); + PROVIDE(_SVCallServiceRoutine = 0); + PROVIDE(_DebugMonitorServiceRoutine = 0); + PROVIDE(_PendSVServiceRoutine = 0); + PROVIDE(_SysTickServiceRoutine = 0); + PROVIDE(_WWDGServiceRoutine = 0); + PROVIDE(_PVDServiceRoutine = 0); + PROVIDE(_TampStampServiceRoutine = 0); + PROVIDE(_RtcWakeupServiceRoutine = 0); + PROVIDE(_FlashServiceRoutine = 0); + PROVIDE(_RCCServiceRoutine = 0); + PROVIDE(_EXTI0ServiceRoutine = 0); + PROVIDE(_EXTI1ServiceRoutine = 0); + PROVIDE(_EXTI2ServiceRoutine = 0); + PROVIDE(_EXTI3ServiceRoutine = 0); + PROVIDE(_EXTI4ServiceRoutine = 0); + PROVIDE(_DMA1Stream0ServiceRoutine = 0); + PROVIDE(_DMA1Stream1ServiceRoutine = 0); + PROVIDE(_DMA1Stream2ServiceRoutine = 0); + PROVIDE(_DMA1Stream3ServiceRoutine = 0); + PROVIDE(_DMA1Stream4ServiceRoutine = 0); + PROVIDE(_DMA1Stream5ServiceRoutine = 0); + PROVIDE(_DMA1Stream6ServiceRoutine = 0); + .isr_vector_table ORIGIN(FLASH) : { /* When booting, the STM32F42xx fetches the content of address 0x0, and * extracts from it various key infos: the initial value of the PC register @@ -28,34 +64,31 @@ SECTIONS { * * Note that address 0x0 is always an alias. It points to the beginning of * Flash, SRAM, or integrated bootloader depending on the boot mode chosen. - * (This mode is chosen by setting BOOTn pins on the chip. + * (This mode is chosen by setting BOOTn pins on the chip). * * We're generating the ISR vector table in C, because it's very convenient: - * using function pointers, we can easily point to the service routing for + * using function pointers, we can easily point to the service routine for * each interrupt. - * See ST/RM0090/p70 for more infos. - * - * Last but not least, the ISR vector table contains pointer to functions - * that we may want to override depending on the binary we want to produce. - * The C implementation uses _NameServiceRoutine symbols. If those symbols - * are defined elsewhere, we'll use that version. If they aren't defined, we - * will provide here a default implementation (namely, calling crt0's _start - * on reset, and an infinite loop on HardFault). */ + * See ST/RM0090/p70 for more infos. */ - _ResetServiceRoutine = DEFINED(_ResetServiceRoutine) ? _ResetServiceRoutine : _start; - _NMIServiceRoutine = DEFINED(_NMIServiceRoutine) ? _NMIServiceRoutine : 0; - _HardFaultServiceRoutine = DEFINED(_HardFaultServiceRoutine) ? _HardFaultServiceRoutine : _halt; - _MemManageServiceRoutine = DEFINED(_MemManageServiceRoutine) ? _MemManageServiceRoutine : 0; - _BusFaultServiceRoutine = DEFINED(_BusFaultServiceRoutine) ? _BusFaultServiceRoutine : 0; - _SVCallServiceRoutine = DEFINED(_SVCallServiceRoutine) ? _SVCallServiceRoutine : 0; - _PendSVServiceRoutine = DEFINED(_PendSVServiceRoutine) ? _PendSVServiceRoutine : 0; - _SysTickServiceRoutine = DEFINED(_SysTickServiceRoutine) ? _SysTickServiceRoutine : 0; *(.isr_vector_table) } >FLASH + .text : { . = ALIGN(4); + + /* We have to finish defining the ISR vectors that might not have been defined + * previously. We are PROVIDing here the non-zero vectors. In other words, the + * one where we want to point to actual code. + * We're doing it here because we want those symbols to live in the .text + * section. We're simply setting the Reset vector to crt0's _start, and the + * HardFault one to crt0's _halt. */ + + PROVIDE(_ResetServiceRoutine = _start); + PROVIDE(_HardFaultServiceRoutine = _halt); + *(.text) } >FLASH