#define PROGRESS_CHUNK_SIZE 0x1000
/* write a word in program memory */
for (off = 0; off < len; off += sizeof(uint32_t)) {
+ uint32_t data;
if (sl->verbose >= 1) {
if ((off & (PROGRESS_CHUNK_SIZE - 1)) == 0) {
/* show progress. writing procedure is slow
}
}
- memcpy(sl->q_buf, (const void*)(base + off), sizeof(uint32_t));
- stlink_write_mem32(sl, addr + off, sizeof(uint32_t));
+ write_uint32((unsigned char*) &data, *(uint32_t*) (base + off));
+ stlink_write_debug32(sl, addr + off, data);
/* wait for sr.busy to be cleared */
wait_flash_busy(sl);
/* write a word in program memory */
for (off = 0; off < len; off += sizeof(uint32_t)) {
+ uint32_t data;
if (sl->verbose >= 1) {
if ((off & (sl->flash_pgsz - 1)) == 0) {
/* show progress. writing procedure is slow
}
}
- memcpy(sl->q_buf, (const void*)(base + off), sizeof(uint32_t));
- stlink_write_mem32(sl, addr + off, sizeof(uint32_t));
+ write_uint32((unsigned char*) &data, *(uint32_t*) (base + off));
+ stlink_write_mem32(sl, addr + off, data);
/* wait for sr.busy to be cleared */
while (stlink_read_debug32(sl, STM32L_FLASH_SR & (1 << 0)) != 0) {
#if 0 /* todo: check redo write operation */
/* check written bytes. todo: should be on a per page basis. */
- stlink_read_mem32(sl, addr + off, sizeof(uint32_t));
- if (memcmp(sl->q_buf, base + off, sizeof(uint32_t))) {
+ data = stlink_read_debug32(sl, addr + off);
+ if (data == *(uint32_t*)(base + off)) {
/* re erase the page and redo the write operation */
uint32_t page;
uint32_t val;