Skip to content

Commit

Permalink
- Added option to erase Info memory
Browse files Browse the repository at this point in the history
  • Loading branch information
grumat committed Mar 14, 2019
1 parent 46d14b9 commit c2f2a3a
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 3 deletions.
5 changes: 3 additions & 2 deletions MSP430Target.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -85,10 +85,11 @@ bool MSP430Proxy::MSP430GDBTarget::Initialize(const GlobalSettings &settings)
if (MSP430_Reset(ALL_RESETS, FALSE, FALSE) != STATUS_OK)
REPORT_AND_RETURN("Cannot reset the MSP430 device", false);

m_bEraseInfoMem = settings.EraseInfoMem;
if (settings.AutoErase)
{
printf("Erasing FLASH...\n");
if (MSP430_Erase(ERASE_MAIN, m_DeviceInfo.mainStart, m_DeviceInfo.mainEnd - m_DeviceInfo.mainStart) != STATUS_OK)
if (MSP430_Erase(m_bEraseInfoMem ? ERASE_ALL : ERASE_MAIN, m_DeviceInfo.mainStart, m_DeviceInfo.mainEnd - m_DeviceInfo.mainStart) != STATUS_OK)
printf("Warning: cannot erase FLASH: %s\n", GetLastMSP430Error());
else
m_bFLASHErased = true;
Expand Down Expand Up @@ -161,7 +162,7 @@ GDBServerFoundation::GDBStatus MSP430Proxy::MSP430GDBTarget::ExecuteRemoteComman
}
else if (command == "erase")
{
if (MSP430_Erase(ERASE_MAIN, m_DeviceInfo.mainStart, m_DeviceInfo.mainEnd - m_DeviceInfo.mainStart) != STATUS_OK)
if (MSP430_Erase(m_bEraseInfoMem ? ERASE_ALL : ERASE_MAIN, m_DeviceInfo.mainStart, m_DeviceInfo.mainEnd - m_DeviceInfo.mainStart) != STATUS_OK)
{
output = "Cannot erase FLASH: ";
output += GetLastMSP430Error();
Expand Down
2 changes: 2 additions & 0 deletions MSP430Target.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ namespace MSP430Proxy

bool m_bFLASHErased;
bool m_b32BitRegisterMode;
bool m_bEraseInfoMem;

protected:
bool m_BreakInPending, m_bFLASHCommandsUsed;
Expand All @@ -48,6 +49,7 @@ namespace MSP430Proxy
, m_bFLASHErased(false)
, m_bFLASHCommandsUsed(false)
, m_b32BitRegisterMode(false)
, m_bEraseInfoMem(false)
{
}
public:
Expand Down
7 changes: 6 additions & 1 deletion msp430-gdbproxy.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,7 @@ All options are optional:\n\
--tcpport=<n> - Listen on TCP port n (default 2000)\n\
--keepalive - Keep running after GDB disconnects, wait for next connection\n\
--autoerase - Erase FLASH when debugging is started\n\
--eraseinfo - Erase FLASH also includes information memory\n\
--nohint - Do not show the 'how to start debugging' message\n\
--verbose - Enable verbose diagnostic output\n\
--iface=jtag/sbw/sbwjtag/auto - Specify connection interface\n\
Expand Down Expand Up @@ -209,6 +210,10 @@ void ParseOptions(int argc, char* argv[], GlobalSettings &settings)
{
settings.Emulate32BitRegisters = true;
}
else if (arg == "eraseinfo")
{
settings.EraseInfoMem = true;
}
}
}

Expand Down Expand Up @@ -249,7 +254,7 @@ int main(int argc, char* argv[])
return 1;
}

printf("msp430-gdbproxy++ v1.8 [http://gnutoolchains.com/msp430/gdbproxy]\nSuccessfully initialized MSP430.DLL on %s\nListening on port %d.\n", settings.PortName, settings.ListenPort);
printf("msp430-gdbproxy++ v1.9 [http://gnutoolchains.com/msp430/gdbproxy]\nSuccessfully initialized MSP430.DLL on %s\nListening on port %d.\n", settings.PortName, settings.ListenPort);

if (settings.Emulate32BitRegisters)
printf("Using 32-bit register mode (GDB 7.7+)\n");
Expand Down
2 changes: 2 additions & 0 deletions settings.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ namespace MSP430Proxy
HardwareInterface Interface;
HardwareInterfaceSpeed InterfaceSpeed;
bool Emulate32BitRegisters;
bool EraseInfoMem;

GlobalSettings()
{
Expand All @@ -59,6 +60,7 @@ namespace MSP430Proxy
Interface = UnspecifiedInterface;
InterfaceSpeed = UnspecifiedSpeed;
Emulate32BitRegisters = false;
EraseInfoMem = false;
}
};
}

0 comments on commit c2f2a3a

Please sign in to comment.