Skip to content

Commit

Permalink
boot_serial: Fix issue with queued commands
Browse files Browse the repository at this point in the history
Fixes an issue whereby multiple commands are received and some
are still being processed. This generally arises when a response
takes a long time (e.g. when image decryption is required),
duplicate commands will now send multiple responses but avoids
the bug of future commands being sent to which previous responses
are received.

Signed-off-by: Jamie McCrae <[email protected]>
  • Loading branch information
nordicjm authored and nvlsianpu committed Sep 20, 2023
1 parent 5c00da4 commit 6ba46c0
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion boot/boot_serial/src/boot_serial.c
Original file line number Diff line number Diff line change
Expand Up @@ -1189,6 +1189,10 @@ boot_serial_read_console(const struct boot_uart_funcs *f,int timeout_in_ms)
int max_input;
int elapsed_in_ms = 0;

#ifndef MCUBOOT_SERIAL_WAIT_FOR_DFU
bool allow_idle = true;
#endif

boot_uf = f;
max_input = sizeof(in_buf);

Expand All @@ -1200,14 +1204,20 @@ boot_serial_read_console(const struct boot_uart_funcs *f,int timeout_in_ms)
* from serial console (if single-thread mode is used).
*/
#ifndef MCUBOOT_SERIAL_WAIT_FOR_DFU
MCUBOOT_CPU_IDLE();
if (allow_idle == true) {
MCUBOOT_CPU_IDLE();
allow_idle = false;
}
#endif
MCUBOOT_WATCHDOG_FEED();
#ifdef MCUBOOT_SERIAL_WAIT_FOR_DFU
uint32_t start = k_uptime_get_32();
#endif
rc = f->read(in_buf + off, sizeof(in_buf) - off, &full_line);
if (rc <= 0 && !full_line) {
#ifndef MCUBOOT_SERIAL_WAIT_FOR_DFU
allow_idle = true;
#endif
goto check_timeout;
}
off += rc;
Expand Down

0 comments on commit 6ba46c0

Please sign in to comment.