Auto-launch arm-none-eabi-gdb after upload script

User avatar
RogerClark
Posts: 6917
Joined: Mon Apr 27, 2015 10:36 am
Location: Melbourne, Australia
Contact:

Re: Auto-launch arm-none-eabi-gdb after upload script

Post by RogerClark » Wed Jun 10, 2015 1:46 am

Martin

There is a defined in boards.txt which enabled the SWD pins.

On the Maple mini builds, SWD will be off by default.

Do you have this set in the upload flags

-DCONFIG_MAPLE_MINI_NO_DISABLE_DEBUG=1

Edit.

Rick we posted at virtually the same time .. (you just beat me ;0)

User avatar
martinayotte
Posts: 1222
Joined: Mon Apr 27, 2015 1:45 pm

Re: Auto-launch arm-none-eabi-gdb after upload script

Post by martinayotte » Wed Jun 10, 2015 2:02 am

Rick Kimball wrote:It is because the maple mini disables the SWD pins.
[...]
The better solution is to delete this code and never use the SWD pins except for debugging.
Oh ! I didn't know ... Thanks for the hint ! ;)
Yes, you're right ! that #define should be inverted and been rename PARANOIAC_DEBUG_DISABLE ... :)

EDIT: I've recompile my sketch, and it is now working on my Maple Mini ! :)
(I was lucky that this disableDebugPorts() wasn't called by default under F4, otherwise I will have scratch my head about this)

victor_pv
Posts: 1654
Joined: Mon Apr 27, 2015 12:12 pm

Re: Auto-launch arm-none-eabi-gdb after upload script

Post by victor_pv » Wed Jun 17, 2015 3:25 am

To launch Texane and GDB in Windows after DFU upload, I modified my platform.txt file to have a new Upload option that is copied from the DFU one, except this last line:

Code: Select all

tools.maple_upload_gdb.upload.pattern="{path}/{cmd}" {serial.port.file} {upload.altID} {upload.usbID} "{build.path}/{build.project_name}.bin" "{runtime.ide.path}/hardware/tools/gcc-arm-none-eabi-4.8.3-2014q1/bin/arm-none-eabi-gdb" "{build.path}/{build.project_name}.elf"
That is to pass the parameters to the maple_upload.bat file, which in turn has now this content:

Code: Select all

@echo off
rem: Note %~dp0 get path of this batch file
rem: Need to change drive if My Documents is on a drive other than C:
set driverLetter=%~dp0
set driverLetter=%driverLetter:~0,2%
%driverLetter%
cd %~dp0
java -jar maple_loader.jar %1 %2 %3 %4
set str=%6
set str=%str:/=\%
start texane-stlink\st-util.exe
start "GDB" %5 %str% -ex "tar ext :4242"
It seems to work fine in my case. It launches Texane and then GDB which connects to Texane and opens the file. GDB gives me some error about not being able to open something, but it does open the .elf file correctly.
I have not had time to test this much, and don't have time to post all the details right now.
In my case I created a new option in the boards menus, then a new option in platform.txt, and then a new maple upload gdb.bat file, so I can upload with this option, or use the old one without GDB, but you can just modify your originals and ignore GDB or close it right away, which is what I normally do most of the time as I don't actually need it.

User avatar
martinayotte
Posts: 1222
Joined: Mon Apr 27, 2015 1:45 pm

Re: Auto-launch arm-none-eabi-gdb after upload script

Post by martinayotte » Wed Jun 17, 2015 7:54 pm

Thanks, Victor !

I will check that when I get chance and I will linuxify the script ... ;)

Ciao !

victor_pv
Posts: 1654
Joined: Mon Apr 27, 2015 12:12 pm

Re: Auto-launch arm-none-eabi-gdb after upload script

Post by victor_pv » Thu Jun 18, 2015 2:37 pm

Have a look at what Rick did with launching GDB for BlackMagic probe, as I mostly based this off of what he posted.
I haven't had much time to play with GDB lately, but I really wish it was rather a graphical application :(

User avatar
martinayotte
Posts: 1222
Joined: Mon Apr 27, 2015 1:45 pm

Re: Auto-launch arm-none-eabi-gdb after upload script

Post by martinayotte » Thu Jun 18, 2015 2:44 pm

Me too I wish to have some GDB GUI soon, because I'm a bit rusty with gdb cmdline. :?

User avatar
martinayotte
Posts: 1222
Joined: Mon Apr 27, 2015 1:45 pm

Re: Auto-launch arm-none-eabi-gdb after upload script

Post by martinayotte » Thu Jun 18, 2015 2:46 pm

BTW, folks, just to let you know, I've played with openocd with STLink, and I decided to try it also on my LPC1768.
After struggling to get the initial reset, I got it to work ! So, I can debug my LPC1768 too ! :)

