From 60872b4dbfe9c3c613991051d2463f16803ed27e Mon Sep 17 00:00:00 2001 From: Victor Chavez Date: Sat, 11 May 2024 14:01:47 +0200 Subject: [PATCH 1/5] boot: zephyr: Added initial tests for MCUBoot serial over CAN Signed-off-by: Victor Chavez --- .../include/bootutil/mcuboot_status.h | 1 + boot/zephyr/CMakeLists.txt | 24 +++ boot/zephyr/Kconfig | 2 +- boot/zephyr/Kconfig.can_recovery | 184 ++++++++++++++++++ boot/zephyr/can_adapter.c | 184 ++++++++++++++++++ .../include/mcuboot_config/mcuboot_config.h | 2 +- boot/zephyr/io.c | 4 +- boot/zephyr/main.c | 4 +- 8 files changed, 399 insertions(+), 6 deletions(-) create mode 100644 boot/zephyr/Kconfig.can_recovery create mode 100644 boot/zephyr/can_adapter.c diff --git a/boot/bootutil/include/bootutil/mcuboot_status.h b/boot/bootutil/include/bootutil/mcuboot_status.h index b734923962..ac2d6092f0 100644 --- a/boot/bootutil/include/bootutil/mcuboot_status.h +++ b/boot/bootutil/include/bootutil/mcuboot_status.h @@ -19,6 +19,7 @@ typedef enum MCUBOOT_STATUS_USB_DFU_ENTERED, MCUBOOT_STATUS_USB_DFU_TIMED_OUT, MCUBOOT_STATUS_SERIAL_DFU_ENTERED, + MCUBOOT_STATUS_CAN_DFU_ENTERED } mcuboot_status_type_t; #if defined(CONFIG_MCUBOOT_ACTION_HOOKS) diff --git a/boot/zephyr/CMakeLists.txt b/boot/zephyr/CMakeLists.txt index 45548e0c3e..adf5c0acc0 100644 --- a/boot/zephyr/CMakeLists.txt +++ b/boot/zephyr/CMakeLists.txt @@ -273,6 +273,30 @@ if(CONFIG_MCUBOOT_SERIAL) endif() endif() +if(CONFIG_MCUBOOT_CAN) + zephyr_sources(${BOOT_DIR}/zephyr/can_adapter.c) + zephyr_sources(${BOOT_DIR}/boot_serial/src/boot_serial.c) + zephyr_sources(${BOOT_DIR}/boot_serial/src/zcbor_bulk.c) + + zephyr_include_directories(${BOOT_DIR}/bootutil/include) + zephyr_include_directories(${BOOT_DIR}/boot_serial/include) + zephyr_include_directories(include) + + zephyr_include_directories_ifdef( + CONFIG_BOOT_ERASE_PROGRESSIVELY + ${BOOT_DIR}/bootutil/src + ) + + if(CONFIG_BOOT_ENCRYPT_IMAGE) + zephyr_library_sources( + ${BOOT_DIR}/boot_serial/src/boot_serial_encryption.c + ) + endif() +endif() + + + + if(NOT CONFIG_BOOT_SIGNATURE_KEY_FILE STREQUAL "") # CONF_FILE points to the KConfig configuration files of the bootloader. foreach (filepath ${CONF_FILE}) diff --git a/boot/zephyr/Kconfig b/boot/zephyr/Kconfig index effedfb4f5..2cadf30d33 100644 --- a/boot/zephyr/Kconfig +++ b/boot/zephyr/Kconfig @@ -595,7 +595,7 @@ config MCUBOOT_INDICATION_LED definitions for this to work. rsource "Kconfig.serial_recovery" - +rsource "Kconfig.can_recovery" rsource "Kconfig.firmware_loader" config BOOT_INTR_VEC_RELOC diff --git a/boot/zephyr/Kconfig.can_recovery b/boot/zephyr/Kconfig.can_recovery new file mode 100644 index 0000000000..151cdc79f5 --- /dev/null +++ b/boot/zephyr/Kconfig.can_recovery @@ -0,0 +1,184 @@ +# Copyright (c) 2024 Victor Chavez + +menuconfig MCUBOOT_CAN + bool "MCUboot CAN recovery" + default n + select REBOOT + select CAN + select BASE64 + select CRC + select ZCBOR + depends on !BOOT_FIRMWARE_LOADER + help + If y, enables a CAN-port based update mode. This allows + MCUboot itself to load update images into flash over CAN. + If unsure, leave at the default value. + +if MCUBOOT_CAN + +config MCUBOOT_CAN_TX_ID + int "CAN ID for transmission of bootloader data" + default 57005 + range 0 536870911 + +config MCUBOOT_CAN_RX_ID + int "CAN ID for reception of bootloader data" + default 48879 + range 0 536870911 + + +config MCUBOOT_SERIAL_DIRECT_IMAGE_UPLOAD + bool "Allow to select image number for DFU" + depends on !SINGLE_APPLICATION_SLOT + help + With the option enabled, the mcuboot serial recovery will + respect the "image" field in mcumgr image update frame + header. + The mapping of image number to partition is as follows: + 0 -> default behaviour, same as 1; + 1 -> image-0 (primary slot of the first image); + 2 -> image-1 (secondary slot of the first image); + 3 -> image-2; + 4 -> image-3. + Note that 0 is default upload target when no explicit + selection is done. + +config BOOT_SERIAL_UNALIGNED_BUFFER_SIZE + int "Stack buffer for unaligned memory writes" + default 64 + range 0 128 + help + Specifies the stack usage for a buffer which is used for unaligned + memory access when data is written to a device with memory alignment + requirements. Set to 0 to disable. + +config BOOT_MAX_LINE_INPUT_LEN + int "Maximum input line length" + default 128 + help + Maximum length of input serial port buffer (SMP serial transport uses + fragments of 128-bytes, this should not need to be changed unless a + different value is used for the transport). + +config BOOT_LINE_BUFS + int "Number of receive buffers" + range 2 128 + default 8 + help + Number of receive buffers for data received via the serial port. + +config BOOT_SERIAL_MAX_RECEIVE_SIZE + int "Maximum command line length" + default 1024 + help + Maximum length of received commands via the serial port (this should + be equal to the maximum line length, BOOT_MAX_LINE_INPUT_LEN times + by the number of receive buffers, BOOT_LINE_BUFS to allow for + optimal data transfer speeds). + +config BOOT_ERASE_PROGRESSIVELY + bool "Erase flash progressively when receiving new firmware" + default y if SOC_FAMILY_NORDIC_NRF + help + If enabled, flash is erased as necessary when receiving new firmware, + instead of erasing the whole image slot at once. This is necessary + on some hardware that has long erase times, to prevent long wait + 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 + bool "Enable system specific mcumgr commands" + help + The option enables processing of system specific mcumgr commands; + system specific commands are within group MGMT_GROUP_ID_PERUSER (64) + and above, as defined within mcumgr library. + These are system specific command and system specific implementation + function is required to process these commands. + +if ENABLE_MGMT_PERUSER + +config BOOT_MGMT_CUSTOM_STORAGE_ERASE + bool "Enable storage erase command" + help + The option enables mcumgr command that allows to erase storage + partition. + Note that the storage partition needs to be defined, in DTS, otherwise + enabling the option will cause a compilation to fail. + +endif # ENABLE_MGMT_PERUSER + +menu "Entrance methods" + +menuconfig BOOT_SERIAL_ENTRANCE_GPIO + bool "GPIO" + default y + depends on GPIO + help + Use a GPIO to enter serial recovery mode. + +config BOOT_SERIAL_DETECT_DELAY + int "CAN detect pin detection delay time [ms]" + default 0 + depends on BOOT_SERIAL_ENTRANCE_GPIO + help + Used to prevent the bootloader from loading on button press. + Useful for powering on when using the same button as + the one used to place the device in bootloader mode. + +menuconfig BOOT_SERIAL_WAIT_FOR_DFU + bool "Wait a prescribed duration to see if DFU is invoked by receiving a MCUmgr comand" + help + If y, MCUboot waits for a prescribed duration of time to allow + for DFU to be invoked. The serial recovery can be entered by receiving any + mcumgr command. + +config BOOT_SERIAL_WAIT_FOR_DFU_TIMEOUT + int "Duration to wait for the serial DFU timeout in ms" + default 500 + depends on BOOT_SERIAL_WAIT_FOR_DFU + help + Timeout in ms for MCUboot to wait to allow for DFU to be invoked. + +config BOOT_SERIAL_BOOT_MODE + bool "Check boot mode via retention subsystem" + depends on RETENTION_BOOT_MODE + help + Allows for entering CAN recovery mode by using Zephyr's boot mode + retention system (i.e. an application must set the boot mode to stay + in serial recovery mode and reboot the module). + +config BOOT_SERIAL_NO_APPLICATION + bool "Stay in bootloader if no application" + help + Allows for entering serial recovery mode if there is no bootable + application that the bootloader can jump to. + +config BOOT_SERIAL_PIN_RESET + bool "Check for device reset by pin" + select HWINFO + help + Checks if the module reset was caused by the reset pin and will + remain in bootloader serial recovery mode if it was. + +endmenu + +config BOOT_SERIAL_IMG_GRP_HASH + bool "Image list hash support" + default y + help + If y, image list responses will include the image hash (adds ~100 + bytes of flash). + +config BOOT_SERIAL_IMG_GRP_IMAGE_STATE + bool "Image state support" + depends on !SINGLE_APPLICATION_SLOT + select BOOT_SERIAL_IMG_GRP_HASH if UPDATEABLE_IMAGE_NUMBER > 1 + help + If y, image states will be included with image lists and the set + state command can be used to mark an image as test/confirmed. + +endif # MCUBOOT_CAN diff --git a/boot/zephyr/can_adapter.c b/boot/zephyr/can_adapter.c new file mode 100644 index 0000000000..10de99557b --- /dev/null +++ b/boot/zephyr/can_adapter.c @@ -0,0 +1,184 @@ +#include +#include +#include +#include +#include +#include "bootutil/bootutil_log.h" + +BOOT_LOG_MODULE_REGISTER(can_adapter); + +#if defined(CONFIG_BOOT_CAN) && \ + (!DT_HAS_CHOSEN(zephyr_can_mcumgr)) +#error Zephyr CAN MCU manager is required for CAN recovery +#endif + + +static const struct can_filter smp_rx_filter = { + .id = CONFIG_MCUBOOT_CAN_RX_ID, + .mask = CAN_EXT_ID_MASK, + .flags = CONFIG_MCUBOOT_CAN_RX_ID > CAN_STD_ID_MASK ? CAN_FILTER_IDE: 0 +}; + +static struct can_frame frame; + +static struct device const *can_dev = DEVICE_DT_GET(DT_CHOSEN(zephyr_can_mcumgr)); + +/** @brief Console input representation + * + * This struct is used to represent an input line from a serial interface. + */ +struct line_input { + /** Required to use sys_slist */ + sys_snode_t node; + + int len; + /** Buffer where the input line is recorded */ + char line[CONFIG_BOOT_MAX_LINE_INPUT_LEN]; +}; + +static struct device const *can_dev; +static struct line_input line_bufs[CONFIG_BOOT_LINE_BUFS]; + +static sys_slist_t avail_queue; +static sys_slist_t lines_queue; + +static uint16_t cur; +static struct line_input *cmd; + +void can_rx_cb(const struct device *dev, struct can_frame *frame, void *user_data) { + if (frame->id == CONFIG_MCUBOOT_CAN_RX_ID) { + if (!cmd) { + sys_snode_t *node; + + node = sys_slist_get(&avail_queue); + if (!node) { + BOOT_LOG_ERR("Not enough memory to store" + " incoming data!"); + return; + } + cmd = CONTAINER_OF(node, struct line_input, node); + } + + for (int i = 0; i < frame->dlc; i++) { + char byte = frame->data[i]; + + if (cur < CONFIG_BOOT_MAX_LINE_INPUT_LEN) { + cmd->line[cur++] = byte; + } + if (byte == '\n') { + cmd->len = cur; + sys_slist_append(&lines_queue, &cmd->node); + cur = 0; + cmd = NULL; + } + } + } +} + +static int +boot_can_fifo_getline(char **line) +{ + static struct line_input *cmd; + sys_snode_t *node; + int key; + + key = irq_lock(); + /* Recycle cmd buffer returned previous time */ + if (cmd != NULL) { + if (sys_slist_peek_tail(&avail_queue) != &cmd->node) { + sys_slist_append(&avail_queue, &cmd->node); + } + } + + node = sys_slist_get(&lines_queue); + irq_unlock(key); + + if (node == NULL) { + cmd = NULL; + *line = NULL; + + return 0; + } + + cmd = CONTAINER_OF(node, struct line_input, node); + *line = cmd->line; + return cmd->len; +} + +void +console_write(const char *str, int cnt) +{ + int i; + int eof_idx = -1; + for (i = 0; i < cnt; i++) { + if (str[i] == EOF) { + eof_idx = i; + break; + } + } + if (eof_idx != -1) { + cnt = eof_idx; + } + while(cnt > 0) { + int len = cnt > CAN_MAX_DLC ? CAN_MAX_DLC : cnt; + frame.id = CONFIG_MCUBOOT_CAN_TX_ID; + frame.dlc = len; + frame.flags = CONFIG_MCUBOOT_CAN_TX_ID > CAN_STD_ID_MASK ? CAN_FILTER_IDE: 0; + memcpy(frame.data, str, len); + can_send(can_dev, &frame, K_FOREVER, NULL, NULL); + str += len; + cnt -= len; + } +} + +int +console_read(char *str, int str_size, int *newline) +{ + char *line; + int len; + + len = boot_can_fifo_getline(&line); + + if (line == NULL) { + *newline = 0; + return 0; + } + + if (len > str_size - 1) { + len = str_size - 1; + } + + memcpy(str, line, len); + str[len] = '\0'; + *newline = 1; + return len + 1; +} + +int +boot_console_init(void) +{ + int i; + + /* Zephyr CAN handler takes an empty buffer from avail_queue, + * stores CAN input in it until EOL, and then puts it into + * lines_queue. + */ + sys_slist_init(&avail_queue); + sys_slist_init(&lines_queue); + + for (i = 0; i < ARRAY_SIZE(line_bufs); i++) { + sys_slist_append(&avail_queue, &line_bufs[i].node); + } + + int rc = can_start(can_dev); + + //calling can_add_rx_filter does not work, the filter checks in the implementation (mcux can driver) + // always fail. Instead call the api directly. + // This was noticed becuase can_add_rx_filter_msgq does not + // have this check and works fine. + //const int filter_id = can_add_rx_filter(can_if, can_rx_cb, self, ); + const struct can_driver_api *api = (const struct can_driver_api *)can_dev->api; + + rc = api->add_rx_filter(can_dev, can_rx_cb, NULL, &smp_rx_filter); + return rc; +} diff --git a/boot/zephyr/include/mcuboot_config/mcuboot_config.h b/boot/zephyr/include/mcuboot_config/mcuboot_config.h index 8f5d17bf5b..a6175cbaa8 100644 --- a/boot/zephyr/include/mcuboot_config/mcuboot_config.h +++ b/boot/zephyr/include/mcuboot_config/mcuboot_config.h @@ -209,7 +209,7 @@ #define MCUBOOT_VERIFY_IMG_ADDRESS #endif -#ifdef CONFIG_MCUBOOT_SERIAL +#if defined(CONFIG_MCUBOOT_SERIAL) || defined(CONFIG_MCUBOOT_CAN) #define MCUBOOT_SERIAL #endif diff --git a/boot/zephyr/io.c b/boot/zephyr/io.c index 309f1ab94e..195b3c443d 100644 --- a/boot/zephyr/io.c +++ b/boot/zephyr/io.c @@ -39,7 +39,7 @@ #endif /* Validate serial recovery configuration */ -#ifdef CONFIG_MCUBOOT_SERIAL +#if defined(CONFIG_MCUBOOT_SERIAL) || defined(CONFIG_MCUBOOT_CAN) #if !defined(CONFIG_BOOT_SERIAL_ENTRANCE_GPIO) && \ !defined(CONFIG_BOOT_SERIAL_WAIT_FOR_DFU) && \ !defined(CONFIG_BOOT_SERIAL_BOOT_MODE) && \ @@ -101,7 +101,7 @@ void io_led_set(int value) #if defined(CONFIG_BOOT_SERIAL_ENTRANCE_GPIO) || defined(CONFIG_BOOT_USB_DFU_GPIO) || \ defined(CONFIG_BOOT_FIRMWARE_LOADER_ENTRANCE_GPIO) -#if defined(CONFIG_MCUBOOT_SERIAL) +#if defined(CONFIG_MCUBOOT_SERIAL) || defined(CONFIG_MCUBOOT_CAN) #define BUTTON_0_DETECT_DELAY CONFIG_BOOT_SERIAL_DETECT_DELAY #elif defined(CONFIG_BOOT_FIRMWARE_LOADER) #define BUTTON_0_DETECT_DELAY CONFIG_BOOT_FIRMWARE_LOADER_DETECT_DELAY diff --git a/boot/zephyr/main.c b/boot/zephyr/main.c index 95da276bdc..7787c162b7 100644 --- a/boot/zephyr/main.c +++ b/boot/zephyr/main.c @@ -69,7 +69,7 @@ #endif /* CONFIG_SOC_FAMILY_ESPRESSIF_ESP32 */ -#ifdef CONFIG_MCUBOOT_SERIAL +#if defined(CONFIG_MCUBOOT_SERIAL) || defined(CONFIG_MCUBOOT_CAN) #include "boot_serial/boot_serial.h" #include "serial_adapter/serial_adapter.h" @@ -387,7 +387,7 @@ void zephyr_boot_log_stop(void) * !defined(CONFIG_LOG_PROCESS_THREAD) && !defined(ZEPHYR_LOG_MODE_MINIMAL) */ -#ifdef CONFIG_MCUBOOT_SERIAL +#if defined(CONFIG_MCUBOOT_SERIAL) || defined(CONFIG_MCUBOOT_CAN) static void boot_serial_enter() { int rc; From ee6282b006271bb10aa6af9c83f6d436358a6cd6 Mon Sep 17 00:00:00 2001 From: Victor Chavez Date: Wed, 15 May 2024 23:13:28 +0200 Subject: [PATCH 2/5] can: Return if could not start can interface --- boot/zephyr/can_adapter.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/boot/zephyr/can_adapter.c b/boot/zephyr/can_adapter.c index 10de99557b..f9d0191114 100644 --- a/boot/zephyr/can_adapter.c +++ b/boot/zephyr/can_adapter.c @@ -119,6 +119,7 @@ console_write(const char *str, int cnt) if (eof_idx != -1) { cnt = eof_idx; } + while(cnt > 0) { int len = cnt > CAN_MAX_DLC ? CAN_MAX_DLC : cnt; frame.id = CONFIG_MCUBOOT_CAN_TX_ID; @@ -171,6 +172,9 @@ boot_console_init(void) } int rc = can_start(can_dev); + if (rc !=0) { + return rc; + } //calling can_add_rx_filter does not work, the filter checks in the implementation (mcux can driver) // always fail. Instead call the api directly. From c56d42cd05522ec8f28689c7a3e176389f1c399e Mon Sep 17 00:00:00 2001 From: Victor Chavez Date: Thu, 16 May 2024 10:37:19 +0200 Subject: [PATCH 3/5] use direct can rx filter api --- boot/zephyr/can_adapter.c | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/boot/zephyr/can_adapter.c b/boot/zephyr/can_adapter.c index f9d0191114..82c7f29cfe 100644 --- a/boot/zephyr/can_adapter.c +++ b/boot/zephyr/can_adapter.c @@ -15,7 +15,7 @@ BOOT_LOG_MODULE_REGISTER(can_adapter); static const struct can_filter smp_rx_filter = { .id = CONFIG_MCUBOOT_CAN_RX_ID, - .mask = CAN_EXT_ID_MASK, + .mask = CONFIG_MCUBOOT_CAN_RX_ID > CAN_STD_ID_MASK ? CAN_EXT_ID_MASK : CAN_STD_ID_MASK, .flags = CONFIG_MCUBOOT_CAN_RX_ID > CAN_STD_ID_MASK ? CAN_FILTER_IDE: 0 }; @@ -176,13 +176,10 @@ boot_console_init(void) return rc; } - //calling can_add_rx_filter does not work, the filter checks in the implementation (mcux can driver) - // always fail. Instead call the api directly. - // This was noticed becuase can_add_rx_filter_msgq does not - // have this check and works fine. - //const int filter_id = can_add_rx_filter(can_if, can_rx_cb, self, ); - const struct can_driver_api *api = (const struct can_driver_api *)can_dev->api; + rc = can_add_rx_filter(can_dev, can_rx_cb, NULL, &smp_rx_filter); - rc = api->add_rx_filter(can_dev, can_rx_cb, NULL, &smp_rx_filter); + if (rc < 0 ) { + rc = -EINVAL; + } return rc; } From cbc9caf0f48927cc27b7018bf5d95198b83e5a8b Mon Sep 17 00:00:00 2001 From: Victor Chavez Date: Thu, 16 May 2024 15:56:26 +0200 Subject: [PATCH 4/5] enter serial timeout only if io pin is set --- boot/zephyr/Kconfig.can_recovery | 17 +++++++++-------- boot/zephyr/io.c | 2 +- boot/zephyr/main.c | 13 +++++++------ 3 files changed, 17 insertions(+), 15 deletions(-) diff --git a/boot/zephyr/Kconfig.can_recovery b/boot/zephyr/Kconfig.can_recovery index 151cdc79f5..91959bb48f 100644 --- a/boot/zephyr/Kconfig.can_recovery +++ b/boot/zephyr/Kconfig.can_recovery @@ -120,14 +120,6 @@ menuconfig BOOT_SERIAL_ENTRANCE_GPIO help Use a GPIO to enter serial recovery mode. -config BOOT_SERIAL_DETECT_DELAY - int "CAN detect pin detection delay time [ms]" - default 0 - depends on BOOT_SERIAL_ENTRANCE_GPIO - help - Used to prevent the bootloader from loading on button press. - Useful for powering on when using the same button as - the one used to place the device in bootloader mode. menuconfig BOOT_SERIAL_WAIT_FOR_DFU bool "Wait a prescribed duration to see if DFU is invoked by receiving a MCUmgr comand" @@ -166,6 +158,15 @@ config BOOT_SERIAL_PIN_RESET endmenu +config BOOT_SERIAL_DETECT_DELAY + int "CAN detect pin detection delay time [ms]" + default 0 + depends on BOOT_SERIAL_ENTRANCE_GPIO || BOOT_SERIAL_WAIT_FOR_DFU + help + Used to prevent the bootloader from loading on button press. + Useful for powering on when using the same button as + the one used to place the device in bootloader mode. + config BOOT_SERIAL_IMG_GRP_HASH bool "Image list hash support" default y diff --git a/boot/zephyr/io.c b/boot/zephyr/io.c index 195b3c443d..34c17b54f2 100644 --- a/boot/zephyr/io.c +++ b/boot/zephyr/io.c @@ -99,7 +99,7 @@ void io_led_set(int value) #endif /* CONFIG_MCUBOOT_INDICATION_LED */ #if defined(CONFIG_BOOT_SERIAL_ENTRANCE_GPIO) || defined(CONFIG_BOOT_USB_DFU_GPIO) || \ - defined(CONFIG_BOOT_FIRMWARE_LOADER_ENTRANCE_GPIO) + defined(CONFIG_BOOT_FIRMWARE_LOADER_ENTRANCE_GPIO) || defined(CONFIG_BOOT_SERIAL_WAIT_FOR_DFU) #if defined(CONFIG_MCUBOOT_SERIAL) || defined(CONFIG_MCUBOOT_CAN) #define BUTTON_0_DETECT_DELAY CONFIG_BOOT_SERIAL_DETECT_DELAY diff --git a/boot/zephyr/main.c b/boot/zephyr/main.c index 7787c162b7..071a0ed9c3 100644 --- a/boot/zephyr/main.c +++ b/boot/zephyr/main.c @@ -507,13 +507,14 @@ int main(void) #endif #ifdef CONFIG_BOOT_SERIAL_WAIT_FOR_DFU - timeout_in_ms -= (k_uptime_get_32() - start); - if( timeout_in_ms <= 0 ) { - /* at least one check if time was expired */ - timeout_in_ms = 1; + if (io_detect_pin()) { + timeout_in_ms -= (k_uptime_get_32() - start); + if( timeout_in_ms <= 0 ) { + /* at least one check if time was expired */ + timeout_in_ms = 1; + } + boot_serial_check_start(&boot_funcs,timeout_in_ms); } - boot_serial_check_start(&boot_funcs,timeout_in_ms); - #ifdef CONFIG_MCUBOOT_INDICATION_LED io_led_set(0); #endif From 4dc91173f9383c515fa05148bb82f5df40bab7d6 Mon Sep 17 00:00:00 2001 From: Victor Chavez Date: Thu, 4 Jul 2024 18:24:57 +0200 Subject: [PATCH 5/5] double initialization bug --- boot/zephyr/main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/boot/zephyr/main.c b/boot/zephyr/main.c index 071a0ed9c3..8995d45ce3 100644 --- a/boot/zephyr/main.c +++ b/boot/zephyr/main.c @@ -486,7 +486,6 @@ int main(void) * some time, so it's better to reuse thistime to already receive the * initial mcumgr command(s) into our buffers */ - rc = boot_console_init(); int timeout_in_ms = CONFIG_BOOT_SERIAL_WAIT_FOR_DFU_TIMEOUT; uint32_t start = k_uptime_get_32(); @@ -513,6 +512,7 @@ int main(void) /* at least one check if time was expired */ timeout_in_ms = 1; } + boot_console_init(); boot_serial_check_start(&boot_funcs,timeout_in_ms); } #ifdef CONFIG_MCUBOOT_INDICATION_LED