[update] disable flash write operation checking

pull/20/head
Fabien Le Mentec 2011-10-23 01:45:01 -05:00
rodzic 85f4519307
commit 2953d3a6e8
1 zmienionych plików z 13 dodań i 2 usunięć

Wyświetl plik

@ -1132,10 +1132,15 @@ int stlink_fwrite_flash(stlink_t *sl, const char* path, stm32_addr_t addr) {
/* use fast word write. todo: half page. */ /* use fast word write. todo: half page. */
uint32_t val; uint32_t val;
#if 0 /* todo: check write operation */
uint32_t nwrites = sl->flash_pgsz; uint32_t nwrites = sl->flash_pgsz;
redo_write: redo_write:
#endif /* todo: check write operation */
/* disable pecr protection */ /* disable pecr protection */
write_uint32(sl->q_buf, 0x89abcdef); write_uint32(sl->q_buf, 0x89abcdef);
stlink_write_mem32(sl, STM32L_FLASH_PEKEYR, sizeof(uint32_t)); stlink_write_mem32(sl, STM32L_FLASH_PEKEYR, sizeof(uint32_t));
@ -1179,6 +1184,8 @@ int stlink_fwrite_flash(stlink_t *sl, const char* path, stm32_addr_t addr) {
if ((read_uint32(sl->q_buf, 0) & (1 << 0)) == 0) break ; if ((read_uint32(sl->q_buf, 0) & (1 << 0)) == 0) break ;
} }
#if 0 /* todo: check write operation */
/* check written bytes. todo: should be on a per page basis. */ /* check written bytes. todo: should be on a per page basis. */
stlink_read_mem32(sl, addr + off, sizeof(uint32_t)); stlink_read_mem32(sl, addr + off, sizeof(uint32_t));
if (memcmp(sl->q_buf, mf.base + off, sizeof(uint32_t))) if (memcmp(sl->q_buf, mf.base + off, sizeof(uint32_t)))
@ -1193,14 +1200,15 @@ int stlink_fwrite_flash(stlink_t *sl, const char* path, stm32_addr_t addr) {
goto on_error; goto on_error;
} }
fprintf(stderr, "invalid write @%x(%x). retrying.\n", page, addr + off);
nwrites = 0; nwrites = 0;
/* assume addr aligned */ /* assume addr aligned */
if (off % sl->flash_pgsz) off &= ~(sl->flash_pgsz - 1); if (off % sl->flash_pgsz) off &= ~(sl->flash_pgsz - 1);
page = addr + off; page = addr + off;
fprintf(stderr, "invalid write @%x(%x): %x != %x. retrying.\n",
page, addr + off, read_uint32(mf.base + off, 0), read_uint32(sl->q_buf, 0));
/* reset lock bits */ /* reset lock bits */
stlink_read_mem32(sl, STM32L_FLASH_PECR, sizeof(uint32_t)); stlink_read_mem32(sl, STM32L_FLASH_PECR, sizeof(uint32_t));
val = read_uint32(sl->q_buf, 0) | (1 << 0) | (1 << 1) | (1 << 2); val = read_uint32(sl->q_buf, 0) | (1 << 0) | (1 << 1) | (1 << 2);
@ -1214,6 +1222,9 @@ int stlink_fwrite_flash(stlink_t *sl, const char* path, stm32_addr_t addr) {
/* increment successive writes counter */ /* increment successive writes counter */
++nwrites; ++nwrites;
#endif /* todo: check write operation */
} }
/* reset lock bits */ /* reset lock bits */