首页 > 技术文章 > Ubuntu环境下载程序到STM32

xdq101 2019-05-21 11:01 原文

1 JLink方式

传送门:SEGGER官网

图1.0 下载JLink
双击打开下载文件:JLink_Linux_V644i_x86_64.deb

1.3 检验安装

cd /opt/

文件目录

└── SEGGER
    ├── JLink
    ├── JLink_V644i
cd /opt/SEGGER/JLink
./JLinkExe

未连接开发板

图1.2 进入JLink命令行
连接J-Link仿真器即可完成连接. ## 1.5 下载程序 ``` # 启动J-Link ./JLinkExe # 停止运行的程序 h # 选择芯片型号 exec device=STM32F103ZE # 下载程序 loadbin LED.bin 0x8000000 ``` # 2 ST-Link方式 ## 2.1 安装usb依赖 ``` sudo apt-get install libusb-dev sudo apt-get install libusb-1.0-0-dev ``` ## 2.2 添加编译器并初始化 ``` sudo apt-get update sudo apt-get install gcc-arm-none-eabi ``` ## 2.3 下载stlink 传送门:[https://github.com/texane/stlink](https://github.com/texane/stlink) ## 2.4 安装工具 ``` sudo apt-get install autoconf automake libtool sudo apt-get install libgtk-3-dev ``` ## 2.5 编译 ``` cd stlink make release make debug cd build cmake -DCMAKE_BUILD_TYPE=Debug .. make cd build/Release sudo make install ``` ## 2.6 创建节点 ``` sudo udevadm control --reload-rules sudo udevadm trigger ``` ## 2.7 文件部署 将st-flash复制到/usr/bin目录下 ## 2.8 查看st-link版本 ``` st-info --version ``` ``` v1.5.1-28-gd040db5 ``` ## 2.9 查看芯片信息

注意:使用ST-Link连接电路板.
命令行显示

st-util
图2.1 芯片信息

界面显示

stlink-gui
图2.1 ST-Link 界面显示芯片信息

2.10 生成bin文件

看图说话:

图2.2 配置生成bin

其中配置路径为:
编译文件fromelf.exe路径--bin --output 输出bin文件路径 编译生成的axf源文件

/path/core/ARM/ARMCC/bin/fromelf.exe --bin --output ./OBJ/led.bin ./OBJ/led.axf

2.12 下载文件到芯片

sudo st-flash wirte led.bin 0x8000000
图2.3 下载程序

3 查看usb接口

查看usb接口状态

lsusb
图3.1 芯片接口信息

查看接口权限

ll /dev/ttyUSB0
crw-rw---- 1 root dialout 188, 0 5月  21 10:11 /dev/ttyUSB0

查看usb接入状态

dmesg
图3.1 连接成功

4 问题

Problem1

st-info: error while loading shared libraries: libstlink.so.1: cannot open shared object file: No such file or directory

plan

sudo ldconfig

[参考文献]
1 https://blog.csdn.net/lc_cc/article/details/66982821
2 https://blog.csdn.net/weixin_40606111/article/details/84636067
3 http://www.cnblogs.com/zjutlitao/archive/2015/12/22/5065322.html
4 https://blog.csdn.net/a13526758473/article/details/60468652
5 https://github.com/texane/stlink/blob/master/doc/compiling.md
6 http://www.stmcu.org.cn/module/forum/thread-618905-1-1.html
7 https://www.cnblogs.com/alanfeng/p/5659253.html

推荐阅读