-
Notifications
You must be signed in to change notification settings - Fork 7.6k
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
SoftwareArchitekt
wants to merge
2
commits into
zephyrproject-rtos:main
Choose a base branch
from
SoftwareArchitekt:main
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.
+543
−0
Open
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
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
This file contains hidden or 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 Thomas Boje | ||
# SPDX-License-Identifier: Apache-2.0 | ||
|
||
config BOARD_CH32V307EVT | ||
select SOC_CH32V307 |
This file contains hidden or 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) 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) |
This file contains hidden or 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: ch32v307evt | ||
full_name: SCDZ_CH32V307EVT | ||
vendor: scdz | ||
socs: | ||
- name: ch32v307 |
This file contains hidden or 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 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; | ||
}; | ||
}; | ||
}; |
This file contains hidden or 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,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"; | ||
}; |
This file contains hidden or 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,12 @@ | ||||||
identifier: scdz_ch32v307evt | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
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 |
This file contains hidden or 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 Thomas Boje | ||
# SPDX-License-Identifier: Apache-2.0 | ||
|
||
CONFIG_GPIO=y | ||
|
||
CONFIG_SERIAL=y | ||
CONFIG_CONSOLE=y | ||
CONFIG_UART_CONSOLE=y |
Binary file not shown.
This file contains hidden or 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,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 |
This file contains hidden or 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,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" |
This file contains hidden or 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,10 @@ | ||
.. _boards-scdz: | ||
|
||
SCDZ - Shenzhen Qiushi IoT Technology Co., Ltd. | ||
############################################### | ||
|
||
.. toctree:: | ||
:maxdepth: 1 | ||
:glob: | ||
|
||
**/* |
This file contains hidden or 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
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.
Uh oh!
There was an error while loading. Please reload this page.