Skip to content

Commit 8d0f4d8

Browse files
committed
boards/arm/stm32: switch nucleo-f412zg console to USART3 VCP
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 #17722. Signed-off-by: aviralgarg05 <gargaviral99@gmail.com>
1 parent e9de74d commit 8d0f4d8

4 files changed

Lines changed: 43 additions & 27 deletions

File tree

Documentation/platforms/arm/stm32f4/boards/nucleo-f412zg/index.rst

Lines changed: 32 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,8 @@ Pins and Connectors::
123123
TXD: PA2 CN9 pin 2(See SB13, 14, 62, 63). CN10 pin 35
124124
PD5
125125

126-
UART2 is the default in all of these configurations.
126+
USART2 is available on the board headers. It is not the default ``nsh``
127+
console path.
127128

128129
TTL to RS-232 converter connection::
129130

@@ -153,6 +154,30 @@ To configure USART2 as the console::
153154
CONFIG_USART2_PARITY=0
154155
CONFIG_USART2_2STOP=0
155156

157+
USART3
158+
------
159+
160+
Pins and Connectors::
161+
162+
RXD: PD9
163+
TXD: PD8
164+
165+
By default the board solder bridges connect USART3 to the on-board
166+
ST-LINK Virtual COM Port. This is the default ``nsh`` console path in
167+
NuttX.
168+
169+
To configure USART3 as the console::
170+
171+
CONFIG_STM32_USART3=y
172+
CONFIG_USART3_SERIALDRIVER=y
173+
CONFIG_USART3_SERIAL_CONSOLE=y
174+
CONFIG_USART3_RXBUFSIZE=256
175+
CONFIG_USART3_TXBUFSIZE=256
176+
CONFIG_USART3_BAUD=115200
177+
CONFIG_USART3_BITS=8
178+
CONFIG_USART3_PARITY=0
179+
CONFIG_USART3_2STOP=0
180+
156181
USART6
157182
------
158183

@@ -178,28 +203,10 @@ To configure USART6 as the console::
178203
Virtual COM Port
179204
----------------
180205

181-
Yet another option is to use UART2 and the USB virtual COM port. This
182-
option may be more convenient for long term development, but is painful
183-
to use during board bring-up.
184-
185-
Solder Bridges. This configuration requires:
186-
187-
- SB62 and SB63 Open: PA2 and PA3 on STM32 MCU are disconnected to D1
188-
and D0 (pin 7 and pin 8) on Arduino connector CN9 and ST Morpho
189-
connector CN10.
190-
191-
- SB13 and SB14 Closed: PA2 and PA3 on STM32F103C8T6 (ST-LINK MCU) are
192-
connected to PA3 and PA2 on STM32 MCU to have USART communication
193-
between them. Thus SB61, SB62 and SB63 should be OFF.
194-
195-
Configuring USART2 is the same as given above.
196-
197-
Question: What BAUD should be configure to interface with the Virtual
198-
COM port? 115200 8N1?
199-
200-
Default:
201-
As shipped, SB62 and SB63 are open and SB13 and SB14 closed, so the
202-
virtual COM port is enabled.
206+
The NUCLEO-F412ZG ST-LINK virtual COM port is connected to USART3 on
207+
PD8/PD9. As shipped, the default solder bridge configuration enables
208+
this routing, so the default ``nsh`` configuration uses USART3 for the
209+
console.
203210

204211
Configurations
205212
==============
@@ -208,8 +215,8 @@ nsh
208215
---
209216

210217
Configures the NuttShell (nsh) located at apps/examples/nsh for the
211-
Nucleo-F410RB board. The Configuration enables the serial interfaces
212-
on UART2. Support for builtin applications is enabled, but in the base
218+
Nucleo-F412ZG board. The configuration enables the serial interfaces
219+
on USART3. Support for builtin applications is enabled, but in the base
213220
configuration no builtin applications are selected (see NOTES below).
214221

215222
NOTES:

arch/arm/src/stm32/Kconfig

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1686,6 +1686,7 @@ config STM32_STM32F412
16861686
select STM32_HAVE_TIM12
16871687
select STM32_HAVE_TIM13
16881688
select STM32_HAVE_TIM14
1689+
select STM32_HAVE_USART3
16891690
select STM32_HAVE_USART2
16901691
select STM32_HAVE_USART6
16911692
select STM32_HAVE_I2C1

boards/arm/stm32/nucleo-f412zg/configs/nsh/defconfig

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,9 +51,9 @@ CONFIG_STM32_DISABLE_IDLE_SLEEP_DURING_DEBUG=y
5151
CONFIG_STM32_FLASH_PREFETCH=y
5252
CONFIG_STM32_JTAG_SW_ENABLE=y
5353
CONFIG_STM32_SERIAL_DISABLE_REORDERING=y
54-
CONFIG_STM32_USART2=y
54+
CONFIG_STM32_USART3=y
5555
CONFIG_SYSTEM_NSH=y
5656
CONFIG_TASK_NAME_SIZE=32
5757
CONFIG_TIMER=y
58-
CONFIG_USART2_SERIAL_CONSOLE=y
58+
CONFIG_USART3_SERIAL_CONSOLE=y
5959
CONFIG_USEC_PER_TICK=1000

boards/arm/stm32/nucleo-f412zg/include/board.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,14 @@
125125
# define GPIO_USART2_RX GPIO_USART2_RX_2
126126
# define GPIO_USART2_TX GPIO_USART2_TX_2
127127

128+
/* USART3 (ST-LINK Virtual COM Port):
129+
* RXD: PD9
130+
* TXD: PD8
131+
*/
132+
133+
# define GPIO_USART3_RX GPIO_USART3_RX_3
134+
# define GPIO_USART3_TX GPIO_USART3_TX_3
135+
128136
/* USART6:
129137
* RXD: PG9 CN10 pin 16
130138
* TXD: PG14 CN10 pin 14

0 commit comments

Comments
 (0)