diff --git a/gdb/ChangeLog b/gdb/ChangeLog index 0f0eb3339e..6c438de5d5 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,3 +1,25 @@ +Sun Sep 8 15:14:00 1996 Stu Grossman (grossman@critters.cygnus.com) + + * blockframe.c (inside_main_func): Cleanup slightly. Move + mainsym def into the block it's used in. + * configure.in configure: Allow NATDEPFILES to be recognized in + .mh files regardless of whitespace. + + * cpu32bug-rom.c (cpu32bug_cmds): Change load_response string to + keep downloads from hanging. + + * remote-wiggler.c: Add support for flash upgrades. + * (wiggler_error): Fix message format. Add new error code. + * (wiggler_write_byets): Error code is hex. Report errors with + proper routine name. + * (wiggler_read_byets): Report errors with proper routine name. + * (get_packet): Add support for new flash commands. + * (wiggler_load): Call clear_symtab_users() to reset things + properly after download. + * (flash_xfer_memory bdm_update_flash_command): New funxtions to + support flash upgrades for Wiggler. + * (_initialize_remote_wiggler): Add `bdm update-flash' command. + Fri Sep 6 13:14:13 1996 Geoffrey Noer * ser-tcp.c: don't include netinet/tcp.h if __CYGWIN32__ diff --git a/gdb/configure b/gdb/configure index 3301b659f5..3eecffd96c 100755 --- a/gdb/configure +++ b/gdb/configure @@ -3481,7 +3481,7 @@ EOF cat >> $CONFIG_STATUS <<\EOF if test "${nativefile}" = ""; then -sed -e '/^NATDEPFILES= /s//# NATDEPFILES= /' \ +sed -e '/^NATDEPFILES[ ]*=[ ]*/s//# NATDEPFILES=/' \ < Makefile > Makefile.tem mv -f Makefile.tem Makefile fi diff --git a/gdb/configure.in b/gdb/configure.in index df786c2757..f33178daf0 100644 --- a/gdb/configure.in +++ b/gdb/configure.in @@ -750,7 +750,7 @@ dnl Autoconf doesn't provide a mechanism for modifying definitions dnl provided by makefile fragments. dnl if test "${nativefile}" = ""; then -sed -e '/^NATDEPFILES= /s//# NATDEPFILES= /' \ +sed -e '/^NATDEPFILES[[ ]]*=[[ ]]*/s//# NATDEPFILES=/' \ < Makefile > Makefile.tem mv -f Makefile.tem Makefile fi diff --git a/gdb/cpu32bug-rom.c b/gdb/cpu32bug-rom.c index 43f76f62a0..58052c8af5 100644 --- a/gdb/cpu32bug-rom.c +++ b/gdb/cpu32bug-rom.c @@ -138,7 +138,7 @@ static struct monitor_ops cpu32bug_cmds = cpu32bug_supply_register, /* supply_register */ NULL, /* load_routine (defaults to SRECs) */ "lo\r", /* download command */ - "lo\r\n", /* load response */ + "\n", /* load response */ "CPU32Bug>", /* monitor command prompt */ "\r", /* end-of-line terminator */ NULL, /* optional command terminator */ diff --git a/gdb/remote-wiggler.c b/gdb/remote-wiggler.c index 26a6a23496..c767641175 100644 --- a/gdb/remote-wiggler.c +++ b/gdb/remote-wiggler.c @@ -81,6 +81,11 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #define WIGGLER_WRITE_INT_MEM 0x81 /* Write Internal Memory */ #define WIGGLER_JUMP 0x82 /* Jump to Subroutine */ +#define WIGGLER_ERASE_FLASH 0x90 /* Erase flash memory */ +#define WIGGLER_PROGRAM_FLASH 0x91 /* Write flash memory */ +#define WIGGLER_EXIT_MON 0x93 /* Exit the flash programming monitor */ +#define WIGGLER_ENTER_MON 0x94 /* Enter the flash programming monitor */ + #define WIGGLER_SET_STATUS 0x0a /* Set status */ #define WIGGLER_FLAG_STOP 0x0 /* Stop the target, enter BDM */ #define WIGGLER_FLAG_START 0x01 /* Start the target at PC */ @@ -195,6 +200,7 @@ wiggler_error (s, error_code) char buf[100]; fputs_filtered (s, gdb_stderr); + fputs_filtered (" ", gdb_stderr); switch (error_code) { @@ -211,6 +217,7 @@ wiggler_error (s, error_code) case 0x14: s = "Parameter error"; break; case 0x15: s = "Internal error"; break; case 0x16: s = "Register buffer error"; break; + case 0x80: s = "Flash erase error"; break; default: sprintf (buf, "Unknown error code %d", error_code); s = buf; @@ -829,7 +836,6 @@ wiggler_write_bytes (memaddr, myaddr, len) int status, error_code; numbytes = min (len, 256 - 8); -/* numbytes = min (len, 40);*/ buf[1] = memaddr >> 24; buf[2] = memaddr >> 16; @@ -847,7 +853,7 @@ wiggler_write_bytes (memaddr, myaddr, len) status = p[1]; error_code = p[2]; - if (error_code == 11) /* Got a bus error? */ + if (error_code == 0x11) /* Got a bus error? */ { CORE_ADDR error_address; @@ -864,7 +870,7 @@ wiggler_write_bytes (memaddr, myaddr, len) break; } else if (error_code != 0) - wiggler_error ("wiggler_store_registers:", error_code); + wiggler_error ("wiggler_write_bytes:", error_code); len -= numbytes; memaddr += numbytes; @@ -937,7 +943,7 @@ wiggler_read_bytes (memaddr, myaddr, len) break; } else if (error_code != 0) - wiggler_error ("wiggler_store_registers:", error_code); + wiggler_error ("wiggler_read_bytes:", error_code); memcpy (myaddr, &p[4], numbytes); @@ -955,7 +961,7 @@ wiggler_read_bytes (memaddr, myaddr, len) /* ARGSUSED */ static int -wiggler_xfer_memory(memaddr, myaddr, len, should_write, target) +wiggler_xfer_memory (memaddr, myaddr, len, should_write, target) CORE_ADDR memaddr; char *myaddr; int len; @@ -1307,6 +1313,10 @@ get_packet (cmd, lenp, timeout) case WIGGLER_MOVE_MEM: /* Move Memory */ case WIGGLER_WRITE_INT_MEM: /* Write Internal Memory */ case WIGGLER_JUMP: /* Jump to Subroutine */ + case WIGGLER_ERASE_FLASH: /* Erase flash memory */ + case WIGGLER_PROGRAM_FLASH: /* Write flash memory */ + case WIGGLER_EXIT_MON: /* Exit the flash programming monitor */ + case WIGGLER_ENTER_MON: /* Enter the flash programming monitor */ len = 0; break; case WIGGLER_GET_VERSION: /* Get Version */ @@ -1446,7 +1456,16 @@ wiggler_load (args, from_tty) int from_tty; { generic_load (args, from_tty); + inferior_pid = 0; + +/* This is necessary because many things were based on the PC at the time that + we attached to the monitor, which is no longer valid now that we have loaded + new code (and just changed the PC). Another way to do this might be to call + normal_stop, except that the stack may not be valid, and things would get + horribly confused... */ + + clear_symtab_users (); } /* BDM (at least on CPU32) uses a different breakpoint */ @@ -1506,6 +1525,91 @@ bdm_restart_command (args, from_tty) wait_for_inferior (); normal_stop (); } + +static int +flash_xfer_memory (memaddr, myaddr, len, should_write, target) + CORE_ADDR memaddr; + char *myaddr; + int len; + int should_write; + struct target_ops *target; /* ignored */ +{ + char buf[256 + 10]; + unsigned char *p; + int origlen; + + if (!should_write) + abort (); + + origlen = len; + + buf[0] = WIGGLER_PROGRAM_FLASH; + + while (len > 0) + { + int numbytes; + int pktlen; + int status, error_code; + + numbytes = min (len, 256 - 6); + + buf[1] = memaddr >> 24; + buf[2] = memaddr >> 16; + buf[3] = memaddr >> 8; + buf[4] = memaddr; + + buf[5] = numbytes; + + memcpy (&buf[6], myaddr, numbytes); + put_packet (buf, 6 + numbytes); + p = get_packet (WIGGLER_PROGRAM_FLASH, &pktlen, remote_timeout); + if (pktlen < 3) + error ("Truncated response packet from Wiggler"); + + status = p[1]; + error_code = p[2]; + + if (error_code != 0) + wiggler_error ("flash_xfer_memory:", error_code); + + len -= numbytes; + memaddr += numbytes; + myaddr += numbytes; + } + + return origlen - len; +} + +static void +bdm_update_flash_command (args, from_tty) + char *args; + int from_tty; +{ + int status, pktlen; + struct cleanup *old_chain; + + if (!wiggler_desc) + error ("Not connected to wiggler."); + + if (!args) + error ("Must specify file containing new Wiggler code."); + +/* old_chain = make_cleanup (flash_cleanup, 0);*/ + + do_command (WIGGLER_ENTER_MON, &status, &pktlen); + + do_command (WIGGLER_ERASE_FLASH, &status, &pktlen); + + wiggler_ops.to_xfer_memory = flash_xfer_memory; + + generic_load (args, from_tty); + + wiggler_ops.to_xfer_memory = wiggler_xfer_memory; + + do_command (WIGGLER_EXIT_MON, &status, &pktlen); + +/* discard_cleanups (old_chain);*/ +} /* Define the target subroutine names */ @@ -1570,4 +1674,5 @@ _initialize_remote_wiggler () add_cmd ("reset", class_obscure, bdm_reset_command, "", &bdm_cmd_list); add_cmd ("restart", class_obscure, bdm_restart_command, "", &bdm_cmd_list); + add_cmd ("update-flash", class_obscure, bdm_update_flash_command, "", &bdm_cmd_list); }