88#include <zephyr/sys/reboot.h>
99#include <zephyr/drivers/gpio.h>
1010#include <dk_buttons_and_leds.h>
11+ #include <fw_info.h>
12+ #include <bl_storage.h>
13+ #include <ncs_commit.h>
1114
1215#include <zephyr/logging/log.h>
1316LOG_MODULE_REGISTER (bulk_commands , CONFIG_BRIDGE_BULK_LOG_LEVEL );
@@ -16,17 +19,21 @@ LOG_MODULE_REGISTER(bulk_commands, CONFIG_BRIDGE_BULK_LOG_LEVEL);
1619#define ID_DAP_VENDOR15 (0x80 + 15)
1720#define ID_DAP_VENDOR16 (0x80 + 16)
1821#define ID_DAP_VENDOR17 (0x80 + 17)
22+ #define ID_DAP_VENDOR18 (0x80 + 18)
1923#define ID_DAP_VENDOR_NRF53_BOOTLOADER ID_DAP_VENDOR14
2024#define ID_DAP_VENDOR_NRF91_BOOTLOADER ID_DAP_VENDOR15
2125#define ID_DAP_VENDOR_NRF53_RESET ID_DAP_VENDOR16
2226#define ID_DAP_VENDOR_NRF91_RESET ID_DAP_VENDOR17
27+ #define ID_DAP_VENDOR_NRF53_VERSION ID_DAP_VENDOR18
2328
2429#define DAP_COMMAND_SUCCESS 0x00
2530#define DAP_COMMAND_FAILED 0xFF
2631
2732#define NRF91_RESET_DURATION K_MSEC(100)
2833#define NRF91_BUTTON1_DURATION K_MSEC(1000)
2934
35+ #define USB_BULK_PACKET_SIZE 64
36+
3037static const struct gpio_dt_spec reset_pin =
3138 GPIO_DT_SPEC_GET_OR (DT_PATH (zephyr_user ), reset_gpios , {});
3239static const struct gpio_dt_spec button1_pin =
@@ -125,6 +132,24 @@ size_t dap_execute_cmd(uint8_t *in, uint8_t *out)
125132 }
126133 goto success ;
127134 }
135+ if (in [0 ] == ID_DAP_VENDOR_NRF53_VERSION ) {
136+ const struct fw_info * s0_info = fw_info_find (s0_address_read ());
137+ const struct fw_info * s1_info = fw_info_find (s1_address_read ());
138+ const size_t VERSION_STRING_LEN = USB_BULK_PACKET_SIZE - 2 ;
139+
140+ __ASSERT_NO_MSG (s0_info != NULL );
141+ __ASSERT_NO_MSG (s1_info != NULL );
142+ int len = snprintf (out + 2 , VERSION_STRING_LEN ,
143+ "S0: %u, S1: %u, app: " NCS_COMMIT_STRING ,
144+ s0_info -> version , s1_info -> version );
145+ if (len < 0 || len >= VERSION_STRING_LEN ) {
146+ LOG_ERR ("Failed to format version string" );
147+ goto error ;
148+ }
149+ out [0 ] = in [0 ];
150+ out [1 ] = len ;
151+ return len + 2 ;
152+ }
128153
129154error :
130155 /* default reply: command failed */
0 commit comments