This is an automated email from Gerrit. Michael Hope ([email protected]) just uploaded a new patch set to Gerrit, which you can find at http://openocd.zylin.com/5706
-- gerrit commit 4a279b23b7d30d745c7032899be833024262eb31 Author: Michael Hope <[email protected]> Date: Fri May 29 22:30:44 2020 +0200 flash/nor/atsame5: Fix a timeout when erasing According to the datasheet, erasing a block can take up to 200 ms. When using a Segger J-Link with a 2 MHz clock the current loop finishes after < 50 ms, ignores the timeout, and then fails when erasing the next block. Extend the number of tries, add an explicit sleep, and report an error on timeout. Change-Id: I8255401d1e59f427a08d2cccb8a66143dcdbb324 Signed-off-by: Michael Hope <[email protected]> diff --git a/src/flash/nor/atsame5.c b/src/flash/nor/atsame5.c index eac7847..0afff51 100644 --- a/src/flash/nor/atsame5.c +++ b/src/flash/nor/atsame5.c @@ -338,7 +338,8 @@ static int same5_probe(struct flash_bank *bank) static int same5_wait_and_check_error(struct target *target) { int ret, ret2; - int rep_cnt = 100; + /* Table 54-40 says the maximum erase block time is 200 ms */ + int rep_cnt = 1000; uint16_t intflag; do { @@ -346,12 +347,18 @@ static int same5_wait_and_check_error(struct target *target) SAMD_NVMCTRL + SAME5_NVMCTRL_INTFLAG, &intflag); if (ret == ERROR_OK && intflag & SAME5_NVMCTRL_INTFLAG_DONE) break; + jtag_sleep(1000); } while (--rep_cnt); if (ret != ERROR_OK) { LOG_ERROR("Can't read NVM INTFLAG"); return ret; } + + if (!(intflag & SAME5_NVMCTRL_INTFLAG_DONE)) { + LOG_ERROR("SAM: NVM programming timed out"); + ret = ERROR_FLASH_OPERATION_FAILED; + } #if 0 if (intflag & SAME5_NVMCTRL_INTFLAG_ECCSE) LOG_ERROR("SAM: ECC Single Error"); -- _______________________________________________ OpenOCD-devel mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/openocd-devel
