if (sl->flash_type == FLASH_TYPE_F4) {
cr_reg = FLASH_F4_CR;
- cr_lock_shift = STM32L4_FLASH_CR_LOCK;
+ cr_lock_shift = FLASH_F4_CR_LOCK;
} else if (sl->flash_type == FLASH_TYPE_L4) {
cr_reg = STM32L4_FLASH_CR;
cr_lock_shift = STM32L4_FLASH_CR_LOCK;
void stlink_close(stlink_t *sl) {
DLOG("*** stlink_close ***\n");
+ if (!sl)
+ return;
sl->backend->close(sl);
free(sl);
}
ret = sl->backend->read_debug32(sl, addr, data);
if (!ret)
- DLOG("*** stlink_read_debug32 %x is %#x\n", data, addr);
+ DLOG("*** stlink_read_debug32 %x is %#x\n", *data, addr);
return ret;
}
flashaddr -= STM32_FLASH_BASE;
if (flashopt & (1lu << STM32L4_FLASH_OPTR_DUALBANK)) {
uint32_t banksize = sl->flash_size / 2;
- if (flashaddr > banksize) {
+ if (flashaddr >= banksize) {
flashaddr -= banksize;
bker = 0x100;
}
// calculate the actual bank+page from the address
uint32_t page = calculate_L4_page(sl, flashaddr);
+ fprintf(stderr, "EraseFlash - Page:0x%x Size:0x%x ", page, stlink_calculate_pagesize(sl, flashaddr));
+
write_flash_cr_bker_pnb(sl, page);
} else if (sl->chip_id == STM32_CHIPID_F7) {
// calculate the actual page from the address
uint32_t sector=calculate_F7_sectornum(flashaddr);
- fprintf(stderr, "EraseFlash - Sector:0x%x Size:0x%x\n", sector, stlink_calculate_pagesize(sl, flashaddr));
+ fprintf(stderr, "EraseFlash - Sector:0x%x Size:0x%x ", sector, stlink_calculate_pagesize(sl, flashaddr));
write_flash_cr_snb(sl, sector);
} else {
// calculate the actual page from the address
uint32_t sector=calculate_F4_sectornum(flashaddr);
- fprintf(stderr, "EraseFlash - Sector:0x%x Size:0x%x\n", sector, stlink_calculate_pagesize(sl, flashaddr));
+ fprintf(stderr, "EraseFlash - Sector:0x%x Size:0x%x ", sector, stlink_calculate_pagesize(sl, flashaddr));
//the SNB values for flash sectors in the second bank do not directly follow the values for the first bank on 2mb devices...
if (sector >= 12) sector += 4;
WLOG("Failed to erase_flash_page(%#zx) == -1\n", addr);
return -1;
}
- fprintf(stdout,"\rFlash page at %5d/%5d erased", i, num_pages);
+ fprintf(stdout,"-> Flash page at %5d/%5d erased\n", i, num_pages);
fflush(stdout);
}
fprintf(stdout, "\n");