【嵌入式小白的學(xué)習(xí)之路】1.Ubuntu嵌入式開發(fā)-環(huán)境搭建

第一步、安裝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. 配置環(huán)境變量 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. 應(yīng)用環(huán)境變量 source /etc/profile?
2. 查看是否安裝成功 arm-none-eabi-gcc -v
第二步、安裝openocd
1. 下載xpgk包?https://xpack.github.io/dev-tools/openocd
2. 提取后隨便放在哪個路徑都行,但是要記得放在哪了
3. 運(yùn)行bin下的可執(zhí)行文件openocd,看是否安裝成功
(openocd路徑)/openocd -v?
4. 插入dap-link,看是否能查詢到設(shè)備?
(openocd路徑)/openocd -f interface/cmsis-dap.cfg
第三步、安裝STM32CubeMX
在ST官網(wǎng)下載安裝
生成工程,勾選
Toolchain/IDE設(shè)置為makefile
第四步、配置VScode 并編譯及運(yùn)行工程
1. 打開生成的工程?
2. 安裝擴(kuò)展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
??
可能出現(xiàn)的問題
問題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,基本上只出現(xiàn)在linux上,windows是不會有這個的
這個很明顯是權(quán)限問題。也就是openocd沒有權(quán)限看到、操作調(diào)試器。
解決方法:
打開目錄openocd/contrib,linux:/usr/share/openocd/contrib,將dd-openocd.rules拷貝到/etc/udev/rules.d/下。
sudo cp ./60-openocd.rules /etc/udev/rules.d
解釋一下,該*.rules文件是一系列設(shè)備描述和權(quán)限配置的文件。官方已經(jīng)給配好調(diào)試器的權(quán)限。只需要把這個文件放進(jìn)udev的rules.d目錄下,令其生效即可。有些時候,需要把調(diào)試器重新插上去,按照新規(guī)則進(jìn)行掛載。
??