Skip to content

ensure board_uart_write return -1 on default#3628

Open
HiFiPhile wants to merge 2 commits intomasterfrom
fix_uart_write
Open

ensure board_uart_write return -1 on default#3628
HiFiPhile wants to merge 2 commits intomasterfrom
fix_uart_write

Conversation

@HiFiPhile
Copy link
Copy Markdown
Collaborator

@HiFiPhile HiFiPhile commented Apr 29, 2026

to fix sys_write blocking if no UART is defined

Signed-off-by: HiFiPhile <admin@hifiphile.com>
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Updates BSP UART write stubs to return an error (-1) when UART logging isn’t available, preventing the default sys_write() retarget from spinning indefinitely when board_uart_write() previously returned 0 in “no UART” builds.

Changes:

  • Change board_uart_write() stub/default paths from return 0; to return -1; across multiple BSP families.
  • Update PIC32MZ weak board_uart_write() to return -1 instead of falsely reporting success.
  • Adjust FT9xx board_uart_write() control flow so return count; is inside the #ifdef branch and the stub branch returns -1.

Reviewed changes

Copilot reviewed 34 out of 34 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
hw/bsp/xmc4000/family.c Return -1 when UART is not configured to avoid sys_write() retry loops.
hw/bsp/stm32wb/family.c Return -1 in no-UART stub path.
hw/bsp/stm32u5/family.c Return -1 in no-UART stub path.
hw/bsp/stm32u0/family.c Return -1 in no-UART stub path.
hw/bsp/stm32n6/family.c Return -1 in no-UART stub path.
hw/bsp/stm32l4/family.c Return -1 in no-UART stub path.
hw/bsp/stm32l0/family.c Return -1 in no-UART stub path.
hw/bsp/stm32h7rs/family.c Return -1 in no-UART stub path.
hw/bsp/stm32h7/family.c Return -1 in no-UART stub path.
hw/bsp/stm32h5/family.c Return -1 in no-UART stub path.
hw/bsp/stm32g4/family.c Return -1 in no-UART stub path.
hw/bsp/stm32g0/family.c Return -1 in no-UART stub path.
hw/bsp/stm32f7/family.c Return -1 in no-UART stub path.
hw/bsp/stm32f4/family.c Return -1 in no-UART stub path.
hw/bsp/stm32f3/family.c Return -1 in no-UART stub path.
hw/bsp/stm32f2/family.c Return -1 in no-UART stub path.
hw/bsp/stm32f1/family.c Return -1 in no-UART stub path.
hw/bsp/stm32f0/family.c Return -1 in no-UART stub path.
hw/bsp/stm32c0/family.c Return -1 in no-UART stub path.
hw/bsp/rp2040/family.c Return -1 in no-UART stub path.
hw/bsp/pic32mz/family.c Change weak UART write stub to return -1 instead of reporting all bytes written.
hw/bsp/mm32/family.c Return -1 in no-UART stub path.
hw/bsp/kinetis_k/family.c Return -1 in no-UART stub path.
hw/bsp/gd32vf103/family.c Return -1 in no-UART stub path.
hw/bsp/ft9xx/family.c Ensure stub returns -1 and move return count into UART-enabled branch.
hw/bsp/ch32v20x/family.c Return -1 in no-UART stub path.
hw/bsp/at32f45x/family.c Return -1 in no-UART stub path.
hw/bsp/at32f435_437/family.c Return -1 in no-UART stub path.
hw/bsp/at32f425/family.c Return -1 in no-UART stub path.
hw/bsp/at32f423/family.c Return -1 in no-UART stub path.
hw/bsp/at32f415/family.c Return -1 in no-UART stub path.
hw/bsp/at32f413/family.c Return -1 in no-UART stub path.
hw/bsp/at32f403a_407/family.c Return -1 in no-UART stub path.
hw/bsp/at32f402_405/family.c Return -1 in no-UART stub path.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread hw/bsp/stm32f4/family.c
Comment thread hw/bsp/ft9xx/family.c
Signed-off-by: HiFiPhile <admin@hifiphile.com>
@github-actions
Copy link
Copy Markdown

Size Difference Report

Because TinyUSB code size varies by port and configuration, the metrics below represent the averaged totals across all example builds.

Note: If there is no change, only one value is shown.

Changes >1% in size

No entries.

Changes <1% in size

No entries.

