Author Topic: Need help with Linux avr-gdb and C::B  (Read 9054 times)

Offline twgray

  • Multiple posting newcomer
  • *
  • Posts: 30
Need help with Linux avr-gdb and C::B
« on: August 08, 2011, 05:35:41 am »
I have done a search and found no resolutions to my problems, so I'll ask directly:

How do i set up to debug using avr-gdb and Linux C::B?  I have followed directions given various places on the web.  I am using the latest nightly debug builds from:

deb http://apt.jenslody.de/ any dbg and
deb-src http://apt.jenslody.de/ any dbg

and have gotten C::B to use avarice to create the files and program the device with:

Code: [Select]
avr-size $(TARGET_OUTPUT_FILE)
avr-objcopy -O ihex -R .eeprom -R .eesafe $(TARGET_OUTPUT_FILE) $(TARGET_OUTPUT_FILE).hex
avr-objcopy -O binary -R .eeprom -R .eesafe $(TARGET_OUTPUT_FILE) $(TARGET_OUTPUT_FILE).bin
avarice -1 -P atmega169  -e -p -f $(TARGET_OUTPUT_FILE).hex -j /dev/ttyUSB0
avr-objcopy --no-change-warnings -j .eeprom --change-section-lma .eeprom=0 -O ihex $(TARGET_OUTPUT_FILE)  $(TARGET_OUTPUT_FILE).eep.hex
avr-objcopy -O binary -R .eeprom -R .eesafe $(TARGET_OUTPUT_FILE)  $(TARGET_OUTPUT_FILE).bin
avr-objcopy --no-change-warnings -j .eeprom --change-section-lma .eeprom=0 -O binary $(TARGET_OUTPUT_FILE) $(TARGET_OUTPUT_FILE).eep.bin

placed in the Post-build steps of the Projects Build Options.  I am using an older MK1 Jtag debugger. These are the results from the build:

Code: [Select]

-------------- Clean: Debug in lcd-test ---------------

Cleaned "lcd-test - Debug"

-------------- Build: Debug in lcd-test ---------------

Compiling: lcd_driver.c
In file included from lcd_driver.c:13:
/usr/lib/gcc/avr/4.3.5/../../../avr/include/avr/signal.h:36:2: warning: #warning "This header file is obsolete.  Use <avr/interrupt.h>."
Compiling: lcd_functions.c
Compiling: main.c
Linking console executable: bin/Debug/lcd-test.elf
Output size is 14.50 KB
Running target post-build steps
avr-size bin/Debug/lcd-test.elf
   text    data     bss     dec     hex filename
   1784       2      51    1837     72d bin/Debug/lcd-test.elf
avr-objcopy -O ihex -R .eeprom -R .eesafe bin/Debug/lcd-test.elf bin/Debug/lcd-test.elf.hex
avr-objcopy -O binary -R .eeprom -R .eesafe bin/Debug/lcd-test.elf bin/Debug/lcd-test.elf.bin
avarice -1 -P atmega169  -e -p -f bin/Debug/lcd-test.elf.hex -j /dev/ttyUSB0
AVaRICE version 2.10, Feb  8 2010 07:22:18
Defaulting JTAG bitrate to 250 kHz.
JTAG config starting.
Hardware Version: 0xc2
Software Version: 0x7b
Reported JTAG device ID: 0x0
Configured for device ID: 0x9405 atmega169 -- FORCED with atmega169
JTAG config complete.
Erasing program memory.
Erase complete.
Downloading FLASH image to target...
.
..
.
.
.
.
..
.
..
Download complete.
avr-objcopy --no-change-warnings -j .eeprom --change-section-lma .eeprom=0 -O ihex bin/Debug/lcd-test.elf  bin/Debug/lcd-test.elf.eep.hex
avr-objcopy -O binary -R .eeprom -R .eesafe bin/Debug/lcd-test.elf  bin/Debug/lcd-test.elf.bin
avr-objcopy --no-change-warnings -j .eeprom --change-section-lma .eeprom=0 -O binary bin/Debug/lcd-test.elf bin/Debug/lcd-test.elf.eep.bin
Process terminated with status 0 (0 minutes, 6 seconds)
0 errors, 1 warnings (0 minutes, 6 seconds)


I then open avarice in a seperate console:

Code: [Select]
avarice -1 -P atmega169 -j /dev/ttyUSB0 localhost:4242
AVaRICE version 2.10, Feb  8 2010 07:22:18

Defaulting JTAG bitrate to 250 kHz.

JTAG config starting.
Hardware Version: 0xc2
Software Version: 0x7b
Reported JTAG device ID: 0x0
Configured for device ID: 0x9405 atmega169 -- FORCED with atmega169
JTAG config complete.
Preparing the target device for On Chip Debugging.

Disabling lock bits:
  LockBits -> 0xff

Enabling on-chip debugging:
  Extended Fuse byte -> 0xff
      High Fuse byte -> 0x18
       Low Fuse byte -> 0xe2
Waiting for connection on port 4242.

I have the Project Properties Debugger Settings set to:  Connection type: Serial Port, Serial port: /dev/ttyUSB0, Baud: 115200, IP address: localhost, Port: 4242

I then invoke the debugger by pressing Continue, and get the following in the Debugger window:

Code: [Select]
Building to ensure sources are up-to-date
Build succeeded
Selecting target:
Debug
Adding source dir: /home/twgray/Software-Projects/AVR/lcd-test/
Adding source dir: /home/twgray/Software-Projects/AVR/lcd-test/
Adding file: bin/Debug/lcd-test.elf
Starting debugger:
done
Registered new type: wxString
Registered new type: STL String
Registered new type: STL Vector
Setting serial connection speed to 115200
Connecting to remote target
Setting breakpoints
Debugger name and version: GNU gdb 6.4
Connected
The program is not being run.
Debugger finished with status 0


