Author YU Fan
Install CMake and Ninja, as well as GCC and OpenOCD provided by MRS
On Windows
Execute the .exe file to install, then add the installation path to the environment variables.
OpenOCD must be the version provided by MRS to support WCH-Link. At present, WCH has not submitted the function of WCH-Link to the upstream branch of riscv-openocd. I only found the binary files of MRS on the Internet.
On Linux
After decompressing each tool, add the path to the environment variable
export PATH:$PATH=/home/$USER/opt/cmake/bin
export PATH:$PATH=/home/$USER/opt/ninja/bin
export PATH:$PATH=/home/$USER/opt/openocd/bin
export PATH:$PATH=/home/$USER/opt/toolchain/bin
Develop on Chitu board in terminal
Test each tools
Compile the Integrated-Test project
Enter make build APP=Integrated_Test
in the terminal
$ make build APP=Integrated_Test
cmake -E make_directory build.ninja
cd build.ninja && cmake .. -G"Ninja" -DAPP=Integrated_Test
-- TOOLCHAIN_PATH:E:\MounRiver\MounRiver_Studio\toolchain\RISC-V Embedded GCC\bin\riscv-none-embed-gcc.exe
-- The C compiler identification is GNU 8.2.0
-- The CXX compiler identification is GNU 8.2.0
-- The ASM compiler identification is GNU
-- Found assembler: E:/MounRiver/MounRiver_Studio/toolchain/RISC-V Embedded GCC/bin/riscv-none-embed-gcc.exe
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: E:/MounRiver/MounRiver_Studio/toolchain/RISC-V Embedded GCC/bin/riscv-none-embed-gcc.exe - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: E:/MounRiver/MounRiver_Studio/toolchain/RISC-V Embedded GCC/bin/riscv-none-embed-g++.exe - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- [register library component: SRC ], path:C:/Users/salieri/Desktop/opench-ch32v307/firmware/SRC
[run app:Integrated_Test],path:C:/Users/salieri/Desktop/opench-ch32v307/firmware/Integrated_Test
-- Configuring done
-- Generating done
-- Build files have been written to: C:/Users/salieri/Desktop/opench-ch32v307/build.ninja
ninja -C build.ninja -j8
ninja: Entering directory `build.ninja'
[40/40] Linking C executable ..\cmake_output\Integrated_Test\Integrated_Test.elf
text data bss dec hex filename
53440 208 2080 55728 d9b0 C:/Users/salieri/Desktop/opench-ch32v307/cmake_output/Integrated_Test/Integrated_Test.elf
The binary file is output in the path of cmake-output
Download the code to Flash
Type make program APP=Integrated_Test
After waiting a few seconds, programming to flash is complete. Press the reset button on Chitu board to execute the new program.
$ make program APP=Integrated_Test
ninja programtask -C build.ninja -j8
ninja: Entering directory `build.ninja'
[1/1] cmd.exe /C "cd /D C:\Users\salieri\Desktop\opench-ch32v307\build.ninja && openoc...eri/Desktop/opench-ch32v307/cmake_output/Integrated_Test/Integrated_Test.hex" -c exit"
Open On-Chip Debugger 0.10.0+dev-gb0ae840-dirty (2021-06-19-14:16)
Licensed under GNU GPL v2
For bug reports, read
http://openocd.org/doc/doxygen/bugs.html
Info : only one transport option; autoselect 'jtag'
Ready for Remote Connections
Info : WCH-Link version 2.1
Info : wlink_init ok
Info : This adapter doesn't support configurable speed
Info : JTAG tap: riscv.cpu tap/device found: 0x20000001 (mfg: 0x000 (<invalid>), part: 0x0000, ver: 0x2)
Warn : Bypassing JTAG setup events due to errors
Info : datacount=2 progbufsize=8
Info : Examined RISC-V core; found 1 harts
Info : hart 0: XLEN=32, misa=0x40901125
Info : Listening on port 3333 for gdb connections
Info : device id = 0x20000410
erased sectors 0 through 511 on flash bank 0 in 0.140874s
Open On-Chip Debugger 0.10.0+dev-gb0ae840-dirty (2021-06-19-14:16)
Licensed under GNU GPL v2
For bug reports, read
http://openocd.org/doc/doxygen/bugs.html
Info : only one transport option; autoselect 'jtag'
Ready for Remote Connections
Info : WCH-Link version 2.1
Info : wlink_init ok
Info : This adapter doesn't support configurable speed
Info : JTAG tap: riscv.cpu tap/device found: 0x20000001 (mfg: 0x000 (<invalid>), part: 0x0000, ver: 0x2)
Warn : Bypassing JTAG setup events due to errors
Info : datacount=2 progbufsize=8
Info : Examined RISC-V core; found 1 harts
Info : hart 0: XLEN=32, misa=0x40901125
Info : Listening on port 3333 for gdb connections
Info : JTAG tap: riscv.cpu tap/device found: 0x20000001 (mfg: 0x000 (<invalid>), part: 0x0000, ver: 0x2)
Warn : Bypassing JTAG setup events due to errors
** Programming Started **
Info : device id = 0x20000410
** Programming Finished **
Open On-Chip Debugger 0.10.0+dev-gb0ae840-dirty (2021-06-19-14:16)
Licensed under GNU GPL v2
For bug reports, read
http://openocd.org/doc/doxygen/bugs.html
Info : only one transport option; autoselect 'jtag'
Ready for Remote Connections
Info : WCH-Link version 2.1
Info : wlink_init ok
Info : This adapter doesn't support configurable speed
Info : JTAG tap: riscv.cpu tap/device found: 0x20000001 (mfg: 0x000 (<invalid>), part: 0x0000, ver: 0x2)
Warn : Bypassing JTAG setup events due to errors
Info : datacount=2 progbufsize=8
Info : Examined RISC-V core; found 1 harts
Info : hart 0: XLEN=32, misa=0x40901125
Info : Listening on port 3333 for gdb connections
Info : Verify Success
Export Eclipse project
Take the Integrated_Test project as an example, type make build_eclipse APP=Integrated_Test
The project file will output in the path
. Open any Eclipse-based IDE.opench-ch32v307/build.eclipse
Take MRS as an example:
Find
in the menufile --> import --> General --> Existing Projects into Workspace
Afterwards, compile and debug as usual
There is a bug in MRS here. We cannot add the debugging configuration page in a project file imported from outside. So, it is recommended to use the eclipse-cdt from upstream branch.
The boards designed by VeriMake are getting more and more refined!
Appendix
openCH Chitu Board
openCH Chitu Board is an open-source development board. It is powered by a WCH "Chitu" CH32V307 MCU, based on RISC-V ISA. With the help of RT-Thread RTOS, Chitu can be easily applied in industrial control, smart home, portable medical devices, edge connective devices and many other areas. It is also suitable for developers to DIY own creations.
Features
MCU: WCH "Chitu" CH32V307
- single "Qingke" V4 core @ 144MHz, based on RV32IMAFC
- 256KB Flash, 64KB SRAM
- Seperate GPIO voltage
- Advanced Timer (suitable for motors) × 4, General-Purpose Timer × 4, Basic Timer × 2, Watchdog Timer × 2
- 24-bit System Tick Timer
- RTC (Real-Time Clock)
- ADC/TKey Unit × 2 (16 channels), DAC Unit × 2
- Operational amplifier / comparator × 4
- True Random Number Generator (TRNG)
- U(S)ART × 8, SPI × 3, I²C × 2, I²S × 2, CAN × 2, SDIO × 1, FSMC × 1, DVP × 1
- USB (Full-Speed, support OTG), USB (High-Speed)
- Ethernet (1G MAC + 10M PHY)
On-board modules
- USB Type-C socket (support OTG)
- Debugger based on WCH CH549
- LEDs
- Buttons
- 5-way tactile switch
- LCD screen
- Temperature and humidity sensor
- IR & Proximity & Ambient Light Sensor
- MPU6050 (a Motion Processing Unit)
- Condenser microphone
- 3.5mm audio port, MP3 codec, MP3 analog switch
- 16MB SPI Flash
- TF card slot
- 2 × 4 pin support for ESP8266
Description
openCH Chitu Board is an open-sourced development board co-designed by WCH, RT-Thread, and VeriMake.
Chitu is a prized horse in The Romance of the Three Kingdoms. It can travel over mountains and rivers to assist heroes make an arduous journey. Qingke is a Chinese word, means highland barley, which is extremely cold-resistant and has strong vitality. Qingke is the fodder for horses and can empower Chitu to go further. We hope this chip and this board can bring developers with extraordinary experience of horse-like speed and strength.
Chitu Board is powered by a WCH "Chitu" CH32V307 MCU, based on RISC-V ISA. Chitu MCU is a general-purpose MCU integrated with various on-chip peripherals, including ADC, DAC, U(S)ART, SPI, I²C, I²S, CAN, SDIO, FSMC, DVP, USB, Ethernet, etc.
Chitu Board also has plentiful on-board modules, including screen, sensors, microphone, audio port and other interfaces, which make the board supportiver to different kinds of applications.
With the help of RT-Thread RTOS, Chitu can be easily applied in industrial control, smart home, portable medical devices, edge connective devices and many other areas. It is also suitable for developers to DIY own creations.
WCH is an IC design company focusing on connectivity technology and MCU core research. RT-Thread is a leading IoT operating system producer in China. VeriMake is an innovation partner committed to inspire developers by providing open-source reference designs and creative hardware. VeriMake also joins hands with semiconductor companies in building worlwide chip ecosystem.
video: RISC-V openCH Chitu Board Instruction RT-Thread Special
video: RISC-V openCH Chitu Board Abstract
Source:
Chitu CH32V307 Instruction: Development Environment-CMake
openCH
This article is only for information sharing. If there is any infringement, please contact the editor for deletion.