Open dav322 opened 1 year ago
Thanks for reporting this issue.
connect stlink
I saw some internal documentation that it won't work. @umbynos, can you please help tell users what is (and will be (https://github.com/arduino/arduino-ide/pull/2281)) supported? Thank you!
Hello @dav322. Debugger support has been added in mbed core v4.0.10 but debugging leverage some features that are not available in the IDE2 yet. Debugging the Giga with the stlink will be a supported use case.
I would be happy using any debugger. Without debugging I can't use arduino ide. It is absolutely a requirement for a real development environment. I am already using 4.0.10 and it does not work.
I am already using 4.0.10 and it does not work.
Please try with the nightly build and let us know if it's still the same: https://www.arduino.cc/en/software/#nightly-builds We made some debugger changes (https://github.com/arduino/arduino-ide/commit/73b6dc4774297e53f7ea0affdbc3f7e963b8e980)
connect stlink v3 to arduino giga with ribbon cable.
Unfortunately, I do not have the hardware to try it out.
to verify it is connected I clicked on tools -> get board info and it displayed
running this sketch
void setup() {
// put your setup code here, to run once:
Serial.begin(115200);
}
void loop() {
// put your main code here, to run repeatedly:
Serial.println("Hello world");
delay(1000);
}
I can upload the sketch using the upload button and it displays following on monitor
Hello world
Hello world
Hello world
Hello world
...
When I set a breakpoint on Serial.begin line and click on start debugging I get following lines in gdb-server tab
Waiting for gdb server to start...[2023-12-14T21:32:30.584Z] SERVER CONSOLE DEBUG: onBackendConnect: gdb-server session connected. You can switch to "DEBUG CONSOLE" to see GDB interactions.
"C:\\Users\\david\\AppData\\Local\\Arduino15\\packages\\arduino\\tools\\openocd\\0.11.0-arduino2/bin/openocd" -c "gdb_port 50000" -c "tcl_port 50001" -c "telnet_port 50002" -s "c:\\Users\\david\\Documents\\Arduino\\giga\\test\\sketch_dec14a" -f "C:/Program Files/Arduino IDE/resources/app/plugins/cortex-debug/extension/support/openocd-helpers.tcl" -f interface/stlink.cfg -f "C:\\Users\\david\\AppData\\Local\\Arduino15\\packages\\arduino\\hardware\\mbed_giga\\4.0.10/debugger/select_hla.cfg" -f target/stm32h7x_dual_bank.cfg
Open On-Chip Debugger 0.11.0+dev-gab95bac57-dirty (2021-05-11-10:45)
Licensed under GNU GPL v2
For bug reports, read
http://openocd.org/doc/doxygen/bugs.html
CDRTOSConfigure
hla_swd
Info : The selected transport took over low-level target control. The results might differ compared to plain JTAG/SWD
Info : Listening on port 50001 for tcl connections
Info : Listening on port 50002 for telnet connections
Info : clock speed 1800 kHz
Info : STLINK V3J13M4B5S1 (API v3) VID:PID 0483:374F
Info : Target voltage: 3.225347
Info : stm32h7x.cpu0: hardware has 8 breakpoints, 4 watchpoints
Info : starting gdb server for stm32h7x.cpu0 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: Thread
xPSR: 0x61000000 pc: 0x08049d8c psp: 0x24002860
Info : Device: STM32H74x/75x
Info : flash size probed value 2048
Info : STM32H7 flash has dual banks
Info : Bank (0) size is 1024 kb, base address is 0x08000000
Info : Device: STM32H74x/75x
Info : flash size probed value 2048
Info : STM32H7 flash has dual banks
Info : Bank (1) size is 1024 kb, base address is 0x08100000
target halted due to debug-request, current mode: Thread
xPSR: 0x01000000 pc: 0x0800067c msp: 0x24080000
target halted due to debug-request, current mode: Thread
xPSR: 0x01000000 pc: 0x0800067c msp: 0x24080000
Info : Unable to match requested speed 4000 kHz, using 3300 kHz
Info : Unable to match requested speed 4000 kHz, using 3300 kHz
Info : Padding image section 0 at 0x0805b6f8 with 8 bytes (bank write end alignment)
target halted due to debug-request, current mode: Thread
xPSR: 0x01000000 pc: 0x0800067c msp: 0x24080000
target halted due to debug-request, current mode: Thread
xPSR: 0x01000000 pc: 0x0800067c msp: 0x24080000
and these lines in debug console
Cortex-Debug: VSCode debugger extension version 1.5.1 git(be7d3c8+dirty). Usaage info: https://github.com/Marus/cortex-debug#usage
Reading symbols from C:\Users\david\AppData\Local\Arduino15\packages\arduino\tools\arm-none-eabi-gcc\7-2017q4\bin\arm-none-eabi-objdump.exe --syms -C -h -w C:/Users\david\AppData\Local\Temp\arduino\sketches\FD26ADCEFE08EBA501EA55F802AE2D01\sketch_dec14a.ino.elf
Reading symbols from c:/users\david\appdata\local\arduino15\packages\arduino\tools\arm-none-eabi-gcc\7-2017q4\bin\arm-none-eabi-nm.exe --defined-only -S -l -C -p C:/Users\david\AppData\Local\Temp\arduino\sketches\FD26ADCEFE08EBA501EA55F802AE2D01\sketch_dec14a.ino.elf
Launching GDB: "C:\\Users\\david\\AppData\\Local\\Arduino15\\packages\\arduino\\tools\\arm-none-eabi-gcc\\7-2017q4\\bin\\arm-none-eabi-gdb.exe" -q --interpreter=mi2 "C:/Users\\david\\AppData\\Local\\Temp\\arduino\\sketches\\FD26ADCEFE08EBA501EA55F802AE2D01\\sketch_dec14a.ino.elf"
IMPORTANT: Set "showDevDebugOutput": "raw" in "launch.json" to see verbose GDB transactions here. Very helpful to debug issues or report problems
Launching gdb-server: "C:\\Users\\david\\AppData\\Local\\Arduino15\\packages\\arduino\\tools\\openocd\\0.11.0-arduino2/bin/openocd" -c "gdb_port 50000" -c "tcl_port 50001" -c "telnet_port 50002" -s "c:\\Users\\david\\Documents\\Arduino\\giga\\test\\sketch_dec14a" -f "C:/Program Files/Arduino IDE/resources/app/plugins/cortex-debug/extension/support/openocd-helpers.tcl" -f interface/stlink.cfg -f "C:\\Users\\david\\AppData\\Local\\Arduino15\\packages\\arduino\\hardware\\mbed_giga\\4.0.10/debugger/select_hla.cfg" -f target/stm32h7x_dual_bank.cfg
Please check TERMINAL tab (gdb-server) for output from C:\Users\david\AppData\Local\Arduino15\packages\arduino\tools\openocd\0.11.0-arduino2/bin/openocd
Finished reading symbols from objdump: Time: 871 ms
Finished reading symbols from nm: Time: 852 ms
WARNING: Cortex-Debug will deprecate use of GDB version 8 after July 2022. Please upgrade to version 9+
Reading symbols from C:/Users\david\AppData\Local\Temp\arduino\sketches\FD26ADCEFE08EBA501EA55F802AE2D01\sketch_dec14a.ino.elf...done.
0x08049d8c in HAL_PWR_EnterSLEEPMode ()
Program stopped, probably due to a reset and/or halt issued by debugger
target halted due to debug-request, current mode: Thread
xPSR: 0x01000000 pc: 0x0800067c msp: 0x24080000
target halted due to debug-request, current mode: Thread
xPSR: 0x01000000 pc: 0x0800067c msp: 0x24080000
end debug console
launch.json was:
{
"version": "0.2.0",
"configurations": [
{
"configId": "arduino:mbed_giga:giga:programmer=stlink",
"cwd": "${workspaceRoot}",
"request": "launch",
"type": "cortex-debug",
"executable": "C:\\Users\\david\\AppData\\Local\\Temp\\arduino\\sketches\\FD26ADCEFE08EBA501EA55F802AE2D01/sketch_dec14a.ino.elf",
"toolchainPrefix": "arm-none-eabi",
"svdFile": "C:\\Users\\david\\AppData\\Local\\Arduino15\\packages\\arduino\\hardware\\mbed_giga\\4.0.10/svd/STM32H747_CM7.svd",
"overrideRestartCommands": [
"monitor reset halt",
"monitor gdb_sync",
"c"
],
"postAttachCommands": [
"set remote hardware-watchpoint-limit 2",
"monitor reset halt",
"monitor gdb_sync",
"c"
],
"name": "Arduino Giga R1 (stlink)",
"serverpath": "C:\\Users\\david\\AppData\\Local\\Arduino15\\packages\\arduino\\tools\\openocd\\0.11.0-arduino2/bin/openocd",
"servertype": "openocd",
"armToolchainPath": "C:\\Users\\david\\AppData\\Local\\Arduino15\\packages\\arduino\\tools\\arm-none-eabi-gcc\\7-2017q4/bin/",
"configFiles": [
"interface/stlink.cfg",
"C:\\Users\\david\\AppData\\Local\\Arduino15\\packages\\arduino\\hardware\\mbed_giga\\4.0.10/debugger/select_hla.cfg",
"target/stm32h7x_dual_bank.cfg"
]
}
]
}
end launch.json
To verify the stlink / giga is working I started an empty project with STM32CUBEIDE. Program loaded and stopped at first line of main
to make it run again with arduino ide I run this command after putting giga in boot mode.
"%LOCALAPPDATA%\Arduino15\packages\arduino\tools\dfu-util\0.10.0-arduino1\dfu-util" --device ,0x0483:0xdf11 -D "%LOCALAPPDATA%\Arduino15\packages\arduino\hardware\mbed_giga\4.0.10\bootloaders\GIGA\bootloader.bin" -a0 --dfuse-address=0x8000000
a 2nd try had these log files showing it stopped. Clicking on step seemed to step into routines and follow code as expected.
debug console
Reading symbols from C:/Users\david\AppData\Local\Temp\arduino\sketches\FD26ADCEFE08EBA501EA55F802AE2D01\sketch_dec14a.ino.elf...done.
0x08049d8c in HAL_PWR_EnterSLEEPMode ()
Program stopped, probably due to a reset and/or halt issued by debugger
target halted due to debug-request, current mode: Thread
xPSR: 0x01000000 pc: 0x0800067c msp: 0x24080000
target halted due to debug-request, current mode: Thread
xPSR: 0x01000000 pc: 0x0800067c msp: 0x24080000
Note: automatically using hardware breakpoints for read-only addresses.
Breakpoint 1, setup () at C:\Users\david\Documents\Arduino\giga\test\sketch_dec14a/sketch_dec14a.ino:3
3 Serial.begin(115200);
gdb_server
Waiting for gdb server to start...[2023-12-14T21:39:51.076Z] SERVER CONSOLE DEBUG: onBackendConnect: gdb-server session connected. You can switch to "DEBUG CONSOLE" to see GDB interactions.
"C:\\Users\\david\\AppData\\Local\\Arduino15\\packages\\arduino\\tools\\openocd\\0.11.0-arduino2/bin/openocd" -c "gdb_port 50000" -c "tcl_port 50001" -c "telnet_port 50002" -s "c:\\Users\\david\\Documents\\Arduino\\giga\\test\\sketch_dec14a" -f "C:/Program Files/Arduino IDE/resources/app/plugins/cortex-debug/extension/support/openocd-helpers.tcl" -f interface/stlink.cfg -f "C:\\Users\\david\\AppData\\Local\\Arduino15\\packages\\arduino\\hardware\\mbed_giga\\4.0.10/debugger/select_hla.cfg" -f target/stm32h7x_dual_bank.cfg
Open On-Chip Debugger 0.11.0+dev-gab95bac57-dirty (2021-05-11-10:45)
Licensed under GNU GPL v2
For bug reports, read
http://openocd.org/doc/doxygen/bugs.html
CDRTOSConfigure
hla_swd
Info : The selected transport took over low-level target control. The results might differ compared to plain JTAG/SWD
Info : Listening on port 50001 for tcl connections
Info : Listening on port 50002 for telnet connections
Info : clock speed 1800 kHz
Info : STLINK V3J13M4B5S1 (API v3) VID:PID 0483:374F
Info : Target voltage: 3.225347
Info : stm32h7x.cpu0: hardware has 8 breakpoints, 4 watchpoints
Info : starting gdb server for stm32h7x.cpu0 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: Thread
xPSR: 0x61000000 pc: 0x08049d8c psp: 0x24002860
Info : Device: STM32H74x/75x
Info : flash size probed value 2048
Info : STM32H7 flash has dual banks
Info : Bank (0) size is 1024 kb, base address is 0x08000000
Info : Device: STM32H74x/75x
Info : flash size probed value 2048
Info : STM32H7 flash has dual banks
Info : Bank (1) size is 1024 kb, base address is 0x08100000
target halted due to debug-request, current mode: Thread
xPSR: 0x01000000 pc: 0x0800067c msp: 0x24080000
target halted due to debug-request, current mode: Thread
xPSR: 0x01000000 pc: 0x0800067c msp: 0x24080000
Info : Unable to match requested speed 4000 kHz, using 3300 kHz
Info : Unable to match requested speed 4000 kHz, using 3300 kHz
Info : Padding image section 0 at 0x0805b6f8 with 8 bytes (bank write end alignment)
target halted due to debug-request, current mode: Thread
xPSR: 0x01000000 pc: 0x0800067c msp: 0x24080000
target halted due to debug-request, current mode: Thread
xPSR: 0x01000000 pc: 0x0800067c msp: 0x24080000
I would like to add to this issue.....
Setup: Hardware Intel Corporation NUC6i7KYB Memory 16.0 GiB Processor Intel® Core™ i7-6770HQ × 8 OS Name Debian GNU/Linux 12 (bookworm) DevEnv Arduino-Ide v2.2.1 LogFile ~/.config/2023-12-16_log.log
Execute arduino-ide_2.2.1_Linux_64bit.AppImage Results Debug Icon grayed-out (Not Available) Workaround via Board Manager- select a different board- Debug Icon comes alive via Board Manager- reselect original board- Debug Icon remains alive Continuing on-Then with the following setup using the following upload method- Picoprobe(cmsis-dap) upload the elf file to the target- Success but closes the connection with a openocd reset init (by openocd definition halt) debug fails with the following Arduino Ide Notification- Request 2 connection refused, connection closed.
Peruse the log file and voila! reference warns, errors, daemon, root........enough said File attahed.
Detail $cat ~/.config/2023-12-16_log.log | grep "Daemon" $cat ~/.config/2023-12-16_log.log | grep "Root" [2023-12-16_log.log] (https://github.com/arduino/arduino-ide/files/13697671/2023-12-16_log.log)
Thanks for your persistence on this.
Debug Icon grayed-out (Not Available) Workaround via Board Manager- select a different board- Debug Icon comes alive via Board Manager- reselect original board- Debug Icon remains alive
It's a known issue (https://github.com/arduino/arduino-ide/issues/2237). It has been fixed (https://github.com/arduino/arduino-ide/pull/2242/commits/4d04aac56d5af1e502f6a596a641e4bccd43a882) and is available in the nightly builds: https://www.arduino.cc/en/software#nightly-builds.
You could try to tweak the request
type in the launch config. (I am on macOS and have no hardware for this issue, so I am guessing here.)
You can see the warning here if you open the launch.json
in the editor. This does not look correct; let's change the request type:
Please try if the following helps:
Create a New Tab
by clicking on ...
(or Ctrl/⌘+Shift+N),
Name the file as debug_custom.json
, press OK,
Create this file content: (The new file is a JSON, which contains an array of debug config customizations, identified by the Arduino IDE-specific configId
consisting of the FQBN and the programmer ID)
[
{
"configId": "arduino:mbed_giga:giga:programmer=stlink",
"request": "attach"
}
]
Click on the debug toolbar.
To verify the procedure was correct, you can open the lunach.json
and verify that the request
type is attach
instead of launch
and that the warning on the postAttachCommands
property has gone.
Let me know how it went. Please make sure to use the 4.0.10
version of the Arduino Mbed OS Giga Boards
(arduino:mbed_giga
) package.
It seems it could be a problem related to an old bootloader, could you please try to update it? https://support.arduino.cc/hc/en-us/articles/7991505977116-Burn-the-bootloader-on-GIGA-R1-WiFi
Thanks, Kittaakos I got the nightly build update. I have a comment regarding the issue thread and my original post to share with others (dav322). First we are seeing the same problem with different boards. I'm using a RPi Pico and getting your results. That's why I'm here. We have two boards seeing the same results. I think the problem is one layer removed from the boards.
I performed more troubleshooting for the same problem using picoprobe (cmsis-dap). It really looks to me like a contention issue between the upload thread ( first to acquire /dev/ttyACM0 via serial monitor) and the second process thread (debug) getting locked out of that resource. I agree that a simple fix might go into the launch.json file however if that gets applied, is the way openocd terminates appropriate for both upload and debug cases? It may break the upload process . I don't know.
In the end, I think the once the serial monitor opens the /dev/ttyACM0 for the upload process then the debug path might want to check if openocd and the resource are already open and if so then attach rather than launch.
I think the problem is one layer removed from the boards.
It really looks to me like a contention issue between the upload thread ( first to acquire /dev/ttyACM0 via serial monitor) and the second process thread (debug) getting locked out of that resource. I agree that a simple fix might go into the launch.json file however if that gets applied, is the way openocd terminates appropriate for both upload and debug cases?
I do not understand it. Can you please explain?
It may break the upload process
Are you referring to https://github.com/arduino/arduino-ide/issues/1846?
the serial monitor opens the /dev/ttyACM0 for the upload process then the debug path might want to check if openocd and the resource are already open and if so then attach rather than launch.
Can we simplify the use case and not upload/open the serial monitor when debugging?
PR upstream to change request type: https://github.com/arduino/ArduinoCore-mbed/pull/806
@dav322, have you had the chance to workaround the bug in the mbed platform using the steps I have provided at https://github.com/arduino/arduino-ide/issues/2299#issuecomment-1859699452? Feel free to let me know if you need help. Thank you!
issue #1846 indeed covers what I am seeing. The fix for #2299 did not work for me. I'll try again. The launch.json edits look like what I was expecting but there is a launch.json file for every project. Is there a master copy or master template that could be edited just once?
@kittaakos - I downloaded the current nightly build arduino-ide_nightly-20240115_Linux_64bit and I still have the same problem although with a popup message "Debug- No programmer selected for Raspberry Pi Pico". (#2299) This is a change from the original issue.
Thanks for your persistence, @victoryred
Is there a master copy or master template that could be edited just once?
No, there isn't. There cannot be a "master" launch.json
, as the executable
property (the path to the compiled sketch output) varies per sketch folder path.
I still have the same problem although with a popup message "Debug- No programmer selected for Raspberry Pi Pico".
It looks like a different issue to me. The initial bug report was about debugging the Giga board with stlink. To solve that particular problem, I have provided the steps at https://github.com/arduino/arduino-ide/issues/2299#issuecomment-1859699452, and a fix was made in the mbed platform via https://github.com/arduino/ArduinoCore-mbed/pull/806.
"Debug- No programmer selected for Raspberry Pi Pico".
This is getting off-topic, but what happens when you select the programmer for your Raspberry Pi Pico board and start the debugger from the toolbar?
@kittaakos I'll remember to edit the launch.json file for each project.
I tried the nightly build just now (arduino-ide_nightly-20240115_Linux_64bit). The large debug icon in the toolbar remained inactive (gray) but the small debug icon in the debug window successfully launched a debug session and ran to a breakpoint.
I can work with this now. I thank you for your help.
Describe the problem
when I try to start debugger I get request 2 canceled on connection close does not start debugger.
I can upload the sketch and it runs to output the position. I have not tested my sketch with encoders attached yet.
To reproduce
connect stlink v3 to arduino giga with ribbon cable. connect both to pc open arduino ide. click on start debugging I have attached the sketch sketch_nov17a.zip
Expected behavior
I expected the debugger to start and then stop at the breakpoint I set on the first line of the setup routine.
Arduino IDE version
nightly build 11-30-23
Operating system
Windows
Operating system version
windows 11
Additional context
probably not required
Issue checklist