【嵌入式小白的学习之路】1.Ubuntu嵌入式开发-环境搭建

第一步、安装GCC
下载GCC 文件https://developer.arm.com/downloads/-/gnu-rm
1. 解压GCC tar -xvjf gcc-arm-none-eabi-10.3-2021.10-x86_64-linux.tar
2. 配置环境变量 sudo gedit /etc/profile
3. 文档末尾输入
export PATH=\$PATH:/home/tianbot/arm_stm32_study/arm/bin export LD_LIBRARY_PATH=\$LD_LIBRARY_PATH:/home/tianbot/arm_stm32_study/arm/lib
1. 应用环境变量 source /etc/profile
2. 查看是否安装成功 arm-none-eabi-gcc -v
第二步、安装openocd
1. 下载xpgk包 https://xpack.github.io/dev-tools/openocd
2. 提取后随便放在哪个路径都行,但是要记得放在哪了
3. 运行bin下的可执行文件openocd,看是否安装成功
(openocd路径)/openocd -v
4. 插入dap-link,看是否能查询到设备
(openocd路径)/openocd -f interface/cmsis-dap.cfg
第三步、安装STM32CubeMX
在ST官网下载安装
生成工程,勾选
Toolchain/IDE设置为makefile
第四步、配置VScode 并编译及运行工程
1. 打开生成的工程
2. 安装扩展Cortex Debug
3.
- 安装gcc的目录位置
"cortex-debug.gdbPath": "/home/tianbot/arm_stm32_study/arm/bin/arm-none-eabi-gdb"
- 安装openocd的目录位置
"cortex-debug.openocdPath.linux": "/usr/bin/openocd"
4.
"configFiles":[
"interface/cmsis-dap.cfg",
"target/stm32f4x.cfg"
]
openocd -f interface/cmsis-dap.cfg -f target/stm32f4x.cfg
可能出现的问题
问题1:
tianbot@ros2go:~/Desktop/LED_TEST$ arm-none-eabi-gdb -v
arm-none-eabi-gdb: error while loading shared libraries: libncurses.so.5: cannot open shared object file: No such file or directory
解决方案1:
sudo apt-get install libncurses5-dev
问题2:
Experiments with a different CMSIS-DAP show that this is probably a permission issue - openocd does not distinguish between the absence of a CMISIS-DAP programmer vs. lack of permission to access one which is present. The usual solution is to create or install an appropriate udev rule and then restart udev or the system and replug the device.
Permission Deny,基本上只出现在linux上,windows是不会有这个的
这个很明显是权限问题。也就是openocd没有权限看到、操作调试器。
解决方法:
打开目录openocd/contrib,linux:/usr/share/openocd/contrib,将dd-openocd.rules拷贝到/etc/udev/rules.d/下。
sudo cp ./60-openocd.rules /etc/udev/rules.d
解释一下,该*.rules文件是一系列设备描述和权限配置的文件。官方已经给配好调试器的权限。只需要把这个文件放进udev的rules.d目录下,令其生效即可。有些时候,需要把调试器重新插上去,按照新规则进行挂载。