Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Interfacing with avr-gdb #6

Closed
felias-fogg opened this issue Nov 29, 2021 · 10 comments · Fixed by #217
Closed

Interfacing with avr-gdb #6

felias-fogg opened this issue Nov 29, 2021 · 10 comments · Fixed by #217
Assignees

Comments

@felias-fogg
Copy link

Hi,

I tried out seer and it worked quite well. Thanks a lot for your work! There are a few hickups when it comes to embedded debugging for AVR MCUs, though.

  1. You cannot specify an alternative gdb executable as already pointed out in issue #3. I changed the source code in order to try it out. Would be great to have a menu for that.

  2. When specifying the executable to be debugged, I specified the ELF file and for the Gdbserver I gave the serial device. With that seer/avr-gdb could make the connection to thze hardware debugger, but I got the following warning:

thread-group-added,id="i1"
GNU gdb (GDB) 8.1.0.20180409-git
...
Warnung: No executable has been specified and target does not support
determining executable automatically.  Try using the "file" command.

thread-created,id="1",group-id="i1"
0x00000000 in ?? ()

So, I issued the file and the load command:

file tiny85blink.ino.elf
A program is being debugged already.
Are you sure you want to change the file? 
(y or n) [answered Y; input not from terminal]
Load new symbol table from "tiny85blink.ino.elf"? (y or n) [answered Y; input not from terminal]
Reading symbols from tiny85blink.ino.elf...

load
Loading section .text, size 0x1e8 lma 0x0
Start address 0x0, load size 488
Transfer rate: 2 KB/sec, 162 bytes/write.

After that I could set breakpoints, start and stop the program etc.

  1. The debugger does not show any file under the list of source or library files. I could manually select the source file, though.

  2. When the debugger ended up in one of the Arduino 'core' files, I could not set a breakpoint (probably something caused by the two control characters in front of the file name):

Keine Zeile 12 in Datei \302\273/home/parallels/.arduino15/packages/ATTinyCore/hardware/avr/1.5.2/cores/tiny/main.cpp\302\253.

If you want to debug things having to do with avr-gdb, I recommend to download the packages gdb-avr (the avr debugger), simavr (an AVR simulator), and, of course, the avr toolchain gcc-avr.

Best regards,
Bernhard

@epasveer
Copy link
Owner

Hi Bernhard,

Thanks for try it out! And, of course, thanks for your very detailed descriptions. To be honest, I've never used gdbserver before. I knew I would have to revisit it eventually.

I'll get to your points hopefully soon.

Thanks again!

@epasveer
Copy link
Owner

Hi Bernhard,

For the "alternate gdb executable" bug, I've fixed that in version 1.0.6.

I will be working on the other problems you mention.

@epasveer epasveer self-assigned this Dec 23, 2021
@felias-fogg
Copy link
Author

Cool, will try it out! My "hardware debugger" for classic AVR ATtinys is meanwhile in state so that people can use it: https://github.com/felias-fogg/dw-link

@epasveer
Copy link
Owner

Wow, almost a year to the day. I'm getting back to this task.

Over the past year, I've learned a lot about 'gdbserver' and some more about embedded development/debugging. I hope to use this time now to resolve this ticket.

If you want to debug things having to do with avr-gdb, I recommend to download the packages gdb-avr (the avr debugger), simavr (an AVR simulator), and, of course, the avr toolchain gcc-avr.

Fantastic advice. I also found this tidbit that should help me.

https://blog.oddbit.com/post/2019-01-22-debugging-attiny-code-pt-1/

So, I issued the file and the load command:

The 'file' command is already there. It's loading the executable and symbol table from the file. Seer does this and has a optional way to load the symbols from a separate file.

The 'load' command is new to me. It appears to download the executable to the remote end. I'll look to implement this as part of the 'connect' mode in Seer.

The debugger does not show any file under the list of source or library files. I could manually select the source file, though.

I'll debug this with the simavr setup.

I could not set a breakpoint (probably something caused by the two control characters in front of the file name):

Those control characters are actually UTF-8 characters. The first one is a visual tab '>>' character. I wonder how your got the filename? Cut-n-Paste? Or was the filename returned by something? I can filter them out. I just need to know where they are coming from.

@epasveer
Copy link
Owner

I got Seer working with simavr and avr-gdb. avr-gdb seems to have an older version of the MI interpreter (the api for frontends to interface with gdb). I'll see if I can work around this. Also, I have to manually enter the 'file' and 'load' commands, too. I'll work on this.

Anyway, a pic.

$ simavr -m attiny85 -f 1000000 pipower.elf  -g
Loaded 2498 bytes at 0
Loaded 6 bytes at 800060
avr_gdb_init listening on port 1234
$ seergdb --gdb-program /usr/bin/avr-gdb --connect :1234

image

@epasveer
Copy link
Owner

Specifying the program name as the symbol file works for seer.

$ seergdb --gdb-program /usr/bin/avr-gdb --connect :1234 --sym pipower.elf

This has the same effect as using the 'file' command.

@epasveer
Copy link
Owner

After playing around for a bit, I discovered the "avr" package that OpenSuse provides is extremely out of date. Especially for the version of gdb that is provided. Many of the "mi" api calls that Seer depends on just don't exist or work.

I posted a question on r/embedded and someone responded with a website that does standalone builds of the "avr" toolchain.

https://www.reddit.com/r/embedded/comments/18uockj/latest_avr_linux_toolchain/
https://blog.zakkemble.net/avr-gcc-builds/

Installing this on my machine works perfectly. Here's a screenshot.

image

@epasveer
Copy link
Owner

It seems "FLAGS" is not available on avr chips. I'll make this optional in the "assembly view".

@epasveer
Copy link
Owner

So the summary is to use an avr toolchain that is recent. Like gcc/gdb version 12 or newer.

https://blog.zakkemble.net/avr-gcc-builds/

@epasveer
Copy link
Owner

epasveer commented Jan 2, 2024

Closing this task. The mainline has been updated.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants