Skip to content

Commit 231978d

Browse files
committed
boards: wch: Introduce Weact CH32V203 bluepill
Introduces WeActStudio Blue Pill Plus CH32V203 Signed-off-by: Camille BAUD <[email protected]>
1 parent 0c4c0e5 commit 231978d

10 files changed

+243
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# Copyright (c) 2025 MASSDRIVER EI (massdriver.space)
2+
# SPDX-License-Identifier: Apache-2.0
3+
4+
config BOARD_BLUEPILLPLUS_CH32V203
5+
select SOC_CH32V203
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
/*
2+
* Copyright (c) 2025 MASSDRIVER EI (massdriver.space)
3+
* SPDX-License-Identifier: Apache-2.0
4+
*/
5+
6+
#include <zephyr/dt-bindings/pinctrl/ch32v20x_30x-pinctrl.h>
7+
8+
&pinctrl {
9+
usart3_default: usart3_default {
10+
group1 {
11+
pinmux = <USART3_TX_PB10_0>;
12+
output-high;
13+
drive-push-pull;
14+
slew-rate = "max-speed-10mhz";
15+
};
16+
group2 {
17+
pinmux = <USART3_RX_PB11_0>;
18+
bias-pull-up;
19+
};
20+
};
21+
};
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
/*
2+
* Copyright (c) 2025 MASSDRIVER EI (massdriver.space)
3+
* SPDX-License-Identifier: Apache-2.0
4+
*/
5+
6+
/dts-v1/;
7+
8+
#include <wch/ch32v203/ch32v203c8t.dtsi>
9+
#include <zephyr/dt-bindings/gpio/gpio.h>
10+
#include <zephyr/dt-bindings/input/input-event-codes.h>
11+
#include "bluepillplus_ch32v203-pinctrl.dtsi"
12+
13+
/ {
14+
model = "bluepillplus_ch32v203";
15+
compatible = "wch,ch32v203";
16+
17+
chosen {
18+
zephyr,sram = &sram0;
19+
zephyr,flash = &flash0;
20+
zephyr,console = &usart3;
21+
zephyr,shell-uart = &usart3;
22+
};
23+
24+
leds {
25+
compatible = "gpio-leds";
26+
status = "okay";
27+
28+
blue_led: led0 {
29+
gpios = <&gpiob 2 GPIO_ACTIVE_HIGH>;
30+
};
31+
};
32+
33+
buttons {
34+
compatible = "gpio-keys";
35+
36+
mode: sw0 {
37+
gpios = <&gpioa 0 GPIO_ACTIVE_HIGH>;
38+
zephyr,code = <INPUT_KEY_0>;
39+
};
40+
};
41+
42+
aliases {
43+
led0 = &blue_led;
44+
sw0 = &mode;
45+
};
46+
};
47+
48+
&clk_hse {
49+
clock-frequency = <DT_FREQ_M(8)>;
50+
status = "okay";
51+
};
52+
53+
&pll {
54+
clocks = <&clk_hse>;
55+
status = "okay";
56+
};
57+
58+
&rcc {
59+
clocks = <&pll>;
60+
};
61+
62+
&gpioa {
63+
status = "okay";
64+
};
65+
66+
&gpiob {
67+
status = "okay";
68+
};
69+
70+
&gpioc {
71+
status = "okay";
72+
};
73+
74+
&usart3 {
75+
status = "okay";
76+
current-speed = <115200>;
77+
pinctrl-0 = <&usart3_default>;
78+
pinctrl-names = "default";
79+
};
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
identifier: bluepillplus_ch32v203
2+
name: WeActStudio Blue Pill Plus CH32V203
3+
type: mcu
4+
arch: riscv
5+
toolchain:
6+
- cross-compile
7+
- zephyr
8+
ram: 20
9+
flash: 64
10+
supported:
11+
- gpio
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
# Copyright (c) 2025 MASSDRIVER EI
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
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
# Copyright (c) 2025 MASSDRIVER EI (massdriver.space)
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)
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
board:
2+
name: bluepillplus_ch32v203
3+
full_name: Blue Pill Plus CH32V203
4+
vendor: weact
5+
socs:
6+
- name: ch32v203
Binary file not shown.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
.. zephyr:board:: bluepillplus_ch32v203
2+
3+
Overview
4+
********
5+
6+
The `WeActStudio`_ Blue Pill Plus CH32V203 hardware provides support for QingKe 32-bit RISC-V4B
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 and two Buttons.
14+
The `WCH webpage on CH32V203`_ contains the processor's manuals.
15+
The `WeActStudio webpage on BPP`_ contains the Blue Pill's schematic.
16+
17+
Hardware
18+
********
19+
20+
The QingKe 32-bit RISC-V4B processor of the Blue Pill Plus CH32V203 is clocked by an external
21+
8 MHz crystal or the internal 8 MHz oscillator and runs up to 144 MHz.
22+
The CH32V203 SoC Features 2-4 USART, 4 GPIO ports, 1-2 SPI, 0-2 I2C, 9-16 ADC, RTC,
23+
CAN, USB Device, USB Host, OPA, and several timers.
24+
25+
Supported Features
26+
==================
27+
28+
.. zephyr:board-supported-hw::
29+
30+
Connections and IOs
31+
===================
32+
33+
LED
34+
---
35+
36+
* LED0 = Blue User LED
37+
38+
Button
39+
------
40+
41+
* SW0 = User Button
42+
43+
Programming and Debugging
44+
*************************
45+
46+
Applications for the ``bluepillplus_ch32v203`` board target can be built and flashed
47+
in the usual way (see :ref:`build_an_application` and :ref:`application_run`
48+
for more details); however, an external programmer is required since the board
49+
does not have any built-in debug support.
50+
51+
The following pins of the external programmer must be connected to the
52+
following pins on the PCB:
53+
54+
* VCC = VCC
55+
* GND = GND
56+
* SWIO = PA13
57+
* SWCLK = PA14
58+
59+
Flashing
60+
========
61+
62+
You can use ``minichlink`` to flash the board. Once ``minichlink`` has been set
63+
up, build and flash applications as usual (see :ref:`build_an_application` and
64+
:ref:`application_run` for more details).
65+
66+
Here is an example for the :zephyr:code-sample:`blinky` application.
67+
68+
.. zephyr-app-commands::
69+
:zephyr-app: samples/basic/blinky
70+
:board: bluepillplus_ch32v203
71+
:goals: build flash
72+
73+
Debugging
74+
=========
75+
76+
This board can be debugged via OpenOCD or ``minichlink``.
77+
78+
References
79+
**********
80+
81+
.. target-notes::
82+
83+
.. _WeActStudio: https://github.com/WeActStudio
84+
.. _WCH webpage on CH32V203: https://www.wch-ic.com/products/CH32V203.html
85+
.. _WeActStudio webpage on BPP: https://github.com/WeActStudio/WeActStudio.BluePill-Plus-CH32
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)