Skip to content

Commit 6fbd63b

Browse files
jfischer-nokartben
authored andcommitted
cmsis_dap: remove Kconfig option CMSIS_DAP_PACKET_SIZE
We need a way to update the value configured by option CMSIS_DAP_PACKET_SIZE at runtime. For example, the USB backend may have different values depending on the speed at which the device is being enumerated. Signed-off-by: Johann Fischer <johann.fischer@nordicsemi.no>
1 parent e0bb942 commit 6fbd63b

File tree

3 files changed

+16
-14
lines changed

3 files changed

+16
-14
lines changed

subsys/dap/Kconfig

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,6 @@ config CMSIS_DAP_PACKET_COUNT
1717
help
1818
Maximum packet buffers for request and response data.
1919

20-
config CMSIS_DAP_PACKET_SIZE
21-
int "Maximum packet size for request and response data."
22-
default 64
23-
range 64 512
24-
help
25-
Maximum packet size for request and response data.
26-
2720
config CMSIS_DAP_PROBE_VENDOR
2821
string "Probe vendor"
2922
default "Zephyr"

subsys/dap/cmsis_dap.c

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -47,23 +47,25 @@ struct dap_context {
4747

4848
static struct dap_context dap_ctx[1];
4949

50+
#define CMSIS_DAP_PACKET_MIN_SIZE 64
51+
5052
BUILD_ASSERT(sizeof(CONFIG_CMSIS_DAP_PROBE_VENDOR) <=
51-
MIN(CONFIG_CMSIS_DAP_PACKET_SIZE - 2, UINT8_MAX - 2),
53+
MIN(CMSIS_DAP_PACKET_MIN_SIZE - 2, UINT8_MAX - 2),
5254
"PROBE_VENDOR string is too long.");
5355
BUILD_ASSERT(sizeof(CONFIG_CMSIS_DAP_PROBE_NAME) <=
54-
MIN(CONFIG_CMSIS_DAP_PACKET_SIZE - 2, UINT8_MAX - 2),
56+
MIN(CMSIS_DAP_PACKET_MIN_SIZE - 2, UINT8_MAX - 2),
5557
"PROBE_NAME string is too long.");
5658
BUILD_ASSERT(sizeof(CONFIG_CMSIS_DAP_BOARD_VENDOR) <=
57-
MIN(CONFIG_CMSIS_DAP_PACKET_SIZE - 2, UINT8_MAX - 2),
59+
MIN(CMSIS_DAP_PACKET_MIN_SIZE - 2, UINT8_MAX - 2),
5860
"BOARD_VENDOR string is too long.");
5961
BUILD_ASSERT(sizeof(CONFIG_CMSIS_DAP_BOARD_NAME) <=
60-
MIN(CONFIG_CMSIS_DAP_PACKET_SIZE - 2, UINT8_MAX - 2),
62+
MIN(CMSIS_DAP_PACKET_MIN_SIZE - 2, UINT8_MAX - 2),
6163
"BOARD_NAME string is too long.");
6264
BUILD_ASSERT(sizeof(CONFIG_CMSIS_DAP_DEVICE_VENDOR) <=
63-
MIN(CONFIG_CMSIS_DAP_PACKET_SIZE - 2, UINT8_MAX - 2),
65+
MIN(CMSIS_DAP_PACKET_MIN_SIZE - 2, UINT8_MAX - 2),
6466
"DEVICE_VENDOR string is too long.");
6567
BUILD_ASSERT(sizeof(CONFIG_CMSIS_DAP_DEVICE_NAME) <=
66-
MIN(CONFIG_CMSIS_DAP_PACKET_SIZE - 2, UINT8_MAX - 2),
68+
MIN(CMSIS_DAP_PACKET_MIN_SIZE - 2, UINT8_MAX - 2),
6769
"DEVICE_NAME string is too long.");
6870

6971
/* Get DAP Information */
@@ -1037,6 +1039,12 @@ uint32_t dap_execute_cmd(const uint8_t *request,
10371039
return dap_process_cmd(&dap_ctx[0], request, response);
10381040
}
10391041

1042+
void dap_update_pkt_size(const uint16_t pkt_size)
1043+
{
1044+
dap_ctx[0].pkt_size = pkt_size;
1045+
LOG_INF("New packet size %u", dap_ctx[0].pkt_size);
1046+
}
1047+
10401048
int dap_setup(const struct device *const dev)
10411049
{
10421050
dap_ctx[0].swdp_dev = (void *)dev;
@@ -1047,7 +1055,7 @@ int dap_setup(const struct device *const dev)
10471055
}
10481056

10491057
/* Default settings */
1050-
dap_ctx[0].pkt_size = CONFIG_CMSIS_DAP_PACKET_SIZE;
1058+
dap_ctx[0].pkt_size = CMSIS_DAP_PACKET_MIN_SIZE;
10511059
dap_ctx[0].debug_port = 0U;
10521060
dap_ctx[0].transfer.idle_cycles = 0U;
10531061
dap_ctx[0].transfer.retry_count = 100U;

subsys/dap/cmsis_dap.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,5 +132,6 @@
132132
/* Keep it internal until an other interface has been implemented. */
133133
int dap_setup(const struct device *const dev);
134134
uint32_t dap_execute_cmd(const uint8_t *request, uint8_t *response);
135+
void dap_update_pkt_size(const uint16_t pkt_size);
135136

136137
#endif /* ZEPHYR_INCLUDE_CMSIS_DAP_H_ */

0 commit comments

Comments
 (0)