I was planning to debug an ARM board with a hardware debugger to be more efficient. I bought a Redboard Artemis and a J-Link edu mini but I’m facing issues in my setup. My goal is to be able to set breakpoints and inspect variables during the execution of the program in vscode editor. However, I can’t manage to find the good configuration to achieve it.
I’m using cortex debug extension to use gdb server on vscode and arduino-cli extension to compile and upload programs on the board. I’ve been following, this guide to setup the Arduino-cli on vscode and it works fine (at least for building and uploading the code on the board) (https://learn.sparkfun.com/tutorials/efficient-arduino-programming-with-arduino-cli-and-visual-studio-code/vs-code-for-arduino-library-development)
I’m also able to set breakpoints on the vscode editor before building the program but when I upload it into the board, the breakpoints become grey with the error message “no symbol table is loaded. Use the file command” (see the picture bellow). On the other side, it looks like the gdb debugging is working correctly since I’m able to use gdb commands like: “break setup” and “continue”, and the program stops at the setup function. I have been following different guide to setup J-link in Vscode (like this one: https://wiki.segger.com/J-Link_Visual_Studio_Code). In all of them, I noticed that the executable is an .elf file but on my case, the binary that is built for my board is an .avx file. It seems that it is related to the Redboard because when I build programs for an Arduino uno board or an Adafruit metro m4 board, it ends up with an. elf binary. I don’t know if this is relevant because I couldn’t find anything about « .avx debug » or « .avx vs .elf » on the internet. I saw on different forums that this error occurs when you don’t specify the “-g” parameter when building. When I look at the logs during compilation, it seems that I am missing the -g parameter since the output is:
“Compilation du croquis...
C:\\Users\\epixe\\AppData\\Local\\Arduino15\\packages\\SparkFun\\tools\\arm-none-eabi-gcc\\8-2018-q4-major/bin/arm-none-eabi-g++ -include”
At this point I have tried several things to add the “-g” parameter but none of them worked.
- I’ve added the line:
"compilerArgs": [
"-g"
],”
in the “c_cpp_properties.json” but it looks like the argument isn’t recognized because during compilation it still shows the same output. 2) I’ve also looked at the Arduino-cli compile parameters, and added:
"buildPreferences": [
["compiler.cpp.extra_flags", "-g"]
]
In the Arduino.json but the output remains the same. At this point I don’t really understand why it didn’t change anything and I’m not even sure that the error is related to this. Since, I don’t really know where the issue comes from (is it related to a bad usage of Arduino-cli? a bad usage of cortex-debug extension? something related to the board?), I didn’t really know where to post this message and that’s why I ended up here. For references, you can find the launch.json, the Arduino.json and the c_pp_property.json down bellow.
Thanks for reading,
Arduino.json
{
"configuration": "svl_baud=460800,loader=option_svl",
"board": "SparkFun:apollo3:sfe_artemis",
"sketch": "blink.ino",
"buildPreferences": [
[
"compiler.cpp.extra_flags",
"-g"
]
],
"port": "COM6",
"output": "./build"
}
cpp_properties.json
{
"configurations": [
{
"name": "Win32",
"includePath": [
"C:\\Users\\epixe\\AppData\\Local\\arduino15\\packages\\arduino\\hardware\\avr\\1.8.6\\cores\\arduino\\",
"C:\\Users\\epixe\\AppData\\Local\\arduino15\\packages\\arduino\\hardware\\avr\\1.8.6\\libraries\\EEPROM\\src",
"C:\\Users\\epixe\\AppData\\Local\\arduino15\\packages\\arduino\\hardware\\avr\\1.8.6\\libraries\\HID\\src",
"C:\\Users\\epixe\\AppData\\Local\\arduino15\\packages\\arduino\\hardware\\avr\\1.8.6\\libraries\\SoftwareSerial\\src",
"C:\\Users\\epixe\\AppData\\Local\\arduino15\\packages\\arduino\\hardware\\avr\\1.8.6\\libraries\\SPI\\src",
"C:\\Users\\epixe\\AppData\\Local\\arduino15\\packages\\arduino\\hardware\\avr\\1.8.6\\libraries\\Wire\\src"
],
"defines": [
"_DEBUG",
"UNICODE",
"_UNICODE",
"F_CPU=16000000L",
"ARDUINO=10805",
"ARDUINO_AVR_UNO",
"ARDUINO_ARCH_AVR"
],
"compilerPath": "C:\\Users\\epixe\\AppData\\Local\\Arduino15\\packages\\SparkFun\\tools\\arm-none-eabi-gcc\\8-2018-q4-major\\bin\\arm-none-eabi-g++",
"compilerArgs": [
"-g"
],
"cStandard": "c11",
"cppStandard": "c++17",
"intelliSenseMode": "clang-x64"
}
],
"version": 4
}
launch.json
{
// 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": [
{
"type": "cortex-debug",
"request": "launch",
"name": "Debug J-Link",
"cwd": "${workspaceFolder}",
"executable": "./build/blink.ino.axf",
"serverpath": "E:/logiciel/segger/JLink_V792k/JLinkGDBServerCL.exe",
"servertype": "jlink",
"device": "AMA3B1KK-KBR",
"interface": "swd",
"runToEntryPoint": "main",
"armToolchainPath": "E:/logiciel/segger/arm_toolchain/bin/",
}
]
}
build_logs
[Starting] Verifying sketch 'blink.ino'
Please see the build logs in output path: e:\projet_perso\robot\arduino_code\examples\temp\blink\build
Using board 'sfe_artemis' from platform in folder: C:\Users\epixe\AppData\Local\Arduino15\packages\SparkFun\hardware\apollo3\2.2.1
Using core 'arduino' from platform in folder: C:\Users\epixe\AppData\Local\Arduino15\packages\SparkFun\hardware\apollo3\2.2.1
Detecting libraries used...
"C:\\Users\\epixe\\AppData\\Local\\Arduino15\\packages\\SparkFun\\tools\\arm-none-eabi-gcc\\8-2018-q4-major/bin/arm-none-eabi-g++" -include "C:\\Users\\epixe\\AppData\\Local\\Arduino15\\packages\\SparkFun\\hardware\\apollo3\\2.2.1\\variants\\SFE_ARTEMIS/mbed/mbed_config.h" -include "C:\\Users\\epixe\\AppData\\Local\\Arduino15\\packages\\SparkFun\\hardware\\apollo3\\2.2.1/cores/arduino/sdk/ArduinoSDK.h" -iprefix "C:\\Users\\epixe\\AppData\\Local\\Arduino15\\packages\\SparkFun\\hardware\\apollo3\\2.2.1/cores/" "@C:\\Users\\epixe\\AppData\\Local\\Arduino15\\packages\\SparkFun\\hardware\\apollo3\\2.2.1\\variants\\SFE_ARTEMIS/mbed/.cxx-flags" -w -x c++ -E -CC -DARDUINO=10607 -DARDUINO_APOLLO3_SFE_ARTEMIS -DARDUINO_ARCH_MBED -DARDUINO_ARCH_APOLLO3 -DMBED_NO_GLOBAL_USING_DIRECTIVE -DCORDIO_ZERO_COPY_HCI "@C:\\Users\\epixe\\AppData\\Local\\Arduino15\\packages\\SparkFun\\hardware\\apollo3\\2.2.1\\variants\\SFE_ARTEMIS/mbed/.cxx-symbols" "-IC:\\Users\\epixe\\AppData\\Local\\Arduino15\\packages\\SparkFun\\hardware\\apollo3\\2.2.1\\cores\\arduino" "-IC:\\Users\\epixe\\AppData\\Local\\Arduino15\\packages\\SparkFun\\hardware\\apollo3\\2.2.1\\variants\\SFE_ARTEMIS" "-IC:\\Users\\epixe\\AppData\\Local\\Arduino15\\packages\\SparkFun\\hardware\\apollo3\\2.2.1/cores/arduino" "-IC:\\Users\\epixe\\AppData\\Local\\Arduino15\\packages\\SparkFun\\hardware\\apollo3\\2.2.1/cores/arduino/mbed-bridge" "-IC:\\Users\\epixe\\AppData\\Local\\Arduino15\\packages\\SparkFun\\hardware\\apollo3\\2.2.1/cores/arduino/mbed-bridge/core-api" "-IC:\\Users\\epixe\\AppData\\Local\\Arduino15\\packages\\SparkFun\\hardware\\apollo3\\2.2.1/cores/arduino/mbed-bridge/core-api/api/deprecated" "@C:\\Users\\epixe\\AppData\\Local\\Arduino15\\packages\\SparkFun\\hardware\\apollo3\\2.2.1\\variants\\SFE_ARTEMIS/mbed/.includes" "E:\\projet_perso\\robot\\arduino_code\\examples\\temp\\blink\\build\\sketch\\blink.ino.cpp" -o nul
Generating function prototypes...
"C:\\Users\\epixe\\AppData\\Local\\Arduino15\\packages\\SparkFun\\tools\\arm-none-eabi-gcc\\8-2018-q4-major/bin/arm-none-eabi-g++" -include "C:\\Users\\epixe\\AppData\\Local\\Arduino15\\packages\\SparkFun\\hardware\\apollo3\\2.2.1\\variants\\SFE_ARTEMIS/mbed/mbed_config.h" -include "C:\\Users\\epixe\\AppData\\Local\\Arduino15\\packages\\SparkFun\\hardware\\apollo3\\2.2.1/cores/arduino/sdk/ArduinoSDK.h" -iprefix "C:\\Users\\epixe\\AppData\\Local\\Arduino15\\packages\\SparkFun\\hardware\\apollo3\\2.2.1/cores/" "@C:\\Users\\epixe\\AppData\\Local\\Arduino15\\packages\\SparkFun\\hardware\\apollo3\\2.2.1\\variants\\SFE_ARTEMIS/mbed/.cxx-flags" -w -x c++ -E -CC -DARDUINO=10607 -DARDUINO_APOLLO3_SFE_ARTEMIS -DARDUINO_ARCH_MBED -DARDUINO_ARCH_APOLLO3 -DMBED_NO_GLOBAL_USING_DIRECTIVE -DCORDIO_ZERO_COPY_HCI "@C:\\Users\\epixe\\AppData\\Local\\Arduino15\\packages\\SparkFun\\hardware\\apollo3\\2.2.1\\variants\\SFE_ARTEMIS/mbed/.cxx-symbols" "-IC:\\Users\\epixe\\AppData\\Local\\Arduino15\\packages\\SparkFun\\hardware\\apollo3\\2.2.1\\cores\\arduino" "-IC:\\Users\\epixe\\AppData\\Local\\Arduino15\\packages\\SparkFun\\hardware\\apollo3\\2.2.1\\variants\\SFE_ARTEMIS" "-IC:\\Users\\epixe\\AppData\\Local\\Arduino15\\packages\\SparkFun\\hardware\\apollo3\\2.2.1/cores/arduino" "-IC:\\Users\\epixe\\AppData\\Local\\Arduino15\\packages\\SparkFun\\hardware\\apollo3\\2.2.1/cores/arduino/mbed-bridge" "-IC:\\Users\\epixe\\AppData\\Local\\Arduino15\\packages\\SparkFun\\hardware\\apollo3\\2.2.1/cores/arduino/mbed-bridge/core-api" "-IC:\\Users\\epixe\\AppData\\Local\\Arduino15\\packages\\SparkFun\\hardware\\apollo3\\2.2.1/cores/arduino/mbed-bridge/core-api/api/deprecated" "@C:\\Users\\epixe\\AppData\\Local\\Arduino15\\packages\\SparkFun\\hardware\\apollo3\\2.2.1\\variants\\SFE_ARTEMIS/mbed/.includes" "E:\\projet_perso\\robot\\arduino_code\\examples\\temp\\blink\\build\\sketch\\blink.ino.cpp" -o "E:\\projet_perso\\robot\\arduino_code\\examples\\temp\\blink\\build\\preproc\\ctags_target_for_gcc_minus_e.cpp"
"C:\\Users\\epixe\\AppData\\Local\\Arduino15\\packages\\builtin\\tools\\ctags\\5.8-arduino11/ctags" -u --language-force=c++ -f - --c++-kinds=svpf --fields=KSTtzns --line-directives "E:\\projet_perso\\robot\\arduino_code\\examples\\temp\\blink\\build\\preproc\\ctags_target_for_gcc_minus_e.cpp"
Compilation du croquis...
"C:\\Users\\epixe\\AppData\\Local\\Arduino15\\packages\\SparkFun\\tools\\arm-none-eabi-gcc\\8-2018-q4-major/bin/arm-none-eabi-g++" -include "C:\\Users\\epixe\\AppData\\Local\\Arduino15\\packages\\SparkFun\\hardware\\apollo3\\2.2.1\\variants\\SFE_ARTEMIS/mbed/mbed_config.h" -include "C:\\Users\\epixe\\AppData\\Local\\Arduino15\\packages\\SparkFun\\hardware\\apollo3\\2.2.1/cores/arduino/sdk/ArduinoSDK.h" -iprefix "C:\\Users\\epixe\\AppData\\Local\\Arduino15\\packages\\SparkFun\\hardware\\apollo3\\2.2.1/cores/" "@C:\\Users\\epixe\\AppData\\Local\\Arduino15\\packages\\SparkFun\\hardware\\apollo3\\2.2.1\\variants\\SFE_ARTEMIS/mbed/.cxx-flags" -MMD -DARDUINO=10607 -DARDUINO_APOLLO3_SFE_ARTEMIS -DARDUINO_ARCH_MBED -DARDUINO_ARCH_APOLLO3 -DMBED_NO_GLOBAL_USING_DIRECTIVE -DCORDIO_ZERO_COPY_HCI "@C:\\Users\\epixe\\AppData\\Local\\Arduino15\\packages\\SparkFun\\hardware\\apollo3\\2.2.1\\variants\\SFE_ARTEMIS/mbed/.cxx-symbols" "-IC:\\Users\\epixe\\AppData\\Local\\Arduino15\\packages\\SparkFun\\hardware\\apollo3\\2.2.1\\cores\\arduino" "-IC:\\Users\\epixe\\AppData\\Local\\Arduino15\\packages\\SparkFun\\hardware\\apollo3\\2.2.1\\variants\\SFE_ARTEMIS" "-IC:\\Users\\epixe\\AppData\\Local\\Arduino15\\packages\\SparkFun\\hardware\\apollo3\\2.2.1/cores/arduino" "-IC:\\Users\\epixe\\AppData\\Local\\Arduino15\\packages\\SparkFun\\hardware\\apollo3\\2.2.1/cores/arduino/mbed-bridge" "-IC:\\Users\\epixe\\AppData\\Local\\Arduino15\\packages\\SparkFun\\hardware\\apollo3\\2.2.1/cores/arduino/mbed-bridge/core-api" "-IC:\\Users\\epixe\\AppData\\Local\\Arduino15\\packages\\SparkFun\\hardware\\apollo3\\2.2.1/cores/arduino/mbed-bridge/core-api/api/deprecated" "@C:\\Users\\epixe\\AppData\\Local\\Arduino15\\packages\\SparkFun\\hardware\\apollo3\\2.2.1\\variants\\SFE_ARTEMIS/mbed/.includes" "E:\\projet_perso\\robot\\arduino_code\\examples\\temp\\blink\\build\\sketch\\blink.ino.cpp" -o "E:\\projet_perso\\robot\\arduino_code\\examples\\temp\\blink\\build\\sketch\\blink.ino.cpp.o"
Compiling libraries...
Compiling core...
Couldn't deeply cache core build: Rel: can't make E:\projet_perso\robot\arduino_code\examples\temp\blink\build relative to C:\Users\epixe\AppData\Local\Temp\arduino\cores
Running normal build of the core...
"C:\\Users\\epixe\\AppData\\Local\\Arduino15\\packages\\SparkFun\\tools\\arm-none-eabi-gcc\\8-2018-q4-major/bin/arm-none-eabi-g++" -include
....
"C:\\Users\\epixe\\AppData\\Local\\Arduino15\\packages\\SparkFun\\tools\\arm-none-eabi-gcc\\8-2018-q4-major/bin/arm-none-eabi-objcopy" -O binary "E:\\projet_perso\\robot\\arduino_code\\examples\\temp\\blink\\build/blink.ino.axf" "E:\\projet_perso\\robot\\arduino_code\\examples\\temp\\blink\\build/blink.ino.bin"
"C:\\Users\\epixe\\AppData\\Local\\Arduino15\\packages\\SparkFun\\tools\\arm-none-eabi-gcc\\8-2018-q4-major/bin/arm-none-eabi-size" -A "E:\\projet_perso\\robot\\arduino_code\\examples\\temp\\blink\\build/blink.ino.axf"
Le croquis utilise 116124 octets (11%) de l'espace de stockage de programmes. Le maximum est de 983040 octets.
Les variables globales utilisent 27600 octets (7%) de mémoire dynamique, ce qui laisse 365616 octets pour les variables locales. Le maximum est de 393216 octets.
Used platform Version Path
SparkFun:apollo3 2.2.1 C:\Users\epixe\AppData\Local\Arduino15\packages\SparkFun\hardware\apollo3\2.2.1
[Warning] Failed to generate IntelliSense configuration.
[Done] Verifying sketch 'blink.ino'