← Back to CH32V103-EVT
rtthread on CH32V103-EVT

System Version

Not specified

Status

basic

Last Update

2024-06-21

RT-Thread CH32V103C Test Report

Test Environment

Operating System Information

Hardware Information

  • CH32V103C8T6-EVT-R1
  • 1 x USB to UART Debugger
  • 1 x WCH-Link(E)

Installation Steps

Install PlatformIO Core

You can first check if there is a package like platformio-core available in the package manager. If not, you can use the installation script:

curl -fsSL -o get-platformio.py https://raw.githubusercontent.com/platformio/platformio-core-installer/master/get-platformio.py
python3 get-platformio.py

PlatformIO Environment Configuration

Install the CH32V development environment:

pio pkg install -g -p https://github.com/Community-PIO-CH32V/platform-ch32v.git

Add udev rules and apply (may need to change GROUP depending on the distribution):

curl -fsSL https://raw.githubusercontent.com/platformio/platformio-core/develop/platformio/assets/system/99-platformio-udev.rules | sudo tee /etc/udev/rules.d/99-platformio-udev.rules
cat << EOF | sudo tee -a /etc/udev/rules.d/99-platformio-udev.rules
SUBSYSTEM=="usb", ATTR{idVendor}="1a86", ATTR{idProduct}=="8010", GROUP="plugdev"
SUBSYSTEM=="usb", ATTR{idVendor}="4348", ATTR{idProduct}=="55e0", GROUP="plugdev"
SUBSYSTEM=="usb", ATTR{idVendor}="1a86", ATTR{idProduct}=="8012", GROUP="plugdev"
EOF
sudo udevadm control --reload-rules
sudo udevadm trigger

Add user groups:

  • Debian-based systems:
sudo usermod -a -G dialout $USER
sudo usermod -a -G plugdev $USER
  • Arch-based systems:
sudo usermod -a -G uucp $USER
sudo usermod -a -G lock $USER

Prepare Project Repository

Clone the relevant repositories:

git clone https://github.com/Community-PIO-CH32V/platform-ch32v.git

Code Compilation

Compile the code using pio:

cd platform-ch32v/examples/hello-world-rt-thread
pio run

Flashing Image

Once the WCH-Link(E) is connected to the SWD debug port, flash the image using pio:

pio run --target upload

pio will automatically detect the development board. In case of unsuccessful flashing, you can also try manual specification:

pio run -e your_board --target upload

Adding Development Board Series

If using the C8T6 series, please ignore This is because other chips are not in the default chip list, and we need to add them manually. You can find the corresponding json name for your board in platform-ch32v/boards.

cat << EOF | tee -a platformio.ini
[env:your_board]
board = your_board
EOF

Common Issues

  • Error: error writing to flash at address 0x00000000 at offset 0x00000000
    • This is due to the low firmware version of the WCH-Link. (See important-notices).
    • Please use the WCH-Link Toolchain to connect once to W2 with CH-Link for automatic update. Currently, this tool is only available for Windows
  • Error: Read-Protect Status Currently Enabled
    • This is due to the chip’s write protection being enabled. On Windows, we can use the WCH-Link Toolchain to disable protection, and on Linux, OpenOCD can be used:
cd ~/.platformio/packages/tool-openocd-riscv-wch/bin
./openocd -f wch-riscv.cfg -c init -c halt -c "flash protect wch_riscv 0 last  off " -c exit
cd -

Logging into the System

Logging into the system via serial port.

Expected Results

The system should boot up properly and allow connect via the onboard serial port.

Actual Results

The system should boot up properly and allow connect via the onboard serial port.

Boot Log

Screen recording (from compilation to startup):

asciicast

The MCU shown in the log below is incorrect, as the example hardcodes that string. See main.c#L:65 Based on the Device ID, it indeed running on a target board.

 \ | /
- RT -     Thread Operating System
 / | \     3.1.3 build Apr 25 2024
 2006 - 2019 Copyright by rt-thread team

 MCU: CH32V307
SystemClk:72000000
DeviceID: 0000410f
 www.wch.cn
msh >

Test Criteria

Successful: The actual result matches the expected result.

Failed: The actual result does not match the expected result.

Test Conclusion

Test successful.