and this in the Debugger log window:

Code: [Select]
LD_LIBRARY_PATH=.:
Command-line: /usr/bin/avr-gdb -nx -fullname  -quiet -args bin/Debug/lcd-test.elf
Working dir : /home/twgray/Software-Projects/AVR/lcd-test/
(gdb)
> set prompt >>>>>>cb_gdb:
Executing: xterm -T 'Program Console' -e sleep 92194
>>>>>>cb_gdb:
> show version
GNU gdb 6.4
Copyright 2005 Free Software Foundation, Inc.
GDB is free software, covered by the GNU General Public License, and you are
welcome to change it and/or distribute copies of it under certain conditions.
Type "show copying" to see the conditions.
There is absolutely no warranty for GDB.  Type "show warranty" for details.
This GDB was configured as "--host=i486-linux-gnu --target=avr".
>>>>>>cb_gdb:
> set confirm off
>>>>>>cb_gdb:
> set width 0
>>>>>>cb_gdb:
> set height 0
>>>>>>cb_gdb:
> set breakpoint pending on
>>>>>>cb_gdb:
> set print asm-demangle on
>>>>>>cb_gdb:
> set unwindonsignal on
>>>>>>cb_gdb:
> set disassembly-flavor intel
No symbol "disassembly" in current context.
>>>>>>cb_gdb:
> catch throw
Function "__cxa_throw" not defined.
>>>>>>cb_gdb:
> source /usr/share/codeblocks/scripts/stl-views-1.0.3.gdb
>>>>>>cb_gdb:
> break main


Breakpoint 1 at 0x6ac: file main.c, line 33.
>>>>>>cb_gdb:Breakpoint 2 at 0x6ac: file main.c, line 33.
> directory /home/twgray/Software-Projects/AVR/lcd-test/
>>>>>>cb_gdb:Breakpoint 3 at 0x6ac: file main.c, line 33.
> set remotebaud 115200
>>>>>>cb_gdb:>>>>>>cb_gdb:
> target remote /dev/ttyUSB0
>>>>>>cb_gdb:
> break main
Executing: ps x -o tty,pid,command
PS result: ?        12830 ps x -o tty,pid,command
PS result: pts/1    12829 sleep 92194
TTY is[/dev/pts/1]
GetConsoleTTY[/dev/pts/1]ConsolePid[12827]
Queued:[tty /dev/pts/1]
Malformed response to offset query, timeout
Ignoring packet error, continuing...
Ignoring packet error, continuing...
Ignoring packet error, continuing...
>>>>>>cb_gdb:Breakpoint 4 at 0x6ac: file main.c, line 33.
> tty /dev/pts/1
>>>>>>cb_gdb:
> continue
>>>>>>cb_gdb:
The program is not being run.
>>>>>>cb_gdb:
> quit

At no point did avr-gdb actually connect to avarice running in the second console.

Any ideas what I am doing wrong...or leaving out?

Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 12067
    • Travis build status
Re: Need help with Linux avr-gdb and C::B
« Reply #1 on: August 08, 2011, 09:32:43 am »
What is the type of project you're using?
Have you tried to connect using command line gdb?
Are your versions of gdb and gdbserver the same?
(most of the time I ignore long posts)
[strangers don't send me private messages, I'll ignore them; post a topic in the forum, but first read the rules!]

Offline scarphin

  • Lives here!
  • ****
  • Posts: 644
Re: Need help with Linux avr-gdb and C::B
« Reply #2 on: August 08, 2011, 10:52:11 am »
I'm not a linux guru but according to this:
Quote
Connection type: Serial Port, Serial port: /dev/ttyUSB0, Baud: 115200, IP address: localhost, Port: 4242
u are trying to connect to serial port directly. U have to connect to the 'gdb server' which is 'avarice' in this case. Try setting connection type to 'TCP'.

Offline twgray

  • Multiple posting newcomer
  • *
  • Posts: 30
Re: Need help with Linux avr-gdb and C::B
« Reply #3 on: August 08, 2011, 05:36:43 pm »
Thanks, scarphin, that was the solution.  Selecting TCP fixed the connection issue.  Joy!!!

I think I will write YA HowTo go capture all this for posterity.  I love C::B.  I was a diehard Slickedit zealot for years, even though it wasn't open or free, but I have been using C::B for about 4 years now for Linux, Windows, and OSX cross-platform application development.  Now if I could just get C::B to debug Microchip PIC's I'd never use anything else.

If the developers read this stuff, Thanks for all the hard work and such a great tool.

Offline scarphin

  • Lives here!
  • ****
  • Posts: 644
Re: Need help with Linux avr-gdb and C::B
« Reply #4 on: August 08, 2011, 05:54:15 pm »
An advice I can give u is to use 'avrdude' instead of 'avarice' to program. Well at least that's better on win, I haven't tried how well they go on linux yet.

And for the PIC part, as far as I know there isn't any free or open source 'gdb server' that supports some 'gdb-like' (i.e. sdcdb) which CB can be configured to work with. So it seems utopia for now. U may want to check this though:
http://openprog.altervista.org/pdb_eng.html

Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 12067
    • Travis build status
Re: Need help with Linux avr-gdb and C::B
« Reply #5 on: August 08, 2011, 06:20:50 pm »
If you interested you can write your own debugger plugin, which can drive a non-gdb like debugger.
This is only possible in the debugger_branch, which hopefully will be merged in trunk, some day (when it is ready of course:) )
(most of the time I ignore long posts)
[strangers don't send me private messages, I'll ignore them; post a topic in the forum, but first read the rules!]