首页 > 系统相关 >win10安装openocd进行ubuntu远程gdb调试--Apple的学习笔记

win10安装openocd进行ubuntu远程gdb调试--Apple的学习笔记

时间:2023-10-29 12:03:27浏览次数:32  
标签:openocd Loading Apple Src -- section gdb lma size

一,win10版本的openocd+stlink调试环境搭建

1,在官网下载openocd的win10版本解压即可,arm-none-eabi的win10版本解压即可,然后添加到环境变量。

2,stlink连接开发板,且插入stlink。

3,打开一个cmd输入命令,然后可以看到正常识别到stlink,且等待gdb的3333端口。

openocd -f D:\program\OpenOCD-20231002-0.12.0\share\openocd\scripts\interface\stlink.cfg -f D:\program\OpenOCD-20231002-0.12.0\share\openocd\scripts\target\stm32f4x.cfg

4,再在带有elf的路径下,打开一个cmd,作为客户端。

arm-none-eabi-gdb -ex "target remote localhost:3333" led.elf
连接成功后
load led.elf
然后就可以输入gdb常用命令调试了

遇到问题:连接成功后,启动不了,一开始的PC是0x1FFF3da0,非预期。

[stm32f4x.cpu] halted due to debug-request, current mode: Thread
xPSR: 0x01000000 pc: 0x1fff3da0 msp: 0x20001d80

强制设置PC值也没用,后来网上查了其它人操作的命令发现,需要先load elf,命令参考如下。

G:\keil\LED_small_3\Release>arm-none-eabi-gdb -ex "target remote localhost:3333" LED.elf
D:\program\gcc-arm-none-eabi-9-2019-q4-major-win32\bin\arm-none-eabi-gdb.exe: warning: Couldn't determine a path for the index cache directory.
GNU gdb (GNU Tools for Arm Embedded Processors 9-2019-q4-major) 8.3.0.20190709-git
Copyright (C) 2019 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
Type "show copying" and "show warranty" for details.
This GDB was configured as "--host=i686-w64-mingw32 --target=arm-none-eabi".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>.
Find the GDB manual and other documentation resources online at:
    <http://www.gnu.org/software/gdb/documentation/>.

For help, type "help".
Type "apropos word" to search for commands related to "word"...
Reading symbols from LED.elf...
Remote debugging using localhost:3333
0x1fff3834 in ?? ()
(gdb) c
Continuing.

Program received signal SIGINT, Interrupt.
0x1fff36aa in ?? ()
(gdb) load LED.elf
Loading section .isr_vector, size 0x188 lma 0x8000000
Loading section .text, size 0xf1c lma 0x8000188
Loading section .rodata, size 0x10 lma 0x80010a4
Loading section .ARM, size 0x8 lma 0x80010b4
Loading section .init_array, size 0x4 lma 0x80010bc
Loading section .fini_array, size 0x4 lma 0x80010c0
Loading section .data, size 0x54 lma 0x80010c4
Loading section .mysec, size 0x4 lma 0x8001118
Start address 0x8000fc4, load size 4380
Transfer rate: 6 KB/sec, 547 bytes/write.
(gdb) b main
Breakpoint 1 at 0x80005e6: file Src/Core/Src/main.c, line 77.
(gdb) c
Continuing.
Note: automatically using hardware breakpoints for read-only addresses.

Breakpoint 1, main () at Src/Core/Src/main.c:77
77        HAL_Init();
(gdb) c
Continuing.
halted: PC: 0x08000f44

Program received signal SIGINT, Interrupt.
0x08000fba in HAL_Delay (Delay=Delay@entry=500) at Src/Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal.c:402
402       }

仔细想了下,之前没板子单独的app只要file xx.elf就可以了。但是这是有板子的,所以elf需要下载到板子中才可以调试,光gdb还没连接target时候的file命令只能导入symbol表,连接了target后,需要用load命令把代码下载到目标板,才能正常调试,哈哈~

二,启动openocd的远程gdb连接ubuntu

我想在虚拟机直接用vscode的远程gdb调试脚本不通过,连接后断点不会停。命令输入也无效。

于是直接远程命令窗口gdb调试

arm-none-eabi-gdb -ex "target remote 192.168.112.10:3333" led.elf

远程连接不上3333

Type "apropos word" to search for commands related to "word"...
Reading symbols from LED.elf...
192.168.112.10:3333: 连接超时.

网上搜索了下要加-c "bindto 0.0.0.0",原因并不清楚,但是可以解决问题

openocd -f D:\program\OpenOCD-20231002-0.12.0\share\openocd\scripts\interface\stlink.cfg -f D:\program\OpenOCD-20231002-0.12.0\share\openocd\scripts\target\stm32f4x.cfg -c "bindto 0.0.0.0"

于是在ubuntu中可以正常调试了。

Reading symbols from LED.elf...
Remote debugging using 192.168.112.10:3333
0x1fff37b8 in ?? ()
(gdb) load LED.elf
Loading section .isr_vector, size 0x188 lma 0x8000000
Loading section .text, size 0xf1c lma 0x8000188
Loading section .rodata, size 0x10 lma 0x80010a4
Loading section .ARM, size 0x8 lma 0x80010b4
Loading section .init_array, size 0x4 lma 0x80010bc
Loading section .fini_array, size 0x4 lma 0x80010c0
Loading section .data, size 0x54 lma 0x80010c4
Loading section .mysec, size 0x4 lma 0x8001118
Start address 0x8000fc4, load size 4380
Transfer rate: 6 KB/sec, 547 bytes/write.
(gdb) b main
Breakpoint 1 at 0x80005e6: file Src/Core/Src/main.c, line 77.
(gdb) c
Continuing.
Note: automatically using hardware breakpoints for read-only addresses.

