1/* 2 * Copyright (c) 2022 ASR Microelectronics (Shanghai) Co., Ltd. All rights reserved. 3 * Licensed under the Apache License, Version 2.0 (the "License"); 4 * you may not use this file except in compliance with the License. 5 * You may obtain a copy of the License at 6 * 7 * http://www.apache.org/licenses/LICENSE-2.0 8 * 9 * Unless required by applicable law or agreed to in writing, software 10 * distributed under the License is distributed on an "AS IS" BASIS, 11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 * See the License for the specific language governing permissions and 13 * limitations under the License. 14 */ 15 16/************************** startup_cm4.s **********************************************/ 17 .syntax unified 18 .cpu cortex-m4 19 .fpu softvfp 20 .thumb 21 22.global g_pfnVectors 23.global Default_Handler 24 25/* start address for the initialization values of the .data section. 26defined in linker script */ 27.word _sidata 28/* start address for the .data section. defined in linker script */ 29.word _sdata 30/* end address for the .data section. defined in linker script */ 31.word _edata 32/* start address for the initialization values of the .func section. 33defined in linker script */ 34.word _sifunc 35/* start address for the .func section. defined in linker script */ 36.word _sfunc 37/* end address for the .func section. defined in linker script */ 38.word _efunc 39/* start address for the .bss section. defined in linker script */ 40.word _sbss 41/* end address for the .bss section. defined in linker script */ 42.word _ebss 43/* stack used for SystemInit_ExtMemCtl; always internal RAM used */ 44 45/** 46 * @brief This is the code that gets called when the processor first 47 * starts execution following a reset event. Only the absolutely 48 * necessary set is performed, after which the application 49 * supplied main() routine is called. 50 * @param None 51 * @retval : None 52*/ 53 54 .section .text.Reset_Handler 55 .weak Reset_Handler 56 .type Reset_Handler, %function 57Reset_Handler: 58 59/* Set memory map */ 60 movs r1, #0x18 61 movs r2, #0x40000000 62 str r1, [r2,#0x2C] 63 64/* Copy the data segment initializers from flash to SRAM */ 65 movs r1, #0 66 b LoopCopyDataInit 67 68CopyDataInit: 69 ldr r3, =_sidata 70 ldr r3, [r3, r1] 71 str r3, [r0, r1] 72 adds r1, r1, #4 73 74LoopCopyDataInit: 75 ldr r0, =_sdata 76 ldr r3, =_edata 77 adds r2, r0, r1 78 cmp r2, r3 79 bcc CopyDataInit 80 movs r1, #0 81 b LoopCopyFuncInit 82 83CopyFuncInit: 84 ldr r3, =_sifunc 85 ldr r3, [r3, r1] 86 str r3, [r0, r1] 87 adds r1, r1, #4 88 89LoopCopyFuncInit: 90 ldr r0, =_sfunc 91 ldr r3, =_efunc 92 adds r2, r0, r1 93 cmp r2, r3 94 bcc CopyFuncInit 95 ldr r2, =_sbss 96 b LoopFillZerobss 97/* Zero fill the bss segment. */ 98FillZerobss: 99 movs r3, #0 100 str r3, [r2], #4 101 102LoopFillZerobss: 103 ldr r3, = _ebss 104 cmp r2, r3 105 bcc FillZerobss 106 107/* Call the clock system intitialization function. */ 108 bl SystemInit 109/* Call static constructors */ 110 /* bl __libc_init_array */ 111/* Call the application's entry point. */ 112 bl main 113 bx lr 114.size Reset_Handler, .-Reset_Handler 115 116/** 117 * @brief This is the code that gets called when the processor receives an 118 * unexpected interrupt. This simply enters an infinite loop, preserving 119 * the system state for examination by a debugger. 120 * @param None 121 * @retval None 122*/ 123 .section .text.Default_Handler,"ax",%progbits 124Default_Handler: 125Infinite_Loop: 126 b Infinite_Loop 127 .size Default_Handler, .-Default_Handler 128/****************************************************************************** 129* 130* The minimal vector table for a Cortex M3. Note that the proper constructs 131* must be placed on this to ensure that it ends up at physical address 132* 0x0000.0000. 133* 134*******************************************************************************/ 135 .section .isr_vector,"a",%progbits 136 .type g_pfnVectors, %object 137 .size g_pfnVectors, .-g_pfnVectors 138 139g_pfnVectors: 140 .word _estack 141 .word Reset_Handler 142 .word NMI_Handler 143 .word HardFault_Handler 144 .word MemManage_Handler 145 .word BusFault_Handler 146 .word UsageFault_Handler 147 .word 0 148 .word 0 149 .word 0 150 .word 0 151 .word SVC_Handler 152 .word DebugMon_Handler 153 .word 0 154 .word PendSV_Handler 155 .word SysTick_Handler 156 157 /* External Interrupts */ 158 .word intc_irq /* WIFI Interrupt */ 159 .word SLEEP_IRQHandler /* Sleep Wake-Up Interrupt */ 160 .word WDG_IRQHandler /* Window WatchDog */ 161 .word FLASH_IRQHandler /* FLASH */ 162 .word GPIO_IRQHandler /* GPIO */ 163 .word TIMER_IRQHandler /* Timer interrupt */ 164 .word CRYPTOCELL310_IRQHandler /* CryptoCell 310 Interrupt */ 165 .word DMA_IRQHandler /* Generic DMA Ctrl Interrupt */ 166 .word UART0_IRQHandler /* UART0 Interrupt */ 167 .word UART1_IRQHandler /* UART1 Interrupt */ 168 .word UART2_IRQHandler /* UART2 Interrupt */ 169 .word SPI0_IRQHandler /* SPI0 */ 170 .word SPI1_IRQHandler /* SPI1 */ 171 .word SPI2_IRQHandler /* SPI2 */ 172 .word I2C0_IRQHandler /* I2C0 */ 173 .word I2C1_IRQHandler /* I2C1 */ 174 .word SDIO_IRQHandler /* SDIO Combined Interrupt */ 175 .word D_APLL_UNLOCK_IRQHandler /* RF added: D_APLL_UNLOCK */ 176 .word D_SX_UNLOCK_IRQHandler /* RF added: D_SX_UNLOCK */ 177 .word 0x00000000 178 .word AUX_ADC_IRQHandler /* AUX ADC Interrupt */ 179 .word 0x00000000 180 .word 0x00000000 181 .word PLATFORM_WAKEUP_IRQHandler /* !< WiFi SOC Wake-Up Interrupt */ 182 .word I2S_IRQHandler /* I2S */ 183 .word BLE_IRQHandler /* BLE Interrupt */ 184 185/******************************************************************************* 186* 187* Provide weak aliases for each Exception handler to the Default_Handler. 188* As they are weak aliases, any function with the same name will override 189* this definition. 190* 191*******************************************************************************/ 192 .weak NMI_Handler 193 .thumb_set NMI_Handler,Default_Handler 194 195 .weak HardFault_Handler 196 .thumb_set HardFault_Handler,Default_Handler 197 198 .weak MemManage_Handler 199 .thumb_set MemManage_Handler,Default_Handler 200 201 .weak BusFault_Handler 202 .thumb_set BusFault_Handler,Default_Handler 203 204 .weak UsageFault_Handler 205 .thumb_set UsageFault_Handler,Default_Handler 206 207 .weak SVC_Handler 208 .thumb_set SVC_Handler,Default_Handler 209 210 .weak DebugMon_Handler 211 .thumb_set DebugMon_Handler,Default_Handler 212 213 .weak PendSV_Handler 214 .thumb_set PendSV_Handler,Default_Handler 215 216 .weak SysTick_Handler 217 .thumb_set SysTick_Handler,Default_Handler 218 219 .weak intc_irq 220 .thumb_set intc_irq,Default_Handler 221 222 .weak SLEEP_IRQHandler 223 .thumb_set SLEEP_IRQHandler,Default_Handler 224 225 .weak WDG_IRQHandler 226 .thumb_set WDG_IRQHandler,Default_Handler 227 228 .weak FLASH_IRQHandler 229 .thumb_set FLASH_IRQHandler,Default_Handler 230 231 .weak GPIO_IRQHandler 232 .thumb_set GPIO_IRQHandler,Default_Handler 233 234 .weak TIMER_IRQHandler 235 .thumb_set TIMER_IRQHandler,Default_Handler 236 237 .weak CRYPTOCELL310_IRQHandler 238 .thumb_set CRYPTOCELL310_IRQHandler,Default_Handler 239 240 .weak DMA_IRQHandler 241 .thumb_set DMA_IRQHandler,Default_Handler 242 243 .weak UART0_IRQHandler 244 .thumb_set UART0_IRQHandler,Default_Handler 245 246 .weak UART1_IRQHandler 247 .thumb_set UART1_IRQHandler,Default_Handler 248 249 .weak UART2_IRQHandler 250 .thumb_set UART2_IRQHandler,Default_Handler 251 252 .weak SPI0_IRQHandler 253 .thumb_set SPI0_IRQHandler,Default_Handler 254 255 .weak SPI1_IRQHandler 256 .thumb_set SPI1_IRQHandler,Default_Handler 257 258 .weak SPI2_IRQHandler 259 .thumb_set SPI2_IRQHandler,Default_Handler 260 261 .weak I2C0_IRQHandler 262 .thumb_set I2C0_IRQHandler,Default_Handler 263 264 .weak I2C1_IRQHandler 265 .thumb_set I2C1_IRQHandler,Default_Handler 266 267 .weak SDIO_IRQHandler 268 .thumb_set SDIO_IRQHandler,Default_Handler 269 270 .weak D_APLL_UNLOCK_IRQHandler 271 .thumb_set D_APLL_UNLOCK_IRQHandler,Default_Handler 272 273 .weak D_SX_UNLOCK_IRQHandler 274 .thumb_set D_SX_UNLOCK_IRQHandler,Default_Handler 275 276 .weak AUX_ADC_IRQHandler 277 .thumb_set AUX_ADC_IRQHandler,Default_Handler 278 .weak PLATFORM_WAKEUP_IRQHandler 279 .thumb_set PLATFORM_WAKEUP_IRQHandler,Default_Handler 280 281 .weak I2S_IRQHandler 282 .thumb_set I2S_IRQHandler,Default_Handler 283 284 .weak BLE_IRQHandler 285 .thumb_set BLE_IRQHandler,Default_Handler 286 287/*****************END OF FILE*********************/ 288