kopia lustrzana https://github.com/stlink-org/stlink
Moved set the PG flag from loader to code
rodzic
80c31a15a4
commit
2b3a31609c
|
@ -30,15 +30,9 @@ copy:
|
|||
# add r3 to flash_base for support dual bank (see flash_loader.c)
|
||||
ldr r7, flash_base
|
||||
add r7, r7, r3
|
||||
ldr r6, flash_off_cr
|
||||
add r6, r6, r7
|
||||
ldr r5, flash_off_sr
|
||||
add r5, r5, r7
|
||||
|
||||
# FLASH_CR = 0x01 (set PG)
|
||||
ldr r4, =0x1
|
||||
str r4, [r6]
|
||||
|
||||
loop:
|
||||
# copy 2 bytes
|
||||
ldrh r4, [r0]
|
||||
|
@ -68,18 +62,10 @@ wait:
|
|||
bgt loop
|
||||
|
||||
exit:
|
||||
# FLASH_CR &= ~1
|
||||
ldr r7, =0x1
|
||||
ldr r4, [r6]
|
||||
bics r4, r4, r7
|
||||
str r4, [r6]
|
||||
|
||||
bkpt
|
||||
|
||||
.align 2
|
||||
flash_base:
|
||||
.word 0x40022000
|
||||
flash_off_cr:
|
||||
.word 0x10
|
||||
flash_off_sr:
|
||||
.word 0x0c
|
||||
|
|
18
src/common.c
18
src/common.c
|
@ -3257,6 +3257,15 @@ int stlink_flashloader_start(stlink_t *sl, flash_loader_t *fl) {
|
|||
ELOG("stlink_flash_loader_init() == -1\n");
|
||||
return (-1);
|
||||
}
|
||||
|
||||
// unlock flash
|
||||
unlock_flash_if(sl);
|
||||
|
||||
// set programming mode
|
||||
set_flash_cr_pg(sl, BANK_1);
|
||||
if (sl->flash_type == STLINK_FLASH_TYPE_F1_XL) {
|
||||
set_flash_cr_pg(sl, BANK_2);
|
||||
}
|
||||
} else if (sl->flash_type == STLINK_FLASH_TYPE_H7) {
|
||||
ILOG("Starting Flash write for H7\n");
|
||||
|
||||
|
@ -3437,7 +3446,9 @@ int stlink_flashloader_write(stlink_t *sl, flash_loader_t *fl,
|
|||
int stlink_flashloader_stop(stlink_t *sl, flash_loader_t *fl) {
|
||||
uint32_t dhcsr;
|
||||
|
||||
if ((sl->flash_type == STLINK_FLASH_TYPE_F4) ||
|
||||
if ((sl->flash_type == STLINK_FLASH_TYPE_F0) ||
|
||||
(sl->flash_type == STLINK_FLASH_TYPE_F1_XL) ||
|
||||
(sl->flash_type == STLINK_FLASH_TYPE_F4) ||
|
||||
(sl->flash_type == STLINK_FLASH_TYPE_F7) ||
|
||||
(sl->flash_type == STLINK_FLASH_TYPE_L4) ||
|
||||
(sl->flash_type == STLINK_FLASH_TYPE_WB) ||
|
||||
|
@ -3446,8 +3457,9 @@ int stlink_flashloader_stop(stlink_t *sl, flash_loader_t *fl) {
|
|||
(sl->flash_type == STLINK_FLASH_TYPE_H7)) {
|
||||
|
||||
clear_flash_cr_pg(sl, BANK_1);
|
||||
if (sl->flash_type == STLINK_FLASH_TYPE_H7 &&
|
||||
sl->chip_flags & CHIP_F_HAS_DUAL_BANK) {
|
||||
if ((sl->flash_type == STLINK_FLASH_TYPE_H7 &&
|
||||
sl->chip_flags & CHIP_F_HAS_DUAL_BANK) ||
|
||||
sl->flash_type == STLINK_FLASH_TYPE_F1_XL) {
|
||||
clear_flash_cr_pg(sl, BANK_2);
|
||||
}
|
||||
lock_flash(sl);
|
||||
|
|
|
@ -19,44 +19,33 @@
|
|||
/* flashloaders/stm32f0.s -- compiled with thumb2 */
|
||||
static const uint8_t loader_code_stm32vl[] = {
|
||||
0x00, 0xbf, 0x00, 0xbf,
|
||||
0x0e, 0x4f, 0x1f, 0x44,
|
||||
0x0e, 0x4e, 0x3e, 0x44,
|
||||
0x0e, 0x4d, 0x3d, 0x44,
|
||||
0x4f, 0xf0, 0x01, 0x04,
|
||||
0x34, 0x60, 0x04, 0x88,
|
||||
0x0c, 0x80, 0x02, 0x30,
|
||||
0x02, 0x31, 0x4f, 0xf0,
|
||||
0x01, 0x07, 0x2c, 0x68,
|
||||
0x3c, 0x42, 0xfc, 0xd1,
|
||||
0x4f, 0xf0, 0x14, 0x07,
|
||||
0x3c, 0x42, 0x01, 0xd1,
|
||||
0x02, 0x3a, 0xf0, 0xdc,
|
||||
0x09, 0x4f, 0x1f, 0x44,
|
||||
0x09, 0x4d, 0x3d, 0x44,
|
||||
0x04, 0x88, 0x0c, 0x80,
|
||||
0x02, 0x30, 0x02, 0x31,
|
||||
0x4f, 0xf0, 0x01, 0x07,
|
||||
0x34, 0x68, 0xbc, 0x43,
|
||||
0x34, 0x60, 0x00, 0xbe,
|
||||
0x2c, 0x68, 0x3c, 0x42,
|
||||
0xfc, 0xd1, 0x4f, 0xf0,
|
||||
0x14, 0x07, 0x3c, 0x42,
|
||||
0x01, 0xd1, 0x02, 0x3a,
|
||||
0xf0, 0xdc, 0x00, 0xbe,
|
||||
0x00, 0x20, 0x02, 0x40,
|
||||
0x10, 0x00, 0x00, 0x00,
|
||||
0x0c, 0x00, 0x00, 0x00
|
||||
};
|
||||
|
||||
/* flashloaders/stm32f0.s -- thumb1 only, same sequence as for STM32VL, bank ignored */
|
||||
static const uint8_t loader_code_stm32f0[] = {
|
||||
0xc0, 0x46, 0xc0, 0x46,
|
||||
0x0c, 0x4f, 0x1f, 0x44,
|
||||
0x0c, 0x4e, 0x3e, 0x44,
|
||||
0x0c, 0x4d, 0x3d, 0x44,
|
||||
0x0c, 0x4c, 0x34, 0x60,
|
||||
0x08, 0x4f, 0x1f, 0x44,
|
||||
0x08, 0x4d, 0x3d, 0x44,
|
||||
0x04, 0x88, 0x0c, 0x80,
|
||||
0x02, 0x30, 0x02, 0x31,
|
||||
0x09, 0x4f, 0x2c, 0x68,
|
||||
0x06, 0x4f, 0x2c, 0x68,
|
||||
0x3c, 0x42, 0xfc, 0xd1,
|
||||
0x08, 0x4f, 0x3c, 0x42,
|
||||
0x05, 0x4f, 0x3c, 0x42,
|
||||
0x01, 0xd1, 0x02, 0x3a,
|
||||
0xf2, 0xdc, 0x05, 0x4f,
|
||||
0x34, 0x68, 0xbc, 0x43,
|
||||
0x34, 0x60, 0x00, 0xbe,
|
||||
0xf2, 0xdc, 0x00, 0xbe,
|
||||
0x00, 0x20, 0x02, 0x40,
|
||||
0x10, 0x00, 0x00, 0x00,
|
||||
0x0c, 0x00, 0x00, 0x00,
|
||||
0x01, 0x00, 0x00, 0x00,
|
||||
0x14, 0x00, 0x00, 0x00
|
||||
|
|
Ładowanie…
Reference in New Issue