Skip to content

Commit

Permalink
Merge pull request #116 from rgrr/bug/112-fix-pyocd-packet-size
Browse files Browse the repository at this point in the history
limit DAP packet size for pyocd to 512, see #112
  • Loading branch information
rgrr committed Aug 5, 2024
2 parents 4a2296a + c92db4d commit 767b0c8
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions src/cmsis-dap/dap_server.c
Original file line number Diff line number Diff line change
Expand Up @@ -66,10 +66,13 @@
*/
#define _DAP_PACKET_COUNT_OPENOCD 2
#define _DAP_PACKET_SIZE_OPENOCD 512
#define _DAP_PACKET_COUNT_PROBERS 2
#define _DAP_PACKET_COUNT_PROBERS 8
#define _DAP_PACKET_SIZE_PROBERS 1024
#define _DAP_PACKET_COUNT_PYOCD 1
#define _DAP_PACKET_SIZE_PYOCD 1024 // pyocd does not like packets > 128 if COUNT != 1
#define _DAP_PACKET_SIZE_PYOCD 512 // pyocd does not like packets > 128 if COUNT != 1,
// there seems to be also a problem with flashing if
// packet size exceeds flash page size (?)
// see https://github.com/rgrr/yapicoprobe/issues/112
#define _DAP_PACKET_COUNT_UNKNOWN 1
#define _DAP_PACKET_SIZE_UNKNOWN 64

Expand All @@ -83,11 +86,15 @@ uint16_t dap_packet_size = _DAP_PACKET_SIZE_UNKNOWN;
#error "increase CFG_TUD_VENDOR_RX_BUFSIZE"
#endif

#define PACKET_MAXSIZE_1 MAX(_DAP_PACKET_COUNT_OPENOCD*_DAP_PACKET_SIZE_OPENOCD, _DAP_PACKET_COUNT_PROBERS*_DAP_PACKET_SIZE_PROBERS)
#define PACKET_MAXSIZE_2 MAX(_DAP_PACKET_COUNT_PYOCD *_DAP_PACKET_SIZE_PYOCD, _DAP_PACKET_COUNT_UNKNOWN*_DAP_PACKET_SIZE_UNKNOWN)
#define PACKET_MAXSIZE MAX(PACKET_MAXSIZE_1, PACKET_MAXSIZE_2)

#if OPT_CMSIS_DAPV1 || OPT_CMSIS_DAPV2
static uint8_t TxDataBuffer[_DAP_PACKET_COUNT_OPENOCD * CFG_TUD_VENDOR_RX_BUFSIZE]; // maximum required size
static uint8_t TxDataBuffer[PACKET_MAXSIZE];
#endif
#if OPT_CMSIS_DAPV2
static uint8_t RxDataBuffer[_DAP_PACKET_COUNT_OPENOCD * CFG_TUD_VENDOR_RX_BUFSIZE]; // maximum required size
static uint8_t RxDataBuffer[PACKET_MAXSIZE];
#endif


Expand Down

0 comments on commit 767b0c8

Please sign in to comment.