Skip to content

[bsp][ch32v203] add CH32V203C8T6-EVT-R0 support - #11827

Merged
Rbb666 merged 4 commits into
RT-Thread:masterfrom
cms19859230182-lang:bsp/ch32v203c-evt-r0
Sep 24, 2026
Merged

Rbb666 merged 4 commits into
RT-Thread:masterfrom
cms19859230182-lang:bsp/ch32v203c-evt-r0

Conversation

@cms19859230182-lang

Copy link
Copy Markdown
Contributor

拉取/合并请求描述:(PR description)

[

为什么提交这份PR (why to submit this PR)

CH32V203C8T6-EVT-R0 has no BSP in the mainline tree. The part is QingKe V4B, CH32V20x_D6, with 64KB zero-wait Flash and 20KB SRAM. The published CH32V20x SDK package only ships D8W startup and calls Exit() for D6, so a stock package build cannot produce a firmware for this board.

你的解决方案是什么 (what is your solution)

Add bsp/wch/risc-v/ch32v203c-evt-r0. It uses the in-tree ch32_drivers, a D6 vector table whose software-interrupt symbol is SW_handler, and a 64KB/20KB linker script. SConstruct patches only packages/CH32V20x-SDK-for-RTT/SConscript, and only while that file still Exit()s on D6, so D8W packages are left alone.

The default image enables GPIO and UART1 (USART1 on PA9/PA10). PWM, ADC, RTC, the independent watchdog, and USB device stay in menuconfig. 64KB cannot hold USB together with those four peripherals.

Two shared driver fixes are included because this board needs them:

  • drv_usbd.c: USBFS DMA keeps a 16-bit SRAM offset, endpoint buffers must live in SRAM, and SET_ADDRESS is written after the status IN. Full-speed packet size is 64 bytes.
  • drv_iwdt.c: CH32V2 includes ch32v20x_iwdg.h. CH32V3 still includes ch32v30x_iwdg.h.

Verified on CH32V203C8T6-EVT-R0 with WCH RISC-V GCC 8.2.0:

  • Default image: GPIO + UART1, Flash 44480 bytes (67.87%), msh on USART1.
  • PWM on PA8: register readback 1 kHz, 50% duty. No oscilloscope capture.
  • ADC1 channel 17 stayed at 0x5C9; channel 16 settled at 0x6C4. PA0 read 0xFFF on 3.3V and 0x4/0x5 on GND.
  • RTC on LSE advanced across a few seconds. The independent watchdog reset the chip after feeding stopped.
  • USB device on Type-C P7 (PA11/PA12), VID 0FFE PID 0001. With PWM/ADC/RTC/watchdog off, the host COM port answered help and version (RT-Thread 5.3.1). That image was 64780 bytes (98.85%).

Notes: https://notes.seteiro.xyz/posts/ch32v203-msh/

请提供验证的bsp和config (provide the config and bsp)

  • BSP: bsp/wch/risc-v/ch32v203c-evt-r0

  • .config: default is CONFIG_BSP_USING_GPIO, CONFIG_BSP_USING_UART, CONFIG_BSP_USING_UART1. PWM, ADC, RTC, IWDT, and USBD are off in the default image. Enable CONFIG_BSP_USING_USBD only with those four off, and set CONFIG_RT_USBD_THREAD_STACK_SZ=1024.

  • action:

]

当前拉取/合并请求的状态 Intent for your PR

必须选择一项 Choose one (Mandatory):

  • 本拉取/合并请求是一个草稿版本 This PR is for a code-review and is intended to get feedback
  • 本拉取/合并请求是一个成熟版本 This PR is mature, and ready to be integrated into the repo

代码质量 Code Quality:

我在这个拉取/合并请求中已经考虑了 As part of this pull request, I've considered the following:

  • 已经仔细查看过代码改动的对比 Already check the difference between PR and old code
  • 代码风格正确,包括缩进空格,命名及其他风格 Style guide is adhered to, including spacing, naming and other styles
  • 没有垃圾代码,代码尽量精简,不包含#if 0代码,不包含已经被注释了的代码 All redundant code is removed and cleaned up
  • 所有变更均有原因及合理的,并且不会影响到其他软件组件代码或BSP All modifications are justified and not affect other components or BSP
  • 对难懂代码均提供对应的注释 I've commented appropriately where code is tricky
  • 代码是高质量的 Code in this PR is of high quality
  • 已经使用clang-format 源码格式化工具确保格式符合RT-Thread代码规范 This PR has been formatted with clang-format and complies with RT-Thread code specification
  • 如果是新增bsp, 已经添加ci检查到.github/ALL_BSP_COMPILE.json 详细请参考链接BSP自查

