操作系统:Ubuntu20.04
烧录软件:STM32CubeProgrammer v2.13.0
下载器: 1. ST-LINK/V2 2. 串口线(CH340)
芯片:STM32F103C8T6
插上ST-LINK/V2 和串口线后在终端输入命令:
lsusb
从第四行和第六行可以看到,系统已经识别到串口(340)和ST-LINK/V2 设备,否则需先安装驱动。
串口烧录:
选择UART方式,点击刷新图标(蓝圈圈)显示ttyUSB0(不同电脑不一定相同),说明识别到串口驱动。选择Connect后报错:
Error: Cannot open port ttyUSB0, it may be used by another application or port name is invalid.
解决方法:在终端中修改权限
sudo chmod 777 /dev/ttyUSB0
再次Connect仍然报错:
Error: Activating device: KO. Please, verify the boot mode configuration and check the serial port configuration. Reset your device then try again...
解决方法:将电路板Boot0连接到高电平并复位后再连接。
ST-LINK烧录:
选择ST-LINK方式,点击刷新图标(蓝圈圈),可能会显示没有设备并报错,同时无法连接设备:
ST-LINK error (DEV_CONNECT_ERR)
Error:Problem occured while trying to connect
解决方法:在终端中修改权限
sudo chmod 666 /dev/bus/usb/xxx/yyy
其中xxx对应lsusb输出信息中的bus序号,yyy对应device序号。