yushuailong opened a new pull request, #21387:
URL: https://github.com/apache/nuttx/pull/21387
## Summary
Fix an STM32H7 build failure when serial driver support is enabled but all
hardware UARTs are disabled, for example when using a USB CDC ACM console.
`g_uart_devs` is defined only when `HAVE_UART` is set, but
`stm32_serial_get_uart()` references it unconditionally. This causes the build
to fail with:
error: 'g_uart_devs' undeclared
Compile `stm32_serial_get_uart()` only when `HAVE_UART` is defined, matching
the condition that guards its device table. This follows the conditional
function definition used by the common STM32 serial driver.
The function body remains unchanged.
## Impact
- Fixes builds with serial driver support and no hardware UARTs.
- Keeps the UART-enabled implementation unchanged.
- No configuration changes.
- Changes only the STM32H7 serial driver, adding two preprocessor directives.
## Testing
Base: apache/nuttx master at `0e22bd5bd985`.
Host: macOS arm64.
Toolchain: Arm GNU Toolchain 14.2.Rel1, arm-none-eabi-gcc 14.2.1.
Build system: CMake and Ninja.
Using the upstream `nucleo-h743zi:nsh` configuration:
- Reproduced the undeclared `g_uart_devs` error on unmodified upstream with
all hardware UARTs disabled.
- With this fix, completed a full build with all hardware UARTs disabled and
USB CDC ACM console support enabled:
`CONFIG_SERIAL=y`, `CONFIG_STM32_OTGFS=y`, `CONFIG_USBDEV=y`,
`CONFIG_CDCACM=y`, `CONFIG_CDCACM_CONSOLE=y`, and
`CONFIG_NSH_USBCONSOLE=y`.
- Completed a full build of the default configuration with USART3 enabled.
- Confirmed that `stm32_serial_get_uart` is absent from the no-UART object
and present in the UART-enabled object.
- Confirmed that the function body is identical to upstream.
- NuttX checkpatch, commit-message checks, and Git whitespace checks passed.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]