-
Notifications
You must be signed in to change notification settings - Fork 7.6k
Add support for WCH CH32L103 #89451
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
paulwedeck
wants to merge
3
commits into
zephyrproject-rtos:main
Choose a base branch
from
paulwedeck:wch_ch32l103
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.
Open
Add support for WCH CH32L103 #89451
Changes from 1 commit
Commits
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 Paul Wedeck | ||
# SPDX-License-Identifier: Apache-2.0 | ||
|
||
config BOARD_CH32L103EVT | ||
select SOC_CH32L103 |
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) 2024 Michael Hope | ||
# SPDX-License-Identifier: Apache-2.0 | ||
|
||
board_runner_args(minichlink) | ||
include(${ZEPHYR_BASE}/boards/common/minichlink.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: ch32l103evt | ||
full_name: WCH CH32L103C8T6-R0-1v2 | ||
vendor: wch | ||
socs: | ||
- name: ch32l103 |
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,21 @@ | ||
/* | ||
* Copyright (c) 2024 Michael Hope <michaelh@juju.nz> | ||
* 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 { | ||
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. newline gap between child nodes |
||
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,81 @@ | ||
/* | ||
* Copyright (c) 2024 Michael Hope <michaelh@juju.nz> | ||
* Copyright (c) 2025 Paul Wedeck | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
/dts-v1/; | ||
|
||
#include <wch/ch32l103/ch32l103c8t.dtsi> | ||
#include "ch32l103evt-pinctrl.dtsi" | ||
|
||
#include <zephyr/dt-bindings/gpio/gpio.h> | ||
|
||
/ { | ||
model = "ch32l103evt"; | ||
compatible = "wch,ch32l103"; | ||
|
||
chosen { | ||
zephyr,sram = &sram0; | ||
zephyr,flash = &flash0; | ||
zephyr,console = &usart1; | ||
zephyr,shell-uart = &usart1; | ||
}; | ||
|
||
leds { | ||
compatible = "gpio-leds"; | ||
|
||
/* | ||
* Please connect the unconnected LED on the WCH CH32L103EVT | ||
* board to a suitable GPIO pin (like PA1) and then change | ||
* this status to "okay". | ||
*/ | ||
status = "disabled"; | ||
|
||
red_led: led0 { | ||
gpios = <&gpioa 1 GPIO_ACTIVE_HIGH>; | ||
}; | ||
}; | ||
|
||
aliases { | ||
led0 = &red_led; | ||
}; | ||
}; | ||
|
||
&clk_hse { | ||
clock-frequency = <DT_FREQ_M(8)>; | ||
status = "okay"; | ||
}; | ||
|
||
&pll { | ||
clocks = <&clk_hse>; | ||
mul = <12>; | ||
status = "okay"; | ||
}; | ||
|
||
&rcc { | ||
clocks = <&pll>; | ||
}; | ||
|
||
&gpioa { | ||
status = "okay"; | ||
}; | ||
|
||
&gpiob { | ||
status = "okay"; | ||
}; | ||
|
||
&gpioc { | ||
status = "okay"; | ||
}; | ||
|
||
&gpiod { | ||
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: ch32l103evt | ||
name: WCH CH32L103C8T6-R0-1v2 | ||
type: mcu | ||
arch: riscv | ||
toolchain: | ||
- cross-compile | ||
- zephyr | ||
ram: 64 | ||
flash: 20 | ||
supported: | ||
- gpio | ||
- dma |
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 | ||
|
||
CONFIG_GPIO=y | ||
|
||
CONFIG_SERIAL=y | ||
CONFIG_CONSOLE=y | ||
CONFIG_UART_CONSOLE=y |
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. put through https://tinypng.com/ |
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,88 @@ | ||
.. zephyr:board:: ch32l103evt | ||
|
||
Overview | ||
******** | ||
|
||
The `WCH`_ CH32L103EVT hardware provides support for QingKe 32-bit RISC-V4C | ||
processor and the following devices: | ||
|
||
* CLOCK | ||
* :abbr:`GPIO (General Purpose Input Output)` | ||
* :abbr:`NVIC (Nested Vectored Interrupt Controller)` | ||
* :abbr:`DMA (Direct Memory Access)` | ||
|
||
The board is equipped with two LEDs. | ||
The `WCH webpage on CH32L103`_ contains the processor's manuals. | ||
The `WCH webpage on CH32L103EVT`_ contains the CH32L103EVT's schematic. | ||
|
||
Hardware | ||
******** | ||
|
||
The QingKe 32-bit RISC-V4C processor of the WCH CH32L103EVT is clocked by an external | ||
8 MHz crystal or the internal 8 MHz oscillator and runs up to 96 MHz. | ||
The CH32V208 SoC Features 4 USART, 4 GPIO ports, 2 SPI, 2 I2C, ADC, RTC, | ||
CAN FD, USB 2.0 Host, USB Type-C PD, OPA, and several timers. | ||
|
||
Supported Features | ||
================== | ||
|
||
.. zephyr:board-supported-hw:: | ||
|
||
Connections and IOs | ||
=================== | ||
|
||
LED | ||
--- | ||
|
||
* LED3/LED4 = Unconnected. Connect to an I/O pin (PA1). | ||
|
||
Button | ||
------ | ||
|
||
* S1 = Reset Button | ||
|
||
Programming and Debugging | ||
************************* | ||
|
||
.. zephyr:board-supported-runners:: | ||
|
||
Applications for the ``CH32L103EVT`` 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 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: ch32l103evt | ||
:goals: build flash | ||
|
||
Debugging | ||
========= | ||
|
||
This board can be debugged via ``minichlink``. | ||
|
||
References | ||
********** | ||
|
||
.. target-notes:: | ||
|
||
.. _WCH: http://www.wch-ic.com | ||
.. _WCH webpage on CH32L103: https://www.wch-ic.com/products/CH32L103.html | ||
.. _WCH webpage on CH32L103EVT: https://www.wch.cn/downloads/CH32L103EVT_ZIP.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,15 @@ | ||
#interface wlink | ||
adapter driver wlink | ||
wlink_set | ||
set _CHIPNAME riscv | ||
jtag newtap $_CHIPNAME cpu -irlen 5 -expected-id 0x00001 | ||
|
||
set _TARGETNAME $_CHIPNAME.cpu | ||
|
||
target create $_TARGETNAME.0 riscv -chain-position $_TARGETNAME | ||
$_TARGETNAME.0 configure -work-area-phys 0x80000000 -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" |
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.
I"m fine if you want to rewrite the copyright here.