Minor fixes to stm32f1 flash routines.
This commit is contained in:
parent
fad6eb3c14
commit
f06bc0fd79
@ -228,7 +228,7 @@ static int stm32f1_flash_erase(struct target_s *target, uint32_t addr, int len,
|
|||||||
uint16_t sr;
|
uint16_t sr;
|
||||||
|
|
||||||
addr &= ~(pagesize - 1);
|
addr &= ~(pagesize - 1);
|
||||||
len &= ~(pagesize - 1);
|
len = (len + pagesize - 1) & ~(pagesize - 1);
|
||||||
|
|
||||||
stm32f1_flash_unlock(ap);
|
stm32f1_flash_unlock(ap);
|
||||||
|
|
||||||
@ -273,6 +273,8 @@ static int stm32f1_flash_write(struct target_s *target, uint32_t dest,
|
|||||||
ADIv5_AP_t *ap = adiv5_target_ap(target);
|
ADIv5_AP_t *ap = adiv5_target_ap(target);
|
||||||
uint32_t offset = dest % 4;
|
uint32_t offset = dest % 4;
|
||||||
uint32_t words = (offset + len + 3) / 4;
|
uint32_t words = (offset + len + 3) / 4;
|
||||||
|
if (words > 256)
|
||||||
|
return -1;
|
||||||
uint32_t data[2 + words];
|
uint32_t data[2 + words];
|
||||||
|
|
||||||
/* Construct data buffer used by stub */
|
/* Construct data buffer used by stub */
|
||||||
@ -284,7 +286,7 @@ static int stm32f1_flash_write(struct target_s *target, uint32_t dest,
|
|||||||
|
|
||||||
/* Write stub and data to target ram and set PC */
|
/* Write stub and data to target ram and set PC */
|
||||||
target_mem_write_words(target, 0x20000000, (void*)stm32f1_flash_write_stub, 0x2C);
|
target_mem_write_words(target, 0x20000000, (void*)stm32f1_flash_write_stub, 0x2C);
|
||||||
target_mem_write_words(target, 0x2000002C, data, len + 8);
|
target_mem_write_words(target, 0x2000002C, data, sizeof(data));
|
||||||
target_pc_write(target, 0x20000000);
|
target_pc_write(target, 0x20000000);
|
||||||
if(target_check_error(target))
|
if(target_check_error(target))
|
||||||
return -1;
|
return -1;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user