- reformat src/jtag/bitq.c (thanks to Pavel Chromy)

- fix multiple reads from FT2232 into same buffer location (thanks to Magnus Lundin)
- retry JTAG chain validation (thanks to Magnus Lundin)
- reworked GDB packet input handling (thanks to Pavel Chromy)
- output error message when setting a watchpoint failed
- removed duplicate out-of-bounds check in at91sam7.c (thanks to Pavel Chromy)


git-svn-id: svn://svn.berlios.de/openocd/trunk@181 b42882b7-edfa-0310-969c-e2dbd0fdcd60
This commit is contained in:
drath 2007-07-25 10:06:57 +00:00
parent 1429d2c659
commit 290e01c62a
9 changed files with 281 additions and 289 deletions

View File

@ -675,9 +675,6 @@ int at91sam7_write(struct flash_bank_s *bank, u8 *buffer, u32 offset, u32 count)
return ERROR_FLASH_DST_BREAKS_ALIGNMENT;
}
if (offset + count > bank->size)
return ERROR_FLASH_DST_OUT_OF_BANK;
if (at91sam7_info->cidr_arch == 0)
return ERROR_FLASH_BANK_NOT_PROBED;

View File

@ -205,7 +205,8 @@ int ft2232_read(u8* buf, int size, u32* bytes_read)
while ((*bytes_read < size) && timeout--)
{
if ((status = FT_Read(ftdih, buf, size, &dw_bytes_read)) != FT_OK)
if ((status = FT_Read(ftdih, buf + *bytes_read, size -
*bytes_read, &dw_bytes_read)) != FT_OK)
{
*bytes_read = 0;
ERROR("FT_Read returned: %lu", status);

View File

@ -1345,7 +1345,7 @@ int jtag_validate_chain()
char *cbuf = buf_to_str(ir_test, total_ir_length, 16);
ERROR("Error validating JTAG scan chain, IR mismatch, scan returned 0x%s", cbuf);
free(cbuf);
exit(-1);
return ERROR_JTAG_INIT_FAILED;
}
chain_pos += device->ir_length;
device = device->next;
@ -1356,7 +1356,7 @@ int jtag_validate_chain()
char *cbuf = buf_to_str(ir_test, total_ir_length, 16);
ERROR("Error validating JTAG scan chain, IR mismatch, scan returned 0x%s", cbuf);
free(cbuf);
exit(-1);
return ERROR_JTAG_INIT_FAILED;
}
free(ir_test);
@ -1402,7 +1402,7 @@ int jtag_register_commands(struct command_context_s *cmd_ctx)
int jtag_init(struct command_context_s *cmd_ctx)
{
int i;
int i, validate_tries = 0;
DEBUG("-");
@ -1434,9 +1434,18 @@ int jtag_init(struct command_context_s *cmd_ctx)
jtag_add_statemove(TAP_TLR);
jtag_execute_queue();
jtag_examine_chain();
while (jtag_validate_chain() != ERROR_OK)
{
validate_tries++;
if (validate_tries > 5)
{
ERROR("Could not validate JTAG chain, exit");
exit(-1);
}
usleep(10000);
}
jtag_validate_chain();
jtag_examine_chain();
return ERROR_OK;
}

View File

@ -25,7 +25,7 @@
#include "command.h"
#if 1
#if 0
#define _DEBUG_JTAG_IO_
#endif

View File

@ -18,7 +18,7 @@
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
***************************************************************************/
#define OPENOCD_VERSION "Open On-Chip Debugger (2007-07-15 13:15 CEST)"
#define OPENOCD_VERSION "Open On-Chip Debugger (2007-07-25 12:00 CEST)"
#ifdef HAVE_CONFIG_H
#include "config.h"

View File

@ -265,62 +265,30 @@ int gdb_get_packet(connection_t *connection, char *buffer, int *len)
if ((retval = gdb_get_char(connection, &character)) != ERROR_OK)
return retval;
if( !first_char ) {
packet_type = character;
first_char = 1;
}
if (character == '#') break;
if( packet_type == 'X' )
if (character == '}')
{
switch (character)
{
case '#':
break;
case 0x7d:
/* data transmitted in binary mode (X packet)
* uses 0x7d as escape character */
my_checksum += character & 0xff;
gdb_get_char(connection, &character);
if ((retval = gdb_get_char(connection, &character)) != ERROR_OK)
return retval;
my_checksum += character & 0xff;
buffer[count++] = (character ^ 0x20) & 0xff;
if (count > *len)
{
ERROR("packet buffer too small");
return ERROR_GDB_BUFFER_TOO_SMALL;
}
break;
default:
buffer[count++] = character & 0xff;
my_checksum += character & 0xff;
if (count > *len)
{
ERROR("packet buffer too small");
return ERROR_GDB_BUFFER_TOO_SMALL;
}
break;
}
}
else
{
switch (character)
{
case '#':
break;
case 0x3:
gdb_con->ctrl_c = 1;
break;
default:
buffer[count++] = character & 0xff;
my_checksum += character & 0xff;
buffer[count++] = character & 0xff;
}
if (count > *len)
{
ERROR("packet buffer too small");
return ERROR_GDB_BUFFER_TOO_SMALL;
}
break;
}
}
} while (character != '#');
} while (1);
*len = count;

View File

@ -1862,6 +1862,7 @@ int handle_rbp_command(struct command_context_s *cmd_ctx, char *cmd, char **args
int handle_wp_command(struct command_context_s *cmd_ctx, char *cmd, char **args, int argc)
{
target_t *target = get_current_target(cmd_ctx);
int retval;
if (argc == 0)
{
@ -1905,7 +1906,23 @@ int handle_wp_command(struct command_context_s *cmd_ctx, char *cmd, char **args,
{
data_mask = strtoul(args[4], NULL, 0);
}
watchpoint_add(target, strtoul(args[0], NULL, 0), strtoul(args[1], NULL, 0), type, data_value, data_mask);
if ((retval = watchpoint_add(target, strtoul(args[0], NULL, 0),
strtoul(args[1], NULL, 0), type, data_value, data_mask)) != ERROR_OK)
{
switch (retval)
{
case ERROR_TARGET_NOT_HALTED:
command_print(cmd_ctx, "target must be halted to set watchpoints");
break;
case ERROR_TARGET_RESOURCE_NOT_AVAILABLE:
command_print(cmd_ctx, "no more watchpoints available");
break;
default:
command_print(cmd_ctx, "unknown error, watchpoint not set");
break;
}
}
}
else
{