-
Notifications
You must be signed in to change notification settings - Fork 7.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Introduce CH32V203 and WeactStudio CH32V203 Blue Pill plus #87490
Open
VynDragon
wants to merge
5
commits into
zephyrproject-rtos:main
Choose a base branch
from
VynDragon:CH32V203
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+900
−3
Open
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
2687c3b
soc: wch: Introduce Qingke V4B
VynDragon 9764ab4
dts: wch: Introduce CH32V203
VynDragon 7bd16b7
modules: hal_wch: add CH32V203 support
VynDragon 0c4c0e5
drivers: add CH32V203 to wch systick
VynDragon 02e86cd
boards: wch: Introduce Weact CH32V203 bluepill
VynDragon File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
5 changes: 5 additions & 0 deletions
5
boards/weact/bluepillplus_ch32v203/Kconfig.bluepillplus_ch32v203
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
# Copyright (c) 2025 MASSDRIVER EI (massdriver.space) | ||
# SPDX-License-Identifier: Apache-2.0 | ||
|
||
config BOARD_BLUEPILLPLUS_CH32V203 | ||
select SOC_CH32V203 |
22 changes: 22 additions & 0 deletions
22
boards/weact/bluepillplus_ch32v203/bluepillplus_ch32v203-pinctrl.dtsi
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
/* | ||
* Copyright (c) 2025 MASSDRIVER EI (massdriver.space) | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
#include <zephyr/dt-bindings/pinctrl/ch32v20x_30x-pinctrl.h> | ||
|
||
&pinctrl { | ||
usart3_default: usart3_default { | ||
group1 { | ||
pinmux = <USART3_TX_PB10_0>; | ||
output-high; | ||
drive-push-pull; | ||
slew-rate = "max-speed-10mhz"; | ||
}; | ||
|
||
group2 { | ||
pinmux = <USART3_RX_PB11_0>; | ||
bias-pull-up; | ||
}; | ||
}; | ||
}; |
79 changes: 79 additions & 0 deletions
79
boards/weact/bluepillplus_ch32v203/bluepillplus_ch32v203.dts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
/* | ||
* Copyright (c) 2025 MASSDRIVER EI (massdriver.space) | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
/dts-v1/; | ||
|
||
#include <wch/ch32v203/ch32v203c8t.dtsi> | ||
#include <zephyr/dt-bindings/gpio/gpio.h> | ||
#include <zephyr/dt-bindings/input/input-event-codes.h> | ||
#include "bluepillplus_ch32v203-pinctrl.dtsi" | ||
|
||
/ { | ||
model = "bluepillplus_ch32v203"; | ||
compatible = "wch,ch32v203"; | ||
|
||
chosen { | ||
zephyr,sram = &sram0; | ||
zephyr,flash = &flash0; | ||
zephyr,console = &usart3; | ||
zephyr,shell-uart = &usart3; | ||
}; | ||
|
||
leds { | ||
compatible = "gpio-leds"; | ||
status = "okay"; | ||
|
||
blue_led: led0 { | ||
gpios = <&gpiob 2 GPIO_ACTIVE_HIGH>; | ||
}; | ||
}; | ||
|
||
buttons { | ||
compatible = "gpio-keys"; | ||
|
||
mode: sw0 { | ||
gpios = <&gpioa 0 GPIO_ACTIVE_HIGH>; | ||
zephyr,code = <INPUT_KEY_0>; | ||
}; | ||
}; | ||
|
||
aliases { | ||
led0 = &blue_led; | ||
sw0 = &mode; | ||
}; | ||
}; | ||
|
||
&clk_hse { | ||
clock-frequency = <DT_FREQ_M(8)>; | ||
status = "okay"; | ||
}; | ||
|
||
&pll { | ||
clocks = <&clk_hse>; | ||
status = "okay"; | ||
}; | ||
|
||
&rcc { | ||
clocks = <&pll>; | ||
}; | ||
|
||
&gpioa { | ||
status = "okay"; | ||
}; | ||
|
||
&gpiob { | ||
status = "okay"; | ||
}; | ||
|
||
&gpioc { | ||
status = "okay"; | ||
}; | ||
|
||
&usart3 { | ||
status = "okay"; | ||
current-speed = <115200>; | ||
pinctrl-0 = <&usart3_default>; | ||
pinctrl-names = "default"; | ||
}; |
11 changes: 11 additions & 0 deletions
11
boards/weact/bluepillplus_ch32v203/bluepillplus_ch32v203.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
identifier: bluepillplus_ch32v203 | ||
name: WeActStudio Blue Pill Plus CH32V203 | ||
type: mcu | ||
arch: riscv | ||
toolchain: | ||
- cross-compile | ||
- zephyr | ||
ram: 20 | ||
flash: 64 | ||
supported: | ||
- gpio |
8 changes: 8 additions & 0 deletions
8
boards/weact/bluepillplus_ch32v203/bluepillplus_ch32v203_defconfig
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
# Copyright (c) 2025 MASSDRIVER EI | ||
# SPDX-License-Identifier: Apache-2.0 | ||
|
||
CONFIG_GPIO=y | ||
|
||
CONFIG_SERIAL=y | ||
CONFIG_CONSOLE=y | ||
CONFIG_UART_CONSOLE=y |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
# Copyright (c) 2025 MASSDRIVER EI (massdriver.space) | ||
# SPDX-License-Identifier: Apache-2.0 | ||
|
||
board_runner_args(minichlink) | ||
include(${ZEPHYR_BASE}/boards/common/minichlink.board.cmake) | ||
|
||
board_runner_args(openocd "--use-elf" "--cmd-reset-halt" "halt") | ||
include(${ZEPHYR_BASE}/boards/common/openocd.board.cmake) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
board: | ||
name: bluepillplus_ch32v203 | ||
full_name: Blue Pill Plus CH32V203 | ||
vendor: weact | ||
socs: | ||
- name: ch32v203 |
Binary file added
BIN
+94.2 KB
boards/weact/bluepillplus_ch32v203/doc/img/bluepillplus_ch32v203.webp
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
.. zephyr:board:: bluepillplus_ch32v203 | ||
|
||
Overview | ||
******** | ||
|
||
The `WeActStudio`_ Blue Pill Plus CH32V203 hardware provides support for QingKe 32-bit RISC-V4B | ||
processor and the following devices: | ||
|
||
* CLOCK | ||
* :abbr:`GPIO (General Purpose Input Output)` | ||
* :abbr:`NVIC (Nested Vectored Interrupt Controller)` | ||
|
||
The board is equipped with two LEDs and two Buttons. | ||
The `WCH webpage on CH32V203`_ contains the processor's manuals. | ||
The `WeActStudio webpage on BPP`_ contains the Blue Pill's schematic. | ||
|
||
Hardware | ||
******** | ||
|
||
The QingKe 32-bit RISC-V4B processor of the Blue Pill Plus CH32V203 is clocked by an external | ||
8 MHz crystal or the internal 8 MHz oscillator and runs up to 144 MHz. | ||
The CH32V203 SoC Features 2-4 USART, 4 GPIO ports, 1-2 SPI, 0-2 I2C, 9-16 ADC, RTC, | ||
CAN, USB Device, USB Host, OPA, and several timers. | ||
|
||
Supported Features | ||
================== | ||
|
||
.. zephyr:board-supported-hw:: | ||
|
||
Connections and IOs | ||
=================== | ||
|
||
LED | ||
--- | ||
|
||
* LED0 = Blue User LED | ||
|
||
Button | ||
------ | ||
|
||
* SW0 = User Button | ||
|
||
Programming and Debugging | ||
************************* | ||
|
||
Applications for the ``bluepillplus_ch32v203`` board can be built and flashed | ||
in the usual way (see :ref:`build_an_application` and :ref:`application_run` | ||
for more details); however, an external programmer is required since the board | ||
does not have any built-in debug support. | ||
|
||
The following pins of the external programmer must be connected to the | ||
following pins on the PCB: | ||
|
||
* VCC = VCC | ||
* GND = GND | ||
* SWIO = PA13 | ||
* SWCLK = PA14 | ||
|
||
Flashing | ||
======== | ||
|
||
You can use ``minichlink`` to flash the board. Once ``minichlink`` has been set | ||
up, build and flash applications as usual (see :ref:`build_an_application` and | ||
:ref:`application_run` for more details). | ||
|
||
Here is an example for the :zephyr:code-sample:`blinky` application. | ||
|
||
.. zephyr-app-commands:: | ||
:zephyr-app: samples/basic/blinky | ||
:board: bluepillplus_ch32v203 | ||
:goals: build flash | ||
|
||
Debugging | ||
========= | ||
|
||
This board can be debugged via OpenOCD or ``minichlink``. | ||
|
||
References | ||
********** | ||
|
||
.. target-notes:: | ||
|
||
.. _WeActStudio: https://github.com/WeActStudio | ||
.. _WCH webpage on CH32V203: https://www.wch-ic.com/products/CH32V203.html | ||
.. _WeActStudio webpage on BPP: https://github.com/WeActStudio/WeActStudio.BluePill-Plus-CH32 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
# Tested with WCH openOCD liberated fork (https://github.com/jnk0le/openocd-wch) | ||
# Copyright (c) 2024 MASSDRIVER EI (massdriver.space) | ||
# SPDX-License-Identifier: Apache-2.0 | ||
adapter driver wlinke | ||
adapter speed 6000 | ||
transport select sdi | ||
|
||
wlink_set_address 0x00000000 | ||
set _CHIPNAME wch_riscv | ||
sdi newtap $_CHIPNAME cpu -irlen 5 -expected-id 0x00001 | ||
|
||
set _TARGETNAME $_CHIPNAME.cpu | ||
|
||
target create $_TARGETNAME.0 wch_riscv -chain-position $_TARGETNAME | ||
$_TARGETNAME.0 configure -work-area-phys 0x20000000 -work-area-size 10000 -work-area-backup 1 | ||
set _FLASHNAME $_CHIPNAME.flash | ||
|
||
flash bank $_FLASHNAME wch_riscv 0x00000000 0 0 0 $_TARGETNAME.0 | ||
|
||
echo "Ready for Remote Connections" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
# Copyright (c) 2025 MASSDRIVER EI (massdriver.space) | ||
# SPDX-License-Identifier: Apache-2.0 | ||
|
||
description: WCH QingKe V4B RISC-V MCU | ||
|
||
compatible: "wch,qingke-v4b" | ||
|
||
include: riscv,cpus.yaml |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
newline
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done