User forums > Embedded development

Using C:B to debug an AVR with an Atmel jtag mkII, nearly succeding - help

(1/1)

ekh:
First thanks for a fantastic program of high quality :-)

After hours of surfing and work to get C:B working as an AVR development environment I am nearly succeding.

My system:
A PC running Ubuntu Gutsy
latest C:B in Ubuntu repository : svn 5020
An Atmel AVR JTAG MkII
A self developed AVR board with an AT90CAN128.
gcc version 4.1.2
GNU gdb 6.4
AVaRICE version 2.6, Jul 20 2007 11:53:13

I can generate a project example with a small program and compile it, the program is running a flashing LED.

I can program the processor fuses with the command

avarice -2 -r -B 125Khz -W eehhll -j usb ( ee extended buse byte, hh high fuse byte, ll low fuse byte )

$ avarice -2 -r -B 125Khz -W fd39ce -j usb

I can flash the AVR program made by C:B with the command:

$ avarice -2 -P at90can128 -e -p -f can_io.bin -v -j usb

And I can debug the program, first starting avarice in one terminal and avr-gdb in another:

$ avarice -2 -P at90can128 -B 4Mhz -j usb localhost:4242
AVaRICE version 2.6, Jul 20 2007 11:53:13

JTAG config starting.
Found a device: JTAGICEmkII
Serial number:  00:a0:00:00:06:5d
Reported JTAG device ID: 0x9781
Configured for device ID: 0x9781 at90can128 -- Matched with at90can128
JTAG config complete.
Preparing the target device for On Chip Debugging.

Disabling lock bits:
  LockBits -> 0xff

Enabling on-chip debugging:
  Extended Fuse byte -> 0xfc
      High Fuse byte -> 0x39
       Low Fuse byte -> 0xce
Waiting for connection on port 4242.

and in the other terminal:

$ avr-gdb can_io.elf
(gdb) target remote localhost:4242
(gdb) break main
Breakpoint 1 at 0x188: file ../main.cpp, line 12.
(gdb) continue
Continuing.

Breakpoint 1, main () at ../main.cpp:12
12         a = 2;
(gdb)  continue
Continuing.

<\ctrl-c> key pressed to interrupt the program, which runs as expected

Program received signal SIGINT, Interrupt.
0x00000104 in delay_us (us=33675) at ../delay.cpp:10
10              for ( count = 0; count < us; count ++ )
(gdb) q
The program is running.  Exit anyway? (y or n) y
[1]+  Killed                  avr-gdb can_io.elf
$


So no issues so far.


In codeblocks I use this setup for the debugger:

target remote localhost:4242
load
break main
continue

and the "Do not run the debugee" is checked.

When I activate the debugger in codeblocks, the avarice terminal responds:

Connection opened by host 127.0.0.1, port 59395.

The debugger tab shows:

Building to ensure sources are up-to-date
Build succeeded
Selecting target:
Debug
Adding source dir: /home/ekh/develop/conlog/can_io/sw/trunk/can_io/
Adding source dir: /home/ekh/develop/conlog/can_io/sw/trunk/
Adding file: bin/Debug/can_io.elf
Starting debugger:
done
Registered new type: wxString
Registered new type: STL String
Registered new type: STL Vector
Setting breakpoints
Debugger name and version: GNU gdb 6.4
In __vectors () ()


The Debugger (debug) tab shows:

LD_LIBRARY_PATH=.:
Command-line: /usr/bin/avr-gdb -nx -fullname  -quiet -args bin/Debug/can_io.elf
Working dir : /home/ekh/develop/conlog/can_io/sw/trunk/can_io/
(gdb)
> set prompt >>>>>>cb_gdb:
Executing: xterm -T 'Program Console' -e sleep 90014
>>>>>>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:
> target remote localhost:4242
load
break main
continue

Executing: ps x -o tty,pid,command
0x00000000 in __vectors ()


The debugger does not stop at main and show the current location arrow.

After quitting the debugger in codeblocks, the program is no longer present in the AVR.

When terminating a debug session in AVRStudio from atmel, the program is intact for running.

