Visual Studio Code debugging does not work on Mac

08 Feb 2018

I have followed the instructions here: https://docs.mbed.com/docs/mbed-os-handbook/en/latest/debugging/vscode/ but whatever I do, I always get the error: Debugger executable '/usr/local/bin/arm-none-eabi-gdb' is not signed. As a result, debugging may not work properly.

This happens whether I try to use openocd as the debug server, or even st-util. VS code appears to fail to start up the debug server, and as a result arm-none-eabi-gdb cannot connect to it.

(The error message appears to be completely spurious).

Anyone else managed to get this to work on a Mac? Anyone even tried to get this to work on a Mac?

Further info: here is the last part of what appears in the debug console

1: (406) Starting: "/usr/local/bin/st-util" -p 3333

1: (20423) <-logout

ERROR: Unable to start debugging. Debug server process failed to initialize.

C disconnect: {"restart":false}

08 Feb 2018

OK, I have solved it. Please revise the documentation page accordingly:

The documentation page fails to note that you also need to edit the line in launch.json saying

"serverStarted":

You must tell it the last thing the gdb server prints after starting up.

Using openocd and a NucleoF411RE, for example, this would be

"serverStarted": "adapter speed: 4000 kHz",

where you need to put double backslashes in front of each space (cant format that here!)

For the sake of completeness here, I also have

"debugServerArgs": "-f /usr/local/Cellar/open-ocd/0.10.0/share/openocd/scripts/board/st_nucleo_f4.cfg -f /usr/local/Cellar/open-ocd/0.10.0/share/openocd/scripts/interface/stlink-v2-1.cfg -c init -c \"reset init\""

(I suspect st-util would also work using a similar fix, but I also found out that the particular board I was using is not supported by st-util)

11 Feb 2018

One can simplify the arguments line by using the open-ocd -s option to specify the path to the scripts directory. since the board.cfg script files contain un-pathed references to the required link files.

when using the -s option the debugServerArgs line in the previous post i.e.

"debugServerArgs": "-f /usr/local/Cellar/open-ocd/0.10.0/share/openocd/scripts/board/st_nucleo_f4.cfg -f /usr/local/Cellar/open-ocd/0.10.0/share/openocd/scripts/interface/stlink-v2-1.cfg -c init -c \"reset init\""

becomes

"debugServerArgs": "-s /usr/local/Cellar/open-ocd/0.10.0/share/openocd/scripts -f ./board/st_nucleo_f4.cfg -c init -c \"reset init\""

Also on windows machines the forward slashes / in the paths must be replaced with double back slashes \\

11 Feb 2018

Running on Windows I was able to use the following line "target halted due to debug-request, current mode: Thread" instead of "adapter speed: 4000 kHz" as the server started arguments which eliminates a dependency on the speed of the established communication link

The following technique can be helpful if one is having problem with the open-ocd server startup with your board connected

  • 1 open a command line window
  • 2 change the working directory to the bin directory of the open-ocd installation your system i.e. /usr/local/Cellar/open-ocd/0.10.0/share/openocd/bin in the previous post
  • 3 enter the follow command open-ocd -d2 -s../scripts -f ./board/st_nucleo_f4.cfg -c init -c "reset init" replacing st_nucleo_f4.cfg with the name of the configuration file for your board

open_ocd will dump lots of state, status and debugging information to you console window

enter ctrl C to shut down open_ocd and return control to your console