Skip to content

Commit a265a6c

Browse files
committed
WIP: use RPC lib as transport
1 parent 10aecc2 commit a265a6c

File tree

2 files changed

+70
-3
lines changed

2 files changed

+70
-3
lines changed

libraries/ThreadDebug/src/ThreadDebug.cpp

Lines changed: 46 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -697,9 +697,11 @@ void Platform_CommSendChar(int character)
697697
static const char g_memoryMapXml[] = "<?xml version=\"1.0\"?>"
698698
"<!DOCTYPE memory-map PUBLIC \"+//IDN gnu.org//DTD GDB Memory Map V1.0//EN\" \"http://sourceware.org/gdb/gdb-memory-map.dtd\">"
699699
"<memory-map>"
700+
#ifndef CORE_CM4
700701
"<memory type=\"ram\" start=\"0x00000000\" length=\"0x10000\"> </memory>"
701-
"<memory type=\"flash\" start=\"0x08000000\" length=\"0x200000\"> <property name=\"blocksize\">0x20000</property></memory>"
702702
"<memory type=\"ram\" start=\"0x10000000\" length=\"0x48000\"> </memory>"
703+
#endif
704+
"<memory type=\"flash\" start=\"0x08000000\" length=\"0x200000\"> <property name=\"blocksize\">0x20000</property></memory>"
703705
"<memory type=\"ram\" start=\"0x1ff00000\" length=\"0x20000\"> </memory>"
704706
"<memory type=\"ram\" start=\"0x20000000\" length=\"0x20000\"> </memory>"
705707
"<memory type=\"ram\" start=\"0x24000000\" length=\"0x80000\"> </memory>"
@@ -712,7 +714,9 @@ static const char g_memoryMapXml[] = "<?xml version=\"1.0\"?>"
712714
"<memory type=\"ram\" start=\"0x58026000\" length=\"0x800\"> </memory>"
713715
"<memory type=\"ram\" start=\"0x58027000\" length=\"0x400\"> </memory>"
714716
"<memory type=\"flash\" start=\"0x90000000\" length=\"0x10000000\"> <property name=\"blocksize\">0x200</property></memory>"
717+
#ifndef CORE_CM4
715718
"<memory type=\"ram\" start=\"0xc0000000\" length=\"0x800000\"> </memory>"
719+
#endif
716720
"</memory-map>";
717721
#endif
718722

@@ -1145,8 +1149,7 @@ void UartDebugCommInterface::onReceivedData()
11451149
}
11461150
}
11471151

1148-
1149-
1152+
#ifdef SERIAL_CDC
11501153
UsbDebugCommInterface::UsbDebugCommInterface(arduino::USBSerial* pSerial) :
11511154
_pSerial(pSerial)
11521155
{
@@ -1181,3 +1184,43 @@ void UsbDebugCommInterface::attach(void (*pCallback)())
11811184
{
11821185
_pSerial->attach(pCallback);
11831186
}
1187+
#endif
1188+
1189+
#if defined(STM32H747xx) && defined(CORE_CM4)
1190+
1191+
RPCDebugCommInterface::RPCDebugCommInterface(arduino::RPC* pSerial) :
1192+
_pSerial(pSerial)
1193+
{
1194+
_pSerial->begin();
1195+
}
1196+
1197+
RPCDebugCommInterface::~RPCDebugCommInterface()
1198+
{
1199+
}
1200+
1201+
bool RPCDebugCommInterface::readable()
1202+
{
1203+
return _pSerial->available() > 0;
1204+
}
1205+
1206+
bool RPCDebugCommInterface::writeable()
1207+
{
1208+
// The USBSerial::write() method blocks until data is actually sent to the PC.
1209+
return true;
1210+
}
1211+
1212+
uint8_t RPCDebugCommInterface::read()
1213+
{
1214+
return _pSerial->read();
1215+
}
1216+
1217+
void RPCDebugCommInterface::write(uint8_t c)
1218+
{
1219+
_pSerial->write(c);
1220+
}
1221+
1222+
void RPCDebugCommInterface::attach(void (*pCallback)())
1223+
{
1224+
_pSerial->attach(pCallback);
1225+
}
1226+
#endif

libraries/ThreadDebug/src/ThreadDebug.h

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,10 @@
3434
#include <Arduino.h>
3535
//#include <mbed.h>
3636

37+
#if defined(STM32H747xx) && defined(CORE_CM4)
38+
// include RPC out of arduino namespace
39+
#include "RPC_internal.h"
40+
#endif
3741

3842
namespace arduino {
3943

@@ -76,6 +80,7 @@ class DebugCommInterface {
7680
virtual void attach(void (*pCallback)()) = 0;
7781
};
7882

83+
#ifdef SERIAL_CDC
7984
// Use the SerialUSB interface to communicate with GDB.
8085
class UsbDebugCommInterface : public DebugCommInterface {
8186
public:
@@ -91,6 +96,25 @@ class UsbDebugCommInterface : public DebugCommInterface {
9196
protected:
9297
arduino::USBSerial* _pSerial;
9398
};
99+
#endif
100+
101+
#if defined(STM32H747xx) && defined(CORE_CM4)
102+
// Use the RPC interface to communicate with GDB from M4 core
103+
class RPCDebugCommInterface : public DebugCommInterface {
104+
public:
105+
RPCDebugCommInterface(arduino::RPC*);
106+
virtual ~RPCDebugCommInterface();
107+
108+
virtual bool readable();
109+
virtual bool writeable();
110+
virtual uint8_t read();
111+
virtual void write(uint8_t c);
112+
virtual void attach(void (*pCallback)());
113+
114+
protected:
115+
arduino::RPC* _pSerial;
116+
};
117+
#endif
94118

95119
// Use one of the device's hardware UARTs to communicate with GDB.
96120
class UartDebugCommInterface : public DebugCommInterface {

0 commit comments

Comments
 (0)