# stm32f103 rt-thread cherryusb daplink **Repository Path**: xu-jianchao/stm32f103-rt-thread-cherryusb-daplink ## Basic Information - **Project Name**: stm32f103 rt-thread cherryusb daplink - **Description**: 基于rt-thread的stm32f103 bsp,添加cherryusb和cherrydap,实现的daplink. 从测试速度看,与官方的daplink速度相当. 不过由于基于rt-thread工程和cherryusb实现的,代码可移植性,实现都非常简洁。 如果换成更高级的平台(带有usb hs, 并且支持Fast-GPIO,速度会更快) - **Primary Language**: Unknown - **License**: Not specified - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 1 - **Forks**: 0 - **Created**: 2025-10-10 - **Last Updated**: 2025-10-13 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # stm32f103 rt-thread cherryusb daplink ### Description 1. 基于rt-thread的stm32f103 bsp,添加cherryusb和cherrydap,实现的daplink. 2. 支持cherrydap, 支持cdc-acm串口, 不支持msc拖拽烧录 3. 从测试速度看,与官方的daplink速度相当. 不过由于基于rt-thread工程和cherryusb实现的,代码可移植性,实现都非常简洁。 4. 如果换成更高级的平台(带有usb hs, 并且支持Fast-GPIO,速度会更快) 5. 板子基于WeAct的stm32f103c8t6 blue pill ### 测试性能 - 一个stm32f103烧录自制的cherryusb daplink - 一个stm32f103烧录官方的daplink - 比一下相互烧录的速度 - cherrydap识别daplink, 烧录stm32f103xb_stm32f103rb_if.hex固件, 速度10kB/s ![alt text](image-31.png) ![alt text](image-32.png) - 官方daplink识别rt-thread.hex cherrydap固件, 速度11kB/s ![alt text](image-33.png) ![alt text](image-34.png) - cherrydap烧录stm32u575, 速度28.2kB/s - 将优化等级提高到ofast, 速度28.5kB/s,提升一点点 ![alt text](image-35.png) ![alt text](image-36.png) - 官方daplink烧录stm32u575, 速度27.74kB/s ![alt text](image-39.png) ![alt text](image-40.png) - 如果rtt cherrydap工程, main函数中while(1)循环插入2ms延时,速度降到11.85kB/s,降低了一半以上。 - 因此, 我们在rtt cherrydap工程中, 调用chry_dap_handle和chry_dap_usb2uart_handle函数, 可以插入延时,但是严重影响烧录速度. 因此建议不要插入延时. ![alt text](image-37.png) ![alt text](image-38.png) ### 因为使用了rt-thread, 借助于设备驱动,对接daplink的usb2uart, 非常容易. - rt_device_write和rt_device_read函数, 就搞定了 - 串口使用uart2, 引脚PA2和PA3 - 将PA2与PA3短接, 回环测试如下, 非常稳定 ![alt text](image.png) ### 注意点 - 用blue pill制作的daplink,SWDIO_IN与SWDIO_OUT引脚(PB13和PB14, 2个相邻引脚), 需要焊接一个电阻(我焊接的是300欧姆, 官方推荐是100欧姆) - 注意, 为了解决daplink识别问题, 需要nRESET接板子的nRESET引脚 - 有时候, 需要让板子进入bootloader模式, 才能识别器件或稳定烧录 - 解决了识别后, 有时出现烧录不稳定, 或出错现象. 用5V电源给stm32u575供电, 大大改善 - 以上都是可以尝试 ### 可能存在, 在其它电脑上git clone后编译会报错 ```c $ scons -j4 scons: Reading SConscript files ... Newlib version: 4.1.0 scons: done reading SConscript files. scons: Building targets ... scons: building associated VariantDir targets: build CC build\applications\DAP\Source\DAP.o CC build\applications\DAP\Source\DAP_vendor.o CC build\applications\DAP\Source\JTAG_DP.o CC build\applications\DAP\Source\SWO.o In file included from applications\Project/DAP_config.h:25 , from applications\Project/DAP_config.h:25applications\DAP\Source\JTAG_DP.c:28 from : applications\Project/IO_Config.h:25:10: applications\Project/IO_Config.h:25:10:fatal error: stm32f1xx.h: No such file or directory 25 | #include fatal error: "stm32f1xx.h" 25 | #include | ^~~~~~~~~~~~~ | ^~~~~~~~~~~~~co mcpoimlaptiiloant itoernm itneartmed. inated. In file included from applications\Project/DAP_config.h:25, from applications\DAP\Source\SWO.c:28: applications\Project/IO_Config.h:25:10: fatal error: stm32f1xx.h: No such file or directory 25 | #include "stm32f1xx.h" | ^~~~~~~~~~~~~ mpscons: *** [build\applications\DAP\Source\DAP_vendor.o] Error 1 ilation terminated. In file included from applications\Project/DAP_config.h:25, from applications\DAP\Source\DAP.c:29: applications\Project/IO_Config.h:25:10: fatal error: stm32f1xx.h: No such file or directory 25 | #include "stm32f1xx.h" | ^~~~~~~~~~~~~ compilation terminated. scons: *** [build\applications\DAP\Source\SWO.o] Error 1 scons: *** [build\applications\DAP\Source\DAP.o] Error 1 scons: building terminated because of errors. ``` ### 原因是, rtconfig.h文件中丢失了如下内容,加进去即可 ```c #define PKG_USING_STM32F1_HAL_DRIVER #define PKG_USING_STM32F1_HAL_DRIVER_LATEST_VERSION #define PKG_USING_STM32F1_CMSIS_DRIVER #define PKG_USING_STM32F1_CMSIS_DRIVER_LATEST_VERSION ```