Commit e3ff1753 authored by Wouter Cappelle's avatar Wouter Cappelle Committed by David Brown
Browse files

Add support for the mcumgr echo command in serial boot mode



Signed-off-by: default avatarWouter Cappelle <wouter.cappelle@crodeon.com>
parent d8eff810
...@@ -470,6 +470,38 @@ out: ...@@ -470,6 +470,38 @@ out:
#endif //#ifdef MCUBOOT_ENC_IMAGES #endif //#ifdef MCUBOOT_ENC_IMAGES
} }
#ifdef MCUBOOT_BOOT_MGMT_ECHO
static bool
decode_echo(cbor_state_t *state, cbor_string_type_t *result)
{
size_t bsstrdecoded;
int ret;
if (!map_start_decode(state)) {
return false;
}
ret = multi_decode(2, 2, &bsstrdecoded, (void *)tstrx_decode, state, result, sizeof(cbor_string_type_t));
map_end_decode(state);
return ret;
}
static void
bs_echo(char *buf, int len)
{
size_t bsstrdecoded;
cbor_string_type_t str[2];
if (entry_function((const uint8_t *)buf, len, str, &bsstrdecoded, (void *)decode_echo, 1, 2)) {
map_start_encode(&cbor_state, 10);
tstrx_put(&cbor_state, "r");
tstrx_encode(&cbor_state, &str[1]);
map_end_encode(&cbor_state, 10);
boot_serial_output();
}
}
#endif
/* /*
* Send rc code only. * Send rc code only.
*/ */
...@@ -547,6 +579,11 @@ boot_serial_input(char *buf, int len) ...@@ -547,6 +579,11 @@ boot_serial_input(char *buf, int len)
} }
} else if (hdr->nh_group == MGMT_GROUP_ID_DEFAULT) { } else if (hdr->nh_group == MGMT_GROUP_ID_DEFAULT) {
switch (hdr->nh_id) { switch (hdr->nh_id) {
case NMGR_ID_ECHO:
#ifdef MCUBOOT_BOOT_MGMT_ECHO
bs_echo(buf, len);
#endif
break;
case NMGR_ID_CONS_ECHO_CTRL: case NMGR_ID_CONS_ECHO_CTRL:
bs_rc_rsp(0); bs_rc_rsp(0);
break; break;
......
...@@ -48,6 +48,7 @@ extern "C" { ...@@ -48,6 +48,7 @@ extern "C" {
#define MGMT_GROUP_ID_IMAGE 1 #define MGMT_GROUP_ID_IMAGE 1
#define MGMT_GROUP_ID_PERUSER 64 #define MGMT_GROUP_ID_PERUSER 64
#define NMGR_ID_ECHO 0
#define NMGR_ID_CONS_ECHO_CTRL 1 #define NMGR_ID_CONS_ECHO_CTRL 1
#define NMGR_ID_RESET 5 #define NMGR_ID_RESET 5
......
...@@ -583,6 +583,11 @@ config BOOT_ERASE_PROGRESSIVELY ...@@ -583,6 +583,11 @@ config BOOT_ERASE_PROGRESSIVELY
on some hardware that has long erase times, to prevent long wait on some hardware that has long erase times, to prevent long wait
times at the beginning of the DFU process. times at the beginning of the DFU process.
config BOOT_MGMT_ECHO
bool "Enable echo command"
help
if enabled, support for the mcumgr echo command is being added.
menuconfig ENABLE_MGMT_PERUSER menuconfig ENABLE_MGMT_PERUSER
bool "Enable system specific mcumgr commands" bool "Enable system specific mcumgr commands"
help help
......
...@@ -173,6 +173,10 @@ ...@@ -173,6 +173,10 @@
#define MCUBOOT_MGMT_CUSTOM_IMG_LIST #define MCUBOOT_MGMT_CUSTOM_IMG_LIST
#endif #endif
#ifdef CONFIG_BOOT_MGMT_ECHO
#define MCUBOOT_BOOT_MGMT_ECHO
#endif
#ifdef CONFIG_BOOT_IMAGE_ACCESS_HOOKS #ifdef CONFIG_BOOT_IMAGE_ACCESS_HOOKS
#define MCUBOOT_IMAGE_ACCESS_HOOKS #define MCUBOOT_IMAGE_ACCESS_HOOKS
#endif #endif
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment