Skip to content

Commit 767b0c8

Browse files
authored
Merge pull request #116 from rgrr/bug/112-fix-pyocd-packet-size
limit DAP packet size for pyocd to 512, see #112
2 parents 4a2296a + c92db4d commit 767b0c8

File tree

1 file changed

+11
-4
lines changed

1 file changed

+11
-4
lines changed

src/cmsis-dap/dap_server.c

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -66,10 +66,13 @@
6666
*/
6767
#define _DAP_PACKET_COUNT_OPENOCD 2
6868
#define _DAP_PACKET_SIZE_OPENOCD 512
69-
#define _DAP_PACKET_COUNT_PROBERS 2
69+
#define _DAP_PACKET_COUNT_PROBERS 8
7070
#define _DAP_PACKET_SIZE_PROBERS 1024
7171
#define _DAP_PACKET_COUNT_PYOCD 1
72-
#define _DAP_PACKET_SIZE_PYOCD 1024 // pyocd does not like packets > 128 if COUNT != 1
72+
#define _DAP_PACKET_SIZE_PYOCD 512 // pyocd does not like packets > 128 if COUNT != 1,
73+
// there seems to be also a problem with flashing if
74+
// packet size exceeds flash page size (?)
75+
// see https://github.com/rgrr/yapicoprobe/issues/112
7376
#define _DAP_PACKET_COUNT_UNKNOWN 1
7477
#define _DAP_PACKET_SIZE_UNKNOWN 64
7578

@@ -83,11 +86,15 @@ uint16_t dap_packet_size = _DAP_PACKET_SIZE_UNKNOWN;
8386
#error "increase CFG_TUD_VENDOR_RX_BUFSIZE"
8487
#endif
8588

89+
#define PACKET_MAXSIZE_1 MAX(_DAP_PACKET_COUNT_OPENOCD*_DAP_PACKET_SIZE_OPENOCD, _DAP_PACKET_COUNT_PROBERS*_DAP_PACKET_SIZE_PROBERS)
90+
#define PACKET_MAXSIZE_2 MAX(_DAP_PACKET_COUNT_PYOCD *_DAP_PACKET_SIZE_PYOCD, _DAP_PACKET_COUNT_UNKNOWN*_DAP_PACKET_SIZE_UNKNOWN)
91+
#define PACKET_MAXSIZE MAX(PACKET_MAXSIZE_1, PACKET_MAXSIZE_2)
92+
8693
#if OPT_CMSIS_DAPV1 || OPT_CMSIS_DAPV2
87-
static uint8_t TxDataBuffer[_DAP_PACKET_COUNT_OPENOCD * CFG_TUD_VENDOR_RX_BUFSIZE]; // maximum required size
94+
static uint8_t TxDataBuffer[PACKET_MAXSIZE];
8895
#endif
8996
#if OPT_CMSIS_DAPV2
90-
static uint8_t RxDataBuffer[_DAP_PACKET_COUNT_OPENOCD * CFG_TUD_VENDOR_RX_BUFSIZE]; // maximum required size
97+
static uint8_t RxDataBuffer[PACKET_MAXSIZE];
9198
#endif
9299

93100

0 commit comments

Comments
 (0)