在Arduino环境中使用STM32F103 Blue Pill 的USB虚拟串口升级固件
亮点
- 使用超低价格BluePill板(进口STM32F103C8 6 RMB,1.5邮费,@2025/5/21),借助Arduino生态,大幅缩短 小项目 的开发周期
- 无需使用烧录器就可以通过USB烧录(上传)固件(仅第一次需要烧录bootloader)
- USB本身支持默认高速虚拟串口,可以与电脑端上位机通讯,无需其他USB转串口硬件支持
目前仅用于Windows上的配置,其他平台暂未探索
感谢!!!roger clark
1. 安装Arduino并安装开发板(STM32F1 Boards & STM32F4 Boards)
安装Arduino环境, 版本1.8.xx, 注意:不是Arduino IDE
下载Arduino_STM32 开发板并Arduino_STM32xxx文件夹解压到Arduino安装路径下:C:\Program Files (x86)\Arduino\hardware
安装驱动(Maple DFU driver & Maple Serial driver),运行路径C:\Program Files (x86)\Arduino\hardware\Arduino_STM32\drivers\win下的install_drivers.bat,
安装成功提示:(请勿连接硬件,否则信息会有区别)
点击查看
Installing Maple DFU driver...
Extracting driver files...
Success
Installing driver(s)...
Success
Installing Maple Serial driver...
Extracting driver files...
Success
Installing driver(s)...
Success
请按任意键继续. . .
2. 下载并烧录bootloader(仅第一次需要配置)
在STM32duino-bootloader 下载 -> binaries/generic_boot20_pc13.bin
使用ST-Link 或 J-Link 或 OpenOCD 或 CMSIS-DAP 等调试器烧录 generic_boot20_pc13.bin 到板卡
烧录bootloader后,初次将硬件连接电脑并打开设备管理器,可看到 libusb-win32 devices -> Maple DFU 设备,此时硬件板卡状态还处于USB DFU设备类状态。
3. Get_Start Demo测试
打开Arduino环境,执行以下几个步骤
选择 “工具 -> 开发板:“xxxx” -> Generic STM32F103C series”
选择 “工具 -> Variant:“xxxx” -> STM32F103C8(20k RAM, 64k Flash)”
选择 “工具 -> Upload method:“xxxx” -> STM32duino bootloader”
选择 “工具 -> CPU Speed(MHz):“xxxx” -> 48Mhz(Slow - with USB)”
选择 “工具 -> Optimize:“xxxx” -> Smallest (default)”
test.ino
void setup() {
pinMode(PC13, OUTPUT);
Serial.begin(115200); // Ignored by Maple. But needed by boards using hardware serial via a USB to Serial adaptor
Serial.println("setup");
}
void loop() {
digitalWrite(PC13, HIGH);// turn the LED on (HIGH is the voltage level)
delay(100); // wait for a second
digitalWrite(PC13, LOW); // turn the LED off by making the voltage LOW
delay(100); // wait for a second
Serial.println("Hello world! This is the debug channel.");
}
编译器链接:C:\Users\Ez\AppData\Local\Arduino15\packages\arduino\hardware\sam\1.6.12\system\CMSIS\Examples\cmsis_example\gcc_arm
编译并上传,显示上传成功并反馈:
点击查看
项目使用了 15712 字节,占用了 (23%) 程序存储空间。最大为 65536 字节。
全局变量使用了3128字节,(15%)的动态内存,余留17352字节局部变量。最大为20480字节。
maple_loader v0.1
Resetting to bootloader via DTR pulse
Reset via USB Serial Failed! Did you select the right serial port?
Searching for DFU device [1EAF:0003]...
Assuming the board is in perpetual bootloader mode and continuing to attempt dfu programming...
Found it!
Opening USB Device 0x1eaf:0x0003...
Found Runtime: [0x1eaf:0x0003] devnum=1, cfg=0, intf=0, alt=2, name="STM32duino bootloader v1.0 Upload to Flash 0x8002000"
Setting Configuration 1...
Claiming USB DFU Interface...
Setting Alternate Setting ...
Determining device status: state = dfuIDLE, status = 0
dfuIDLE, continuing
Transfer Size = 0x0400
bytes_per_hash=314
Starting download: [##################################################] finished!
state(8) = dfuMANIFEST-WAIT-RESET, status(0) = No error condition is present
error resetting after download: usb_reset: could not reset device, win error: ָ�������ڵ��豸��
Done!
Resetting USB to switch back to runtime mode
首次使用Arduino环境,执行以上步骤后: 设备管理器 端口(COM和LPT) -> Maple Serial (COMx)
4. 异常处理
- 上传失败后提示:
...
上传项目出错
Resetting to bootloader via DTR pulse
Reset via USB Serial Failed! Did you select the right serial port?
Searching for DFU device [1EAF:0003]...
Assuming the board is in perpetual bootloader mode and continuing to attempt dfu programming...
dfu-util - (C) 2007-2008 by OpenMoko Inc.
Couldn't find the DFU device: [1EAF:0003]
This program is Free Software and has ABSOLUTELY NO WARRANTY
出现此问题时,需要在报出错误前手动按一下STM32 Blue Pill复位按键
- 编译时候如果出现
exec: "/bin/arm-none-eabi-g++": file does not exist
Error compiling for board Generic STM32F103C series.
需要安装ARM Cortex-M3的编译器:
工具 -> Board -> Board Manager... 中搜索 Cortex,直接安装 Arduino SAM Boards(32bit ARM Cortex-M3)


浙公网安备 33010602011771号