Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Monitor_Reboot command #100

Merged
merged 1 commit into from
Jan 31, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions src/CLR/WireProtocol/WireProtocol_MonitorCommands.c
Original file line number Diff line number Diff line change
Expand Up @@ -27,3 +27,10 @@ __attribute__((weak)) bool Monitor_WriteMemory(WP_Message* message)
// default to false
return false;
}

// provided as weak to be replaced by actual implementation by application
__attribute__((weak)) bool Monitor_Reboot(WP_Message* message)
{
// default to false
return false;
}
19 changes: 19 additions & 0 deletions src/CLR/WireProtocol/WireProtocol_MonitorCommands.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,19 @@
#include "WireProtocol.h"
#include "WireProtocol_Message.h"

//////////////////////////////////////////
// enums

// structure for Monitor Reboot options
// backwards compatible with .NETMF
typedef enum Monitor_Reboot_Options
{
Monitor_Reboot_c_NormalReboot = 0,
Monitor_Reboot_c_EnterBootloader = 1,
Monitor_Reboot_c_ClrRebootOnly = 2,
Monitor_Reboot_c_ClrStopDebugger = 4
}Monitor_Reboot_Options;

//////////////////////////////////////////
// typedefs

Expand Down Expand Up @@ -37,12 +50,18 @@ typedef struct CLR_DBG_Commands_Monitor_WriteMemory

}CLR_DBG_Commands_Monitor_WriteMemory;

typedef struct Monitor_Reboot_Command
{
uint32_t m_flags;

}Monitor_Reboot_Command;

//////////////////////////////////////////
// function declarations (commands)

bool Monitor_Ping(WP_Message* message);
bool Monitor_OemInfo(WP_Message* message);
bool Monitor_WriteMemory(WP_Message* message);
bool Monitor_Reboot(WP_Message* message);

#endif //_WIREPROTOCOL_COMMANDS_H_
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ static const CommandHandlerLookup c_Lookup_Request[] =
/*******************************************************************************************************************************************************************/
#define DEFINE_CMD(cmd) { CLR_DBG_Commands_c_Monitor_##cmd, &Monitor_##cmd }
DEFINE_CMD(Ping ),
// DEFINE_CMD(Reboot ),
DEFINE_CMD(Reboot ),
// //
// DEFINE_CMD(ReadMemory ),
DEFINE_CMD(WriteMemory),
Expand Down
24 changes: 24 additions & 0 deletions targets/CMSIS-OS/ChibiOS/nanoBooter/WireProtocol_MonitorCommands.c
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
// See LICENSE file in the project root for full license information.
//

#include <cmsis_os.h>

#include <WireProtocol.h>
#include <WireProtocol_MonitorCommands.h>

Expand Down Expand Up @@ -88,3 +90,25 @@ bool Monitor_WriteMemory(WP_Message* message)

return ret;
}

bool Monitor_Reboot(WP_Message* message)
{
Monitor_Reboot_Command* cmd = (Monitor_Reboot_Command*)message->m_payload;

ReplyToCommand(message, true, false, NULL, 0);

if(cmd != NULL)
{
// only reset if we are not trying to get into the bootloader
if((cmd->m_flags & Monitor_Reboot_c_EnterBootloader) != Monitor_Reboot_c_EnterBootloader)
{
// UNDONE: FIXME: Events_WaitForEvents( 0, 100 );

// RESET CPU
// because ChibiOS relies on CMSIS it's recommended to make use of the CMSIS API
NVIC_SystemReset();
}
}

return true;
}