Skip to content

Commit 81080a1

Browse files
nzmichaelhDhiru Kholia
authored andcommitted
boards: add ch32v003evt
This commit adds support for the CH32V003EVT board which features a 32-bit general-purpose RISC-V MCU. Signed-off-by: Michael Hope <[email protected]> Signed-off-by: Dhiru Kholia <[email protected]>
1 parent 2ab7d43 commit 81080a1

File tree

11 files changed

+246
-0
lines changed

11 files changed

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

boards/wch/ch32v003evt/board.cmake

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# Copyright (c) 2024 Michael Hope
2+
# SPDX-License-Identifier: Apache-2.0
3+
4+
board_runner_args(openocd "--use-elf" "--cmd-reset-halt" "halt")
5+
include(${ZEPHYR_BASE}/boards/common/openocd.board.cmake)

boards/wch/ch32v003evt/board.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
board:
2+
name: ch32v003evt
3+
full_name: WCH CH32V003EVT
4+
vendor: wch
5+
socs:
6+
- name: ch32v003
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
/*
2+
* Copyright (c) 2024 Michael Hope <[email protected]>
3+
* SPDX-License-Identifier: Apache-2.0
4+
*/
5+
6+
#include <zephyr/dt-bindings/pinctrl/ch32v003-pinctrl.h>
7+
8+
&pinctrl {
9+
usart1_default: usart1_default {
10+
group1 {
11+
pinmux = <USART1_TX_PD5_0>;
12+
output-high;
13+
drive-push-pull;
14+
slew-rate = "max-speed-10mhz";
15+
};
16+
group2 {
17+
pinmux = <USART1_RX_PD6_0>;
18+
bias-pull-up;
19+
};
20+
};
21+
};
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
/*
2+
* Copyright (c) 2024 Michael Hope <[email protected]>
3+
* SPDX-License-Identifier: Apache-2.0
4+
*/
5+
6+
/dts-v1/;
7+
8+
#include <wch/ch32v00x.dtsi>
9+
#include "ch32v003evt-pinctrl.dtsi"
10+
11+
/ {
12+
model = "ch32v003evt";
13+
compatible = "wch,ch32v003";
14+
15+
chosen {
16+
zephyr,sram = &sram0;
17+
zephyr,flash = &flash0;
18+
zephyr,console = &usart1;
19+
zephyr,shell-uart = &usart1;
20+
};
21+
22+
leds {
23+
compatible = "gpio-leds";
24+
25+
red_led: led0 {
26+
gpios = <&gpiod 4 GPIO_ACTIVE_HIGH>;
27+
};
28+
};
29+
30+
aliases {
31+
led0 = &red_led;
32+
};
33+
};
34+
35+
&clk_hse {
36+
clock-frequency = <DT_FREQ_M(24)>;
37+
status = "okay";
38+
};
39+
40+
&pll {
41+
clocks = <&clk_hse>;
42+
status = "okay";
43+
};
44+
45+
&rcc {
46+
clocks = <&pll>;
47+
};
48+
49+
&gpiod {
50+
status = "okay";
51+
};
52+
53+
&usart1 {
54+
status = "okay";
55+
current-speed = <115200>;
56+
pinctrl-0 = <&usart1_default>;
57+
pinctrl-names = "default";
58+
};
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
identifier: ch32v003evt
2+
name: WCH CH32V003 Evaluation Board
3+
type: mcu
4+
arch: riscv
5+
toolchain:
6+
- cross-compile
7+
- zephyr
8+
ram: 2
9+
flash: 16
10+
supported:
11+
- gpio
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
# Copyright (c) 2024 Michael Hope
2+
# SPDX-License-Identifier: Apache-2.0
3+
4+
CONFIG_MAIN_STACK_SIZE=512
5+
6+
CONFIG_IDLE_STACK_SIZE=256
7+
8+
CONFIG_ISR_STACK_SIZE=256
49.9 KB
Loading
Lines changed: 107 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,107 @@
1+
.. zephyr:board:: ch32v003evt
2+
3+
Overview
4+
********
5+
6+
The `WCH`_ CH32V003EVT hardware provides support for QingKe 32-bit RISC-V2A
7+
processor and the following devices:
8+
9+
* CLOCK
10+
* :abbr:`GPIO (General Purpose Input Output)`
11+
* :abbr:`NVIC (Nested Vectored Interrupt Controller)`
12+
13+
The board is equipped with two LEDs. The `WCH webpage on CH32V003`_ contains
14+
the processor's information and the datasheet.
15+
16+
Hardware
17+
********
18+
19+
The QingKe 32-bit RISC-V2A processor of the WCH CH32V003EVT is clocked by an
20+
external crystal and runs at 48 MHz.
21+
22+
Supported Features
23+
==================
24+
25+
The ``ch32v003evt`` board target supports the following hardware features:
26+
27+
+-----------+------------+----------------------+
28+
| Interface | Controller | Driver/Component |
29+
+===========+============+======================+
30+
| CLOCK | on-chip | clock_control |
31+
+-----------+------------+----------------------+
32+
| GPIO | on-chip | gpio |
33+
+-----------+------------+----------------------+
34+
| PWM | on-chip | pwm |
35+
+-----------+------------+----------------------+
36+
| PINCTRL | on-chip | pinctrl |
37+
+-----------+------------+----------------------+
38+
| TIMER | on-chip | timer |
39+
+-----------+------------+----------------------+
40+
| UART | on-chip | uart |
41+
+-----------+------------+----------------------+
42+
43+
Other hardware features have not been enabled yet for this board.
44+
45+
Connections and IOs
46+
===================
47+
48+
LED
49+
---
50+
51+
* LED1 = Unconnected. Connect to an I/O pin (PD4).
52+
53+
Programming and Debugging
54+
*************************
55+
56+
Applications for the ``ch32v003evt`` board target can be built and flashed
57+
in the usual way (see :ref:`build_an_application` and :ref:`application_run`
58+
for more details); however, an external programmer is required since the board
59+
does not have any built-in debug support.
60+
61+
The following pins of the external programmer must be connected to the
62+
following pins on the PCB (see image):
63+
64+
* VCC = VCC (do not power the board from the USB port at the same time)
65+
* GND = GND
66+
* SWIO = PD1
67+
68+
Flashing
69+
========
70+
71+
You can use ``minichlink`` to flash the board. Once ``minichlink`` has been set
72+
up, build and flash applications as usual (see :ref:`build_an_application` and
73+
:ref:`application_run` for more details).
74+
75+
Here is an example for the :zephyr:code-sample:`blinky` application.
76+
77+
.. zephyr-app-commands::
78+
:zephyr-app: samples/basic/blinky
79+
:board: ch32v003evt
80+
:goals: build flash
81+
82+
Debugging
83+
=========
84+
85+
This board can be debugged via OpenOCD or ``minichlink``.
86+
87+
Testing the LED on the WCH CH32V003EVT
88+
**************************************
89+
90+
There is 1 sample program that allow you to test that the LED on the board is
91+
working properly with Zephyr:
92+
93+
.. code-block:: console
94+
95+
samples/basic/blinky
96+
97+
You can build and flash the examples to make sure Zephyr is running
98+
correctly on your board. The button and LED definitions can be found
99+
in :zephyr_file:`boards/wch/ch32v003evt/ch32v003evt.dts`.
100+
101+
References
102+
**********
103+
104+
.. target-notes::
105+
106+
.. _WCH: http://www.wch-ic.com
107+
.. _WCH webpage on CH32V003: https://www.wch-ic.com/products/CH32V003.html
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)