Skip to content

Commit dca8ce8

Browse files
maxd-nordicrlubos
authored andcommitted
connectivity_bridge: Add BL version command
Get ready for updating bootloader with a command to check bootloader version. Signed-off-by: Maximilian Deubel <[email protected]>
1 parent 14a38dd commit dca8ce8

File tree

3 files changed

+31
-0
lines changed

3 files changed

+31
-0
lines changed

applications/connectivity_bridge/boards/thingy91x_nrf5340_cpuapp.conf

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,3 +34,7 @@ CONFIG_REBOOT=y
3434
CONFIG_GPIO=y
3535

3636
CONFIG_DK_LIBRARY=y
37+
38+
# Bootloader firmware information
39+
CONFIG_FW_INFO=y
40+
CONFIG_SECURE_BOOT_STORAGE=y

applications/connectivity_bridge/src/modules/usb_bulk_commands.c

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,9 @@
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>
1316
LOG_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+
3037
static const struct gpio_dt_spec reset_pin =
3138
GPIO_DT_SPEC_GET_OR(DT_PATH(zephyr_user), reset_gpios, {});
3239
static 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

129154
error:
130155
/* default reply: command failed */

applications/connectivity_bridge/sysbuild/mcuboot/boards/thingy91x_nrf5340_cpuapp.conf

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,3 +58,5 @@ CONFIG_BOOT_SERIAL_IMG_GRP_IMAGE_STATE=y
5858

5959
# Skip checks on the secondary image to make it possible to update MCUBoot on S1/S0
6060
CONFIG_MCUBOOT_VERIFY_IMG_ADDRESS=n
61+
62+
CONFIG_BOOT_SERIAL_NO_APPLICATION=y

0 commit comments

Comments
 (0)