Skip to content

Commit 275a2ee

Browse files
committed
boards: Add support for the board CH32V303EVT
Adds support for the CH32V303EVT board, based on the CH32V303 soc. Signed-off-by: Miguel Gazquez <[email protected]>
1 parent 59dac22 commit 275a2ee

File tree

9 files changed

+180
-0
lines changed

9 files changed

+180
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# Copyright (c) 2025 Bootlin
2+
# SPDX-License-Identifier: Apache-2.0
3+
4+
config BOARD_CH32V303EVT
5+
select SOC_CH32V303

boards/wch/ch32v303evt/board.cmake

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
# Copyright (c) 2025 Bootlin
2+
# SPDX-License-Identifier: Apache-2.0
3+
4+
board_runner_args(minichlink "--dt-flash=y")
5+
include(${ZEPHYR_BASE}/boards/common/minichlink.board.cmake)
6+
7+
board_runner_args(openocd "--use-elf" "--cmd-reset-halt" "halt")
8+
include(${ZEPHYR_BASE}/boards/common/openocd.board.cmake)

boards/wch/ch32v303evt/board.yml

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
board:
2+
name: ch32v303evt
3+
full_name: WCH CH32V303EVT
4+
vendor: wch
5+
socs:
6+
- name: ch32v303
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
/*
2+
* Copyright (c) 2025 Bootlin
3+
* SPDX-License-Identifier: Apache-2.0
4+
*/
5+
6+
#include <zephyr/dt-bindings/pinctrl/ch32v20x_30x-pinctrl.h>
7+
8+
&pinctrl {
9+
usart1_default: usart1_default {
10+
group1 {
11+
pinmux = <USART1_TX_PA9_0>;
12+
output-high;
13+
drive-push-pull;
14+
slew-rate = "max-speed-10mhz";
15+
};
16+
17+
group2 {
18+
pinmux = <USART1_RX_PA10_0>;
19+
bias-pull-up;
20+
};
21+
};
22+
};
+52
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
/*
2+
* Copyright (c) 2025 Bootlin
3+
* SPDX-License-Identifier: Apache-2.0
4+
*/
5+
6+
/dts-v1/;
7+
8+
#include <wch/ch32v303/ch32v303.dtsi>
9+
#include <zephyr/dt-bindings/gpio/gpio.h>
10+
#include <zephyr/dt-bindings/input/input-event-codes.h>
11+
#include "ch32v303evt-pinctrl.dtsi"
12+
13+
/ {
14+
model = "ch32v303ev";
15+
compatible = "wch,ch32v303";
16+
17+
chosen {
18+
zephyr,sram = &sram0;
19+
zephyr,flash = &flash0;
20+
zephyr,console = &usart1;
21+
zephyr,shell-uart = &usart1;
22+
};
23+
};
24+
25+
&clk_hse {
26+
clock-frequency = <DT_FREQ_M(32)>;
27+
status = "okay";
28+
};
29+
30+
&pll {
31+
clocks = <&clk_hse>;
32+
status = "okay";
33+
};
34+
35+
&rcc {
36+
clocks = <&pll>;
37+
};
38+
39+
&gpioa {
40+
status = "okay";
41+
};
42+
43+
&gpioc {
44+
status = "okay";
45+
};
46+
47+
&usart1 {
48+
status = "okay";
49+
current-speed = <115200>;
50+
pinctrl-0 = <&usart1_default>;
51+
pinctrl-names = "default";
52+
};
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
# Copyright (c) 2025 Bootlin
2+
# SPDX-License-Identifier: Apache-2.0
3+
4+
CONFIG_GPIO=y
5+
6+
CONFIG_SERIAL=y
7+
CONFIG_CONSOLE=y
8+
CONFIG_UART_CONSOLE=y
54.1 KB
Binary file not shown.

boards/wch/ch32v303evt/doc/index.rst

+59
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
.. zephyr:board:: ch32v303evt
2+
3+
Overview
4+
********
5+
6+
The `WCH`_ CH3V303EVT hardware provides support for QingKe 32-bit RISC-V4F
7+
processor.
8+
9+
The `WCH webpage on CH32V303`_ contains
10+
the processor's information and the datasheet.
11+
12+
Hardware
13+
********
14+
15+
The QingKe 32-bit RISC-V4F processor of the WCH CH32V303EVT is clocked by an external
16+
32 MHz crystal or the internal 8 MHz oscillator and runs up to 144 MHz.
17+
The CH32V303 SoC features 8 USART, 4 GPIO ports, 3 SPI, 2 I2C, 2 ADC, RTC,
18+
CAN, USB Host/Device, and 4 OPA.
19+
20+
Supported Features
21+
==================
22+
23+
.. zephyr:board-supported-hw::
24+
25+
Programming and Debugging
26+
*************************
27+
28+
Applications for the ``ch32v303evt`` board target can be built and flashed
29+
in the usual way (see :ref:`build_an_application` and :ref:`application_run`
30+
for more details); however, an external programmer (like the `WCH LinkE`_) is required since the board
31+
does not have any built-in debug support.
32+
33+
Flashing
34+
========
35+
36+
You can use ``minichlink`` to flash the board. Once ``minichlink`` has been set
37+
up, build and flash applications as usual (see :ref:`build_an_application` and
38+
:ref:`application_run` for more details).
39+
40+
Here is an example for the :zephyr:code-sample:`hello_world` application.
41+
42+
.. zephyr-app-commands::
43+
:zephyr-app: samples/hello_world
44+
:board: ch32v303evt
45+
:goals: build flash
46+
47+
Debugging
48+
=========
49+
50+
This board can be debugged via OpenOCD using the WCH openOCD liberated fork, available at https://github.com/jnk0le/openocd-wch.
51+
52+
References
53+
**********
54+
55+
.. target-notes::
56+
57+
.. _WCH: http://www.wch-ic.com
58+
.. _WCH webpage on CH32V303: https://www.wch-ic.com/products/CH32V303.html
59+
.. _WCH LinkE: https://www.wch-ic.com/products/WCH-Link.html
+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
# Tested with WCH openOCD liberated fork (https://github.com/jnk0le/openocd-wch)
2+
# Copyright (c) 2024 MASSDRIVER EI (massdriver.space)
3+
# SPDX-License-Identifier: Apache-2.0
4+
adapter driver wlinke
5+
adapter speed 6000
6+
transport select sdi
7+
8+
wlink_set_address 0x00000000
9+
set _CHIPNAME wch_riscv
10+
sdi newtap $_CHIPNAME cpu -irlen 5 -expected-id 0x00001
11+
12+
set _TARGETNAME $_CHIPNAME.cpu
13+
14+
target create $_TARGETNAME.0 wch_riscv -chain-position $_TARGETNAME
15+
$_TARGETNAME.0 configure -work-area-phys 0x20000000 -work-area-size 10000 -work-area-backup 1
16+
set _FLASHNAME $_CHIPNAME.flash
17+
18+
flash bank $_FLASHNAME wch_riscv 0x00000000 0 0 0 $_TARGETNAME.0
19+
20+
echo "Ready for Remote Connections"

0 commit comments

Comments
 (0)