forked from majbthrd/pico-debug
-
Notifications
You must be signed in to change notification settings - Fork 0
/
picodebug_Startup.s
156 lines (138 loc) · 3.96 KB
/
picodebug_Startup.s
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
/*
* The MIT License (MIT)
*
* Copyright (c) 2021 Peter Lawrence
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
/* this code was tweaked specifically for pico-debug; it is *NOT* a generic crt implementation */
.macro ISR_HANDLER name=
.section .vectors, "ax"
.word \name
.endm
.macro ISR_RESERVED
.section .vectors, "ax"
.word 0
.endm
.macro ISR_UNUSED name=
.section .vectors, "ax"
.word exit_handler
.endm
.syntax unified
.global boot_entry
.extern main
.extern multicore_launch_core1_raw
.global exit
.weak exit
.section .boot, "ax"
.thumb_func
boot_entry:
#ifndef STAY_IN_SRAM
/* disable flash cache (allowing XIP_SRAM access) */
ldr r0, =0x14000000
ldr r1, =0
str r1, [r0]
/* undocumented step to ensure XIP_SRAM is ready for accesses */
ldr r1, [r0, #4]
#endif
ldr r0, =__SRAM_segment_end__
mov sp, r0
bl SystemInit
ldr r2, =__vectors_start__ /* origin of where vector table now resides */
ldr r1, [r2] /* load stack pointer from user app */
ldr r0, [r2, #4] /* load reset address from user app */
ldr r3, =multicore_launch_core1_raw
blx r3
sleep:
wfi
b sleep
.section .vectors, "ax"
.code 16
.global _vectors
.align 8
_vectors:
.word __stack_end__
.word reset_handler
ISR_UNUSED NMI_Handler
ISR_UNUSED HardFault_Handler
ISR_UNUSED MemManage_Handler
ISR_UNUSED BusFault_Handler
ISR_UNUSED UsageFault_Handler
ISR_RESERVED
ISR_RESERVED
ISR_RESERVED
ISR_RESERVED
ISR_UNUSED SVC_Handler
ISR_UNUSED DebugMon_Handler
ISR_RESERVED
ISR_UNUSED PendSV_Handler
ISR_UNUSED SysTick_Handler
ISR_UNUSED TIMER0_IRQHandler
ISR_UNUSED TIMER1_IRQHandler
ISR_UNUSED TIMER2_IRQHandler
ISR_UNUSED TIMER3_IRQHandler
ISR_UNUSED PWM_IRQHandler
ISR_HANDLER USB_IRQHandler
ISR_UNUSED XIP_IRQHandler
ISR_UNUSED PIO0_0_IRQHandler
ISR_UNUSED PIO0_1_IRQHandler
ISR_UNUSED PIO1_0_IRQHandler
ISR_UNUSED PIO1_1_IRQHandler
ISR_UNUSED DMA0_IRQHandler
ISR_UNUSED DMA1_IRQHandler
ISR_UNUSED IO_IRQHandler
ISR_UNUSED QSPI_IRQHandler
ISR_UNUSED SIO0_IRQHandler
ISR_UNUSED SIO1_IRQHandler
ISR_UNUSED CLOCKS_Handler
ISR_UNUSED SPI0_Handler
ISR_UNUSED SPI1_IRQHandler
ISR_UNUSED UART0_IRQHandler
ISR_UNUSED UART1_Handler
ISR_UNUSED ADC_Handler
ISR_UNUSED I2C0_IRQHandler
ISR_UNUSED I2C1_IRQHandler
ISR_UNUSED RTC_IRQHandler
.thumb_func
reset_handler:
/* zero-ize the bss */
ldr r0, =__bss_start__
ldr r1, =__bss_end__
movs r2, #0
bss_loop:
cmp r0, r1
beq bss_finished
strb r2, [r0]
adds r0, r0, #1
b bss_loop
bss_finished:
/* Setup initial call frame */
movs r0, #0
mov lr, r0
mov r12, sp
/* jump to app entry point */
ldr r2, =main
blx r2
.thumb_func
exit:
/* handler if app returned or unexpected IRQ happened */
exit_handler:
b exit_handler
/* Setup attributes of stack section so that it doesn't take up room in the elf file */
.section .stack, "wa", %nobits