Skip to content

espressif: fix esp32 console_write loop forever if cnt too large #2398

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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
12 changes: 9 additions & 3 deletions boot/espressif/port/esp32/serial_adapter.c
Original file line number Diff line number Diff line change
Expand Up @@ -68,12 +68,18 @@ static uart_dev_t *serial_boot_uart_dev = (SERIAL_BOOT_UART_NUM == 0) ?
void console_write(const char *str, int cnt)
{
uint32_t tx_len;
uint32_t write_len;

do {
tx_len = uart_ll_get_txfifo_len(serial_boot_uart_dev);
} while (tx_len < cnt);

uart_ll_write_txfifo(serial_boot_uart_dev, (const uint8_t *)str, cnt);
if (tx_len > 0) {
write_len = tx_len < cnt ? tx_len : cnt;
uart_ll_write_txfifo(serial_boot_uart_dev, (const uint8_t *)str, write_len);
cnt -= write_len;
}
MCUBOOT_WATCHDOG_FEED();
esp_rom_delay_us(1000);
} while (cnt > 0);
}

int console_read(char *str, int cnt, int *newline)
Expand Down
Loading