Skip to content

Commit e642b3b

Browse files
KozhinovAlexanderkartben
authored andcommitted
boards: makerbase: mks_canable_v20: add new board MKS CANable V2.0
A cheap and affordable stm32g4 based simple CAN and CAN-FD to usb adapter board Signed-off-by: Alexander Kozhinov <[email protected]>
1 parent 4212b52 commit e642b3b

File tree

10 files changed

+310
-0
lines changed

10 files changed

+310
-0
lines changed

boards/makerbase/index.rst

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
.. _boards-makerbase:
2+
3+
Makerbase
4+
#########
5+
6+
.. toctree::
7+
:maxdepth: 1
8+
:glob:
9+
10+
**/*
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# Copyright (c) 2024 Alexander Kozhinov <[email protected]>
2+
# SPDX-License-Identifier: Apache-2.0
3+
4+
config BOARD_MKS_CANABLE_V20
5+
select SOC_STM32G431XX
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
# Copyright (c) 2024 Alexander Kozhinov <[email protected]>
2+
# SPDX-License-Identifier: Apache-2.0
3+
4+
board_runner_args(openocd "--config=${BOARD_DIR}/support/openocd.cfg")
5+
6+
include(${ZEPHYR_BASE}/boards/common/openocd.board.cmake)
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
board:
2+
name: mks_canable_v20
3+
full_name: MKS CANable V2.0
4+
vendor: makerbase
5+
socs:
6+
- name: stm32g431xx
18.8 KB
Loading
Lines changed: 170 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,170 @@
1+
.. zephyr:board:: mks_canable_v20
2+
3+
Overview
4+
********
5+
6+
The Makerbase MKS CANable V2.0 board features an ARM Cortex-M4 based STM32G431C8 MCU
7+
with a CAN, USB and debugger connections.
8+
Here 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+
19+
The LED red/power_led (D1) is connected directly to on-board 3.3 V and not controllable by the MCU.
20+
21+
More information about the board can be found at the `MKS CANable V2.0 website`_.
22+
It is very advisable to take a look in on user manual `MKS CANable V2.0 User Manual`_ and
23+
schematic `MKS CANable V2.0 schematic`_ before start.
24+
25+
More information about STM32G431KB can be found here:
26+
27+
- `STM32G431C8 on www.st.com`_
28+
- `STM32G4 reference manual`_
29+
30+
Supported Features
31+
==================
32+
33+
The 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+
49+
Other hardware features are not yet supported on this Zephyr port.
50+
51+
The default configuration can be found in the defconfig file:
52+
:zephyr_file:`boards/makerbase/mks_canable_v20/mks_canable_v20_defconfig`
53+
54+
55+
Connections and IOs
56+
===================
57+
58+
Default 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+
73+
For more details please refer to `MKS CANable V2.0 schematic`_.
74+
75+
System Clock
76+
------------
77+
78+
The MKS CANable V2.0 system clock is driven by internal high speed oscillator.
79+
By default system clock is driven by PLL clock at 160 MHz,
80+
the PLL is driven by the 16 MHz high speed internal oscillator.
81+
82+
The FDCAN1 peripheral is driven by PLLQ, which has 80 MHz frequency.
83+
84+
Programming and Debugging
85+
*************************
86+
87+
MKS 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+
93+
Applications for the ``mks_canable_v20`` board target can be built and
94+
flashed in the usual way (see :ref:`build_an_application` and
95+
:ref:`application_run` for more details).
96+
97+
Flashing
98+
========
99+
100+
The board could be flashed using west.
101+
102+
Flashing an application to MKS CANable V2.0
103+
-------------------------------------------
104+
105+
The debugger shall be wired to MKS CANable V2.0 board's J4 connector
106+
according `MKS CANable V2.0 schematic`_.
107+
108+
Build 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+
118+
The argument ``-S rtt-console`` is needed for debug purposes with SEGGER RTT protocol.
119+
This option is optional and may be omitted. Omitting it frees up RAM space but prevents RTT usage.
120+
121+
If 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+
127+
You 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+
137+
Debugging
138+
=========
139+
140+
You 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+
149+
References
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
Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
/*
2+
* Copyright (c) 2024 Alexander Kozhinov <[email protected]>
3+
* SPDX-License-Identifier: Apache-2.0
4+
*/
5+
6+
/dts-v1/;
7+
#include <st/g4/stm32g431X8.dtsi>
8+
#include <st/g4/stm32g431c(6-8-b)tx-pinctrl.dtsi>
9+
10+
/ {
11+
model = "Makerbase MKS CANable V2.0";
12+
compatible = "makerbase,mks-canable-v20";
13+
14+
chosen {
15+
zephyr,sram = &sram0;
16+
zephyr,flash = &flash0;
17+
zephyr,canbus = &fdcan1;
18+
};
19+
20+
aliases {
21+
led0 = &blue_led;
22+
led1 = &green_led;
23+
};
24+
25+
leds: leds {
26+
compatible = "gpio-leds";
27+
blue_led: led_2 {
28+
gpios = <&gpioa 15 GPIO_ACTIVE_LOW>;
29+
label = "blue-status D2";
30+
};
31+
green_led: led_3 {
32+
gpios = <&gpioa 0 GPIO_ACTIVE_LOW>;
33+
label = "green-word D3";
34+
};
35+
};
36+
};
37+
38+
&clk_hsi {
39+
/* Internal 16 MHz clock used to drive PLL */
40+
status = "okay";
41+
};
42+
43+
&clk_hsi48 {
44+
/* Internal 48 MHz clock used to drive USB */
45+
status = "okay";
46+
};
47+
48+
/* Adjust the pll for a SYSTEM Clock of 160 MHz */
49+
&pll {
50+
div-m = <4>;
51+
mul-n = <80>;
52+
div-p = <2>;
53+
div-q = <4>;
54+
div-r = <2>;
55+
clocks = <&clk_hsi>;
56+
status = "okay";
57+
};
58+
59+
&rcc {
60+
clocks = <&pll>;
61+
clock-frequency = <DT_FREQ_M(160)>;
62+
ahb-prescaler = <1>;
63+
apb1-prescaler = <1>;
64+
apb2-prescaler = <1>;
65+
};
66+
67+
stm32_lp_tick_source: &lptim1 {
68+
clocks = <&rcc STM32_CLOCK_BUS_APB1 0x80000000>,
69+
<&rcc STM32_SRC_LSE LPTIM1_SEL(3)>;
70+
status = "okay";
71+
};
72+
73+
zephyr_udc0: &usb {
74+
pinctrl-0 = <&usb_dm_pa11 &usb_dp_pa12>;
75+
pinctrl-names = "default";
76+
clocks = <&rcc STM32_CLOCK(APB1, 23U)>,
77+
<&rcc STM32_SRC_HSI48 CLK48_SEL(0)>;
78+
status = "okay";
79+
};
80+
81+
&fdcan1 {
82+
pinctrl-0 = <&fdcan1_rx_pb8 &fdcan1_tx_pb9>;
83+
pinctrl-names = "default";
84+
clocks = <&rcc STM32_CLOCK_BUS_APB1 0x00001000>,
85+
<&rcc STM32_SRC_PLL_Q FDCAN_SEL(1)>;
86+
status = "okay";
87+
};
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
identifier: mks_canable_v20
2+
name: MKS CANable V2.0
3+
type: mcu
4+
arch: arm
5+
toolchain:
6+
- zephyr
7+
- gnuarmemb
8+
ram: 32
9+
flash: 64
10+
supported:
11+
- can
12+
- counter
13+
- gpio
14+
- usb_device
15+
- usbd
16+
vendor: makerbase
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# Copyright (c) 2024 Alexander Kozhinov <[email protected]>
2+
# SPDX-License-Identifier: Apache-2.0
3+
4+
CONFIG_GPIO=y
5+
CONFIG_ARM_MPU=y
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# Copyright (c) 2024 Alexander Kozhinov <[email protected]>
2+
# SPDX-License-Identifier: Apache-2.0
3+
4+
source [find interface/stlink.cfg]
5+
source [find target/stm32g4x.cfg]

0 commit comments

Comments
 (0)