You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: src/rp2_common/pico_crt0/crt0.S
+20-6Lines changed: 20 additions & 6 deletions
Original file line number
Diff line number
Diff line change
@@ -15,6 +15,11 @@
15
15
#include "boot/picobin.h"
16
16
#include "pico/bootrom.h"
17
17
18
+
// PICO_CONFIG: PICO_CRT0_NEAR_CALLS, Whether calls from crt0 into the binary are near (<16M away) - ignored for PICO_COPY_TO_RAM, default=0, type=bool, group=pico_crt0
19
+
#ifndef PICO_CRT0_NEAR_CALLS
20
+
#define PICO_CRT0_NEAR_CALLS 0
21
+
#endif
22
+
18
23
#ifdef NDEBUG
19
24
#ifndef COLLAPSE_IRQS
20
25
#define COLLAPSE_IRQS
@@ -377,6 +382,12 @@ _entry_point:
377
382
sev
378
383
1:
379
384
#endif
385
+
#if !__ARM_ARCH_6M__
386
+
// Make sure stack limit is 0 if we came in thru the debugger; we do not know what it should be
387
+
movs r0, #0
388
+
msr msplim, r0
389
+
#endif
390
+
380
391
ldr r0, =__vectors
381
392
// Vector through our own table (SP, VTOR will not have been set upat
382
393
// this point). Same path for debugger entry and bootloader entry.
@@ -403,6 +414,9 @@ _enter_vtable_in_r0:
403
414
.type _reset_handler,%function
404
415
.thumb_func
405
416
_reset_handler:
417
+
// Note if we entered thru here on core 0, then we should have gone thru bootrom, so SP (and MSPLIM) on Armv8-M
418
+
// should already be set
419
+
406
420
// Only core 0 should run the C runtime startup code; core 1 is normally
407
421
// sleeping in the bootromatthis point but check to be sure (e.g. if
408
422
// debugger put core 1atthe ELF entry point for some reason)
@@ -465,20 +479,20 @@ bss_fill_test:
465
479
bne bss_fill_loop
466
480
467
481
platform_entry: // symbol for stack traces
482
+
#if PICO_CRT0_NEAR_CALLS && !PICO_COPY_TO_RAM
483
+
bl runtime_init
484
+
bl main
485
+
bl exit
486
+
#else
468
487
// Use 32-bit jumps,in case these symbols are moved out of branch range
469
488
// (e.g. if main is in SRAM and crt0 in flash)
470
-
#if !__ARM_ARCH_6M__
471
-
// Make sure stack limit is 0- the user can set it themselves
472
-
// todo probably worth adding to the EXE_DEF in the future
473
-
movs r0, #0
474
-
msr msplim, r0
475
-
#endif
476
489
ldr r1, =runtime_init
477
490
blx r1
478
491
ldr r1, =main
479
492
blx r1
480
493
ldr r1, =exit
481
494
blx r1
495
+
#endif
482
496
// exit should not return. If it does, hang the core.
483
497
1: // separate label because _exit can be moved out of branch range
0 commit comments