boot2.s (962B)
1 .cpu cortex-m0plus 2 .thumb 3 4 .section .boot2 5 boot2: 6 // setup xip 7 ldr r3, rom_base 8 ldrh r0, [r3, #0x14] // rom_func_table 9 ldr r1, =('C' | 'X' << 8) // _flash_enter_cmd_xip() 10 ldrh r2, [r3, #0x18] // rom_table_lookup 11 blx r2 12 blx r0 13 14 // Clear sram contents for debugging. 15 mov r0, #0 16 ldr r3, sram_base 17 ldr r4, sram_end 18 mem_clear_loop: 19 str r0, [r3, #0] 20 add r3, #4 21 cmp r3, r4 22 blt mem_clear_loop 23 24 // load main program to sram 25 ldr r0, =prog_start 26 ldr r1, =prog_size 27 mov r2, #0 28 ldr r3, sram4_base 29 copy: 30 cmp r1, r2 31 blt end 32 ldr r4, [r0, r2] 33 str r4, [r3, r2] 34 add r2, #4 35 b copy 36 end: 37 38 // setup vector table 39 ldr r0, =vectors 40 ldr r1, m0plus_vtor 41 str r0, [r1, #0] // M0PLUS: VTOR 42 ldr r1, [r0, #4] // entry point 43 ldr r0, [r0, #0] // stack pointer 44 mov sp, r0 45 bx r1 46 47 .align 2 48 rom_base: 49 .word 0x00000000 50 sram_base: 51 .word 0x20000000 52 sram4_base: 53 .word 0x20040000 54 sram_end: 55 .word 0x20042000 56 m0plus_vtor: 57 .word 0xe0000000 + 0xed08 58 literals: 59 .ltorg 60