do not check checksums in noack case
git-svn-id: svn://svn.berlios.de/openocd/trunk@969 b42882b7-edfa-0310-969c-e2dbd0fdcd60
This commit is contained in:
parent
34d3bfbcf2
commit
f5507d8929
|
@ -395,52 +395,17 @@ int gdb_put_packet(connection_t *connection, char *buffer, int len)
|
||||||
return retval;
|
return retval;
|
||||||
}
|
}
|
||||||
|
|
||||||
int gdb_get_packet_inner(connection_t *connection, char *buffer, int *len)
|
static __inline__ int fetch_packet(connection_t *connection, int *checksum_ok, int noack, int *len, char *buffer)
|
||||||
{
|
{
|
||||||
int character;
|
|
||||||
int count = 0;
|
|
||||||
int retval;
|
|
||||||
char checksum[3];
|
|
||||||
unsigned char my_checksum = 0;
|
unsigned char my_checksum = 0;
|
||||||
|
char checksum[3];
|
||||||
|
int character;
|
||||||
|
int retval;
|
||||||
|
|
||||||
gdb_connection_t *gdb_con = connection->priv;
|
gdb_connection_t *gdb_con = connection->priv;
|
||||||
|
|
||||||
while (1)
|
|
||||||
{
|
|
||||||
do
|
|
||||||
{
|
|
||||||
if ((retval = gdb_get_char(connection, &character)) != ERROR_OK)
|
|
||||||
return retval;
|
|
||||||
|
|
||||||
#ifdef _DEBUG_GDB_IO_
|
|
||||||
LOG_DEBUG("character: '%c'", character);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
switch (character)
|
|
||||||
{
|
|
||||||
case '$':
|
|
||||||
break;
|
|
||||||
case '+':
|
|
||||||
/* gdb sends a dummy ack '+' at every remote connect - see remote_start_remote (remote.c)
|
|
||||||
* incase anyone tries to debug why they receive this warning every time */
|
|
||||||
LOG_WARNING("acknowledgment received, but no packet pending");
|
|
||||||
break;
|
|
||||||
case '-':
|
|
||||||
LOG_WARNING("negative acknowledgment, but no packet pending");
|
|
||||||
break;
|
|
||||||
case 0x3:
|
|
||||||
gdb_con->ctrl_c = 1;
|
|
||||||
*len = 0;
|
|
||||||
return ERROR_OK;
|
|
||||||
default:
|
|
||||||
LOG_WARNING("ignoring character 0x%x", character);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
} while (character != '$');
|
|
||||||
|
|
||||||
my_checksum = 0;
|
my_checksum = 0;
|
||||||
|
int count = 0;
|
||||||
count = 0;
|
count = 0;
|
||||||
gdb_connection_t *gdb_con = connection->priv;
|
|
||||||
for (;;)
|
for (;;)
|
||||||
{
|
{
|
||||||
/* The common case is that we have an entire packet with no escape chars.
|
/* The common case is that we have an entire packet with no escape chars.
|
||||||
|
@ -531,22 +496,77 @@ int gdb_get_packet_inner(connection_t *connection, char *buffer, int *len)
|
||||||
checksum[1] = character;
|
checksum[1] = character;
|
||||||
checksum[2] = 0;
|
checksum[2] = 0;
|
||||||
|
|
||||||
if (my_checksum == strtoul(checksum, NULL, 16))
|
if (!noack)
|
||||||
{
|
{
|
||||||
if (gdb_con->noack_mode)
|
*checksum_ok=(my_checksum == strtoul(checksum, NULL, 16));
|
||||||
break;
|
|
||||||
gdb_write(connection, "+", 1);
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!gdb_con->noack_mode)
|
return ERROR_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
int gdb_get_packet_inner(connection_t *connection, char *buffer, int *len)
|
||||||
|
{
|
||||||
|
int character;
|
||||||
|
int retval;
|
||||||
|
gdb_connection_t *gdb_con = connection->priv;
|
||||||
|
|
||||||
|
while (1)
|
||||||
{
|
{
|
||||||
LOG_WARNING("checksum error, requesting retransmission");
|
do
|
||||||
gdb_write(connection, "-", 1);
|
{
|
||||||
|
if ((retval = gdb_get_char(connection, &character)) != ERROR_OK)
|
||||||
|
return retval;
|
||||||
|
|
||||||
|
#ifdef _DEBUG_GDB_IO_
|
||||||
|
LOG_DEBUG("character: '%c'", character);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
switch (character)
|
||||||
|
{
|
||||||
|
case '$':
|
||||||
|
break;
|
||||||
|
case '+':
|
||||||
|
/* gdb sends a dummy ack '+' at every remote connect - see remote_start_remote (remote.c)
|
||||||
|
* incase anyone tries to debug why they receive this warning every time */
|
||||||
|
LOG_WARNING("acknowledgment received, but no packet pending");
|
||||||
|
break;
|
||||||
|
case '-':
|
||||||
|
LOG_WARNING("negative acknowledgment, but no packet pending");
|
||||||
|
break;
|
||||||
|
case 0x3:
|
||||||
|
gdb_con->ctrl_c = 1;
|
||||||
|
*len = 0;
|
||||||
|
return ERROR_OK;
|
||||||
|
default:
|
||||||
|
LOG_WARNING("ignoring character 0x%x", character);
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
else
|
} while (character != '$');
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
int checksum_ok;
|
||||||
|
/* explicit code expansion here to get faster inlined code in -O3 by not
|
||||||
|
* calculating checksum
|
||||||
|
*/
|
||||||
|
if (gdb_con->noack_mode)
|
||||||
{
|
{
|
||||||
LOG_WARNING("checksum error, no-ack-mode");
|
if ((retval=fetch_packet(connection, &checksum_ok, 1, len, buffer))!=ERROR_OK)
|
||||||
|
return retval;
|
||||||
|
} else
|
||||||
|
{
|
||||||
|
if ((retval=fetch_packet(connection, &checksum_ok, 0, len, buffer))!=ERROR_OK)
|
||||||
|
return retval;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (gdb_con->noack_mode)
|
||||||
|
{
|
||||||
|
/* checksum is not checked in noack mode */
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
if (checksum_ok)
|
||||||
|
{
|
||||||
|
gdb_write(connection, "+", 1);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue