Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add BOOT_SERIAL_WAIT_FOR_DFU_ALWAYS Zephyr Kconfig option. #1903

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion boot/zephyr/Kconfig.serial_recovery
Original file line number Diff line number Diff line change
Expand Up @@ -150,13 +150,21 @@ config BOOT_SERIAL_DETECT_DELAY
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"
bool "Wait a prescribed duration to see if DFU is invoked by receiving a MCUmgr command"
depends on BOOT_SERIAL_UART || BOOT_SERIAL_CDC_ACM
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_ALWAYS
bool "Always enter serial recovery mode upon startup"
depends on BOOT_SERIAL_WAIT_FOR_DFU
help
If y, MCUboot always enters serial recovery mode upon startup for the
duration of BOOT_SERIAL_WAIT_FOR_DFU_TIMEOUT. Otherwise, MCUboot only
enters serial recovery mode if the board was physically reset.
Comment on lines +164 to +166
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This comment doesn't really make sense, what does resetting have to do with staying in serial recovery mode?


config BOOT_SERIAL_WAIT_FOR_DFU_TIMEOUT
int "Duration to wait for the serial DFU timeout in ms"
default 500
Expand Down
8 changes: 6 additions & 2 deletions boot/zephyr/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -385,8 +385,12 @@ static void boot_serial_enter()
BOOT_LOG_INF("Enter the serial recovery mode");
rc = boot_console_init();
__ASSERT(rc == 0, "Error initializing boot console.\n");
#ifdef CONFIG_BOOT_SERIAL_WAIT_FOR_DFU
boot_serial_check_start(&boot_funcs, CONFIG_BOOT_SERIAL_WAIT_FOR_DFU_TIMEOUT);
#else
boot_serial_start(&boot_funcs);
__ASSERT(0, "Bootloader serial process was terminated unexpectedly.\n");
#endif
}
#endif

Expand Down Expand Up @@ -464,7 +468,7 @@ int main(void)
}
#endif

#ifdef CONFIG_BOOT_SERIAL_WAIT_FOR_DFU
#ifdef CONFIG_BOOT_SERIAL_WAIT_FOR_DFU_ALWAYS
/* Initialize the boot console, so we can already fill up our buffers while
* waiting for the boot image check to finish. This image check, can take
* some time, so it's better to reuse thistime to already receive the
Expand All @@ -490,7 +494,7 @@ int main(void)
}
#endif

#ifdef CONFIG_BOOT_SERIAL_WAIT_FOR_DFU
#ifdef CONFIG_BOOT_SERIAL_WAIT_FOR_DFU_ALWAYS
timeout_in_ms -= (k_uptime_get_32() - start);
if( timeout_in_ms <= 0 ) {
/* at least one check if time was expired */
Expand Down