stlink/flashloaders/stm32l4.s

49 wiersze
719 B
ArmAsm

2020-04-24 08:59:47 +00:00
.syntax unified
.text
2015-07-20 19:15:25 +00:00
/*
* Arguments:
* r0 - source memory ptr
* r1 - target memory ptr
* r2 - count of bytes
* r3 - flash register offset
*/
2020-04-29 14:40:06 +00:00
.global copy
copy:
2020-04-24 08:59:47 +00:00
ldr r12, flash_base
ldr r10, flash_off_sr
2020-04-24 08:59:47 +00:00
add r10, r10, r12
2015-07-20 19:15:25 +00:00
2020-04-29 14:40:06 +00:00
loop:
2020-04-24 08:59:47 +00:00
# copy 8 bytes
ldr r5, [r0]
2020-04-24 08:59:47 +00:00
ldr r4, [r0, #4]
str r5, [r1]
2020-04-24 08:59:47 +00:00
str r4, [r1, #4]
2015-07-20 19:15:25 +00:00
# increment address
2020-04-24 08:59:47 +00:00
add r0, r0, #8
add r1, r1, #8
2015-07-20 19:15:25 +00:00
2020-05-22 13:11:43 +00:00
wait:
# get FLASH_SR
ldr r4, [r10]
# wait until BUSY flag is reset
tst r4, #0x10000
bne wait
# loop if count > 0
subs r2, r2, #8
bgt loop
2015-07-20 19:15:25 +00:00
2020-04-29 14:40:06 +00:00
exit:
2020-04-24 08:59:47 +00:00
bkpt
2015-07-20 19:15:25 +00:00
2020-04-24 08:59:47 +00:00
.align 2
2020-04-25 06:08:58 +00:00
flash_base:
2015-07-20 19:15:25 +00:00
.word 0x40022000
flash_off_sr:
.word 0x10