I'm on windows 10 trying to debug my bluepill (STM32f103C8) board using a stlink, openocd, and vscode. I get this pop up: "OpenOCD GDB Server Quit Unexpectedly. See gdb-server output for more details."
And this message in the terminal:
Open On-Chip Debugger 0.11.0 (2021-11-18) [https://github.com/sysprogs/openocd]
Licensed under GNU GPL v2
libusb1 09e75e98b4d9ea7909e8837b7a3f00dda4589dc3
For bug reports, read
http://openocd.org/doc/doxygen/bugs.html
CDRTOSConfigure
Info : auto-selecting first available session transport "hla_swd". To override use 'transport select <transport>'.
Info : The selected transport took over low-level target control. The results might differ compared to plain JTAG/SWD
Info : DEPRECATED target event trace-config; use TPIU events {pre,post}-{enable,disable}
Info : Listening on port 50001 for tcl connections
Info : Listening on port 50002 for telnet connections
Info : clock speed 1000 kHz
Info : STLINK V2J36S7 (API v2) VID:PID 0483:3748
Info : Target voltage: 3.186911
Info : stm32f1x.cpu: Cortex-M3 r1p1 processor detected
Info : stm32f1x.cpu: target has 6 breakpoints, 4 watchpoints
Info : starting gdb server for stm32f1x.cpu on 50000
Info : Listening on port 50000 for gdb connections
[2022-06-07T02:43:25.028Z] SERVER CONSOLE DEBUG: onBackendConnect: gdb-server session closed
GDB server session ended. This terminal will be reused, waiting for next session to start...
My launch.json is as follows:
"version": "0.2.0",
"configurations":
[
{
"name": "GDB",
"cwd": "${workspaceFolder}",
"executable": "./Test/Build/snake.elf",
"request": "launch",
"type": "cortex-debug",
"runToEntryPoint": "main",
"servertype": "openocd",
"device": "STM32f103C8",
"interface": "swd",
"configFiles":
[
"interface/stlink.cfg",
"target/stm32f1x.cfg",
],
}
]
}
I'm not sure what I'm doing wrong. Any help would be greatly appreciated.
I figured out my problem, so I figured I'd shared in case anyone else has similar issues.
arm-none-eabi-gdb was crashing at start up. This was due to me missing python27.dll. You need to have python 2.7 installed, and it has to be the x86 version of python 2.7 because gnu arm for windows is x86.
Its very odd that arm-none-eabi-gdb requires python 2.7 to be installed as it was EOL in 2020, but here we are. I imagine in some future release the python 2.7 dependency will be removed.
Ed's answer is totally correct.
An alternative solution: I ended up running into the same issue and just went with an earlier version of the ARM Embedded Toolchain (gcc-arm-none-eabi-10.3-2021.10) and got my project to debug using OpenOCD for the Nucleo STM32L476RG.
Hope this helps.
Related
Suddenly, with a new installation of Vagrant/Homestead running a freshly installed Big Sur (macOS), my (old) Xdebug configuration for some reason didn't want to work with my VSCode.
I spent a good few hours trying to figure it out, trying many different setups but with no luck. Xdebug didn't want to work.
So how to set it up correctly to make it work?
The main reason that it didn't work correctly anymore is that suddenly with the newest version of Homestead we have a Xdebug in version 3 which changes many options of Xdebug 2. It mostly simplifies the thing but also breaks previous setups. You can read more about the changes done to configuration variables in Xdebug 3 on their page.
For Xdebug to work on Homestead / Vagrant / macOS (Big Sur) these are the steps needed.
You have to find xdebug.ini location which is easily done displaying phpinfo() and checking the path, which in my case is: /etc/php/7.3/fpm/conf.d/20-xdebug.ini
Open it and edit: sudo vi /etc/php/7.3/fpm/conf.d/20-xdebug.ini:
My configuration looks like:
zend_extension=xdebug.so
xdebug.client_port = 9003
xdebug.max_nesting_level = 512
xdebug.mode=debug
xdebug.start_upon_error = true
xdebug.idekey = VSCODE
; The MacOS way
xdebug.discover_client_host = false
xdebug.client_host = 10.254.254.254
Things that has changed:
the port - now it is 9003,
for debugging setup - many options are now set using this one simple option: xdebug.mode=debug
You have to save the file and restart php-fpm by: sudo service php7.3-fpm reload
For macOS (on my Windows machine this wasn't needed) you have to:
Ensure you have created an Host address alias on MacOS and
10.254.254.254 is aliased to your localhost.
By doing: sudo ifconfig lo0 alias 10.254.254.254.
Which is in more detail also explained here.
Install VSCode PHP Debug (vscode-php-debug) extension.
Configure VSCode by clicking the debug icon from the left menu and then edit JSON file containing debugger configuration.
Paste this:
{
"version": "0.2.0",
"configurations": [
{
"name": "My XDebug on Homestead",
"type": "php",
"request": "launch",
"pathMappings": {
"/home/vagrant/code/myproject": "${workspaceFolder}"
},
"port": 9003
}
]
}
Finally install Chrome Xdebug Helper extension and turn on the (green bug) debug mode when you want to do the debugging.
One extra thing. If you want to enable/disable Xdebug, lets say for performance reasons there is a very easy and fast way to do this.
enable:
sudo phpenmod xdebug
sudo service php7.3-fpm reload
disable:
sudo phpdismod xdebug
sudo service php7.3-fpm reload
As you can see a lot of different things in different places must be set correctly to make it work. It takes a lot of googling and patience so I thought it would be useful to put it here for you and for my future installations. :)
First of all, make sure about which version of PHP-FPM your site is running (change laravel.test to the name of your configured site). Remember that you can choose the PHP version to use for each site in the Homested.yaml file.
$ cat /etc/nginx/sites-available/laravel.test | grep fastcgi_pass
fastcgi_pass unix:/var/run/php/php8.0-fpm.sock;
This will tell you which configuration file to edit in the Homestead virtual machine (NB: change 8.0 to your version of PHP, if different).
$ sudo nano /etc/php/8.0/fpm/conf.d/20-xdebug.ini
Here, you can remove all lines starting with xdebug.* and instead add these lines:
xdebug.mode=debug
xdebug.client_host=192.168.10.1
xdebug.client_port=9003
xdebug.max_nesting_level = 512
NB: 192.168.10.1 is by default the IP address of the host machine in VirtualBox, it is supposed to be different than your actual IP address in your LAN. Note that max_nesting_level is not necessary, it's a default by Homestead so I left it there.
Now in Visual Studio Code on your host machine you can set your launch.json file to the following:
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"name": "Listen for Xdebug",
"type": "php",
"request": "launch",
// "stopOnEntry": true,
"pathMappings": {
"/home/vagrant/laravel.test": "${workspaceFolder}"
},
"port": 9003
},
{
"name": "Launch currently open script",
"type": "php",
"request": "launch",
"program": "${file}",
"cwd": "${fileDirname}",
"port": 9003
}
]
}
PS. I keep "stopOnEntry": true commented so that I can simply uncomment it when needed, otherwise I simply use breakpoints in vscode.
for Xdebug Version 3.0.3
set IDE to use a debugging port - 9003
modify the /etc/php/7.x/fpm/conf.d/20-xdebug.ini
zend_extension = xdebug.so
xdebug.remote_port = 9003
xdebug.max_nesting_level = 512
xdebug.mode = debug
xdebug.client_host = 192.168.10.1
If Homestead.yaml contains a different subnet for the IP address, this IP address may be different...
BTW, after editing 20-xdebug.ini, restart you FPM like so
$ sudo service php7.4-fpm restart
and restart your browser and IDE
PS
Tested on NetBeans and Vagrant (Laravel homestead) with php 7.4, host - WIN-10
I am using VSCode on Windows to debug a process on remote Linux host. I have added launch configuration that look like this:
{
"type": "gdb",
"request": "attach",
"name": "Attach to PID",
"target": "3441",
"cwd": "${workspaceRoot}"
},
But when I am trying to launch debugged I get this output in Debug console:
Attaching to process 3441
[New LWP 3442]
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib/arm-linux-gnueabihf/libthread_db.so.1".
__libc_do_syscall () at ../sysdeps/unix/sysv/linux/arm/libc-do-syscall.S:47
47 ../sysdeps/unix/sysv/linux/arm/libc-do-syscall.S: No such file or directory.
Not implemented stop reason (assuming exception): undefined
The last line looks suspicious as if the debugger was not able to stop the process for some reason. At the same time a message box with the following text is displayed:
Failed to attach: Cannot change this setting while the inferior is running. (from gdb-set target-async on)
I tried running gdb on the machine through ssh and attach to the process and it works ok.
So the question is: how do I get this running? I also tried enabling logging by adding this to launch.json:
"logging": {
"engineLogging": false
}
But vscode editor claims Property logging is not allowed and it doesn't seem to make any difference.
Any ideas?
I am setting up openOCD and Eclipse on a new operating system, using a Nucleo F030R8 board that debugs fine on another system. When I run the debugger in Eclipse I get "error in final launch sequence":
Error in final launch sequence
Failed to execute MI command:
-target-select remote localhost:3333
Error message from debugger back end:
localhost:3333: No such file or directory.
Failed to execute MI command:
-target-select remote localhost:3333
Error message from debugger back end:
localhost:3333: No such file or directory.
localhost:3333: No such file or directory.
I can run the debugger in terminal with ./openocd -f board/st_nucleo_f0.cfg and get:
*GNU ARM Eclipse 64-bits Open On-Chip Debugger 0.9.0-00073-gdd34716
(2015-05-19-12:55)
Licensed under GNU GPL v2
For bug reports, read
http://openocd.org/doc/doxygen/bugs.html
Info : The selected transport took over low-level target control. The results
might differ compared to plain JTAG/SWD
adapter speed: 1000 kHz
adapter_nsrst_delay: 100
none separate
srst_only separate srst_nogate srst_open_drain connect_deassert_srst
Info : Unable to match requested speed 1000 kHz, using 950 kHz
Info : Unable to match requested speed 1000 kHz, using 950 kHz
Info : clock speed 950 kHz
Info : STLINK v2 JTAG v25 API v2 SWIM v13 VID 0x0483 PID 0x374B
Info : using stlink api v2
Info : Target voltage: 3.257369
Info : stm32f0x.cpu: hardware has 4 breakpoints, 2 watchpoints''*
and the LED LD1 blinks alternatively green and red. Similarly, I can run External Tools in Eclipse just fine, but this doesn't open the debugger. So it seems like I'm close, but something isn't quite right. Let me know if you need any other details of my system.
Using:
Eclipse Mars.2 (4.5.2)
Mac 10.12.1
OpenOCD 0.10.0-201601101000-dev
GNU Tools gcc-arm-none-eabi-5_4-2016q3
Ok so I figured it out with major credit due to http://www.carminenoviello.com. Running this in terminal:
>telnet localhost 3333
localhost: nodename nor servname provided, or not known
showed this wasn't working correctly. checking /etc/hosts, the file was empty. I changed it to:
##
# Host Database
#
# localhost is used to configure the loopback interface
# when the system is booting. Do not change this entry.
##
127.0.0.1 localhost
255.255.255.255 broadcasthost
::1 localhost
And that was that. Can now enter debug mode.
When I start a debugging session under eclipse (luna) for my STM32F429 Discovery board. I get the following error:
OpenOCD failed with code (1).
The information in the console pane is:
Open On-Chip Debugger 0.9.0-dev-00223-g1567cae (2015-01-12-13:43)
Licensed under GNU GPL v2
For bug reports, read
http://openocd.sourceforge.net/doc/doxygen/bugs.html
Info : The selected transport took over low-level target control. The results might differ compared to plain JTAG/SWD
adapter speed: 2000 kHz
adapter_nsrst_delay: 100
srst_only separate srst_nogate srst_open_drain connect_deassert_srst
Started by GNU ARM Eclipse
Info : clock speed 2000 kHz
Error: open failed
in procedure 'init'
in procedure 'ocd_bouncer'
in procedure 'transport'
in procedure 'init'
The "board" file being referenced in the debug setup is: stm32f429discovery.cfg
I did have this working for another ST-Micro board and I could do a full debug session with no problems. Suddenly it just stopped being able to access the board and I get the same errors for it as I get with this board.
I was hoping to be able to use the purely open source s/w that runs on Linux to be able to work with these boards. I'm hoping that someone can get me out of this situation.
Thanks in advance.
Cheers!!
What you use the command and debugger?
try:
openocd -f interface/jlink.cfg -f target/stm32f429discovery.cfg
I'm trying to use Eclipse with GNU ARM plugins to debug my stm32f4-discovery board, however, still no luck. The same board works perfectly in Keil running in the virtual machine, so, it doesn't seem to be hardware problem.
I use Linux Mint 13, I've installed all the prerequisites, I have created templated hello world project, it compiles, and when I try to start debug, it stops at the step "Configuring GDB", and after a couple of seconds it fails with the following:
Error in final launch sequence
Failed to execute MI command:
-target-select remote localhost:3333
Error message from debugger back end:
localhost:3333: Connection timed out.
localhost:3333: Connection timed out.
Then I tried to manually start openocd:
$ openocd -f /usr/local/share/openocd/scripts/board/stm32f4discovery.cfg
Open On-Chip Debugger 0.7.0 (2014-11-08-01:25)
Licensed under GNU GPL v2
For bug reports, read
http://openocd.sourceforge.net/doc/doxygen/bugs.html
srst_only separate srst_nogate srst_open_drain connect_deassert_srst
Info : This adapter doesn't support configurable speed
Info : STLINK v2 JTAG v23 API v2 SWIM v0 VID 0x0483 PID 0x3748
Info : Target voltage: 2.918263
Info : stm32f4x.cpu: hardware has 6 breakpoints, 4 watchpoints
And arm-none-eabi-gdb:
$ arm-none-eabi-gdb ~/projects/test_stm/arm_c_1/Debug/arm_c_1.elf
GNU gdb (GNU Tools for ARM Embedded Processors) 7.6.0.20140731-cvs
Copyright (C) 2013 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-pc-linux-gnu --target=arm-none-eabi".
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>...
Reading symbols from /home/dimon/projects/test_stm/arm_c_1/Debug/arm_c_1.elf...done.
(gdb) target remote localhost:3333
Remote debugging using localhost:3333
0x00000000 in ?? ()
(gdb)
Then, openocd said that connection is accepted:
Info : accepting 'gdb' connection from 3333
Info : stm32f4x errata detected - fixing incorrect MCU_IDCODE
Info : device id = 0x10006413
Info : flash size = 1024kbytes
Warn : acknowledgment received, but no packet pending
undefined debug reason 6 - target needs reset
But, when started by Eclipse, it doesn't work, for some reason.
Well, then I tried to keep openocd started manually and alter my Debug configuration: at the "Debugger" tab, I've unchecked "Start OpenOCD locally". Now, debug session a kind of starts: debug perspective is opened, no meaningful errors are echoed, but debug buttons (resume, suspend, etc) remain inactive. The chip isn't even reprogrammed: previous firmware programmed from inside Keil keeps flashing LEDs.
Here's a screenshot of what Eclipse looks like: http://i.imgur.com/sszA0hr.png
Output of openocd:
$ /usr/local/share/openocd/scripts/board openocd -f ./stm32f4discovery.cfg
Open On-Chip Debugger 0.7.0 (2014-11-08-01:25)
Licensed under GNU GPL v2
For bug reports, read
http://openocd.sourceforge.net/doc/doxygen/bugs.html
srst_only separate srst_nogate srst_open_drain connect_deassert_srst
Info : This adapter doesn't support configurable speed
Info : STLINK v2 JTAG v23 API v2 SWIM v0 VID 0x0483 PID 0x3748
Info : Target voltage: 2.919691
Info : stm32f4x.cpu: hardware has 6 breakpoints, 4 watchpoints
Info : accepting 'gdb' connection from 3333
Info : stm32f4x errata detected - fixing incorrect MCU_IDCODE
Info : device id = 0x10006413
Info : flash size = 1024kbytes
Warn : acknowledgment received, but no packet pending
undefined debug reason 6 - target needs reset
target state: halted
target halted due to debug-request, current mode: Thread
xPSR: 0x01000000 pc: 0x08000154 msp: 0x20030000
semihosting is enabled
target state: halted
target halted due to debug-request, current mode: Thread
xPSR: 0x01000000 pc: 0x08000154 msp: 0x20030000, semihosting
I even tried to re-install all the Eclipse plugins as well as openocd, nothing helped. What could be the trouble?