anjiahao1 opened a new pull request, #18526:
URL: https://github.com/apache/nuttx/pull/18526

   ## Summary
   
     * The Nucleo-L552ZE-Q board ships with LPUART1 (PG7/PG8) connected to the 
ST-Link virtual COM port by default, but the NuttX BSP only supported USART3 
which requires an external TTL adapter. This change enables LPUART1 as the 
default NSH console so the board works out-of-the-box with the built-in VCP.
     * Three bugs prevented LPUART1 from working:
       1. **stm32l5_lowputc**: Missing LPUART-specific BRR formula. LPUART uses 
`BRR = 256 * fCK / baud` instead of the standard USART divisor.
       2. **stm32_boot**: LPUART1 pins PG7/PG8 are on GPIOG which is powered by 
VDDIO2. The low-level GPIO setup in `stm32l5_lowsetup()` runs before VDDIO2 is 
enabled, so GPIOG writes silently fail. Added VDDIO2 enable and GPIO 
reconfiguration in `stm32l5_board_initialize()`.
       3. **stm32l5_serial**: LPUART1 `apbclock` was incorrectly set to PCLK2 
(should be PCLK1 per RCC_APB1ENR2), and the runtime `setformat()` lacked an 
LPUART BRR branch. Also cast to `uint64_t` to prevent 32-bit overflow in `(fCK 
<< 8)`.
     * The nsh defconfig is switched from USART3 to LPUART1, GPIO_LPUART1 pin 
definitions are added to board.h, and board documentation is updated.
   
   ## Impact
   
     * Is new feature added? YES — LPUART1 serial driver support for STM32L5 
Nucleo-L552ZE-Q.
     * Impact on user? YES — The default nsh console is now on LPUART1 (ST-Link 
VCP) instead of USART3. Users who rely on USART3 need to reconfigure.
     * Impact on build? NO.
     * Impact on hardware? YES — STM32L5 arch serial driver and Nucleo-L552ZE 
board BSP are changed.
     * Impact on documentation? YES — Board documentation updated to reflect 
LPUART1 as default console.
     * Impact on security? NO.
     * Impact on compatibility? YES — Existing users of nucleo-l552ze:nsh who 
use USART3 with external adapter will need to switch defconfig back. The USART3 
configuration is documented.
   
   ## Testing
   
     I confirm that changes are verified on local setup and works as intended:
     * Build Host(s): Ubuntu 24.04 x86_64, arm-none-eabi-gcc 12.2.1
     * Target(s): Nucleo-L552ZE-Q real hardware with ST-Link VCP
   
     Testing logs before change:
   
     ```
     N/A — LPUART1 was not functional before this change. NSH console was only 
available on USART3 with external TTL adapter.
     ```
   
     Testing logs after change:
   
     ```
     $ picocom -b 115200 /dev/ttyACM0
   
     NuttShell (NSH) NuttX-12.8.0
     nsh>
     ```
   
     Verified via GDB/OpenOCD register inspection:
     - LPUART1_BRR = 0x3BADC (correct: 256 × 110MHz / 115200)
     - GPIOG_MODER PG7/PG8 = AF mode
     - GPIOG_AFRL/AFRH = AF8
   
   ## PR verification Self-Check
   
     * [X] This PR introduces only one functional change.
     * [X] I have updated all required description fields above.
     * [X] My PR adheres to Contributing Guidelines and Documentation (git 
commit title and message, coding standard, etc).
     * [ ] My PR is still work in progress (not ready for review).
     * [X] My PR is ready for review and can be safely merged into a codebase.


-- 
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]

Reply via email to