fix issue with exmaple

This commit is contained in:
hathach
2026-04-02 23:56:47 +07:00
parent 134e14849b
commit 9368e5d40f
2 changed files with 9 additions and 14 deletions

View File

@ -43,14 +43,10 @@ static size_t console_read(uint8_t *buf, size_t bufsize) {
}
static size_t console_write(const uint8_t *buf, size_t bufsize) {
size_t count = 0;
while (count < bufsize) {
if (board_putchar((int)buf[count]) < 0) {
break;
}
count++;
}
return count;
// Use board_uart_write directly for non-blocking behavior.
// board_putchar -> sys_write has a blocking retry loop that causes UART RX overrun.
int wr = board_uart_write(buf, (int) bufsize);
return (wr > 0) ? (size_t) wr : 0;
}
// forward from console to usbh
@ -78,7 +74,7 @@ void cdc_app_task(void) {
do {
// uart write is slow, while waiting forward uart -> usbh else uart rx can be overflow
if (count) {
wr += console_write(buf + wr, count);
wr += console_write(buf + wr, count - wr);
}
console_to_usbh(idx);
} while (wr < count);

View File

@ -1189,9 +1189,8 @@ def test_example(board, f1, example):
print(f'Flashing {fw_name}.elf')
# flash firmware. It may fail randomly, retry a few times
max_rety = max_retry
start_s = time.time()
for i in range(max_rety):
for i in range(max_retry):
ret = globals()[f'flash_{board["flasher"]["name"].lower()}'](board, fw_name)
if ret.returncode == 0:
try:
@ -1202,14 +1201,14 @@ def test_example(board, f1, example):
print(' OK', end='')
break
except Exception as e:
if i == max_rety - 1:
if i == max_retry - 1:
err_count += 1
print(f'{STATUS_FAILED}: {e}')
else:
print(f'\n Test failed: {e}, retry {i+2}/{max_rety}', end='')
print(f'\n Test failed: {e}, retry {i+2}/{max_retry}', end='')
time.sleep(0.5)
else:
print(f'\n Flash failed, retry {i+2}/{max_rety}', end='')
print(f'\n Flash failed, retry {i+2}/{max_retry}', end='')
time.sleep(0.5)
if ret.returncode != 0: