diff --git a/subsys/dap/Kconfig b/subsys/dap/Kconfig index cfa50bf80ea..9359047e465 100644 --- a/subsys/dap/Kconfig +++ b/subsys/dap/Kconfig @@ -17,13 +17,6 @@ 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. - config CMSIS_DAP_PROBE_VENDOR string "Probe vendor" default "Zephyr" diff --git a/subsys/dap/cmsis_dap.c b/subsys/dap/cmsis_dap.c index 4148346e15f..cd68f634a56 100644 --- a/subsys/dap/cmsis_dap.c +++ b/subsys/dap/cmsis_dap.c @@ -47,23 +47,25 @@ struct dap_context { static struct dap_context dap_ctx[1]; +#define CMSIS_DAP_PACKET_MIN_SIZE 64 + BUILD_ASSERT(sizeof(CONFIG_CMSIS_DAP_PROBE_VENDOR) <= - MIN(CONFIG_CMSIS_DAP_PACKET_SIZE - 2, UINT8_MAX - 2), + MIN(CMSIS_DAP_PACKET_MIN_SIZE - 2, UINT8_MAX - 2), "PROBE_VENDOR string is too long."); BUILD_ASSERT(sizeof(CONFIG_CMSIS_DAP_PROBE_NAME) <= - MIN(CONFIG_CMSIS_DAP_PACKET_SIZE - 2, UINT8_MAX - 2), + MIN(CMSIS_DAP_PACKET_MIN_SIZE - 2, UINT8_MAX - 2), "PROBE_NAME string is too long."); BUILD_ASSERT(sizeof(CONFIG_CMSIS_DAP_BOARD_VENDOR) <= - MIN(CONFIG_CMSIS_DAP_PACKET_SIZE - 2, UINT8_MAX - 2), + MIN(CMSIS_DAP_PACKET_MIN_SIZE - 2, UINT8_MAX - 2), "BOARD_VENDOR string is too long."); BUILD_ASSERT(sizeof(CONFIG_CMSIS_DAP_BOARD_NAME) <= - MIN(CONFIG_CMSIS_DAP_PACKET_SIZE - 2, UINT8_MAX - 2), + MIN(CMSIS_DAP_PACKET_MIN_SIZE - 2, UINT8_MAX - 2), "BOARD_NAME string is too long."); BUILD_ASSERT(sizeof(CONFIG_CMSIS_DAP_DEVICE_VENDOR) <= - MIN(CONFIG_CMSIS_DAP_PACKET_SIZE - 2, UINT8_MAX - 2), + MIN(CMSIS_DAP_PACKET_MIN_SIZE - 2, UINT8_MAX - 2), "DEVICE_VENDOR string is too long."); BUILD_ASSERT(sizeof(CONFIG_CMSIS_DAP_DEVICE_NAME) <= - MIN(CONFIG_CMSIS_DAP_PACKET_SIZE - 2, UINT8_MAX - 2), + MIN(CMSIS_DAP_PACKET_MIN_SIZE - 2, UINT8_MAX - 2), "DEVICE_NAME string is too long."); /* Get DAP Information */ @@ -1037,6 +1039,12 @@ uint32_t dap_execute_cmd(const uint8_t *request, return dap_process_cmd(&dap_ctx[0], request, response); } +void dap_update_pkt_size(const uint16_t pkt_size) +{ + dap_ctx[0].pkt_size = pkt_size; + LOG_INF("New packet size %u", dap_ctx[0].pkt_size); +} + int dap_setup(const struct device *const dev) { dap_ctx[0].swdp_dev = (void *)dev; @@ -1047,7 +1055,7 @@ int dap_setup(const struct device *const dev) } /* Default settings */ - dap_ctx[0].pkt_size = CONFIG_CMSIS_DAP_PACKET_SIZE; + dap_ctx[0].pkt_size = CMSIS_DAP_PACKET_MIN_SIZE; dap_ctx[0].debug_port = 0U; dap_ctx[0].transfer.idle_cycles = 0U; dap_ctx[0].transfer.retry_count = 100U; diff --git a/subsys/dap/cmsis_dap.h b/subsys/dap/cmsis_dap.h index d8869e2160a..94743582875 100644 --- a/subsys/dap/cmsis_dap.h +++ b/subsys/dap/cmsis_dap.h @@ -132,5 +132,6 @@ /* Keep it internal until an other interface has been implemented. */ int dap_setup(const struct device *const dev); uint32_t dap_execute_cmd(const uint8_t *request, uint8_t *response); +void dap_update_pkt_size(const uint16_t pkt_size); #endif /* ZEPHYR_INCLUDE_CMSIS_DAP_H_ */