No changes
file .text .rodata .data .bss size % diff
audio_device.c 2896 0 1259 1625 4515 +0.0%
cdc_device.c 1239 16 1092 735 1972 +0.0%
cdc_host.c 6381 487 15 985 7579 +0.0%
dcd_ch32_usbfs.c 1475 0 0 2444 3919 +0.0%
dcd_ch32_usbhs.c 1468 0 0 448 1916 +0.0%
dcd_ci_fs.c 1924 0 0 1290 3214 +0.0%
dcd_ci_hs.c 1758 0 0 1344 2535 +0.0%
dcd_da146xx.c 3067 0 0 144 3211 +0.0%
dcd_dwc2.c 4245 19 0 265 4529 +0.0%
dcd_eptri.c 2272 0 0 259 2531 +0.0%
dcd_ft9xx.c 3280 0 0 172 3452 +0.0%
dcd_khci.c 1952 0 0 1290 3242 +0.0%
dcd_lpc17_40.c 1478 0 0 648 1802 +0.0%
dcd_lpc_ip3511.c 1463 0 0 264 1683 +0.0%
dcd_mm32f327x_otg.c 1477 0 0 1290 2767 +0.0%
dcd_msp430x5xx.c 1799 0 0 176 1975 +0.0%
dcd_musb.c 2226 0 0 171 2396 +0.0%
dcd_nrf5x.c 2916 0 0 292 3208 +0.0%
dcd_nuc120.c 1095 0 0 78 1173 +0.0%
dcd_nuc121.c 1168 0 0 101 1270 +0.0%
dcd_nuc505.c 0 0 1532 157 1689 +0.0%
dcd_rp2040.c 841 0 764 653 2258 +0.0%
dcd_rusb2.c 2917 0 0 156 3073 +0.0%
dcd_samd.c 1036 0 0 266 1302 +0.0%
dcd_samg.c 1321 0 0 72 1393 +0.0%
dcd_stm32_fsdev.c 2558 0 0 291 2849 +0.0%
dfu_device.c 776 28 712 138 914 +0.0%
dfu_rt_device.c 157 0 134 0 157 +0.0%
dwc2_common.c 603 22 0 0 615 +0.0%
ecm_rndis_device.c 1044 0 1 2759 3803 +0.0%
ehci.c 2763 0 0 6043 7597 +0.0%
fsdev_common.c 180 0 0 0 180 +0.0%
hcd_ch32_usbfs.c 2485 0 0 498 2983 +0.0%
hcd_ci_hs.c 184 0 0 0 184 +0.0%
hcd_dwc2.c 5007 25 1 513 5545 +0.0%
hcd_khci.c 2442 0 0 449 2891 +0.0%
hcd_musb.c 3073 0 0 157 3230 +0.0%
hcd_pio_usb.c 262 0 240 0 502 +0.0%
hcd_rp2040.c 2000 17 4 321 2342 +0.0%
hcd_rusb2.c 2923 0 0 245 3168 +0.0%
hcd_samd.c 2220 0 0 324 2544 +0.0%
hcd_stm32_fsdev.c 3259 0 1 420 3680 +0.0%
hid_device.c 1125 44 997 119 1244 +0.0%
hid_host.c 1240 0 0 1251 2491 +0.0%
hub.c 1384 8 8 30 1418 +0.0%
midi_device.c 1151 0 1007 624 1773 +0.0%
midi_host.c 1341 7 7 3635 4979 +0.0%
msc_device.c 2517 108 2281 806 3323 +0.0%
msc_host.c 1587 0 0 394 1982 +0.0%
mtp_device.c 1696 22 735 588 2292 +0.0%
ncm_device.c 1534 28 718 4452 6000 +0.0%
ohci.c 1940 0 0 2414 4353 +0.0%
printer_device.c 830 0 706 566 1394 +0.0%
rp2040_usb.c 366 35 647 11 1060 +0.0%
rusb2_common.c 160 0 16 0 176 +0.0%
tusb.c 469 0 397 3 470 +0.0%
tusb_fifo.c 850 0 483 0 845 +0.0%
typec_stm32.c 820 8 2 12 842 +0.0%
usbc.c 420 2 20 166 608 +0.0%
usbd.c 3231 58 88 275 3571 +0.0%
usbd_control.c 567 0 508 79 645 +0.0%
usbh.c 4652 55 99 1034 5807 +0.0%
usbtmc_device.c 2196 24 68 316 2544 +0.0%
vendor_device.c 641 0 534 565 1204 +0.0%
video_device.c 4443 5 1235 479 4914 +0.0%
TOTAL 118790 1018 16311 45302 165723 +0.0%

@github-actions
Copy link
Copy Markdown

MemBrowse Memory Report

Top 10 targets by memory change (%) (out of 2233 targets) View Project Dashboard →

target .text .rodata .data .bss total % diff
stm32f207nucleo/board_test 5,920 → 5,924 (+4) 6,456 → 6,460 (+4) +0.1%
stm32f303disco/board_test 6,124 → 6,128 (+4) 6,688 → 6,692 (+4) +0.1%
hpm6750evk2/board_test 14,984 → 14,992 (+8) 16,304 → 16,312 (+8) +0.0%
stm32h503nucleo/board_test 9,076 → 9,080 (+4) 9,928 → 9,932 (+4) +0.0%
msp_exp430f5529lp/board_test 4,916 → 4,918 (+2) 5,188 → 5,190 (+2) +0.0%
stm32f303disco/dfu 14,652 → 14,656 (+4) 15,800 → 15,804 (+4) +0.0%
stm32f207nucleo/dfu 15,368 → 15,372 (+4) 16,536 → 16,540 (+4) +0.0%
stm32h503nucleo/dfu 16,996 → 17,000 (+4) 18,432 → 18,436 (+4) +0.0%
at_start_f413/hid_composite_freertos 20,216 → 20,220 (+4) 21,300 → 21,304 (+4) +0.0%
at32f403a_weact_blackpill/hid_composite_freertos 20,224 → 20,228 (+4) 21,328 → 21,332 (+4) +0.0%

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants