summaryrefslogtreecommitdiff
path: root/src/server
diff options
context:
space:
mode:
authorØyvind Harboe <oyvind.harboe@zylin.com>2010-05-04 13:26:52 +0200
committerØyvind Harboe <oyvind.harboe@zylin.com>2010-05-05 15:24:24 +0200
commit82ea640830fe13f9ab8ef33c65a76480b697f856 (patch)
tree3db8a893b3bf7ac1fd7d92cf39691a8f5fe0a69d /src/server
parent812e21ac396247767da0144748b5f52ad11b3e17 (diff)
downloadopenocd+libswd-82ea640830fe13f9ab8ef33c65a76480b697f856.tar.gz
openocd+libswd-82ea640830fe13f9ab8ef33c65a76480b697f856.tar.bz2
openocd+libswd-82ea640830fe13f9ab8ef33c65a76480b697f856.tar.xz
openocd+libswd-82ea640830fe13f9ab8ef33c65a76480b697f856.zip
gdb: connect will now fail if flash autoprobe fails
This stops GDB from launching with an empty memory map, making gdb load w/flashing fail for no obvious reason. The error message points in the direction of the gdb-attach event that can be set up to issue a halt or "reset init" which will put GDB in a well defined stated upon attach and thus have a robust flash autoprobe. Signed-off-by: Øyvind Harboe <oyvind.harboe@zylin.com>
Diffstat (limited to 'src/server')
-rw-r--r--src/server/gdb_server.c26
1 files changed, 23 insertions, 3 deletions
diff --git a/src/server/gdb_server.c b/src/server/gdb_server.c
index f46980e1..275d4146 100644
--- a/src/server/gdb_server.c
+++ b/src/server/gdb_server.c
@@ -855,6 +855,26 @@ static int gdb_new_connection(struct connection *connection)
gdb_putback_char(connection, initial_ack);
target_call_event_callbacks(gdb_service->target, TARGET_EVENT_GDB_ATTACH);
+ if (gdb_use_memory_map)
+ {
+ /* Connect must fail if the memory map can't be set up correctly.
+ *
+ * This will cause an auto_probe to be invoked, which is either
+ * a no-op or it will fail when the target isn't ready(e.g. not halted).
+ */
+ int i;
+ for (i = 0; i < flash_get_bank_count(); i++)
+ {
+ struct flash_bank *p;
+ retval = get_flash_bank_by_num(i, &p);
+ if (retval != ERROR_OK)
+ {
+ LOG_ERROR("Connect failed. Consider setting up a gdb-attach event for the target to prepare target for GDB connect.");
+ return retval;
+ }
+ }
+ }
+
gdb_actual_connections++;
LOG_DEBUG("New GDB Connection: %d, Target %s, state: %s",
gdb_actual_connections,
@@ -1692,10 +1712,10 @@ static int gdb_memory_map(struct connection *connection,
banks = malloc(sizeof(struct flash_bank *)*flash_get_bank_count());
for (i = 0; i < flash_get_bank_count(); i++) {
- p = get_flash_bank_by_num(i);
- if (p == NULL) {
+ retval = get_flash_bank_by_num(i, &p);
+ if (retval != ERROR_OK)
+ {
free(banks);
- retval = ERROR_FAIL;
gdb_send_error(connection, retval);
return retval;
}