Skip to content

Adding SOC WCH ch32v307 and board scdz ch32v307evt #91702

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

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions boards/scdz/ch32v307evt/Kconfig.ch32v307evt
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# Copyright (c) 2025 Thomas Boje
# SPDX-License-Identifier: Apache-2.0

config BOARD_CH32V307EVT
select SOC_CH32V307
8 changes: 8 additions & 0 deletions boards/scdz/ch32v307evt/board.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# Copyright (c) 2024 Michael Hope
# SPDX-License-Identifier: Apache-2.0

board_runner_args(minichlink "--dt-flash=y")
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)
6 changes: 6 additions & 0 deletions boards/scdz/ch32v307evt/board.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
board:
name: ch32v307evt
full_name: SCDZ_CH32V307EVT
vendor: scdz
socs:
- name: ch32v307
22 changes: 22 additions & 0 deletions boards/scdz/ch32v307evt/ch32v307evt-pinctrl.dtsi
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
/*
* Copyright (c) 2025 Thomas Boje
* SPDX-License-Identifier: Apache-2.0
*/

#include <zephyr/dt-bindings/pinctrl/ch32v20x_30x-pinctrl.h>

&pinctrl {
usart1_default: usart1_default {
group1 {
pinmux = <USART1_TX_PA9_0>;
output-high;
drive-push-pull;
slew-rate = "max-speed-10mhz";
};

group2 {
pinmux = <USART1_RX_PA10_0>;
bias-pull-up;
};
};
};
82 changes: 82 additions & 0 deletions boards/scdz/ch32v307evt/ch32v307evt.dts
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
/*
* Copyright (c) 2025 Thomas Boje
* SPDX-License-Identifier: Apache-2.0
*/

/dts-v1/;

#include <wch/ch32v307/ch32v307vc.dtsi>
#include <zephyr/dt-bindings/gpio/gpio.h>
#include <zephyr/dt-bindings/input/input-event-codes.h>
#include "ch32v307evt-pinctrl.dtsi"

/ {
model = "scdz_ch32v307evt";
compatible = "scdz,ch32v307";

chosen {
zephyr,sram = &sram0;
zephyr,flash = &flash0;
zephyr,console = &usart1;
zephyr,shell-uart = &usart1;
};

leds {
compatible = "gpio-leds";

/*
* Please connect the unconnected LED1 on the SCDZ CH32V307EVT
* board to a suitable GPIO pin (like PD1) and then change
* this status to "okay".
*/
status = "disabled";

red_led: led0 {
gpios = <&gpiod 1 GPIO_ACTIVE_LOW>;
};
};
buttons {
compatible = "gpio-keys";

user_button0: sw0 {
label = "User SW0";
gpios = <&gpioa 1 (GPIO_ACTIVE_LOW | GPIO_PULL_UP)>;
zephyr,code = <INPUT_KEY_0>;
};
};

aliases {
led0 = &red_led;
sw0 = &user_button0;
};
};

&clk_hse {
clock-frequency = <DT_FREQ_M(32)>;
status = "okay";
};

&pll {
clocks = <&clk_hse>;
status = "okay";
};

&rcc {
clocks = <&pll>;
};


&gpioa {
status = "okay";
};

&gpioc {
status = "okay";
};

&usart1 {
status = "okay";
current-speed = <115200>;
pinctrl-0 = <&usart1_default>;
pinctrl-names = "default";
};
12 changes: 12 additions & 0 deletions boards/scdz/ch32v307evt/ch32v307evt.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
identifier: scdz_ch32v307evt
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
identifier: scdz_ch32v307evt
identifier: ch32v307evt

this should fix the CI error.

name: SCDZ CH32V307 Evaluation Board
type: mcu
arch: riscv
toolchain:
- cross-compile
- zephyr
ram: 32
flash: 256
supported:
- gpio
- i2c
8 changes: 8 additions & 0 deletions boards/scdz/ch32v307evt/ch32v307evt_defconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# Copyright (c) 2025 Thomas Boje
# SPDX-License-Identifier: Apache-2.0

CONFIG_GPIO=y

CONFIG_SERIAL=y
CONFIG_CONSOLE=y
CONFIG_UART_CONSOLE=y
Binary file added boards/scdz/ch32v307evt/doc/img/ch32v003evt.webp
Binary file not shown.
82 changes: 82 additions & 0 deletions boards/scdz/ch32v307evt/doc/index.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
.. zephyr:board:: ch32v307evt

Overview
********

The `SCDZ`_ CH32V307EVT hardware provides support for QingKe V4F 32-bit RISC-V
processor.

The `WCH webpage on CH32V307`_ contains
the processor's information and the datasheet.

Hardware
********

The QingKe V4F 32-bit RISC-V processor of the SCDZ CH32V307EVT is clocked by an external
32 MHz crystal or the internal 8 MHz oscillator and runs with 127 MHz.
The CH32V307 SoC features 8 USART, 5 GPIO banks, 3 SPI, 2 I2C, 2 ADC, RTC,
2 CAN, USB Host/Device, Ethernet and 4 OPA.

Supported Features
==================
- GPIO
- USART

Connections and IOs
===================

LED
---

* LED1 = Unconnected. Connect to an I/O pin (PD0).
* LED2 = Unconnected. Connect to an I/O pin (PD1).

BUTTON
------

* USER0 = Unconnected. Connect to an I/O pinn (PC0).

.. zephyr:board-supported-hw::

Programming and Debugging
*************************

Applications for the ``ch32v307evt`` board target 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 (like the `WCH LinkE`_) 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 (best way is to use a ribbon cable):

* VCC = VCC (do not power the board from the USB port at the same time)
* GND = GND
* SWIO = PA13

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:`hello_world` application.

.. zephyr-app-commands::
:zephyr-app: samples/hello_world
:board: ch32v307evt
:goals: build flash

Debugging
=========

This board can be debugged via OpenOCD using the WCH openOCD liberated fork, available at https://github.com/jnk0le/openocd-wch.

References
**********

.. target-notes::

.. _WCH: http://www.wch-ic.com
.. _WCH webpage on CH32V307: https://www.wch-ic.com/products/CH32V307.html
.. _WCH LinkE: https://www.wch-ic.com/products/WCH-Link.html
18 changes: 18 additions & 0 deletions boards/scdz/ch32v307evt/support/openocd.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#interface wlink
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"
10 changes: 10 additions & 0 deletions boards/scdz/index.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
.. _boards-scdz:

SCDZ - Shenzhen Qiushi IoT Technology Co., Ltd.
###############################################

.. toctree::
:maxdepth: 1
:glob:

**/*
1 change: 1 addition & 0 deletions dts/bindings/vendor-prefixes.txt
Original file line number Diff line number Diff line change
Expand Up @@ -595,6 +595,7 @@ sandisk Sandisk Corporation
satoz Satoz International Co., Ltd
sbs Smart Battery System
sc Space Cubics, LLC
scdz Shenzhen Qiushi IoT Technology Co., Ltd.
schindler Schindler
sciosense Sciosense B.V.
seagate Seagate Technology PLC
Expand Down
Loading
Loading