In the manual gdb session the avarice program responded
Connection opened by host 127.0.0.1, port 58839.

In the codeblocks session it responded:
Connection opened by host 127.0.0.1, port 59395

Any ideas to get the debugger work in codeblocks, what am I missing ?

[EDIT] corrected extended fuse byte from 0xFC to 0xFD (no factory test)

mandrav:

--- Quote ---In codeblocks I use this setup for the debugger:

target remote localhost:4242
load
break main
continue
--- End quote ---

Where do you put these? I hope not in the global debugger settings?
In case you missed it, open project's properties and go to the debugger tab.

ekh:

Your fears were true, thanks a lot :-) it brought me one step further.

under "Projects->Properties..." and the debugger tab I now select target debug and the "Remote connection" tab.

I set "IP address:" to "localhost" and set "Port:" to "4242"

Then I select "Additional commands" and put the two lines

break main
continue

in the "After connection:" window.

If I add the "load" the program in the AVR gets lost.

A debug session now started with programming of the AVR from a terminal window:

avarice -2 -P at90can128 -e -p -f can_io.bin -v -j usb

Then

avarice -2 -d -P at90can128 -B 4Mhz -j usb localhost:4242

 
Now I start debug in C:B by clicking the "Debug/Continue" button in the debug toolbar.

Now gdb connects to the avarice server, and I get the terminal message:

Connection opened by host 127.0.0.1, port 52538.


So far so good, but...


if I then Use the buttons:

"Debug/Continue" or "Run to cursor"

a debugger "run" command is issued, and an error generates the message in the "Debugger (debug)" tab:

> run
Don't know how to run.  Try "help target".
>>>>>>cb_gdb:

and the terminal window says:

gdb exited.
[1]+  Killed                  avarice -2 -P at90can128 -B 4Mhz -j usb localhost:4242


I can only run the program with "next line", "Next instruction", "Step into" and "Step out"

Using "Step out" from deeper levels makes me able to run to a breakpoint, but that does not work in main, so I renamed the main() function to main1() and called main1 from the new main, this is a workaround making debugging more practical ( it is hard only being able to step ), but it does not work always.

What do I do about that ?

I found two minor issues in C:B:

When I single step the "Next line" by clicking it, I have to move the arrow cursor away from the button before I can click the button again so a single step is performed.

When I pull the border between the "Management" and the "Breakpoints" pane down, then the field below the "Breakpoints" pane, containing the file name, gets covered by the "Breakpoints" pane.

ekh:
I have tried the "Debug->Send user command to debugger", and when I issue "cont" the Debugger does as expected within C:B.

Allow me to suggest this is solved by adding a boolean variable eg. "debug_session_not_yet_executed". The variable is initialized to true.

When clicking on "Debug/Continue" this code is executed:


--- Code: ---if ( debug_session_not_yet_executed )
{
   // issue a "run" command to the debugger
   debug_session_not_yet_executed = false;
}
else
   // issue a "continue" command to the debugger

--- End code ---

when the debug session is terminated, then


--- Code: ---debug_session_not_yet_executed = true;

--- End code ---

As the debug C:B button has the text "Debug/Continue", and the gdb has both a "run" and a "continue" command, and issuing "run" more than once terminates the debug session, then this makes sense to me.

When manually entering "cont" all is fine, clicking  "Debug/Continue" teminates instead of continuing the program.

> cont
Breakpoint 3, main1 () at ../main.cpp:16
/home/ekh/develop/conlog/can_io/sw/trunk/main.cpp:16:166:beg:0xc90
>>>>>>cb_gdb:
> run
Don't know how to run.  Try "help target".
>>>>>>cb_gdb:

And server response:

"gdb exited."

ekh:

Just after making the above post, I tried:

Settings->Compiler and debugger..., "Debugger settings" and unchecked "Do *not* run the debugee"

Now run is only issued the first time :-)

Question:

Is it a property in wxWidgets, that the cursor arrow must be moved from a button before it can be clicked again, This adds to muscle strain when stepping a program.

Navigation

[0] Message Index

Go to full version