boards/arm/stm32: route nucleo-f412zg console through ST-LINK VCP.#18766
boards/arm/stm32: route nucleo-f412zg console through ST-LINK VCP.#18766aviralgarg05 wants to merge 1 commit intoapache:masterfrom
Conversation
linguini1
left a comment
There was a problem hiding this comment.
Please document this change on the board docs.
Can you please test on hardware?
I will update the board documentation for this change. I do not have NUCLEO-F412ZG hardware available, so I cannot provide a real hardware test log for the issue. I do not want to overstate the validation. At this point, the change has been verified with clean If this PR needs on-board confirmation before merge, could someone with access to the board please help verify that |
|
Thank you @aviralgarg05 this comes from my issue #17722 and will help in testing, will check in a free moment on a real hardware!! :-) |
|
My testing below, before and after change, also no nsh on console.. let me see what is going on here o_O Before: After: |
|
Here is the DS for NUCLEO-F412ZG: [1] https://www.st.com/resource/en/user_manual/um1974-stm32-nucleo144-boards-mb1137-stmicroelectronics.pdf. Looking at Revision History, on 28-Aug-2020, rev 8, they "Removed Electrical schematics." how nice ;-) Looking at section 7.9 USART communication The USART3 interface available on PD8 and PD9 of the STM32 can be connected either to ST-LINK or to ST morpho connector. The choice is changed by setting the related solder bridges. By default the USART3 communication is enabled between the target STM32 and both the ST-LINK and the ST morpho connector. Table 9. USART3 pins
Looks like we need to use PD8 and PD9 at USART3, but NuttX uses USART2 for console, and USART3 is not available in "STM32 Perohperal Support". Let me see the DS for STM32F412ZG as STM chips cannot route any signal to any GPIO ;-) Here is DS for STM32F412ZG: [2] https://www.st.com/resource/en/datasheet/stm32f412zg.pdf. Table 9. STM32F412xE/G pin definition (page 49/202) contains function to pin map versus used chip package. Looking back at [1] NUCLEO board uses LQFP144 package. We have:
Table 11. STM32F412xE/G alternate functions (page 66/202) shows altenrate function codes: AF7 for SPI3/I2S3/USART1/USART2/USART3, AF8 for DFSDM1/USART3/USART6/CAN1. That confirms we can replace USART2_RX:PD6->PA3 and USART2_TX:PD5->PA2 as proposed in the patch. But STM removed schematics from DS in order to make things simple for everyone on top of no gpio-mux and restricted pins routing in their MCUs. Call me whatever you like but ESP breaks the bank here with their any-function-to-any-pin :D According to [1] ST-LINK CDC is at USART3_TX=PD8, USART3_RX=PD9 and we cannot route USART2 over there. We probably will have to enable USART3 to get console over ST-LINK. Let me see the physical board how stuff is connected. I found the schematics here: [3] https://www.st.com/resource/en/schematic_pack/nucleo_144pins_sch.zip. Luckily PDF is included :-) Following the license [4] www.st.com/opla we have confirmation that STLK_RX uses only PD8 pin of USART3_TX, and STLK_TX uses only PD9 pin of USART3_RX.
PA2 is used as RMII_MDIO, PA3 is routed CN9.1, PD5 is routed to CN9.6 and CN11.41, PD6 is routed to CN9.4 and CN11.43, which exhausts possible use of USART2 as ST-LINK connection. The only was to have NuttX console on STM32-NUCLEO-F412ZG's ST-LINK is to use USART3 and configure for:
|
cederom
left a comment
There was a problem hiding this comment.
Thank you @aviralgarg05 ! :-)
The only way to have NuttX console on STM32-NUCLEO-F412ZG's ST-LINK is to use USART3 and configure for:
- STLK_RX uses only PD8 pin of USART3_TX.
- STLK_TX uses only PD9 pin of USART3_RX.
Enable USART3 support for STM32F412 and use it as the default NUCLEO-F412ZG nsh console path. The ST-LINK virtual COM port on this board is wired to USART3 on PD8/PD9. Restore USART2 to its header-pin routing, switch the nsh defconfig to USART3, and update the board documentation to match the shipped solder-bridge configuration described in issue apache#17722. Signed-off-by: aviralgarg05 <gargaviral99@gmail.com>
437d53c to
8d0f4d8
Compare
|
Works now! Great work @aviralgarg05 !! =) |


Summary
Fixed the NUCLEO-F412ZG board default console routing so
nshuses the on-board ST-LINK virtual COM port by default.The board header now maps
USART2to thePA2/PA3pinmux instead of thePD5/PD6header pins. This matches the board’s shipped solder-bridge configuration and aligns the default console path with the hardware wiring described in issue #17722.Impact
This change affects only the
boards/arm/stm32/nucleo-f412zgboard configuration.nshconsole now appears on the ST-LINK VCP, which is the expected out-of-the-box serial path.Testing
Host: macOS on Apple Silicon, using the local NuttX workspace and the Apache NuttX Linux CI container image for a clean build environment.
Validation performed:
./tools/checkpatch.sh -c -u -m -f boards/arm/stm32/nucleo-f412zg/include/board.h./tools/configure.sh -E -l nucleo-f412zg:nshmake -j8Build result:
nuttxlinked successfully.nuttx.hexandnuttx.binwere generated successfully.