I tested version v0.4.0-rc1-98-g6c75f52 of OpenOCD for STR912 target. I tried to erase all the contents of the flash, sectors 0 to 7. Commands:
reset init flash erase_address 0 0x80000 (or flash erase_sector 0 0 7) The expected result is: erased sectors 0 through 7 on flash bank 0 in x.xx0000s but instead the command returned erase timed out: erase timed out failed erasing sectors 0 to 7 (-4) Here are the last lines of the logs: Debug: 25605 4184220 arm7_9_common.c:2210 arm7_9_read_memory(): address: 0x00000000, size: 0x00000001, count: 0x00000001 Debug: 25606 4184220 target.c:1527 target_read_u8(): address: 0x00000000, value: 0x00 Error: 25607 4184220 str9x.c:278 str9x_erase(): erase timed out Error: 25608 4184230 core.c:48 flash_driver_erase(): failed erasing sectors 0 to 7 (-4) It worked fine when the process was divided in two: started with the first 7 (0 to 6) sectors and then erased the last one, sector #7 separately. Using the erase bank command will cause a time out error. Replacing this with the erase sector bank will provide a slower but safer and stable method to erase the flash. Signed-off-by: Laurentiu Cocanu <laurentiu.coc...@zylin.com> --- src/flash/nor/str9x.c | 18 +++--------------- 1 files changed, 3 insertions(+), 15 deletions(-) diff --git a/src/flash/nor/str9x.c b/src/flash/nor/str9x.c index bf3f750..d0c1278 100644 --- a/src/flash/nor/str9x.c +++ b/src/flash/nor/str9x.c @@ -230,17 +230,9 @@ static int str9x_erase(struct flash_bank *bank, int first, int last) return ERROR_TARGET_NOT_HALTED; } - /* Check if we erase whole bank */ - if ((first == 0) && (last == (bank->num_sectors - 1))) - { - /* Optimize to run erase bank command instead of sector */ - erase_cmd = 0x80; - } - else - { - /* Erase sector command */ - erase_cmd = 0x20; - } + /*A slower but stable way of erasing*/ + /* Erase sector command */ + erase_cmd = 0x20; for (i = first; i <= last; i++) { @@ -296,10 +288,6 @@ static int str9x_erase(struct flash_bank *bank, int first, int last) LOG_ERROR("error erasing flash bank, status: 0x%x", status); return ERROR_FLASH_OPERATION_FAILED; } - - /* If we ran erase bank command, we are finished */ - if (erase_cmd == 0x80) - break; } for (i = first; i <= last; i++) -- 1.6.0.4 _______________________________________________ Openocd-development mailing list Openocd-development@lists.berlios.de https://lists.berlios.de/mailman/listinfo/openocd-development