michael_l
Posts: 337
Joined: Mon Aug 24, 2015 6:11 pm

Re: Auto-launch arm-none-eabi-gdb after upload script

Post by michael_l » Mon Aug 31, 2015 8:44 pm

Rick: Could you share your scripts for auto upload & start debugging. Thanks. Also thanks for great tutorial.

On the other thread http://www.stm32duino.com/viewtopic.php?f=29&t=522 I am trying to get Eclipse debugging working using win32 and openocd with ST-link on nucleo board. It works perfectly and is easy to setup with GNU ARM plugins. IDE does all the magic with GNU OpenOCd plugin to connect to target and provide scripts for gdb too. The only and very very annoying problem is that the IDE can't find the source for .ino! Lol. It can find sources for everything else that I've tested. I'd be really grateful to hear comments if you have ideas what to try next. I just feel I'm so close I don't want to give up yet. Seeing your screenshot with .ino source gave me some more motivation to continue. Ok it was in Linux but anyway ... :-) Thanks.
Last edited by michael_l on Mon Aug 31, 2015 8:49 pm, edited 1 time in total.

User avatar
Rick Kimball
Posts: 1014
Joined: Tue Apr 28, 2015 1:26 am
Location: Eastern NC, US
Contact:

Re: Auto-launch arm-none-eabi-gdb after upload script

Post by Rick Kimball » Mon Aug 31, 2015 8:48 pm

Did you try adding the directory where the .ino lives to your gdb search path?

At the gdb prompt, you can add to the file search directory using the "directory" command. Here I add the sketch directory blink_std ... where /mnt/vbox/shared/Arduino_STM32RK_Sketch is the setting of my arduino sketch preference:

Code: Select all

(gdb) directory
Source directories searched: $cdir:$cwd
(gdb) directory /mnt/vbox/shared/Arduino_STM32RK_Sketch/blink_std
Source directories searched: /mnt/vbox/shared/Arduino_STM32RK_Sketch/blink_std:$cdir:$cwd
(gdb) list setup
17      // the setup function runs once when you press reset or power the board
18      void setup() {
19        // initialize digital pin 13 as an output.
20        pinMode(PC13, OUTPUT);
21      }
22
23      // the loop function runs over and over again forever
24      void loop() {
In the eclipse debugger, I thought it told you when it couldn't find the file and gives you an option to find the file by clicking on a link that lets you file manager browser for it, no?

-rick
Last edited by Rick Kimball on Mon Aug 31, 2015 10:04 pm, edited 4 times in total.
-rick

User avatar
Rick Kimball
Posts: 1014
Joined: Tue Apr 28, 2015 1:26 am
Location: Eastern NC, US
Contact:

Re: Auto-launch arm-none-eabi-gdb after upload script

Post by Rick Kimball » Mon Aug 31, 2015 9:06 pm

michael_l wrote:Rick: Could you share your scripts for auto upload & start debugging. Thanks. Also thanks for great tutorial.
I've diverged from the mainstream stm32duino significantly. I'm sure my stuff wouldn't work with the current source. I don't use any of the scripts that facilitate the usb reset stuff, or have any support for the bootloader. I actually ripped out everything except the boards I have. Unfortunately, I got rid of the debugging when used with the stlink device and only have it setup for BMP now.

If you want to see what I do for debugging, you can look at my github:

https://github.com/RickKimball/stm32dui ... al/stm32f1

There is no stm32f103rb stuff, just the stm32f103c8t6 and the maple mini. I was trying to pare down the code to only the stuff I use. Sorry.

However, with my setup it does find the .ino file and list it in gdb. : ) .. probably because of my extremely long ass gdb command:

https://github.com/RickKimball/stm32dui ... m.txt#L149

Code: Select all

tools.bmp_gdb_upload.upload.pattern=xterm -e "{path}{cmd}" -q -cd "{build.path}" -b {upload.speed} {upload.verbose} -ex "set debug remote 0" -ex "set target-async off" -ex "set remotetimeout 60" -ex "set mem inaccessible-by-default off" -ex "set confirm off" -ex "set height 0" -ex "target extended-remote {serial.port}" -ex "monitor swdp_scan" -ex "attach 1" -ex "x/wx 0x8000004" -ex "monitor erase_mass" -ex "echo 0x8000004 expect 0xffffffff after erase\n" -ex "x/wx 0x8000004" -ex "file {build.project_name}.elf" -ex "load" -ex "x/wx 0x08000004" -ex "directory {sketchbook.path}" -ex "tbreak setup"
Oh yeah, and I only care about linux.

-rick
Last edited by Rick Kimball on Tue Sep 08, 2015 3:59 am, edited 1 time in total.
-rick

Post Reply