if ((retval = flash_erase_address_range(target, address, length)) == ERROR_OK)
{
- duration_stop_measure(&duration, &duration_text);
+ if ((retval = duration_stop_measure(&duration, &duration_text)) != ERROR_OK)
+ {
+ free(duration_text);
+ return retval;
+ }
command_print(cmd_ctx, "erased address 0x%8.8x length %i in %s", address, length, duration_text);
free(duration_text);
}
if ((retval = flash_driver_erase(p, first, last)) == ERROR_OK)
{
- duration_stop_measure(&duration, &duration_text);
+ if ((retval = duration_stop_measure(&duration, &duration_text)) != ERROR_OK)
+ {
+ free(duration_text);
+ return retval;
+ }
command_print(cmd_ctx, "erased sectors %i through %i on flash bank %i in %s", first, last, strtoul(args[0], 0, 0), duration_text);
free(duration_text);
duration_t duration;
char *duration_text;
- int retval;
+ int retval, retvaltemp;
if (argc < 1)
{
return retval;
}
- duration_stop_measure(&duration, &duration_text);
+ if ((retvaltemp = duration_stop_measure(&duration, &duration_text)) != ERROR_OK)
+ {
+ free(duration_text);
+ image_close(&image);
+ return retvaltemp;
+ }
if (retval == ERROR_OK)
{
command_print(cmd_ctx, "wrote %u byte from file %s in %s (%f kb/s)",
int handle_flash_fill_command(struct command_context_s *cmd_ctx, char *cmd, char **args, int argc)
{
- int err = ERROR_OK;
+ int err = ERROR_OK, retval;
u32 address;
u32 pattern;
u32 count;
}
}
- duration_stop_measure(&duration, &duration_text);
+ if ((retval = duration_stop_measure(&duration, &duration_text)) != ERROR_OK)
+ {
+ free(duration_text);
+ return retval;
+ }
+
if(err == ERROR_OK)
{
duration_t duration;
char *duration_text;
- int retval;
+ int retval, retvaltemp;
flash_bank_t *p;
if (argc != 3)
free(buffer);
buffer = NULL;
- duration_stop_measure(&duration, &duration_text);
+ if ((retvaltemp = duration_stop_measure(&duration, &duration_text)) != ERROR_OK)
+ {
+ free(duration_text);
+ fileio_close(&fileio);
+ return retvaltemp;
+ }
if (retval!=ERROR_OK)
{
command_print(cmd_ctx, "wrote %"PRIi64" byte from file %s to flash bank %i at offset 0x%8.8x in %s (%f kb/s)",
local_buffer[len++] = '#';
local_buffer[len++] = DIGITS[(my_checksum >> 4) & 0xf];
local_buffer[len++] = DIGITS[my_checksum & 0xf];
- gdb_write(connection, local_buffer, len);
+ if((retval = gdb_write(connection, local_buffer, len)) != ERROR_OK)
+ {
+ return retval;
+ }
}
else
{
local_buffer[1] = '#';
local_buffer[2] = DIGITS[(my_checksum >> 4) & 0xf];
local_buffer[3] = DIGITS[my_checksum & 0xf];
- gdb_write(connection, local_buffer, 1);
- gdb_write(connection, buffer, len);
- gdb_write(connection, local_buffer+1, 3);
+ if((retval = gdb_write(connection, local_buffer, 1)) != ERROR_OK)
+ {
+ return retval;
+ }
+ if((retval = gdb_write(connection, buffer, len)) != ERROR_OK)
+ {
+ return retval;
+ }
+ if((retval = gdb_write(connection, local_buffer+1, 3)) != ERROR_OK)
+ {
+ return retval;
+ }
}
if (gdb_con->noack_mode)
}
if (checksum_ok)
{
- gdb_write(connection, "+", 1);
+ if ((retval = gdb_write(connection, "+", 1)) != ERROR_OK)
+ {
+ return retval;
+ }
break;
}
}
snprintf(hex_buffer + 1 + i*2, 3, "%2.2x", line[i]);
hex_buffer[bin_size*2+1] = 0;
- gdb_put_packet(connection, hex_buffer, bin_size*2 + 1);
+ int retval = gdb_put_packet(connection, hex_buffer, bin_size*2 + 1);
free(hex_buffer);
- return ERROR_OK;
+ return retval;
}
int gdb_output(struct command_context_s *context, const char* line)
int gdb_target_callback_event_handler(struct target_s *target, enum target_event event, void *priv)
{
+ int retval;
connection_t *connection = priv;
target_handle_event( target, event );
break;
case TARGET_EVENT_GDB_FLASH_ERASE_START:
target_handle_event( target, TARGET_EVENT_OLD_gdb_program_config );
- jtag_execute_queue();
+ if((retval = jtag_execute_queue()) != ERROR_OK)
+ {
+ return retval;
+ }
break;
default:
break;
return ERROR_OK;
}
-int gdb_connection_closed(connection_t *connection)
+void gdb_connection_closed(connection_t *connection)
{
gdb_service_t *gdb_service = connection->service->priv;
gdb_connection_t *gdb_connection = connection->priv;
log_remove_callback(gdb_log_callback, connection);
target_call_event_callbacks(gdb_service->target, TARGET_EVENT_GDB_DETACH );
- return ERROR_OK;
}
void gdb_send_error(connection_t *connection, u8 the_error)
if (strstr(packet, "vFlashWrite:"))
{
+ int retval;
unsigned long addr;
unsigned long length;
char *parse = packet + 12;
}
/* create new section with content from packet buffer */
- image_add_section(gdb_connection->vflash_image, addr, length, 0x0, (u8*)parse);
+ if((retval = image_add_section(gdb_connection->vflash_image, addr, length, 0x0, (u8*)parse)) != ERROR_OK)
+ {
+ return retval;
+ }
gdb_put_packet(connection, "OK", 2);
armv7m->core_cache->reg_list[num].valid = 1;
armv7m->core_cache->reg_list[num].dirty = 0;
- return ERROR_OK;
+ return retval;
}
int armv7m_write_core_reg(struct target_s *target, int num)
/* This code relies on the target specific resume() and poll()->debug_entry()
sequence to write register values to the processor and the read them back */
- target_resume(target, 0, entry_point, 1, 1);
- target_poll(target);
+ if((retval = target_resume(target, 0, entry_point, 1, 1)) != ERROR_OK)
+ {
+ return retval;
+ }
+ if((retval = target_poll(target)) != ERROR_OK)
+ {
+ return retval;
+ }
- target_wait_state(target, TARGET_HALTED, timeout_ms);
+ if((retval = target_wait_state(target, TARGET_HALTED, timeout_ms)) != ERROR_OK)
+ {
+ return retval;
+ }
if (target->state != TARGET_HALTED)
{
if ((retval=target_halt(target))!=ERROR_OK)
for (i = 0; i < num_mem_params; i++)
{
if (mem_params[i].direction != PARAM_OUT)
- target_read_buffer(target, mem_params[i].address, mem_params[i].size, mem_params[i].value);
+ if((retval = target_read_buffer(target, mem_params[i].address, mem_params[i].size, mem_params[i].value)) != ERROR_OK)
+ {
+ return retval;
+ }
}
/* Copy core register values to reg_params[] */
/* convert flash writing code into a buffer in target endianness */
for (i = 0; i < (sizeof(cortex_m3_crc_code)/sizeof(u16)); i++)
- target_write_u16(target, crc_algorithm->address + i*sizeof(u16), cortex_m3_crc_code[i]);
+ if((retval = target_write_u16(target, crc_algorithm->address + i*sizeof(u16), cortex_m3_crc_code[i])) != ERROR_OK)
+ {
+ return retval;
+ }
armv7m_info.common_magic = ARMV7M_COMMON_MAGIC;
armv7m_info.core_mode = ARMV7M_MODE_ANY;