dap: add Konfig option to set maximum packet size

This also fixes a bug where the packet size returned was only 17 byte.

Signed-off-by: Johan Carlsson <johan.carlsson@teenage.engineering>
This commit is contained in:
Johan Carlsson 2023-04-21 14:47:09 +02:00 committed by Alberto Escolar
parent 7c9259abbc
commit e46e72320e
2 changed files with 10 additions and 3 deletions

View file

@ -17,6 +17,13 @@ config CMSIS_DAP_PACKET_COUNT
help
Maximum packet buffers for request and response data.
config CMSIS_DAP_PACKET_SIZE
int "Maximum packet size for request and response data."
default 64
range 64 512
help
Maximum packet size for request and response data.
module = DAP
module-str = dap
source "subsys/logging/Kconfig.template.log_config"

View file

@ -33,7 +33,7 @@ struct dap_context {
atomic_t state;
uint8_t debug_port;
uint8_t capabilities;
uint8_t pkt_size;
uint16_t pkt_size;
struct {
/* Idle cycles after transfer */
uint8_t idle_cycles;
@ -88,7 +88,7 @@ static uint16_t dap_info(struct dap_context *const ctx,
break;
case DAP_ID_PACKET_SIZE:
LOG_DBG("ID_PACKET_SIZE");
sys_put_le16(ctx->capabilities, &info[0]);
sys_put_le16(ctx->pkt_size, &info[0]);
length = 2U;
break;
case DAP_ID_PACKET_COUNT:
@ -912,7 +912,7 @@ int dap_setup(const struct device *const dev)
}
/* Default settings */
dap_ctx[0].pkt_size = 64U;
dap_ctx[0].pkt_size = CONFIG_CMSIS_DAP_PACKET_SIZE;
dap_ctx[0].debug_port = 0U;
dap_ctx[0].transfer.idle_cycles = 0U;
dap_ctx[0].transfer.retry_count = 100U;