Merge pull request #1411 from stefanrueger/bootloader-ce

Increase timeout for emulated butterfly chip erase
This commit is contained in:
Stefan Rueger
2023-06-23 15:51:56 +01:00
committed by GitHub
2 changed files with 22 additions and 10 deletions

View File

@@ -140,11 +140,21 @@ static int butterfly_vfy_led(const PROGRAMMER *pgm, int value) {
* issue the 'chip erase' command to the butterfly board
*/
static int butterfly_chip_erase(const PROGRAMMER *pgm, const AVRPART *p) {
butterfly_send(pgm, "e", 1);
if (butterfly_vfy_cmd_sent(pgm, "chip erase") < 0)
return -1;
long bak_timeout = serial_recv_timeout;
AVRMEM *fl = avr_locate_mem(p, "flash");
int ret = 0;
return 0;
// Estimated time it takes to erase all pages in bootloader
long new_timeout = p->chip_erase_delay * (fl? fl->num_pages: 999);
if(serial_recv_timeout < new_timeout)
serial_recv_timeout = new_timeout;
butterfly_send(pgm, "e", 1);
if(butterfly_vfy_cmd_sent(pgm, "chip erase") < 0)
ret = -1;
serial_recv_timeout = bak_timeout;
return ret;
}

View File

@@ -2105,16 +2105,16 @@ static int urclock_chip_erase(const PROGRAMMER *pgm, const AVRPART *p) {
buf[0] = Cmnd_STK_CHIP_ERASE;
buf[1] = Sync_CRC_EOP;
if(urclock_send(pgm, buf, 2) < 0)
if(urclock_send(pgm, buf, 2) < 0 || urclock_res_check(pgm, __func__, 0, NULL, 0) < 0) {
serial_recv_timeout = bak_timeout;
return -1;
if(urclock_res_check(pgm, __func__, 0, NULL, 0) < 0)
return -1;
}
} else { // Legacy bootloaders use universal extension
pmsg_notice2("chip erase via universal STK500v1 command\n");
if (pgm->cmd == NULL) { // Should not happen
if(pgm->cmd == NULL) { // Should not happen
pmsg_error("%s programmer does not provide a cmd() method\n", pgm->type);
serial_recv_timeout = bak_timeout;
return -1;
}
@@ -2125,8 +2125,10 @@ static int urclock_chip_erase(const PROGRAMMER *pgm, const AVRPART *p) {
buf[2] = (uint8_t) (Subc_STK_UNIVERSAL_CE>>8);
buf[3] = (uint8_t) (Subc_STK_UNIVERSAL_CE);
if(urclock_cmd(pgm, buf, buf+4) < 0)
if(urclock_cmd(pgm, buf, buf+4) < 0) {
serial_recv_timeout = bak_timeout;
return -1;
}
}
serial_recv_timeout = bak_timeout;