1.. zephyr:board:: mks_canable_v20
2
3Overview
4********
5
6The Makerbase MKS CANable V2.0 board features an ARM Cortex-M4 based STM32G431C8 MCU
7with a CAN, USB and debugger connections.
8Here are some highlights of the MKS CANable V2.0 board:
9
10- STM32 microcontroller in LQFP48 package
11- USB Type-C connector (J1)
12- CAN-Bus connector (J2)
13- ST-LINK/V3E debugger/programmer header (J4)
14- USB VBUS power supply (5 V)
15- Three LEDs: red/power_led (D1), blue/stat_led (D2), green/word_led (D3)
16- One push-button for RESET
17- Development support: serial wire debug (SWD), JTAG, Embedded Trace Macrocell.
18
19The LED red/power_led (D1) is connected directly to on-board 3.3 V and not controllable by the MCU.
20
21More information about the board can be found at the `MKS CANable V2.0 website`_.
22It is very advisable to take a look in on user manual `MKS CANable V2.0 User Manual`_ and
23schematic `MKS CANable V2.0 schematic`_ before start.
24
25More information about STM32G431KB can be found here:
26
27- `STM32G431C8 on www.st.com`_
28- `STM32G4 reference manual`_
29
30Supported Features
31==================
32
33The Zephyr ``mks_canable_v20`` board target supports the following hardware features:
34
35+-----------+------------+-------------------------------------+
36| Interface | Controller | Driver/Component                    |
37+===========+============+=====================================+
38| NVIC      | on-chip    | nested vector interrupt controller  |
39+-----------+------------+-------------------------------------+
40| USB       | on-chip    | universal-serial-bus                |
41+-----------+------------+-------------------------------------+
42| PINMUX    | on-chip    | pinmux                              |
43+-----------+------------+-------------------------------------+
44| GPIO      | on-chip    | gpio                                |
45+-----------+------------+-------------------------------------+
46| FDCAN     | on-chip    | can                                 |
47+-----------+------------+-------------------------------------+
48
49Other hardware features are not yet supported on this Zephyr port.
50
51The default configuration can be found in the defconfig file:
52:zephyr_file:`boards/makerbase/mks_canable_v20/mks_canable_v20_defconfig`
53
54
55Connections and IOs
56===================
57
58Default Zephyr Peripheral Mapping:
59----------------------------------
60
61.. rst-class:: rst-columns
62
63- CAN_RX/BOOT0 : PB8
64- CAN_TX : PB9
65- D2 : PA15
66- D3 : PA0
67- USB_DN : PA11
68- USB_DP : PA12
69- SWDIO : PA13
70- SWCLK : PA14
71- NRST : PG10
72
73For more details please refer to `MKS CANable V2.0 schematic`_.
74
75System Clock
76------------
77
78The MKS CANable V2.0 system clock is driven by internal high speed oscillator.
79By default system clock is driven by PLL clock at 160 MHz,
80the PLL is driven by the 16 MHz high speed internal oscillator.
81
82The FDCAN1 peripheral is driven by PLLQ, which has 80 MHz frequency.
83
84Programming and Debugging
85*************************
86
87MKS CANable V2.0 board includes an SWDIO debug connector header J4.
88
89.. note::
90
91   The debugger is not the part of the board!
92
93Applications for the ``mks_canable_v20`` board target can be built and
94flashed in the usual way (see :ref:`build_an_application` and
95:ref:`application_run` for more details).
96
97Flashing
98========
99
100The board could be flashed using west.
101
102Flashing an application to MKS CANable V2.0
103-------------------------------------------
104
105The debugger shall be wired to MKS CANable V2.0 board's J4 connector
106according `MKS CANable V2.0 schematic`_.
107
108Build and flash an application. Here is an example for
109:zephyr:code-sample:`hello_world`.
110
111.. zephyr-app-commands::
112   :zephyr-app: samples/hello_world
113   :board: mks_canable_v20
114   :goals: build flash
115   :west-args: -S rtt-console
116   :compact:
117
118The argument ``-S rtt-console`` is needed for debug purposes with SEGGER RTT protocol.
119This option is optional and may be omitted. Omitting it frees up RAM space but prevents RTT usage.
120
121If option ``-S rtt-console`` is selected, the connection to the target can be established as follows:
122
123.. code-block:: console
124
125   $ telnet localhost 9090
126
127You should see the following message on the console:
128
129.. code-block:: console
130
131   $ Hello World! mks_canable_v20/stm32g431xx
132
133.. note::
134
135   Current OpenOCD config will skip Segger RTT for OpenOCD under 0.12.0.
136
137Debugging
138=========
139
140You can debug an application in the usual way. Here is an example for the
141:zephyr:code-sample:`hello_world` application.
142
143.. zephyr-app-commands::
144   :zephyr-app: samples/hello_world
145   :board: mks_canable_v20
146   :maybe-skip-config:
147   :goals: debug
148
149References
150**********
151
152.. target-notes::
153
154.. _MKS CANable V2.0 website:
155   https://github.com/makerbase-mks/CANable-MKS
156
157.. _MKS CANable V2.0 User Manual:
158   https://github.com/makerbase-mks/CANable-MKS/blob/main/User%20Manual/CANable%20V2.0/Makerbase%20CANable%20V2.0%20Use%20Manual.pdf
159
160.. _MKS CANable V2.0 schematic:
161   https://github.com/makerbase-mks/CANable-MKS/blob/main/Hardware/MKS%20CANable%20V2.0/MKS%20CANable%20V2.0_001%20schematic.pdf
162
163.. _STM32G431C8 on www.st.com:
164   https://www.st.com/en/microcontrollers-microprocessors/stm32g431c8.html
165
166.. _STM32G4 reference manual:
167   https://www.st.com/resource/en/reference_manual/rm0440-stm32g4-series-advanced-armbased-32bit-mcus-stmicroelectronics.pdf
168
169.. _STM32CubeProgrammer:
170   https://www.st.com/en/development-tools/stm32cubeprog.html
171