From: Angus Gratton Date: Fri, 27 Jun 2014 23:27:11 +0000 (+1000) Subject: stlink_usb: Fix swallowed error on read/write operations, add retries on SWD WAIT... X-Git-Tag: v0.9.0-rc1~315 X-Git-Url: https://review.openocd.org/gitweb?a=commitdiff_plain;h=9fce8a21ca5f7f42ec36aa859637d37f5fba312a;hp=9fce8a21ca5f7f42ec36aa859637d37f5fba312a;p=openocd.git stlink_usb: Fix swallowed error on read/write operations, add retries on SWD WAIT, clean up error debug output. - stlink_usb_get_rw_status() had a bug where FAULT or WAIT responses in read/write operations were ignored, leading to incomplete data. - Added wrapper stlink_cmd_allow_retry to handle SWD_AP_WAIT/SWD_DP_WAIT statuses in most commands. These statuses appear if an SWD read or write received a WAIT ACK response from the target more than 4 times in a row. The driver retries the operation (with exponential backoff) before failing outright (in testing 1 retry was always enough.) - As part of the implementation of stlink_cmd_allow_retry a large number of lines of boilerplate were refactored. - Fleshed out stlink_usb_error_check and added it to some more code paths so WAIT or FAULT responses are logged to debug. WAIT responses will be logged even if they are subsequently retried, which should help in case the retries have subtle side effects (none anticipated.) Tested with two targets: STLINK F0 Discovery, Nordic NRF51822. Only tested with STLINK V2 programmers. Change-Id: I9af24e8f0121b035356dbb9978d6bbf4feb2e4d3 Signed-off-by: Angus Gratton Reviewed-on: http://openocd.zylin.com/2201 Tested-by: jenkins Reviewed-by: Andreas Fritiofson ---