The EVT-R0 board is a QingKe V4B D6 part: 64KB zero-wait Flash and 20KB SRAM. The CH32V20x SDK package ships D8W startup and exits on D6, so this BSP adds a D6 vector table and keeps that package building.

Default config enables GPIO and UART1 so the image fits with room to spare. PWM, ADC, RTC, the independent watchdog, and USB device were checked on the board as separate menuconfig sets. USB CDC on the Type-C port answered help and version.

The shared USBFS device driver keeps endpoint buffers in SRAM and writes the device address after the status IN. CH32V2 watchdog code includes the V2 header.
@github-actions github-actions Bot added BSP action github action yml imporve tools BSP: WCH BSP related with WCH labels Sep 22, 2026
@github-actions

Copy link
Copy Markdown

👋 感谢您对 RT-Thread 的贡献!Thank you for your contribution to RT-Thread!

为确保代码符合 RT-Thread 的编码规范,请在你的仓库中执行以下步骤运行代码格式化工作流(如果格式化CI运行失败)。
To ensure your code complies with RT-Thread's coding style, please run the code formatting workflow by following the steps below (If the formatting of CI fails to run).


🛠 操作步骤 | Steps

  1. 前往 Actions 页面 | Go to the Actions page
    点击进入工作流 → | Click to open workflow →

  2. 点击 Run workflow | Click Run workflow

  • Use workflow from 保持默认分支(通常为 master
    Keep the default branch (usually master) in Use workflow from
  • branch 输入框填写 PR 分支 bsp/ch32v203c-evt-r0
    Enter PR branch bsp/ch32v203c-evt-r0 in the branch field
  • 设置需排除的文件/目录(目录请以"/"结尾)
    Set files/directories to exclude (directories should end with "/")
  1. 等待工作流完成 | Wait for the workflow to complete
    格式化后的代码将作为独立提交推送至你的分支。
    The formatting changes will be pushed to your branch as a separate commit.

完成后,提交将自动更新至 bsp/ch32v203c-evt-r0 分支,关联的 Pull Request 也会同步更新。
Once completed, commits will be pushed to the bsp/ch32v203c-evt-r0 branch automatically, and the related Pull Request will be updated.

如有问题欢迎联系我们,再次感谢您的贡献!💐
If you have any questions, feel free to reach out. Thanks again for your contribution!

@github-actions

github-actions Bot commented Sep 22, 2026

Copy link
Copy Markdown

📌 Code Review Assignment

🏷️ Tag: bsp_wch

Reviewers: @Maihuanyi

Changed Files (Click to expand)
  • bsp/wch/risc-v/ch32v203c-evt-r0/.ci/attachconfig/ci.attachconfig.yml
  • bsp/wch/risc-v/ch32v203c-evt-r0/.config
  • bsp/wch/risc-v/ch32v203c-evt-r0/Kconfig
  • bsp/wch/risc-v/ch32v203c-evt-r0/README.md
  • bsp/wch/risc-v/ch32v203c-evt-r0/SConscript
  • bsp/wch/risc-v/ch32v203c-evt-r0/SConstruct
  • bsp/wch/risc-v/ch32v203c-evt-r0/applications/SConscript
  • bsp/wch/risc-v/ch32v203c-evt-r0/applications/main.c
  • bsp/wch/risc-v/ch32v203c-evt-r0/applications/utest/SConscript
  • bsp/wch/risc-v/ch32v203c-evt-r0/applications/utest/test_wdt.c
  • bsp/wch/risc-v/ch32v203c-evt-r0/board/Kconfig
  • bsp/wch/risc-v/ch32v203c-evt-r0/board/SConscript
  • bsp/wch/risc-v/ch32v203c-evt-r0/board/board.c
  • bsp/wch/risc-v/ch32v203c-evt-r0/board/board.h
  • bsp/wch/risc-v/ch32v203c-evt-r0/board/linker_scripts/link.lds
  • bsp/wch/risc-v/ch32v203c-evt-r0/board/software_irq.c
  • bsp/wch/risc-v/ch32v203c-evt-r0/board/startup_ch32v20x_D6.S
  • bsp/wch/risc-v/ch32v203c-evt-r0/rtconfig.h
  • bsp/wch/risc-v/ch32v203c-evt-r0/rtconfig.py
  • bsp/wch/risc-v/libraries/ch32_drivers/drv_iwdt.c
  • bsp/wch/risc-v/libraries/ch32_drivers/drv_usbd.c

🏷️ Tag: workflow

Reviewers: @Rbb666 @kurisaW @supperthomas

Changed Files (Click to expand)
  • .github/ALL_BSP_COMPILE.json
  • .github/workflows/manual_trigger_scons_except_STM32_all.yml

📊 Current Review Status (Last Updated: 2026-09-24 15:08 CST)


📝 Review Instructions

  1. 维护者可以通过单击此处来刷新审查状态: 🔄 刷新状态
    Maintainers can refresh the review status by clicking here: 🔄 Refresh Status

  2. 确认审核通过后评论 LGTM/lgtm
    Comment LGTM/lgtm after confirming approval

  3. PR合并前需至少一位维护者确认
    PR must be confirmed by at least one maintainer before merging

ℹ️ 刷新CI状态操作需要具备仓库写入权限。
ℹ️ Refresh CI status operation requires repository Write permission.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Copilot review overview

🟡 Changes recommended

The Kconfig exposes unsupported peripherals and invalid pins, while the watchdog command accepts unsafe timeout input.

Get a fresh assessment by requesting another Copilot review.

Review effort: Balanced
Findings: 4 High severity · 2 Medium severity · 3 Low severity

Open (9)
What changed in this PR

Adds CH32V203C8T6-EVT-R0 BSP support, including startup, memory layout, drivers, documentation, and CI integration. / 新增 CH32V203C8T6-EVT-R0 BSP,包括启动、内存布局、驱动、文档和 CI 支持。

Changes:

  • Adds the complete CH32V203C8T6 board configuration and startup path. / 添加完整的板级配置与启动流程。
  • Updates shared USB-device and watchdog drivers. / 更新共享 USB 设备和看门狗驱动。
  • Registers the BSP in documentation and CI matrices. / 将 BSP 加入文档和 CI 矩阵。
File Description
tools/​ci/​toolchain_bsp.yml Adds BSP toolchain mapping.
tools/​ci/​bsp_detail.yml Adds BSP validation metadata.
bsp/​wch/​risc-v/​libraries/​ch32_drivers/​drv_usbd.c Revises USBFS endpoint and DMA handling.
bsp/​wch/​risc-v/​libraries/​ch32_drivers/​drv_iwdt.c Selects family-specific watchdog headers.
bsp/​wch/​risc-v/​ch32v203c-evt-r0/​SConstruct Defines BSP build and SDK workaround.
bsp/​wch/​risc-v/​ch32v203c-evt-r0/​SConscript Collects BSP build groups.
bsp/​wch/​risc-v/​ch32v203c-evt-r0/​rtconfig.py Configures the RISC-V toolchain and linker.
bsp/​wch/​risc-v/​ch32v203c-evt-r0/​rtconfig.h Adds generated default configuration.
bsp/​wch/​risc-v/​ch32v203c-evt-r0/​README.md Documents setup, hardware, and testing.
bsp/​wch/​risc-v/​ch32v203c-evt-r0/​Kconfig Connects BSP and package configuration.
bsp/​wch/​risc-v/​ch32v203c-evt-r0/​board/​startup_ch32v20x_D6.S Adds D6 startup and vector table.
bsp/​wch/​risc-v/​ch32v203c-evt-r0/​board/​software_irq.c Implements software-interrupt support.
bsp/​wch/​risc-v/​ch32v203c-evt-r0/​board/​SConscript Builds board sources.
bsp/​wch/​risc-v/​ch32v203c-evt-r0/​board/​linker_scripts/​link.lds Defines 64-KB Flash and 20-KB RAM layout.
bsp/​wch/​risc-v/​ch32v203c-evt-r0/​board/​Kconfig Exposes board peripheral options.
bsp/​wch/​risc-v/​ch32v203c-evt-r0/​board/​board.h Defines board memory and USB mappings.
bsp/​wch/​risc-v/​ch32v203c-evt-r0/​board/​board.c Initializes board, USB, ADC, and SysTick.
bsp/​wch/​risc-v/​ch32v203c-evt-r0/​applications/​wdt_msh.c Adds watchdog shell commands.
bsp/​wch/​risc-v/​ch32v203c-evt-r0/​applications/​SConscript Builds application sources.
bsp/​wch/​risc-v/​ch32v203c-evt-r0/​applications/​main.c Adds the BSP application entry point.
bsp/​wch/​risc-v/​ch32v203c-evt-r0/​.config Defines the default BSP configuration.
bsp/​wch/​risc-v/​ch32v203c-evt-r0/​.ci/​attachconfig/​ci.attachconfig.yml Adds GPIO and UART CI configurations.
bsp/​README.md Lists supported board peripherals.
.github/​workflows/​manual_trigger_scons_except_STM32_all.yml Adds the BSP to manual CI.
.github/​ALL_BSP_COMPILE.json Adds the BSP to compilation coverage.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment on lines +67 to +79
menuconfig BSP_USING_DAC
bool "Enable DAC"
select RT_USING_DAC
default n

if BSP_USING_DAC
config BSP_USING_DAC_CHANNEL1
bool "Enable DAC CHANNEL1"
default n
config BSP_USING_DAC_CHANNEL2
bool "Enable DAC CHANNEL2"
default n
endif
Comment on lines +126 to +134
config BSP_USING_SPI3
bool "Enable SPI3"
default n

if BSP_USING_SPI3
config BSP_USING_SPI_FLASH
bool "Enable SPI Flash"
default n
endif
Comment on lines +259 to +261
config BSP_USING_CAN2
bool "Using CAN2"
default n
Comment on lines +423 to +425
config BSP_USING_TIM5
bool "Using TIM5"
default n
rt_kprintf("wdt start <seconds>\n");
return -RT_ERROR;
}
timeout = atoi(argv[2]);
Comment on lines +153 to +168
menuconfig BSP_USING_SOFT_SPI2
bool "Enable software SPI2 Bus (swspi2)"
default n
select RT_USING_SOFT_SPI
select RT_USING_SOFT_SPI2
if BSP_USING_SOFT_SPI2
config RT_SOFT_SPI2_SCK_PIN
int "swspi2 SCK pin number"
default 64
config RT_SOFT_SPI2_MISO_PIN
int "swspi2 MISO pin number"
default 66
config RT_SOFT_SPI2_MOSI_PIN
int "swspi2 MOSI pin number"
default 65
endif

