;****************************************************************************** ; ; The reset handler, which gets called when the processor starts. ; ;****************************************************************************** export Reset_Handler Reset_Handler ; ; Initialize the processor. ; bl ProcessorInit
; ; Branch to the SRAM copy of the reset handler. ; ldr pc, =Reset_Handler_In_SRAM
;****************************************************************************** ; ; Initialize the processor by copying the boot loader from flash to SRAM, zero ; filling the .bss section, and moving the vector table to the beginning of ; SRAM. The return address is modified to point to the SRAM copy of the boot ; loader instead of the flash copy, resulting in a branch to the copy now in ; SRAM. ; ;****************************************************************************** export ProcessorInit ProcessorInit ; ; Copy the code image from flash to SRAM. ; if :def:_FLASH_PATCH_COMPATIBLE movs r0, #0x1000 else movs r0, #0x0000 endif movs r1, #0x0000 movt r1, #0x2000 import ||Image$$SRAM$$ZI$$Base|| ldr r2, =||Image$$SRAM$$ZI$$Base|| copy_loop ldr r3, [r0], #4 str r3, [r1], #4 cmp r1, r2 blt copy_loop
; ; Zero fill the .bss section. ; movs r0, #0x0000 import ||Image$$SRAM$$ZI$$Limit|| ldr r2, =||Image$$SRAM$$ZI$$Limit|| zero_loop str r0, [r1], #4 cmp r1, r2 blt zero_loop
; ; Set the vector table pointer to the beginning of SRAM. ; movw r0, #(NVIC_VTABLE & 0xffff) movt r0, #(NVIC_VTABLE >> 16) movs r1, #0x0000 movt r1, #0x2000 str r1, [r0]
; ; Return to the caller. ; bx lr |