kopia lustrzana https://github.com/stlink-org/stlink
stlink-common: Update STM32L0/1 loaders to return remaining count in r2
All the loaders returns remaining work count in r2, except stm32l0/1. Make these loaders behaving as the others to simplify run_flash_loader() code. Signed-off-by: Maxime Coquelin <mcoquelin.stm32@gmail.com>pull/384/head
rodzic
907383da8e
commit
e43a737c3c
|
@ -39,26 +39,24 @@
|
|||
r2 - count
|
||||
*/
|
||||
|
||||
// Set 0 to r3
|
||||
movs r3, #0
|
||||
// Go to compare
|
||||
b.n test_done
|
||||
b test_done
|
||||
|
||||
write_word:
|
||||
// Load one word from address in r0, increment by 4
|
||||
ldr r4, [r0]
|
||||
// Store the word to address in r1, increment by 4
|
||||
str r4, [r1]
|
||||
// Increment r3
|
||||
adds r3, #1
|
||||
// Decrement r2
|
||||
subs r2, #1
|
||||
adds r1, #4
|
||||
// does not matter, only first addr is important
|
||||
// next 15 bytes are in sequnce RM0367 page 66
|
||||
adds r0, #4
|
||||
|
||||
test_done:
|
||||
// Compare r3 and r2
|
||||
cmp r3, r2
|
||||
// Test r2
|
||||
cmp r2, #0
|
||||
// Loop if not zero
|
||||
bcc.n write_word
|
||||
|
||||
|
|
|
@ -39,22 +39,20 @@
|
|||
r2 - count
|
||||
*/
|
||||
|
||||
// Set 0 to r3
|
||||
movs r3, #0
|
||||
// Go to compare
|
||||
b.n test_done
|
||||
b test_done
|
||||
|
||||
write_word:
|
||||
// Load one word from address in r0, increment by 4
|
||||
ldr.w ip, [r0], #4
|
||||
// Store the word to address in r1, increment by 4
|
||||
str.w ip, [r1], #4
|
||||
// Increment r3
|
||||
adds r3, #1
|
||||
// Decrement r2
|
||||
subs r2, #1
|
||||
|
||||
test_done:
|
||||
// Compare r3 and r2
|
||||
cmp r3, r2
|
||||
// Test r2
|
||||
cmp r2, #0
|
||||
// Loop if not zero
|
||||
bcc.n write_word
|
||||
|
||||
|
|
|
@ -1504,17 +1504,16 @@ int write_loader_to_sram(stlink_t *sl, stm32_addr_t* addr, size_t* size) {
|
|||
r0, input, source addr
|
||||
r1, input, dest addr
|
||||
r2, input, word count
|
||||
r3, output, word count
|
||||
r2, output, remaining word count
|
||||
*/
|
||||
|
||||
0x00, 0x23,
|
||||
0x04, 0xe0,
|
||||
|
||||
0x50, 0xf8, 0x04, 0xcb,
|
||||
0x41, 0xf8, 0x04, 0xcb,
|
||||
0x01, 0x33,
|
||||
0x01, 0x3a,
|
||||
|
||||
0x93, 0x42,
|
||||
0x00, 0x2a,
|
||||
0xf8, 0xd3,
|
||||
0x00, 0xbe
|
||||
};
|
||||
|
@ -1525,19 +1524,18 @@ int write_loader_to_sram(stlink_t *sl, stm32_addr_t* addr, size_t* size) {
|
|||
r0, input, source addr
|
||||
r1, input, dest addr
|
||||
r2, input, word count
|
||||
r3, output, word count
|
||||
r2, output, remaining word count
|
||||
*/
|
||||
|
||||
0x00, 0x23,
|
||||
0x04, 0xe0,
|
||||
|
||||
0x04, 0x68,
|
||||
0x0c, 0x60,
|
||||
0x01, 0x33,
|
||||
0x01, 0x3a,
|
||||
0x04, 0x31,
|
||||
0x04, 0x30,
|
||||
|
||||
0x93, 0x42,
|
||||
0x00, 0x2a,
|
||||
0xf8, 0xd3,
|
||||
0x00, 0xbe
|
||||
};
|
||||
|
@ -2117,19 +2115,11 @@ int run_flash_loader(stlink_t *sl, flash_loader_t* fl, stm32_addr_t target, cons
|
|||
return -1;
|
||||
}
|
||||
|
||||
stlink_read_all_regs(sl, &rr);
|
||||
|
||||
/* check written byte count */
|
||||
if (sl->flash_type == FLASH_TYPE_L0) {
|
||||
if (rr.r[3] != count) {
|
||||
fprintf(stderr, "write error, count == %u\n", rr.r[3]);
|
||||
return -1;
|
||||
}
|
||||
} else {
|
||||
if (rr.r[2] != 0) {
|
||||
fprintf(stderr, "write error, count == %u\n", rr.r[2]);
|
||||
return -1;
|
||||
}
|
||||
stlink_read_all_regs(sl, &rr);
|
||||
if (rr.r[2] != 0) {
|
||||
fprintf(stderr, "write error, count == %u\n", rr.r[2]);
|
||||
return -1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
|
Ładowanie…
Reference in New Issue