rp2040

RP2040 Programming without SDK
Log | Files | Refs

boot2.s (737B)


      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 	// load main program to sram
     15 	ldr r0, =text_start
     16 	ldr r1, =text_size
     17 	mov r2, #0
     18 	ldr r3, sram_base
     19 copy:
     20 	cmp r1, r2
     21 	beq end
     22 	ldr r4, [r0, r2]
     23 	str r4, [r3, r2]
     24 	add r2, #4
     25 	b copy
     26 end:
     27 
     28 	// setup vector table
     29 	ldr r0, =vectors
     30 	ldr r1, m0plus_vtor 
     31 	str r0, [r1, #0] // M0PLUS: VTOR
     32 	ldr r1, [r0, #4] // entry point
     33 	ldr r0, [r0, #0] // stack pointer
     34 	mov sp, r0
     35 	bx r1
     36 
     37 	.align 2
     38 rom_base:
     39 	.word 0x00000000
     40 sram_base:
     41 	.word 0x20000000
     42 m0plus_vtor:
     43 	.word 0xe0000000 + 0xed08
     44 literals:
     45 	.ltorg
     46