Breakpoint 1, main () at Src/Core/Src/main.c:77
77	Src/Core/Src/main.c: 没有那个文件或目录.
(gdb) c
Continuing.
halted: PC: 0x08000f44
^C
Program received signal SIGINT, Interrupt.
0x08000f94 in HAL_GetTick ()
    at Src/Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal.c:325
325	Src/Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal.c: 没有那个文件或目录.

直接用gdb可以调试,但是用ssh连接出来的PC端的vscode中用gdb就无法调试了,那么我考虑ubuntu中安装一个vscode来调试吧!总比gdb调试方便!

我暂时验证环境,所以elf是一个之前本地PC编译的,也不带源码,所以list看不到c代码信息的。

win10安装openocd进行ubuntu远程gdb调试--Apple的学习笔记_ubuntu

三,小结

我为什么愿意花那么多时间在调试环境的建立上,是因为大部分自己写的code基本不用调试,若要快速了解其他人写的code,光看代码怕理解错误,要形成闭环验证,就要靠调试,所以掌握各种调试方法是有必要的。工欲善其事必先利其器,磨刀不误砍柴工。

标签:openocd,Loading,Apple,Src,--,section,gdb,lma,size
From: https://blog.51cto.com/AppleCai/8079048

相关文章

  • go string
    strings.TrimSpace(strstring):去掉字符串首尾空白字符strings.Trim(strstring,cutstring):去掉字符串首尾cut字符strings.TrimLeft(strstring,cutstring):去掉字符串首cut字符strings.TrimRight(strstring,cutstring):去掉字符串首cut字符strings.Field(strstring):返回str......
  • 20.1 OpenSSL 字符BASE64压缩算法
    OpenSSL是一种开源的加密库,提供了一组用于加密和解密数据、验证数字证书以及实现各种安全协议的函数和工具。它可以用于创建和管理公钥和私钥、数字证书和其他安全凭据,还支持SSL/TLS、SSH、S/MIME、PKCS等常见的加密协议和标准。OpenSSL的功能非常强大,可以用于构建安全的网络通......
  • 21.10 Python 使用CRC32校验文件
    CRC文件校验是一种用于验证文件完整性的方法,通过计算文件的CRC值并与预先计算的CRC校验值进行比较,来判断文件是否发生变化,此类功能可以用于验证一个目录中是否有文件发生变化,如果发生变化则我们可以将变化打印输出,该功能可用于实现对特定目录的验证。首先实现文件与目录的遍历功能......
  • sowft
    1.2注解最基本的作用-"扫描器":扫描的意思是循环读取指定的文件夹下面的文件.没有注解需要在文件名上区分,指定哪些文件夹可以加载,哪些文件夹不可以加载.有了注解: a.就可以不用在文件名上区分,用这个第三方库来分析注解,是否符合要求即可. b.有了注解之后,就可以决定......
  • 根据二维表值区域,查找值所对应的左端行标题!
    1职场实例小伙伴们大家好,今天我们来继续讲解Excel在职场中的实例应用:如何根据二维表值区域,查找值所对应的左端行标题?这是公众号粉丝后台留言咨询的一个问题,这个问题具有一定的职场办公代表性,包含我们必须要掌握学习的基础函数以及数组思维,所以小编整理好了解题方案,以备大家不时之需......
  • 20.2 OpenSSL 非对称RSA加解密算法
    RSA算法是一种非对称加密算法,由三位数学家Rivest、Shamir和Adleman共同发明,以他们三人的名字首字母命名。RSA算法的安全性基于大数分解问题,即对于一个非常大的合数,将其分解为两个质数的乘积是非常困难的。RSA算法是一种常用的非对称加密算法,与对称加密算法不同,RSA算法使用一对非对......
  • vue sass
    1.安装:[email protected]注:①.sass-loader依赖于node-sass(1).报错:Modulebuildfailed:TypeError:this.getResolveisnotafunctionatObject.loader(path/node_modules/sass-loader/dist/index.js:52:26)2.注释:①./*......
  • 21.12 Python 实现网站服务器
    Web服务器本质上是一个提供Web服务的应用程序,运行在服务器上,用于处理HTTP请求和响应。它接收来自客户端(通常是浏览器)的HTTP请求,根据请求的URL、参数等信息生成HTTP响应,并将响应返回给客户端,完成客户端的请求。Web服务器可以使用多种编程语言和技术实现,通过对套接字的处理并遵循HTML......
  • GWAS软件包:GAPIT3它来啦
    GAPIT是一款非常老的而且非常流行的软件包,傻瓜式操作,一键出图出结果,一篮子的解决方案,是我最经常使用的GWAS分析软件包。最近,GAPIT现在的版本是GAPIT3,速度比第二版有较大的提升:更大的变化,终于有GAPIT这个软件包了,可以用library载入进去,而且安装方式可以用github安装,更符合R-style。1......
  • ubuntu18.04安装openocd服务器独立进行gdb调试--Apple的学习笔记
    一,前言之前win10的openocd由于没添加loadelf导致无法调试,所以我就在ubuntu中也装了openocd环境,这样就不用依靠win10了。ubntu14.04无法编译openocd,所以换成ubuntu18.04安装openocd。二,ubuntu18.04安装openocd及gdb调试1,下载gitclonegit://git.code.sf.net/p/openocd/codeopenoc......