Skip to content

Commit 3fe4bcb

Browse files
nzmichaelhkartben
authored andcommitted
boards: wch: add the ch32v006evt
The WCH CH32V006EVT is an evaluation board for the RISC-V based CH32V006K8U6 SOC. The board is equipped with a power LED, reset button, USB port for power, and two user LEDs. Add the board definition, documentation, and sample overlay. Signed-off-by: Michael Hope <[email protected]>
1 parent e039b8d commit 3fe4bcb

File tree

13 files changed

+359
-0
lines changed

13 files changed

+359
-0
lines changed
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# Copyright (c) 2025 Michael Hope
2+
# SPDX-License-Identifier: Apache-2.0
3+
4+
config BOARD_CH32V006EVT
5+
select SOC_CH32V006

boards/wch/ch32v006evt/board.cmake

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
# Copyright (c) 2025 Michael Hope <[email protected]>
2+
# SPDX-License-Identifier: Apache-2.0
3+
4+
board_runner_args(minichlink)
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/ch32v006evt/board.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
board:
2+
name: ch32v006evt
3+
full_name: WCH CH32V006EVT
4+
vendor: wch
5+
socs:
6+
- name: ch32v006
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
/*
2+
* Copyright (c) 2025 Michael Hope <[email protected]>
3+
*
4+
* SPDX-License-Identifier: Apache-2.0
5+
*/
6+
7+
#include <zephyr/dt-bindings/pinctrl/ch32v00x-pinctrl.h>
8+
9+
&pinctrl {
10+
usart1_default: usart1_default {
11+
group1 {
12+
pinmux = <USART1_TX_PD5_0>;
13+
output-high;
14+
drive-push-pull;
15+
};
16+
17+
group2 {
18+
pinmux = <USART1_RX_PD6_0>;
19+
bias-pull-up;
20+
};
21+
};
22+
23+
usart2_default: usart2_default {
24+
group1 {
25+
pinmux = <USART2_TX_PA7_0>;
26+
output-high;
27+
drive-push-pull;
28+
};
29+
30+
group2 {
31+
pinmux = <USART2_RX_PB3_0>;
32+
bias-pull-up;
33+
};
34+
};
35+
36+
i2c1_default: i2c1_default {
37+
group1 {
38+
pinmux = <I2C1_SDA_PC1_0>, <I2C1_SCL_PC2_0>;
39+
output-high;
40+
drive-open-drain;
41+
};
42+
};
43+
44+
blue_pwm_pinctrl: blue_pwm_pinctrl {
45+
group1 {
46+
pinmux = <TIM2_CH3_PC0_0>;
47+
output-high;
48+
drive-push-pull;
49+
};
50+
};
51+
};
Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
/*
2+
* Copyright (c) 2025 Michael Hope <[email protected]>
3+
* SPDX-License-Identifier: Apache-2.0
4+
*/
5+
6+
/dts-v1/;
7+
8+
#include <wch/ch32v0/ch32v006k8u.dtsi>
9+
#include "ch32v006evt-pinctrl.dtsi"
10+
11+
#include <zephyr/dt-bindings/gpio/gpio.h>
12+
#include <zephyr/dt-bindings/i2c/i2c.h>
13+
#include <zephyr/dt-bindings/pwm/pwm.h>
14+
15+
/ {
16+
model = "ch32v006evt";
17+
compatible = "wch,ch32v006";
18+
19+
chosen {
20+
zephyr,sram = &sram0;
21+
zephyr,flash = &flash0;
22+
zephyr,console = &usart1;
23+
zephyr,shell-uart = &usart1;
24+
};
25+
26+
leds {
27+
compatible = "gpio-leds";
28+
29+
/*
30+
* Please connect the unconnected LED1 on the WCH CH32V006EVT
31+
* board to PD0 and then change this status to "okay".
32+
*/
33+
status = "disabled";
34+
35+
blue_led1: led1 {
36+
gpios = <&gpiod 0 GPIO_ACTIVE_LOW>;
37+
};
38+
39+
blue_led2: led2 {
40+
gpios = <&gpioc 0 GPIO_ACTIVE_LOW>;
41+
};
42+
};
43+
44+
pwmleds: pwmleds {
45+
compatible = "pwm-leds";
46+
status = "disabled";
47+
48+
/* LED1 is on PD0 which does not have a PWM channel */
49+
50+
blue_pwm2: blue_pwm2 {
51+
pwms = <&pwm2 2 PWM_MSEC(20) PWM_POLARITY_INVERTED>;
52+
label = "Blue LED 2";
53+
};
54+
};
55+
56+
aliases {
57+
led0 = &blue_led1;
58+
led1 = &blue_led2;
59+
pwm-led0 = &blue_pwm2;
60+
};
61+
};
62+
63+
&clk_hse {
64+
clock-frequency = <DT_FREQ_M(24)>;
65+
status = "okay";
66+
};
67+
68+
&pll {
69+
clocks = <&clk_hse>;
70+
status = "okay";
71+
};
72+
73+
&rcc {
74+
clocks = <&pll>;
75+
};
76+
77+
&gpioc {
78+
status = "okay";
79+
};
80+
81+
&gpiod {
82+
status = "okay";
83+
};
84+
85+
&usart1 {
86+
status = "okay";
87+
current-speed = <115200>;
88+
pinctrl-0 = <&usart1_default>;
89+
pinctrl-names = "default";
90+
};
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
identifier: ch32v006evt
2+
name: WCH CH32V006 Evaluation Board
3+
type: mcu
4+
arch: riscv
5+
toolchain:
6+
- cross-compile
7+
- zephyr
8+
ram: 8
9+
flash: 62
10+
supported:
11+
- gpio
12+
- i2c
13+
- pwm
14+
- watchdog
15+
vendor: wch
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
# Copyright (c) 2025 Michael Hope <[email protected]>
2+
# SPDX-License-Identifier: Apache-2.0
3+
4+
CONFIG_GPIO=y
5+
CONFIG_SERIAL=y
6+
CONFIG_CONSOLE=y
7+
CONFIG_UART_CONSOLE=y
35.8 KB
Loading
Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
.. zephyr:board:: ch32v006evt
2+
3+
Overview
4+
********
5+
6+
The `WCH`_ CH32V006EVT is an evaluation board for the RISC-V based CH32V006K8U6
7+
SOC.
8+
9+
The board is equipped with a power LED, reset button, USB port for power, and
10+
two user LEDs. The `WCH webpage on CH32V006`_ contains the processor's
11+
information and the datasheet.
12+
13+
Hardware
14+
********
15+
16+
The QingKe 32-bit RISC-V2C processor of the WCH CH32V006EVT is clocked by an
17+
external crystal and runs at 48 MHz.
18+
19+
Supported Features
20+
==================
21+
22+
.. zephyr:board-supported-hw::
23+
24+
Connections and IOs
25+
===================
26+
27+
LED
28+
---
29+
30+
* LED1 = Unconnected. Connect to an I/O pin (PD0).
31+
* LED2 = Unconnected. Connect to an I/O pin (PC0).
32+
33+
Programming and Debugging
34+
*************************
35+
36+
.. zephyr:board-supported-runners::
37+
38+
Applications for the ``ch32v006evt`` board can be built and flashed
39+
in the usual way (see :ref:`build_an_application` and :ref:`application_run`
40+
for more details); however, an external programmer is required since the board
41+
does not have any built-in debug support.
42+
43+
Connect the programmer to the following pins on the PCB:
44+
45+
* VCC = VCC (do not power the board from the USB port at the same time)
46+
* GND = GND
47+
* SWIO = PD1
48+
49+
Flashing
50+
========
51+
52+
You can use minichlink_ to flash the board. Once ``minichlink`` has been set
53+
up, build and flash applications as usual (see :ref:`build_an_application` and
54+
:ref:`application_run` for more details).
55+
56+
Here is an example for the :zephyr:code-sample:`blinky` application.
57+
58+
.. zephyr-app-commands::
59+
:zephyr-app: samples/basic/blinky
60+
:board: ch32v006evt
61+
:goals: build flash
62+
63+
Debugging
64+
=========
65+
66+
This board can be debugged via OpenOCD or ``minichlink``.
67+
68+
Testing the LED on the WCH CH32V006EVT
69+
**************************************
70+
71+
The ``blinky`` sample can be used to test that the LEDs on the board are working
72+
properly with Zephyr:
73+
74+
* :zephyr:code-sample:`blinky`
75+
76+
You can build and flash the examples to make sure Zephyr is running
77+
correctly on your board. The LED definitions can be found in
78+
:zephyr_file:`boards/wch/ch32v006evt/ch32v006evt.dts`.
79+
80+
References
81+
**********
82+
83+
.. target-notes::
84+
85+
.. _WCH: http://www.wch-ic.com
86+
.. _WCH webpage on CH32V006: https://www.wch-ic.com/downloads/CH32V006DS0_PDF.html
87+
.. _minichlink: https://github.com/cnlohr/ch32fun/tree/master/minichlink
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
#interface wlink
2+
adapter driver wlink
3+
wlink_set
4+
set _CHIPNAME riscv
5+
jtag newtap $_CHIPNAME cpu -irlen 5 -expected-id 0x00001
6+
7+
set _TARGETNAME $_CHIPNAME.cpu
8+
9+
target create $_TARGETNAME.0 riscv -chain-position $_TARGETNAME
10+
$_TARGETNAME.0 configure -work-area-phys 0x80000000 -work-area-size 10000 -work-area-backup 1
11+
set _FLASHNAME $_CHIPNAME.flash
12+
13+
flash bank $_FLASHNAME wch_riscv 0x00000000 0 0 0 $_TARGETNAME.0
14+
15+
echo "Ready for Remote Connections"

0 commit comments

Comments
 (0)