jlink 发表于 2022-6-11 21:17:54

如何使用STLink在其他飞控硬件上进行调试

本人手中有一块鹏心飞控(飞控硬件资源),硬件配置跟fmuV5差不多.
目前在做FMT移植工作。
bootloader已经做好,可以正常连接QGroundControl,见图1.

现在使用STlink进行下载调试FMT,vscode中的task.json配置如下
"version": "2.0.0",
    "tasks": [
      {
            "label": "echo",
            "type": "shell",
            "command": "echo ${env:USERNAME}"
      },
      {
            "dependsOn":"Build",
            "label": "Build and Download",
            "type": "shell",
            "command": "openocd",
            "args": [
            "-f",
            "interface/stlink-v2.cfg",
            "-f",
            "target/stm32f7x.cfg",
         "-c",
         "program ./target/pixhawk/fmu-v5/build/fmt_fmuv5.elf verify reset exit "
            ],
            "problemMatcher": []
      }
    ]


lauch.json配置如下:
"version": "0.2.0",
    "configurations": [
      {
            "name": "FMUv5 Debug J-Link",
            "type": "cortex-debug",
            "request": "launch",
            "cwd": "${workspaceRoot}",
            "executable": "target/pixhawk/fmu-v5/build/fmt_fmuv5.elf",
            //"serverpath": "${env:JLINK_SERVER}",
            "servertype": "openocd",
            "device": "STM32F765II",
            "interface": "swd",
            "configFiles": [
            "interface/stlink-v2.cfg",
            "target/stm32f7x.cfg"
             ],
            "armToolchainPath": "${env:RTT_EXEC_PATH}",
            "serialNumber": "", //If you have more than one J-Link probe, add the serial number here.
            "svdFile": "target/pixhawk/fmu-v5/STM32F7x5.svd",
            "runToMain": true,
         "preLaunchTask":"Build and Download"
      },


使用的是openocd进行下载,调试。
程序可以正常下载,但是无法调试,终端提示错误如下:
Info : clock speed 2000 kHz
Info : STLINK V2J35S7 (API v2) VID:PID 0483:3748
Info : Target voltage: 4.780826
Info : Cortex-M7 r1p0 processor detected
Info : target has 8 breakpoints, 4 watchpoints
Info : starting gdb server for stm32f7x.cpu on 50000
Info : Listening on port 50000 for gdb connections
Info : accepting 'gdb' connection on tcp/50000
target halted due to debug-request, current mode: Handler HardFault
xPSR: 0x00000003 pc: 00000000 msp: 0x464c4558
Info : device id = 0x10016451
Info : flash size = 2048 kbytes
Info : Single Bank 2048 kiB STM32F76x/77x found
Info : flash size = 1024 bytes
Info : Unable to match requested speed 2000 kHz, using 1800 kHz
Info : Unable to match requested speed 2000 kHz, using 1800 kHz
target halted due to debug-request, current mode: Thread
xPSR: 0x01000000 pc: 0x00010100 msp: 0x464c457c
Info : Unable to match requested speed 2000 kHz, using 1800 kHz
Info : Unable to match requested speed 2000 kHz, using 1800 kHz
target halted due to debug-request, current mode: Thread
xPSR: 0x01000000 pc: 0x00010100 msp: 0x464c457c
Info : Unable to match requested speed 8000 kHz, using 4000 kHz
Info : Unable to match requested speed 8000 kHz, using 4000 kHz
Info : Unable to match requested speed 2000 kHz, using 1800 kHz
Info : Unable to match requested speed 2000 kHz, using 1800 kHz
target halted due to debug-request, current mode: Thread
xPSR: 0x01000000 pc: 0x00010100 msp: 0x464c457c
Info : Unable to match requested speed 2000 kHz, using 1800 kHz
Info : Unable to match requested speed 2000 kHz, using 1800 kHz
target halted due to debug-request, current mode: Thread
xPSR: 0x01000000 pc: 0x00010100 msp: 0x464c457c

指针始终指向

一时不知道如何解决,请大佬帮忙看看



jlink 发表于 2022-6-12 11:10:22

问题已解决,偏移地址问题,
参考文档https://github.com/platformio/platform-ststm32/issues/343
https://community.platformio.org/t/vsc-debug-with-stlink-fails-but-upload-is-successful/26656

在task.json中的"program ./target/pixhawk/fmu-v5/build/fmt_fmuv5.elf verify reset exit "更改为
"program ./target/pixhawk/fmu-v5/build/fmt_fmuv5.elf 0x8000 verify reset exit "
link.lds中App地址是从0x08008000加载的

上古小浣熊 发表于 2022-6-12 11:41:31

没玩过什么STlink不懂

jiangxu 发表于 2022-6-14 09:24:22

老哥知道jlink调试ozone的问题吗

jiangxu 发表于 2022-6-14 09:26:04

jlink 发表于 2022-6-12 11:10
问题已解决,偏移地址问题,
参考文档https://github.com/platformio/platform-ststm32/issues/343
https:/ ...

老哥知道怎么用jlink配合ozone调试飞控吗,看到消息加个好友一起讨论下qq982903071

Balance 发表于 2022-6-15 15:49:49

问题已解决,已经可以用openocd来调试了是吗?
页: [1]
查看完整版本: 如何使用STLink在其他飞控硬件上进行调试