Skip to content

Commit

Permalink
Add support for configurable Wire Protocol packet size
Browse files Browse the repository at this point in the history
Signed-off-by: José Simões <[email protected]>
  • Loading branch information
josesimoes committed Jul 16, 2018
1 parent efff69a commit 333caa9
Show file tree
Hide file tree
Showing 5 changed files with 41 additions and 4 deletions.
11 changes: 11 additions & 0 deletions src/CLR/Debugger/Debugger.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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) );
}
Expand Down
18 changes: 16 additions & 2 deletions src/CLR/Include/WireProtocol.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
#include <stddef.h>
#include <string.h>
#include <nanoSupport.h>
#include <target_common.h>

#ifndef min
#define min(a,b) (((a) < (b)) ? (a) : (b))
Expand All @@ -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
Expand Down Expand Up @@ -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,
Expand All @@ -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;


Expand Down
2 changes: 1 addition & 1 deletion src/CLR/Include/WireProtocol_App_Interface.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);

//////////////////////////////////////////
Expand Down
2 changes: 1 addition & 1 deletion src/CLR/WireProtocol/WireProtocol_Message.c
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
#include <nanoSupport.h>
#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;
Expand Down
12 changes: 12 additions & 0 deletions targets/CMSIS-OS/ChibiOS/nanoBooter/WireProtocol_MonitorCommands.c
Original file line number Diff line number Diff line change
Expand Up @@ -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));
}

Expand Down

0 comments on commit 333caa9

Please sign in to comment.