summaryrefslogtreecommitdiff
path: root/src/jtag
diff options
context:
space:
mode:
authordrath <drath@b42882b7-edfa-0310-969c-e2dbd0fdcd60>2006-11-05 17:38:35 +0000
committerdrath <drath@b42882b7-edfa-0310-969c-e2dbd0fdcd60>2006-11-05 17:38:35 +0000
commit83440065c00cce9d36f23182b439d7bf2306cfb2 (patch)
treee70d7de58ac13ecb87025e2ef9e5ec6f8799726a /src/jtag
parent456737b08bbc37d13e4e08fa625413f8b91a6458 (diff)
downloadopenocd_libswd-83440065c00cce9d36f23182b439d7bf2306cfb2.tar.gz
openocd_libswd-83440065c00cce9d36f23182b439d7bf2306cfb2.tar.bz2
openocd_libswd-83440065c00cce9d36f23182b439d7bf2306cfb2.tar.xz
openocd_libswd-83440065c00cce9d36f23182b439d7bf2306cfb2.zip
- correctly enter debug state on a "soft_reset_halt" command
- several small fixes - retry reading from a FT2232 device on incomplete reads git-svn-id: svn://svn.berlios.de/openocd/trunk@110 b42882b7-edfa-0310-969c-e2dbd0fdcd60
Diffstat (limited to 'src/jtag')
-rw-r--r--src/jtag/ft2232.c27
1 files changed, 19 insertions, 8 deletions
diff --git a/src/jtag/ft2232.c b/src/jtag/ft2232.c
index e681b3e5..9af57dd1 100644
--- a/src/jtag/ft2232.c
+++ b/src/jtag/ft2232.c
@@ -189,15 +189,19 @@ int ft2232_read(u8* buf, int size, u32* bytes_read)
#if BUILD_FT2232_FTD2XX == 1
DWORD dw_bytes_read;
FT_STATUS status;
- if ((status = FT_Read(ftdih, buf, size, &dw_bytes_read)) != FT_OK)
+ int timeout = 5;
+ *bytes_read = 0;
+
+ while ((*bytes_read < size) && timeout--)
{
- *bytes_read = dw_bytes_read;
- ERROR("FT_Read returned: %i", status);
- return ERROR_JTAG_DEVICE_ERROR;
+ if ((status = FT_Read(ftdih, buf, size, &dw_bytes_read)) != FT_OK)
+ {
+ *bytes_read = 0;
+ ERROR("FT_Read returned: %i", status);
+ return ERROR_JTAG_DEVICE_ERROR;
+ }
+ *bytes_read += dw_bytes_read;
}
- *bytes_read = dw_bytes_read;
- return ERROR_OK;
-
#elif BUILD_FT2232_LIBFTDI == 1
int retval;
int timeout = 100;
@@ -213,8 +217,15 @@ int ft2232_read(u8* buf, int size, u32* bytes_read)
}
*bytes_read += retval;
}
- return ERROR_OK;
#endif
+
+ if (*bytes_read < size)
+ {
+ ERROR("couldn't read the requested number of bytes from FT2232 device (%i < %i)", *bytes_read, size);
+ return ERROR_JTAG_DEVICE_ERROR;
+ }
+
+ return ERROR_OK;
}
int ft2232_speed(int speed)