mirror of
https://github.com/linux-msm/openocd.git
synced 2026-02-25 13:15:07 -08:00
- 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:
@@ -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;
|
||||
|
||||
@@ -688,7 +685,7 @@ int at91sam7_write(struct flash_bank_s *bank, u8 *buffer, u32 offset, u32 count)
|
||||
|
||||
/* Configure the flash controller timing */
|
||||
at91sam7_read_clock_info(bank);
|
||||
at91sam7_set_flash_mode(bank,FMR_TIMING_FLASH);
|
||||
at91sam7_set_flash_mode(bank,FMR_TIMING_FLASH);
|
||||
|
||||
for (pagen=first_page; pagen<last_page; pagen++) {
|
||||
if (bytes_remaining<dst_min_alignment)
|
||||
|
||||
444
src/jtag/bitq.c
444
src/jtag/bitq.c
File diff suppressed because it is too large
Load Diff
@@ -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);
|
||||
|
||||
@@ -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("-");
|
||||
|
||||
@@ -1433,11 +1433,20 @@ int jtag_init(struct command_context_s *cmd_ctx)
|
||||
|
||||
jtag_add_statemove(TAP_TLR);
|
||||
jtag_execute_queue();
|
||||
|
||||
|
||||
while (jtag_validate_chain() != ERROR_OK)
|
||||
{
|
||||
validate_tries++;
|
||||
if (validate_tries > 5)
|
||||
{
|
||||
ERROR("Could not validate JTAG chain, exit");
|
||||
exit(-1);
|
||||
}
|
||||
usleep(10000);
|
||||
}
|
||||
|
||||
jtag_examine_chain();
|
||||
|
||||
jtag_validate_chain();
|
||||
|
||||
return ERROR_OK;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -25,7 +25,7 @@
|
||||
|
||||
#include "command.h"
|
||||
|
||||
#if 1
|
||||
#if 0
|
||||
#define _DEBUG_JTAG_IO_
|
||||
#endif
|
||||
|
||||
|
||||
@@ -166,7 +166,7 @@ int presto_open(char *req_serial)
|
||||
if (FT_GetDeviceInfo(presto->handle,&device,&vidpid,presto->serial,devname,NULL)==FT_OK)
|
||||
{
|
||||
if (vidpid==PRESTO_VID_PID && (req_serial==NULL || !strcmp(presto->serial,req_serial)))
|
||||
break;
|
||||
break;
|
||||
}
|
||||
FT_Close(presto->handle);
|
||||
presto->handle=INVALID_HANDLE_VALUE;
|
||||
|
||||
@@ -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"
|
||||
|
||||
@@ -264,63 +264,31 @@ 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( packet_type == 'X' )
|
||||
|
||||
if (character == '#') break;
|
||||
|
||||
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);
|
||||
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;
|
||||
}
|
||||
/* data transmitted in binary mode (X packet)
|
||||
* uses 0x7d as escape character */
|
||||
my_checksum += character & 0xff;
|
||||
if ((retval = gdb_get_char(connection, &character)) != ERROR_OK)
|
||||
return retval;
|
||||
my_checksum += character & 0xff;
|
||||
buffer[count++] = (character ^ 0x20) & 0xff;
|
||||
}
|
||||
else
|
||||
{
|
||||
switch (character)
|
||||
{
|
||||
case '#':
|
||||
break;
|
||||
case 0x3:
|
||||
gdb_con->ctrl_c = 1;
|
||||
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;
|
||||
}
|
||||
my_checksum += character & 0xff;
|
||||
buffer[count++] = character & 0xff;
|
||||
}
|
||||
} while (character != '#');
|
||||
|
||||
if (count > *len)
|
||||
{
|
||||
ERROR("packet buffer too small");
|
||||
return ERROR_GDB_BUFFER_TOO_SMALL;
|
||||
}
|
||||
} while (1);
|
||||
|
||||
*len = count;
|
||||
|
||||
|
||||
@@ -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
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user