# ch32v305_dap **Repository Path**: xu-jianchao/ch32v305_dap ## Basic Information - **Project Name**: ch32v305_dap - **Description**: No description available - **Primary Language**: Unknown - **License**: Not specified - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 16 - **Created**: 2025-10-22 - **Last Updated**: 2025-10-25 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # ch32v305_dap # 编译方法 - 首先要配置编译器路径, 这里使用的是MounRiver Studio的编译器, 将其加入到环境变量中去 ![alt text](image-6.png) - 然后用cmake+ninja编译 ```c (.venv) Administrator@DESKTOP-0UKCPD3 E:\Share\github\ch32v305_dap # cd build (.venv) Administrator@DESKTOP-0UKCPD3 E:\Share\github\ch32v305_dap\build # cmake .. -G "Ninja" -- The C compiler identification is GNU 8.2.0 -- The ASM compiler identification is GNU -- Found assembler: E:/MounRiver/MounRiver_Studio2/resources/app/resources/win32/components/WCH/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_Studio2/resources/app/resources/win32/components/WCH/Toolchain/RISC-V Embedded GCC/bin/riscv-none-embed-gcc.exe - skipped -- Detecting C compile features -- Detecting C compile features - done -- Minimal optimization, debug info included -- Configuring done (3.0s) -- Generating done (0.1s) -- Build files have been written to: E:/Share/github/ch32v305_dap/build (.venv) Administrator@DESKTOP-0UKCPD3 E:\Share\github\ch32v305_dap\build # cmake --build . [30/46] Building C object CMakeFiles/CH32V305_DAP.elf.dir/CherryDAP/DAP/Source/DAP.c.obj E:/Share/github/ch32v305_dap/CherryDAP/DAP/Source/DAP.c: In function 'DAP_SWJ_Clock': E:/Share/github/ch32v305_dap/CherryDAP/DAP/Source/DAP.c:408:12: warning: unused variable 'delay' [-Wunused-variable] uint32_t delay; ^~~~~ [39/46] Building C object CMakeFiles/CH32V305_DAP.elf.dir/DAPHost/swd_host.c.obj E:/Share/github/ch32v305_dap/DAPHost/swd_host.c:675:16: warning: 'swd_wait_until_halted' defined but not used [-Wunused-function] static uint8_t swd_wait_until_halted(void) ^~~~~~~~~~~~~~~~~~~~~ E:/Share/github/ch32v305_dap/DAPHost/swd_host.c:567:16: warning: 'swd_write_debug_state' defined but not used [-Wunused-function] static uint8_t swd_write_debug_state(DEBUG_STATE *state) ^~~~~~~~~~~~~~~~~~~~~ [43/46] Building C object CMakeFiles/CH32V305_DAP.elf.dir/CherryDAP/dap_main.c.obj E:/Share/github/ch32v305_dap/CherryDAP/dap_main.c: In function 'usbd_cdc_acm_bulk_in': E:/Share/github/ch32v305_dap/CherryDAP/dap_main.c:354:14: warning: unused variable 'buffer' [-Wunused-variable] uint8_t *buffer; ^~~~~~ E:/Share/github/ch32v305_dap/CherryDAP/dap_main.c:353:14: warning: unused variable 'size' [-Wunused-variable] uint32_t size; ^~~~ E:/Share/github/ch32v305_dap/CherryDAP/dap_main.c: At top level: E:/Share/github/ch32v305_dap/CherryDAP/dap_main.c:412:18: warning: initialization discards 'const' qualifier from pointer target type [-Wdiscarded-qualifiers] .compat_id = USBD_WinUSBDescriptorSetDescriptor, ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ E:/Share/github/ch32v305_dap/CherryDAP/dap_main.c:417:15: warning: initialization discards 'const' qualifier from pointer target type [-Wdiscarded-qualifiers] .string = USBD_BinaryObjectStoreDescriptor, ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ [46/46] Linking C executable CH32V305_DAP.elf Memory region Used Size Region Size %age Used FLASH: 81224 B 128 KB 61.97% RAM: 29552 B 32 KB 90.19% text data bss dec hex filename 55192 26032 3520 84744 14b08 E:/Share/github/ch32v305_dap/build/CH32V305_DAP.elf ``` - 输出结果 ![alt text](image.png) - 烧录stm32f103rb的波形 - 注意RST是OD输出(可以看代码), 必须接到target的RST才有波形输出。直接逻辑分析仪抓RST线是没有波形的。 - ![alt text](image-1.png) # 速度对比 ![alt text](image-2.png) ![alt text](image-3.png) ![alt text](image-4.png) - 这与编译优化等级有关系 ![alt text](image-5.png) - 采用cmake .. -G "Ninja" -DCMAKE_BUILD_TYPE=Release编译出来的固件非常小,但是不识别daplink。失败。 - 采用cmake .. -G "Ninja" -DCMAKE_BUILD_TYPE=RelWithDebInfo编译出来的固件,和fanhuacloud提供的基本一样大。速度接近