Remote debugging involves running a gdb server on the AVR32 target board, and a gdb debugger on a desktop machine. I will only cover debugging using TCP/IP (ethernet) connections.
First, you will need the gdbserver application loaded onto the AVR32 board. You can find the sources for gdbserver in the BSP 2.0 package. The source is in the following directory: gdb/gdb/gdbserver. You can build it like this:
./configure --host=avr32-linux --prefix=/usr/avr32-linux PKG_CONFIG_PATH=/usr/avr32-linux/lib/pkgconfig
make
Copy the executables to your AVR32 board. Now you are ready to debug.
Now make sure the application you intend to debug is compiled with debugging symbols by using
CFLAGS="-O0 -g3 -I/usr/avr32-linux/include"
or whatever ./configure options you have available.
Start the gdb server on the AVR32 board using a serial console or ssh. Start it like this:
gdbserver 10.0.0.1:12345 buggyprog
With 10.0.0.1 being the IP address of the AVR32 board. You will see the following output:
Process buggyprog created; pid = 448
Listening on port 12345
Now, from your desktop machine, you can run avr32-linux-gdb. Run it from within the source directory of "buggyprog". You will see the message
Remote debugging from host 10.0.0.22
when you have successfully connected. Run it like so:
gdb programname
(Optional) If you want to step into shared libraries explicitly loaded by your program with dlopen at runtime, tell gdb where to find them with a command like set solib-search-path /usr/avr32-linux/lib
Tell gdb to connect to the remote gdbserver: target remote 10.0.1.1:1234
Then set a breakpoint, e.g. break main
and continue execution: cont
You can also use a graphical debugger like kdbg, by doing the following. First, you must start kdbg from within the source directory like this: kdbg -r 10.0.1.1:1234 buggyprog
Then click Settings->Global Options and enter avr32-linux-gdb --fullname --nx
into the text box for "How to invoke gdb".
Remote debugging with AVR32Studio (a.k.a. Eclipse CDT)
Setting up the target
1. Make sure your AVR32 board has a user setup with the password set to be able to login succesfully using dropbear (ssh)
2. Make sure uClibc is compiled with debugging options enabled
3. Make sure that the application you intend to debug is compiled with debugging symbols and has not been stripped.
Setting up the debugging IDE (Eclipse)
1. Click Window->Open Perspective->Other
2. Select Debug
3. Click Window->Show View->Other
4. Select C/C++ Projects
5. In the Projects pane right-click and select New->Project
6. Click Standard Make AVR32 C/C++ Project
7. Name the project, select the proper MCU type, and AVR32 Linux Executable
8. Right-click the newly created project in the project pane and select Import
9. Select General->Filesystem
10. Navigate to the project folder you want to debug
11. Check the project box and select Create complete folder structure, click finish
12. From the menu bar, click Run->Debug
13. Right click C/C++ Remote Application and select New
14. Under the Main tab, click the New Connection button.
15. Select AVR32 Linux and click Next
16. give the connection a meaningful name and enter the hostname or IP address of the target
17. Click Next and then click Finish
18. in the Main tab, click the Search Project button and select the binary you want to debug.
19. In the Remote Path for C/C++ Executable, enter the path to the executable on the target
20. Check the box Skip download to target path if you don't want to download the file over ftp before debugging.
21. Under the Arguments tab enter any command line arguments to pass to the executable on startup
22. Under the Debugger tab, in the Main tab enter avr32-linux-gdb. Make sure that the location of avr32-linux-gdb is in your path (i.e. /usr/bin)
23. Click the Apply button below, then click Debug.
24. Eclipse will upload the binary to the target using FTP (if you chose to do so) and then login using SSH to start the gdbserver on the target.
25. After the gdbserver starts, the source pane will open up to the main() entry point in the source code.
26. You are now debugging!