From 82ea640830fe13f9ab8ef33c65a76480b697f856 Mon Sep 17 00:00:00 2001 From: Øyvind Harboe Date: Tue, 4 May 2010 13:26:52 +0200 Subject: gdb: connect will now fail if flash autoprobe fails MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 --- src/server/gdb_server.c | 26 +++++++++++++++++++++++--- 1 file changed, 23 insertions(+), 3 deletions(-) (limited to 'src/server') 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; } -- cgit v1.2.3