diff --git a/src/CLR/Debugger/Debugger.cpp b/src/CLR/Debugger/Debugger.cpp index 71d56eca80..3ff2490c45 100644 --- a/src/CLR/Debugger/Debugger.cpp +++ b/src/CLR/Debugger/Debugger.cpp @@ -314,6 +314,17 @@ bool CLR_DBG_Debugger::Monitor_Ping( WP_Message* msg) #if defined(WP_IMPLEMENTS_CRC32) cmdReply.m_dbg_flags |= Monitor_Ping_c_Ping_WPFlag_SupportsCRC32; #endif + + // Wire Protocol packet size + #if (WP_PACKET_SIZE == 512) + cmdReply.m_dbg_flags |= Monitor_Ping_c_PacketSize_0512; + #elif (WP_PACKET_SIZE == 256) + cmdReply.m_dbg_flags |= Monitor_Ping_c_PacketSize_0256; + #elif (WP_PACKET_SIZE == 128) + cmdReply.m_dbg_flags |= Monitor_Ping_c_PacketSize_0128; + #elif (WP_PACKET_SIZE == 1024) + cmdReply.m_dbg_flags |= Monitor_Ping_c_PacketSize_1024; + #endif WP_ReplyToCommand( msg, true, false, &cmdReply, sizeof(cmdReply) ); } diff --git a/src/CLR/Include/WireProtocol.h b/src/CLR/Include/WireProtocol.h index d6afe65554..0410740451 100644 --- a/src/CLR/Include/WireProtocol.h +++ b/src/CLR/Include/WireProtocol.h @@ -12,6 +12,7 @@ #include #include #include +#include #ifndef min #define min(a,b) (((a) < (b)) ? (a) : (b)) @@ -24,6 +25,11 @@ #define MARKER_DEBUGGER_V1 "NFDBGV1" // Used to identify the debugger at boot time. #define MARKER_PACKET_V1 "NFPKTV1" // Used to identify the start of a packet. +#ifndef WP_PACKET_SIZE +// no Wire Protocol defined at target_common, set to default as 1024 +#define WP_PACKET_SIZE 1024U +#endif + // enum with Wire Protocol flags // backwards compatible with .NETMF typedef enum WP_Flags @@ -133,8 +139,9 @@ typedef struct WP_Message // enum with flags for Monitor ping source and debugger flags -// backwards compatible with .NETMF in debugger flags only -// adds NEW flags for nanoBooter and nanoCLR +/////////////////////////////////////////////////////////////////////// +// !!! KEEP IN SYNC WITH Monitor_Ping (in debugger library code) !!! // +/////////////////////////////////////////////////////////////////////// typedef enum Monitor_Ping_Source_Flags { Monitor_Ping_c_Ping_Source_NanoCLR = 0x00010000, @@ -145,6 +152,13 @@ typedef enum Monitor_Ping_Source_Flags // flags specific to Wire Protocol capabilities Monitor_Ping_c_Ping_WPFlag_SupportsCRC32 = 0x00000010, + + // Wire Protocol packet size (3rd position) + Monitor_Ping_c_PacketSize_1024 = 0x00000100, + Monitor_Ping_c_PacketSize_0512 = 0x00000200, + Monitor_Ping_c_PacketSize_0256 = 0x00000300, + Monitor_Ping_c_PacketSize_0128 = 0x00000400, + }Monitor_Ping_Source_Flags; diff --git a/src/CLR/Include/WireProtocol_App_Interface.h b/src/CLR/Include/WireProtocol_App_Interface.h index 1c87bce07f..fa3c133526 100644 --- a/src/CLR/Include/WireProtocol_App_Interface.h +++ b/src/CLR/Include/WireProtocol_App_Interface.h @@ -9,7 +9,7 @@ #include "WireProtocol.h" ////////////////////////////////////////// -extern uint8_t receptionBuffer[2048]; +extern uint8_t receptionBuffer[sizeof(WP_Packet) + WP_PACKET_SIZE]; extern void ReplyToCommand(WP_Message* message, int fSuccess, int fCritical, void* ptr, int size); ////////////////////////////////////////// diff --git a/src/CLR/WireProtocol/WireProtocol_Message.c b/src/CLR/WireProtocol/WireProtocol_Message.c index 5af0514d2f..d68a1e6f8b 100644 --- a/src/CLR/WireProtocol/WireProtocol_Message.c +++ b/src/CLR/WireProtocol/WireProtocol_Message.c @@ -8,7 +8,7 @@ #include #include "WireProtocol_Message.h" -uint8_t receptionBuffer[2048]; +uint8_t receptionBuffer[sizeof(WP_Packet) + WP_PACKET_SIZE]; static uint16_t lastOutboundMessage; // FIXME #146 uint32_t m_payloadTicks; static uint8_t* marker; diff --git a/targets/CMSIS-OS/ChibiOS/nanoBooter/WireProtocol_MonitorCommands.c b/targets/CMSIS-OS/ChibiOS/nanoBooter/WireProtocol_MonitorCommands.c index c2e325babc..df868c63c5 100644 --- a/targets/CMSIS-OS/ChibiOS/nanoBooter/WireProtocol_MonitorCommands.c +++ b/targets/CMSIS-OS/ChibiOS/nanoBooter/WireProtocol_MonitorCommands.c @@ -73,6 +73,18 @@ int Monitor_Ping(WP_Message* message) cmdReply.m_dbg_flags |= Monitor_Ping_c_Ping_WPFlag_SupportsCRC32; #endif + // Wire Protocol packet size + #if (WP_PACKET_SIZE == 512) + cmdReply.m_dbg_flags |= Monitor_Ping_c_PacketSize_0512; + #elif (WP_PACKET_SIZE == 256) + cmdReply.m_dbg_flags |= Monitor_Ping_c_PacketSize_0256; + #elif (WP_PACKET_SIZE == 128) + cmdReply.m_dbg_flags |= Monitor_Ping_c_PacketSize_0128; + #elif (WP_PACKET_SIZE == 1024) + cmdReply.m_dbg_flags |= Monitor_Ping_c_PacketSize_1024; + #endif + + WP_ReplyToCommand(message, true, false, &cmdReply, sizeof(cmdReply)); }