1. 安装 [WCH RISC-V GCC](https://github.com/NanjingQinheng/sdk-toolchain-RISC-V-GCC-WCH) 与 [Env](https://github.com/RT-Thread/env-windows/releases)
2. 进入本目录,设置 `RTT_EXEC_PATH` 为工具链 `bin`
3. `pkgs --update` 拉取 `CH32V20x_SDK`(或按 `package.json` clone `kaidegit/CH32V20x-SDK-for-RTT` 到 `packages/`)
try:
from building import *
except:
print('Cannot found RT-Thread root directory, please check RTT_ROOT')
Comment on lines +62 to +64
config ADC_CHANNEL_17
bool "Enable ADC CHANNEL 17 (inside Verf)"
default n
CH32V203C8 is D6, so the menu no longer offers DAC, SPI3, CAN2, or TIM5-TIM10. Software SPI2 was pointing at GPIOE pins this package does not have. The watchdog command now rejects a timeout that is not a whole number of seconds inside the counter range.

## 1 开发板简介

CH32V203C8T6-EVT-R0 是 WCH 沁恒的 RISC-V 评估板。芯片是 QingKe **V4B(CH32V20x_D6)**,手册零等待 Flash **64KB**、SRAM **20KB**。LinkUtility 读到的 224KB 是 V203 系列总 CodeFlash,**不要**写进链接脚本。

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

麻烦参考一下其他BSP的readme,这整个文章ai味道太重了

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

行,我一会改改

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

ok啦,你看看~

Match the CH32V307 Chinese readme outline and drop the measured peripheral logs.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

这部分测试代码推荐以这种方式加入,对接到utest中,参考 bsp/k230/drivers/utest

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

好的好的,我看看。

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

嘶,有点复杂,可能得明天才能做完了,今天寝室要断电了

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

刚刚发得太草率了,我上板测一遍再说

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

有测试好嘛?没问题我这边就合并了

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

测好力,我测完才发的

Replace the msh start/feed command with a utest case. The case stays out of
the default image unless IWDT and the test switch are both on. This independent
watchdog cannot be stopped after start, so the no-feed half is expected to reset.
The link script keeps the utest case table.

Signed-off-by: seteiro <276597748+cms19859230182-lang@users.noreply.github.com>
@Rbb666
Rbb666 merged commit 386b877 into RT-Thread:master Sep 24, 2026
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

action github action yml imporve BSP: WCH BSP related with WCH BSP tools

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants