14 using namespace BazisLib;
15 using namespace GDBServerFoundation;
45 using namespace MSP430Proxy;
56 : m_Settings(settings)
60 virtual IGDBStub *CreateStub(GDBServer *pServer)
63 if (m_Settings.EnableEEMMode)
70 printf(
"Cannot start a new debugging session before the old session ends.\n");
76 printf(
"Failed to initialize MSP430 debugging engine. Aborting.\n");
80 printf(
"New GDB debugging session started.\n");
82 if (m_Settings.SingleSessionOnly)
83 pServer->StopListening();
88 virtual void OnProtocolError(
const TCHAR *errorDescription)
90 _tprintf(_T(
"Protocol error: %s\n"), errorDescription);
99 printf(
"Usage: msp430-gdbproxy [options]\n\
100 All options are optional:\n\
101 --noeem - Disable EEM mode (required for advanced breakpoints)\n\
102 --keepbp - Keep software breakpoints in FLASH (reduces erase cycles)\n\
103 --bp_insn=0xNNNN - Override software breakpoint instruction (default 0x4343)\n\
104 --bpmode=<mode> - Specifies how to create breakpoints with \"break\" command:\n\
105 soft - always create software breakpoints (run \"hbreak\" to override)\n\
106 hard - always create hardware breakpoints, fail when out of them\n\
107 auto - create hardware breakpoints while available, then software\n\
108 --progport=<port> - Specify port for TI FET (default is \"USB\")\n\
109 --voltage=<nnnn> - Specify Vcc voltage in mV (default = 3333)\n\
110 --tcpport=<n> - Listen on TCP port n (default 2000)\n\
111 --keepalive - Keep running after GDB disconnects, wait for next connection\n\
112 --autoerase - Erase FLASH when debugging is started\n\
118 for (
int i = 1; i < argc; i++)
121 char *sep = strchr(argv[i],
'=');
124 arg = std::string(argv[i], sep - argv[i]), val = sep + 1;
128 if (arg.length() < 2 || arg[0] !=
'-' || arg[1] !=
'-')
130 printf(
"Warning: unknown option: %s\n", arg.c_str());
138 else if (arg ==
"keepbp")
140 else if (arg ==
"bp_insn")
142 if (strlen(val) < 3 || _memicmp(val,
"0x", 2))
144 printf(
"Warning: wrong bp_insn format\n");
148 sscanf(val,
"%x", &insn);
151 else if (arg ==
"bpmode")
155 if (!strcmp(val,
"soft"))
157 else if (!strcmp(val,
"hard"))
159 else if (!strcmp(val,
"auto"))
162 else if (arg ==
"progport")
164 else if (arg ==
"tcpport")
166 else if (arg ==
"voltage")
168 else if (arg ==
"keepalive")
170 else if (arg ==
"autoerase")
175 int main(
int argc,
char* argv[])
179 if (argc >= 2 && !strcmp(argv[1],
"--help"))
188 STATUS_T status = MSP430_Initialize((
char *)settings.
PortName, &version);
189 if (status != STATUS_OK)
192 printf(
"\nRun msp430-gdbproxy --help for usage instructions.\n");
198 ActionStatus st = srv.Start(settings.
ListenPort);
199 if (!st.Successful())
201 _tprintf(_T(
"Cannot start listening on port %d: %s\n"), settings.
ListenPort, st.GetMostInformativeText().c_str());
205 printf(
"msp430-gdbproxy++ v1.0 [http://gnutoolchains.com/msp430/gdbproxy]\n\
206 Run \"msp430-gdbproxy --help\" to get help.\n\
207 Listening on port %d.\nTo start debugging:\n\
208 \t1. Start \"msp430-gdb <yourfile.elf>\"\n\
209 \t2. Run the \"target remote :%d\" command in GDB.\n\
210 \t3. Run \"load\" to program the FLASH memory.\n\
211 \t4. In case of GDB errors, see this window for more info.\n", settings.
ListenPort, settings.
ListenPort);
213 printf(
"If you don't have msp430-gdb, visit http://gnutoolchains.com/msp430 to get it.\n\n");
215 srv.WaitForTermination();