diff --git a/src/rp2_common/cmsis/include/cmsis/rename_exceptions.h b/src/rp2_common/cmsis/include/cmsis/rename_exceptions.h index 0db37f4ca..5ab49e824 100644 --- a/src/rp2_common/cmsis/include/cmsis/rename_exceptions.h +++ b/src/rp2_common/cmsis/include/cmsis/rename_exceptions.h @@ -52,7 +52,12 @@ #if PICO_RP2350 #define isr_nmi NMI_Handler #define isr_hardfault HardFault_Handler +#define isr_memmanage MemManage_Handler +#define isr_busfault BusFault_Handler +#define isr_usagefault UsageFault_Handler +#define isr_securefault SecureFault_Handler #define isr_svcall SVC_Handler +#define isr_debugmonitor DebugMon_Handler #define isr_pendsv PendSV_Handler #define isr_systick SysTick_Handler #define isr_irq0 TIMER0_IRQ_0_Handler diff --git a/src/rp2_common/pico_crt0/crt0.S b/src/rp2_common/pico_crt0/crt0.S index 3e6c692d8..43ce5ed34 100644 --- a/src/rp2_common/pico_crt0/crt0.S +++ b/src/rp2_common/pico_crt0/crt0.S @@ -52,15 +52,26 @@ __vectors: #else .word isr_nmi .word isr_hardfault +#if PICO_RP2040 .word isr_invalid // Reserved, should never fire .word isr_invalid // Reserved, should never fire .word isr_invalid // Reserved, should never fire .word isr_invalid // Reserved, should never fire +#else +.word isr_memmanage +.word isr_busfault +.word isr_usagefault +.word isr_securefault +#endif .word isr_invalid // Reserved, should never fire .word isr_invalid // Reserved, should never fire .word isr_invalid // Reserved, should never fire .word isr_svcall +#if PICO_RP2040 .word isr_invalid // Reserved, should never fire +#else +.word isr_debugmonitor +#endif .word isr_invalid // Reserved, should never fire .word isr_pendsv .word isr_systick @@ -287,8 +298,20 @@ if_irq_decl 79 isr_irq79 #if PICO_NUM_VTABLE_IRQS > 80 #error more IRQ entries required #endif +#if !PICO_RP2040 +// since these are disabled by default, map them all to __unhandled_user_irq (will have +// a negative number +decl_isr isr_memmanage +decl_isr isr_busfault +decl_isr isr_usagefault +decl_isr isr_securefault +decl_isr isr_debugmonitor +#endif -// All unhandled USER IRQs fall through to here +// All unhandled USER IRQs fall through to here. +// Additionally, if the Armv9-M MemManage/BusFault/UsageFault/SecureFault/DebugMonitor exceptions +// are enabled, but the handlers are not defined, then unhandled_user_irq_num_in_r0 will +// also be reached, but with a negative exception number (e.g. MemManage == -12) .global __unhandled_user_irq .thumb_func __unhandled_user_irq: @@ -305,7 +328,7 @@ unhandled_user_irq_num_in_r0: decl_isr_bkpt isr_invalid #if !PICO_MINIMAL_STORED_VECTOR_TABLE -// these are separated out for clarity +// these are separated out into individual BKPT instructions with label for clarity decl_isr_bkpt isr_nmi decl_isr_bkpt isr_hardfault decl_isr_bkpt isr_svcall