Skip to content

Commit 1412f8a

Browse files
committed
Add PICO_MINIMAL_VECTOR_TABLE option
Creates vector tables which only contains NMI and HardFault vectors, and a single bkpt instruction for them to point to
1 parent c54475d commit 1412f8a

File tree

1 file changed

+13
-0
lines changed
  • src/rp2_common/pico_crt0

1 file changed

+13
-0
lines changed

src/rp2_common/pico_crt0/crt0.S

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,11 +26,21 @@ pico_default_asm_setup
2626
.section .vectors, "ax"
2727
.align 2
2828

29+
// PICO_CONFIG: PICO_MINIMAL_VECTOR_TABLE, Use Minimal Vector Table - this prevents use of all interrupts, type=bool, default=0, advanced=true, group=pico_crt0
30+
#ifndef PICO_MINIMAL_VECTOR_TABLE
31+
#define PICO_MINIMAL_VECTOR_TABLE 0
32+
#endif
33+
2934
.global __vectors, __VECTOR_TABLE
3035
__VECTOR_TABLE:
3136
__vectors:
3237
.word __StackTop
3338
.word _reset_handler
39+
40+
#if PICO_MINIMAL_VECTOR_TABLE
41+
.word isr_invalid // NMI
42+
.word isr_invalid // HardFault
43+
#else
3444
.word isr_nmi
3545
.word isr_hardfault
3646
.word isr_invalid // Reserved, should never fire
@@ -146,6 +156,7 @@ if_irq_word 79 isr_irq79
146156
#error more IRQ entries required
147157
#endif
148158
#endif
159+
#endif // #if !PICO_MINIMAL_VECTOR_TABLE
149160

150161
// all default exception handlers do nothing, and we can check for them being set to our
151162
// default values by seeing if they point to somewhere between __defaults_isrs_start and __default_isrs_end
@@ -166,6 +177,7 @@ __default_isrs_start:
166177

167178
// these are separated out for clarity
168179
decl_isr_bkpt isr_invalid
180+
#if !PICO_MINIMAL_VECTOR_TABLE
169181
decl_isr_bkpt isr_nmi
170182
decl_isr_bkpt isr_hardfault
171183
decl_isr_bkpt isr_svcall
@@ -287,6 +299,7 @@ __unhandled_user_irq:
287299
.global unhandled_user_irq_num_in_r0
288300
unhandled_user_irq_num_in_r0:
289301
bkpt #0
302+
#endif // #if !PICO_MINIMAL_VECTOR_TABLE
290303

291304
// ----------------------------------------------------------------------------
292305

0 commit comments

Comments
 (0)