Skip to content

Commit 524b80b

Browse files
moculllalmir-okato
authored andcommitted
espressif: fix esp32 console_write loop forever if cnt too large
spilt buffer to make sure console_write won't occupy forever Signed-off-by: moculll <[email protected]>
1 parent 5311589 commit 524b80b

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

boot/espressif/port/esp32/serial_adapter.c

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -68,12 +68,18 @@ static uart_dev_t *serial_boot_uart_dev = (SERIAL_BOOT_UART_NUM == 0) ?
6868
void console_write(const char *str, int cnt)
6969
{
7070
uint32_t tx_len;
71+
uint32_t write_len;
7172

7273
do {
7374
tx_len = uart_ll_get_txfifo_len(serial_boot_uart_dev);
74-
} while (tx_len < cnt);
75-
76-
uart_ll_write_txfifo(serial_boot_uart_dev, (const uint8_t *)str, cnt);
75+
if (tx_len > 0) {
76+
write_len = tx_len < cnt ? tx_len : cnt;
77+
uart_ll_write_txfifo(serial_boot_uart_dev, (const uint8_t *)str, write_len);
78+
cnt -= write_len;
79+
}
80+
MCUBOOT_WATCHDOG_FEED();
81+
esp_rom_delay_us(1000);
82+
} while (cnt > 0);
7783
}
7884

7985
int console_read(char *str, int cnt, int *newline)

0 commit comments

Comments
 (0)