1 /* Target communications support for Macraigor Systems' On-Chip Debugging
3 Copyright 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2004 Free
4 Software Foundation, Inc.
6 This file is part of GDB.
8 This program is free software; you can redistribute it and/or modify
9 it under the terms of the GNU General Public License as published by
10 the Free Software Foundation; either version 2 of the License, or
11 (at your option) any later version.
13 This program is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
18 You should have received a copy of the GNU General Public License
19 along with this program; if not, write to the Free Software
20 Foundation, Inc., 59 Temple Place - Suite 330,
21 Boston, MA 02111-1307, USA. */
25 #include "gdb_string.h"
32 #include "exceptions.h"
35 #include "gdb-stabs.h"
36 #include <sys/types.h>
42 /* Prototypes for local functions */
44 static int ocd_read_bytes (CORE_ADDR memaddr, char *myaddr, int len);
46 static int ocd_start_remote (void *dummy);
48 static int readchar (int timeout);
50 static void ocd_interrupt (int signo);
52 static void ocd_interrupt_twice (int signo);
54 static void interrupt_query (void);
56 static unsigned char *ocd_do_command (int cmd, int *statusp, int *lenp);
58 static void ocd_put_packet (unsigned char *packet, int pktlen);
60 static unsigned char *ocd_get_packet (int cmd, int *pktlen, int timeout);
62 static struct target_ops *current_ops = NULL;
64 static int last_run_status;
66 /* Descriptor for I/O to remote machine. Initialize it to NULL so that
67 ocd_open knows that we don't have a file open when the program
69 static struct serial *ocd_desc = NULL;
72 ocd_error (char *s, int error_code)
76 fputs_filtered (s, gdb_stderr);
77 fputs_filtered (" ", gdb_stderr);
88 s = "Cable disconnected";
91 s = "Couldn't enter OCD mode";
94 s = "Target stuck in reset";
97 s = "OCD hasn't been initialized";
100 s = "Write verify failed";
103 s = "Reg buff error (during MPC5xx fp reg read/write)";
106 s = "Invalid CPU register access attempt failed";
112 s = "Checksum error";
115 s = "Illegal command";
118 s = "Parameter error";
121 s = "Internal error";
124 s = "Flash erase error";
127 sprintf (buf, "Unknown error code %d", error_code);
134 /* Return nonzero if the thread TH is still alive on the remote system. */
137 ocd_thread_alive (ptid_t th)
142 /* Clean up connection to a remote debugger. */
145 ocd_close (int quitting)
148 serial_close (ocd_desc);
152 /* Stub for catch_errors. */
155 ocd_start_remote (void *dummy)
157 unsigned char buf[10], *p;
162 enum ocd_target_type target_type;
164 target_type = *(enum ocd_target_type *) dummy;
166 immediate_quit++; /* Allow user to interrupt it */
168 serial_send_break (ocd_desc); /* Wake up the wiggler */
170 speed = 80; /* Divide clock by 4000 */
174 buf[2] = speed & 0xff;
175 buf[3] = target_type;
176 ocd_put_packet (buf, 4); /* Init OCD params */
177 p = ocd_get_packet (buf[0], &pktlen, remote_timeout);
180 error (_("Truncated response packet from OCD device"));
186 ocd_error (_("OCD_INIT:"), error_code);
188 ocd_do_command (OCD_AYT, &status, &pktlen);
190 p = ocd_do_command (OCD_GET_VERSION, &status, &pktlen);
192 printf_unfiltered (_("[Wiggler version %x.%x, capability 0x%x]\n"),
193 p[0], p[1], (p[2] << 16) | p[3]);
195 /* If processor is still running, stop it. */
197 if (!(status & OCD_FLAG_BDM))
200 /* When using a target box, we want to asynchronously return status when
201 target stops. The OCD_SET_CTL_FLAGS command is ignored by Wigglers.dll
202 when using a parallel Wiggler */
203 buf[0] = OCD_SET_CTL_FLAGS;
206 ocd_put_packet (buf, 3);
208 p = ocd_get_packet (buf[0], &pktlen, remote_timeout);
211 error (_("Truncated response packet from OCD device"));
217 ocd_error ("OCD_SET_CTL_FLAGS:", error_code);
221 /* This is really the job of start_remote however, that makes an assumption
222 that the target is about to print out a status message of some sort. That
223 doesn't happen here (in fact, it may not be possible to get the monitor to
224 send the appropriate packet). */
226 flush_cached_frames ();
227 registers_changed ();
228 stop_pc = read_pc ();
229 print_stack_frame (get_selected_frame (NULL), 0, SRC_AND_LOC);
231 buf[0] = OCD_LOG_FILE;
232 buf[1] = 3; /* close existing WIGGLERS.LOG */
233 ocd_put_packet (buf, 2);
234 p = ocd_get_packet (buf[0], &pktlen, remote_timeout);
236 buf[0] = OCD_LOG_FILE;
237 buf[1] = 2; /* append to existing WIGGLERS.LOG */
238 ocd_put_packet (buf, 2);
239 p = ocd_get_packet (buf[0], &pktlen, remote_timeout);
244 /* Open a connection to a remote debugger.
245 NAME is the filename used for communication. */
248 ocd_open (char *name, int from_tty, enum ocd_target_type target_type,
249 struct target_ops *ops)
251 unsigned char buf[10], *p;
255 error (_("To open an OCD connection, you need to specify the\n\
256 device the OCD device is attached to (e.g. /dev/ttya)."));
258 target_preopen (from_tty);
262 unpush_target (current_ops);
264 ocd_desc = serial_open (name);
266 perror_with_name (name);
270 if (serial_setbaudrate (ocd_desc, baud_rate))
272 serial_close (ocd_desc);
273 perror_with_name (name);
277 serial_raw (ocd_desc);
279 /* If there is something sitting in the buffer we might take it as a
280 response to a command, which would be bad. */
281 serial_flush_input (ocd_desc);
285 puts_filtered ("Remote target wiggler connected to ");
286 puts_filtered (name);
287 puts_filtered ("\n");
289 push_target (current_ops); /* Switch to using remote target now */
291 /* Without this, some commands which require an active target (such as kill)
292 won't work. This variable serves (at least) double duty as both the pid
293 of the target process (if it has such), and as a flag indicating that a
294 target is active. These functions should be split out into seperate
295 variables, especially since GDB will someday have a notion of debugging
296 several processes. */
298 inferior_ptid = pid_to_ptid (42000);
299 /* Start the remote connection; if error (0), discard this target.
300 In particular, if the user quits, be sure to discard it
301 (we'd be in an inconsistent state otherwise). */
302 if (!catch_errors (ocd_start_remote, &target_type,
303 "Couldn't establish connection to remote target\n",
307 error (_("Failed to connect to OCD."));
311 /* This takes a program previously attached to and detaches it. After
312 this is done, GDB can be used to debug some other program. We
313 better not have left any breakpoints in the target program or it'll
314 die when it hits one. */
317 ocd_detach (char *args, int from_tty)
320 error (_("Argument given to \"detach\" when remotely debugging."));
324 puts_filtered ("Ending remote debugging.\n");
327 /* Tell the remote machine to resume. */
330 ocd_resume (ptid_t ptid, int step, enum target_signal siggnal)
335 ocd_do_command (OCD_STEP, &last_run_status, &pktlen);
337 ocd_do_command (OCD_RUN, &last_run_status, &pktlen);
346 ocd_do_command (OCD_STOP, &status, &pktlen);
348 if (!(status & OCD_FLAG_BDM))
349 error (_("Can't stop target via BDM"));
352 static volatile int ocd_interrupt_flag;
354 /* Send ^C to target to halt it. Target will respond, and send us a
358 ocd_interrupt (int signo)
360 /* If this doesn't work, try more severe steps. */
361 signal (signo, ocd_interrupt_twice);
364 printf_unfiltered ("ocd_interrupt called\n");
371 ocd_put_packet (buf, 1);
372 ocd_interrupt_flag = 1;
376 static void (*ofunc) ();
378 /* The user typed ^C twice. */
380 ocd_interrupt_twice (int signo)
382 signal (signo, ofunc);
386 signal (signo, ocd_interrupt);
389 /* Ask the user what to do when an interrupt is received. */
392 interrupt_query (void)
394 target_terminal_ours ();
396 if (query ("Interrupted while waiting for the program.\n\
397 Give up (and stop debugging it)? "))
399 target_mourn_inferior ();
400 deprecated_throw_reason (RETURN_QUIT);
403 target_terminal_inferior ();
406 /* If nonzero, ignore the next kill. */
407 static int kill_kludge;
409 /* Wait until the remote machine stops, then return,
410 storing status in STATUS just as `wait' would.
411 Returns "pid" (though it's not clear what, if anything, that
412 means in the case of this target). */
422 ocd_interrupt_flag = 0;
424 /* Target might already be stopped by the time we get here. */
425 /* If we aren't already stopped, we need to loop until we've dropped
426 back into BDM mode */
428 while (!(last_run_status & OCD_FLAG_BDM))
431 ocd_put_packet (buf, 1);
432 p = ocd_get_packet (OCD_AYT, &pktlen, -1);
434 ofunc = (void (*)()) signal (SIGINT, ocd_interrupt);
435 signal (SIGINT, ofunc);
438 error (_("Truncated response packet from OCD device"));
440 last_run_status = p[1];
444 ocd_error ("target_wait:", error_code);
446 if (last_run_status & OCD_FLAG_PWF)
447 error (_("OCD device lost VCC at BDM interface."));
448 else if (last_run_status & OCD_FLAG_CABLE_DISC)
449 error (_("OCD device cable appears to have been disconnected."));
452 if (ocd_interrupt_flag)
458 /* Read registers from the OCD device. Specify the starting and ending
459 register number. Return the number of regs actually read in *NUMREGS.
460 Returns a pointer to a static array containing the register contents. */
463 ocd_read_bdm_registers (int first_bdm_regno, int last_bdm_regno, int *reglen)
465 unsigned char buf[10];
469 int error_code, status;
472 buf[0] = OCD_READ_REGS;
473 buf[1] = first_bdm_regno >> 8;
474 buf[2] = first_bdm_regno & 0xff;
475 buf[3] = last_bdm_regno >> 8;
476 buf[4] = last_bdm_regno & 0xff;
478 ocd_put_packet (buf, 5);
479 p = ocd_get_packet (OCD_READ_REGS, &pktlen, remote_timeout);
485 ocd_error ("read_bdm_registers:", error_code);
493 error (_("Register block size bad: %d"), i);
502 /* Read register BDM_REGNO and returns its value ala read_register() */
505 ocd_read_bdm_register (int bdm_regno)
511 p = ocd_read_bdm_registers (bdm_regno, bdm_regno, ®len);
512 regval = extract_unsigned_integer (p, reglen);
518 ocd_write_bdm_registers (int first_bdm_regno, unsigned char *regptr, int reglen)
522 int error_code, status;
525 buf = alloca (4 + reglen);
527 buf[0] = OCD_WRITE_REGS;
528 buf[1] = first_bdm_regno >> 8;
529 buf[2] = first_bdm_regno & 0xff;
531 memcpy (buf + 4, regptr, reglen);
533 ocd_put_packet (buf, 4 + reglen);
534 p = ocd_get_packet (OCD_WRITE_REGS, &pktlen, remote_timeout);
537 error (_("Truncated response packet from OCD device"));
543 ocd_error ("ocd_write_bdm_registers:", error_code);
547 ocd_write_bdm_register (int bdm_regno, CORE_ADDR reg)
549 unsigned char buf[4];
551 store_unsigned_integer (buf, 4, reg);
553 ocd_write_bdm_registers (bdm_regno, buf, 4);
557 ocd_prepare_to_store (void)
561 /* Write memory data directly to the remote machine.
562 This does not inform the data cache; the data cache uses this.
563 MEMADDR is the address in the remote memory space.
564 MYADDR is the address of the buffer in our space.
565 LEN is the number of bytes.
567 Returns number of bytes transferred, or 0 for error. */
569 static int write_mem_command = OCD_WRITE_MEM;
572 ocd_write_bytes (CORE_ADDR memaddr, char *myaddr, int len)
580 buf[0] = write_mem_command;
581 buf[5] = 1; /* Write as bytes */
582 buf[6] = 0; /* Don't verify */
588 int status, error_code;
590 numbytes = min (len, 256 - 8);
592 buf[1] = memaddr >> 24;
593 buf[2] = memaddr >> 16;
594 buf[3] = memaddr >> 8;
599 memcpy (&buf[8], myaddr, numbytes);
600 ocd_put_packet (buf, 8 + numbytes);
601 p = ocd_get_packet (OCD_WRITE_MEM, &pktlen, remote_timeout);
603 error (_("Truncated response packet from OCD device"));
608 if (error_code == 0x11) /* Got a bus error? */
610 CORE_ADDR error_address;
612 error_address = p[3] << 24;
613 error_address |= p[4] << 16;
614 error_address |= p[5] << 8;
615 error_address |= p[6];
616 numbytes = error_address - memaddr;
624 else if (error_code != 0)
625 ocd_error ("ocd_write_bytes:", error_code);
632 return origlen - len;
635 /* Read memory data directly from the remote machine.
636 This does not use the data cache; the data cache uses this.
637 MEMADDR is the address in the remote memory space.
638 MYADDR is the address of the buffer in our space.
639 LEN is the number of bytes.
641 Returns number of bytes transferred, or 0 for error. */
644 ocd_read_bytes (CORE_ADDR memaddr, char *myaddr, int len)
652 buf[0] = OCD_READ_MEM;
653 buf[5] = 1; /* Read as bytes */
659 int status, error_code;
661 numbytes = min (len, 256 - 7);
663 buf[1] = memaddr >> 24;
664 buf[2] = memaddr >> 16;
665 buf[3] = memaddr >> 8;
670 ocd_put_packet (buf, 7);
671 p = ocd_get_packet (OCD_READ_MEM, &pktlen, remote_timeout);
673 error (_("Truncated response packet from OCD device"));
678 if (error_code == 0x11) /* Got a bus error? */
680 CORE_ADDR error_address;
682 error_address = p[3] << 24;
683 error_address |= p[4] << 16;
684 error_address |= p[5] << 8;
685 error_address |= p[6];
686 numbytes = error_address - memaddr;
694 else if (error_code != 0)
695 ocd_error ("ocd_read_bytes:", error_code);
697 memcpy (myaddr, &p[4], numbytes);
704 return origlen - len;
707 /* Read or write LEN bytes from inferior memory at MEMADDR, transferring
708 to or from debugger address MYADDR. Write to inferior if SHOULD_WRITE is
709 nonzero. Returns length of data written or read; 0 for error. TARGET
713 ocd_xfer_memory (CORE_ADDR memaddr, char *myaddr, int len, int should_write,
714 struct mem_attrib *attrib, struct target_ops *target)
719 res = ocd_write_bytes (memaddr, myaddr, len);
721 res = ocd_read_bytes (memaddr, myaddr, len);
727 ocd_files_info (struct target_ops *ignore)
729 puts_filtered ("Debugging a target over a serial line.\n");
732 /* Stuff for dealing with the packets which are part of this protocol.
733 See comment at top of file for details. */
735 /* Read a single character from the remote side, handling wierd errors. */
738 readchar (int timeout)
742 ch = serial_readchar (ocd_desc, timeout);
747 error (_("Remote connection closed"));
749 perror_with_name (_("Remote communication error"));
756 /* Send a packet to the OCD device. The packet framed by a SYN character,
757 a byte count and a checksum. The byte count only counts the number of
758 bytes between the count and the checksum. A count of zero actually
759 means 256. Any SYNs within the packet (including the checksum and
760 count) must be quoted. The quote character must be quoted as well.
761 Quoting is done by replacing the character with the two-character sequence
762 DLE, {char} | 0100. Note that the quoting mechanism has no effect on the
766 ocd_put_packet (unsigned char *buf, int len)
768 unsigned char checksum;
770 unsigned char *packet, *packet_ptr;
772 packet = alloca (len + 1 + 1); /* packet + SYN + checksum */
777 *packet_ptr++ = 0x55;
787 *packet_ptr++ = -checksum;
788 if (serial_write (ocd_desc, packet, packet_ptr - packet))
789 perror_with_name (_("output_packet: write failed"));
792 /* Get a packet from the OCD device. Timeout is only enforced for the
793 first byte of the packet. Subsequent bytes are expected to arrive in
794 time <= remote_timeout. Returns a pointer to a static buffer containing
795 the payload of the packet. *LENP contains the length of the packet.
798 static unsigned char *
799 ocd_get_packet (int cmd, int *lenp, int timeout)
803 static unsigned char packet[512];
804 unsigned char *packet_ptr;
805 unsigned char checksum;
807 ch = readchar (timeout);
810 error (_("ocd_get_packet (readchar): %d"), ch);
813 error (_("ocd_get_packet (readchar): %d"), ch);
815 /* Found the start of a packet */
820 /* Read command char. That sort of tells us how long the packet is. */
822 ch = readchar (timeout);
825 error (_("ocd_get_packet (readchar): %d"), ch);
832 ch = readchar (timeout);
835 error (_("ocd_get_packet (readchar): %d"), ch);
839 /* Get error code. */
841 ch = readchar (timeout);
844 error (_("ocd_get_packet (readchar): %d"), ch);
848 switch (ch) /* Figure out length of packet */
850 case 0x7: /* Write verify error? */
851 len = 8; /* write address, value read back */
853 case 0x11: /* Bus error? */
854 /* write address, read flag */
855 case 0x15: /* Internal error */
856 len = 5; /* error code, vector */
858 default: /* Error w/no params */
861 case 0x0: /* Normal result */
864 case OCD_AYT: /* Are You There? */
865 case OCD_SET_BAUD_RATE: /* Set Baud Rate */
866 case OCD_INIT: /* Initialize OCD device */
867 case OCD_SET_SPEED: /* Set Speed */
868 case OCD_SET_FUNC_CODE: /* Set Function Code */
869 case OCD_SET_CTL_FLAGS: /* Set Control Flags */
870 case OCD_SET_BUF_ADDR: /* Set Register Buffer Address */
871 case OCD_RUN: /* Run Target from PC */
872 case OCD_RUN_ADDR: /* Run Target from Specified Address */
873 case OCD_STOP: /* Stop Target */
874 case OCD_RESET_RUN: /* Reset Target and Run */
875 case OCD_RESET: /* Reset Target and Halt */
876 case OCD_STEP: /* Single Step */
877 case OCD_WRITE_REGS: /* Write Register */
878 case OCD_WRITE_MEM: /* Write Memory */
879 case OCD_FILL_MEM: /* Fill Memory */
880 case OCD_MOVE_MEM: /* Move Memory */
881 case OCD_WRITE_INT_MEM: /* Write Internal Memory */
882 case OCD_JUMP: /* Jump to Subroutine */
883 case OCD_ERASE_FLASH: /* Erase flash memory */
884 case OCD_PROGRAM_FLASH: /* Write flash memory */
885 case OCD_EXIT_MON: /* Exit the flash programming monitor */
886 case OCD_ENTER_MON: /* Enter the flash programming monitor */
887 case OCD_LOG_FILE: /* Make Wigglers.dll save Wigglers.log */
888 case OCD_SET_CONNECTION: /* Set type of connection in Wigglers.dll */
891 case OCD_GET_VERSION: /* Get Version */
894 case OCD_GET_STATUS_MASK: /* Get Status Mask */
897 case OCD_GET_CTRS: /* Get Error Counters */
898 case OCD_READ_REGS: /* Read Register */
899 case OCD_READ_MEM: /* Read Memory */
900 case OCD_READ_INT_MEM: /* Read Internal Memory */
904 error (_("ocd_get_packet: unknown packet type 0x%x."), ch);
908 if (len == 257) /* Byte stream? */
909 { /* Yes, byte streams contain the length */
910 ch = readchar (timeout);
913 error (_("ocd_get_packet (readchar): %d"), ch);
921 while (len-- >= 0) /* Do rest of packet and checksum */
923 ch = readchar (timeout);
926 error (_("ocd_get_packet (readchar): %d"), ch);
932 error (_("ocd_get_packet: bad packet checksum"));
934 if (cmd != -1 && cmd != packet[0])
935 error (_("Response phase error. Got 0x%x, expected 0x%x"), packet[0], cmd);
937 *lenp = packet_ptr - packet - 1; /* Subtract checksum byte */
941 /* Execute a simple (one-byte) command. Returns a pointer to the data
942 following the error code. */
944 static unsigned char *
945 ocd_do_command (int cmd, int *statusp, int *lenp)
947 unsigned char buf[100], *p;
948 int status, error_code;
951 unsigned char logbuf[100];
955 ocd_put_packet (buf, 1); /* Send command */
956 p = ocd_get_packet (*buf, lenp, remote_timeout);
959 error (_("Truncated response packet from OCD device"));
966 sprintf (errbuf, "ocd_do_command (0x%x):", cmd);
967 ocd_error (errbuf, error_code);
970 if (status & OCD_FLAG_PWF)
971 error (_("OCD device can't detect VCC at BDM interface."));
972 else if (status & OCD_FLAG_CABLE_DISC)
973 error (_("BDM cable appears to be disconnected."));
977 logbuf[0] = OCD_LOG_FILE;
978 logbuf[1] = 3; /* close existing WIGGLERS.LOG */
979 ocd_put_packet (logbuf, 2);
980 ocd_get_packet (logbuf[0], &logpktlen, remote_timeout);
982 logbuf[0] = OCD_LOG_FILE;
983 logbuf[1] = 2; /* append to existing WIGGLERS.LOG */
984 ocd_put_packet (logbuf, 2);
985 ocd_get_packet (logbuf[0], &logpktlen, remote_timeout);
993 /* For some mysterious reason, wait_for_inferior calls kill instead of
994 mourn after it gets TARGET_WAITKIND_SIGNALLED. Work around it. */
998 target_mourn_inferior ();
1002 /* Don't wait for it to die. I'm not really sure it matters whether
1004 target_mourn_inferior ();
1010 unpush_target (current_ops);
1011 generic_mourn_inferior ();
1014 /* All we actually do is set the PC to the start address of exec_bfd, and start
1015 the program at that point. */
1018 ocd_create_inferior (char *exec_file, char *args, char **env, int from_tty)
1020 if (args && (*args != '\000'))
1021 error (_("Args are not supported by BDM."));
1023 clear_proceed_status ();
1024 proceed (bfd_get_start_address (exec_bfd), TARGET_SIGNAL_0, 0);
1028 ocd_load (char *args, int from_tty)
1030 generic_load (args, from_tty);
1032 inferior_ptid = null_ptid;
1034 /* This is necessary because many things were based on the PC at the time that
1035 we attached to the monitor, which is no longer valid now that we have loaded
1036 new code (and just changed the PC). Another way to do this might be to call
1037 normal_stop, except that the stack may not be valid, and things would get
1038 horribly confused... */
1040 clear_symtab_users ();
1043 /* This should be defined for each target */
1044 /* But we want to be able to compile this file for some configurations
1045 not yet supported fully */
1047 #define BDM_BREAKPOINT {0x0,0x0,0x0,0x0} /* For ppc 8xx */
1049 /* BDM (at least on CPU32) uses a different breakpoint */
1052 ocd_insert_breakpoint (CORE_ADDR addr, char *contents_cache)
1054 static char break_insn[] = BDM_BREAKPOINT;
1057 val = target_read_memory (addr, contents_cache, sizeof (break_insn));
1060 val = target_write_memory (addr, break_insn, sizeof (break_insn));
1066 ocd_remove_breakpoint (CORE_ADDR addr, char *contents_cache)
1068 static char break_insn[] = BDM_BREAKPOINT;
1071 val = target_write_memory (addr, contents_cache, sizeof (break_insn));
1077 bdm_command (char *args, int from_tty)
1079 error (_("bdm command must be followed by `reset'"));
1083 bdm_reset_command (char *args, int from_tty)
1088 error (_("Not connected to OCD device."));
1090 ocd_do_command (OCD_RESET, &status, &pktlen);
1091 dcache_invalidate (target_dcache);
1092 registers_changed ();
1096 bdm_restart_command (char *args, int from_tty)
1101 error (_("Not connected to OCD device."));
1103 ocd_do_command (OCD_RESET_RUN, &status, &pktlen);
1104 last_run_status = status;
1105 clear_proceed_status ();
1106 wait_for_inferior ();
1110 /* Temporary replacement for target_store_registers(). This prevents
1111 generic_load from trying to set the PC. */
1114 noop_store_registers (int regno)
1119 bdm_update_flash_command (char *args, int from_tty)
1122 struct cleanup *old_chain;
1123 void (*store_registers_tmp) (int);
1126 error (_("Not connected to OCD device."));
1129 error (_("Must specify file containing new OCD code."));
1131 /* old_chain = make_cleanup (flash_cleanup, 0); */
1133 ocd_do_command (OCD_ENTER_MON, &status, &pktlen);
1135 ocd_do_command (OCD_ERASE_FLASH, &status, &pktlen);
1137 write_mem_command = OCD_PROGRAM_FLASH;
1138 store_registers_tmp = current_target.to_store_registers;
1139 current_target.to_store_registers = noop_store_registers;
1141 generic_load (args, from_tty);
1143 current_target.to_store_registers = store_registers_tmp;
1144 write_mem_command = OCD_WRITE_MEM;
1146 ocd_do_command (OCD_EXIT_MON, &status, &pktlen);
1148 /* discard_cleanups (old_chain); */
1151 extern initialize_file_ftype _initialize_remote_ocd; /* -Wmissing-prototypes */
1154 _initialize_remote_ocd (void)
1156 extern struct cmd_list_element *cmdlist;
1157 static struct cmd_list_element *ocd_cmd_list = NULL;
1159 deprecated_add_show_from_set
1160 (add_set_cmd ("remotetimeout", no_class,
1161 var_integer, (char *) &remote_timeout,
1162 "Set timeout value for remote read.\n", &setlist),
1165 add_prefix_cmd ("ocd", class_obscure, bdm_command, "", &ocd_cmd_list, "ocd ",
1168 add_cmd ("reset", class_obscure, bdm_reset_command, "", &ocd_cmd_list);
1169 add_cmd ("restart", class_obscure, bdm_restart_command, "", &ocd_cmd_list);
1170 add_cmd ("update-flash", class_obscure, bdm_update_flash_command, "", &ocd_cmd_list);