2010-07-22 05:58:30 Debugging applications with gnICE+ JTAG and gdbproxy
Robert Homann (GERMANY)
Message: 91579
Hi!
I have some problems debugging applications running on uClinux with bfin-uclinux-gdb/bfin-linux-uclibc-gdb (using SVN trunk version of toolchain and kernel). We don't have ethernet on our board, and we need both UARTs for our application, so debugging via ethernet or serial connection via gdbserver is, unfortunately, not an option. The only possibility I can see is to use the gnICE+ JTAG and following the instructions found on docs.blackfin.uclinux.org/doku.php?id=toolchain:debug:gdbproxy.
So I've made a simple hello-world program for testing, but I cannot even debug that one. The program was compiled using compiler flags -Wall -mcpu=bf525-0.2 -g -O0.
I am able to start bfin-gdbproxy and to connect to the target. Then,
bfin-uclinux-gdb hello.gdb
(gdb) target remote :2000
The target stops execution. I can continue and hit CTRL+C without a problem (no kernel panics or something like that), so there seems to be no problem with JTAG connection and interaction. When setting a breakpoint on main and running the program manually on the target, however, the breakpoint does not get hit. I don't know if this is to be expected, though...
Then I've tried to upload the program to the target using
(gdb) load hello.gdb
Loading section .text, size 0xf00 lma 0x0
Loading section .data, size 0x190 lma 0xf00
Loading section .eh_frame, size 0x4 lma 0x1090
Start address 0x4, load size 4244
Transfer rate: 1476173 bits/sec, 1414 bytes/write.
(gdb) c
Continuing.
This resulted in a kernel panic:
[ 1118.469000] Kernel OOPS in progress
[ 1118.469000] Deferred Exception context
[ 1118.469000] No Valid process in current context
...
[ 1118.469000] Return addresses in stack:
[ 1118.469000] frame 1 : <0x00799f90> { _init_thread_union + 0x1f90 }
[ 1118.469000] address : <0x00798008> { _init_thread_union + 0x8 }
[ 1118.469000] Modules linked in:
[ 1118.469000] Kernel panic - not syncing: Kernel exception
The message "No Valid process in current context" seems plausible since the program was uploaded behind the kernel's back, as far as I can see. I've tried FLAT, statically linked FDPIC ELF, and dynamically linked FDPIC ELF formats, but they all result in a kernel panic
So, can someone point me in the right direction? What am I doing wrong?
Best regards,
Robert Homann
QuoteReplyEditDelete
2010-07-22 07:57:18 Debugging applications with gnICE+ JTAG andgdbproxy
Michael Hennerich (GERMANY)
Message: 91582 Debugging User Space Applications via gdbproxy/JTAG is not supported.
JTAG debugging is typically used for bare metal apps (without OS) or for kernel
debugging.
QuoteReplyEditDelete
2010-07-22 09:51:07 Debugging applications with gnICE+ JTAGandgdbproxy
Michael Hennerich (GERMANY)
Message: 91584 Mike,
Do you think it is possible to use gdbserver with the JTAG tty?
(CONFIG_BFIN_JTAG_COMM)
In case this works you can debug user apps using gdbserver and connect via the JTAG tty.
-Michael
QuoteReplyEditDelete
2010-07-22 09:57:21 Re: Debugging applications with gnICE+ JTAGandgdbproxy
Robin Getz (UNITED STATES)
Message: 91586
Michael:
That was one of the reasons to do it - it's just a little poky (slow) - but it appears to work.
-Robin
QuoteReplyEditDelete
2010-07-22 10:04:08 Re: Debugging applications with gnICE+JTAGandgdbproxy
Michael Hennerich (GERMANY)
Message: 91588 Thanks - might be worth adding some "debug userspace apps via JTAG tty" notes to the wiki.
QuoteReplyEditDelete
2010-07-22 11:21:37 Re: Debugging applications with gnICE+JTAGandgdbproxy
Robert Homann (GERMANY)
Message: 91594
Thanks - might be worth adding some "debug userspace apps via JTAG tty" notes to the wiki. ---
Yes, some documentation on JTAG console debugging would be very useful indeed. Even if it's slow, it would better than nothing.
How I am supposed to connect with bfin-uclinux-gdb?
After starting gdbserver on the Blackfin's /dev/ttyBFJC0, should I run just bfin-gdbproxy and connect to port 2001?
Thanks so far.
Best regards,
Robert Homann
QuoteReplyEditDelete
2010-07-22 14:41:30 Re: Debugging applications with gnICE+JTAGandgdbproxy
Robin Getz (UNITED STATES)
Message: 91607
Robert:
https://docs.blackfin.uclinux.org/doku.php?id=linux-kernel:drivers:jtag-console
It provides a tty - so either run ppp, (I'm not sure if connectting with gdbserver will work or not - have not tried -- Mike?)
-Robin
QuoteReplyEditDelete
2010-07-22 18:35:04 Re: Debugging applications with gnICE+JTAGandgdbproxy
Mike Frysinger (UNITED STATES)
Message: 91621
i havent toyed with ppp over the jtag port yet. i imagine it'll take a bit of tinkering to figure out the right settings.
QuoteReplyEditDelete
2010-07-22 18:36:47 Re: Debugging applications with gnICE+ JTAG and gdbproxy
Mike Frysinger (UNITED STATES)
Message: 91622
if you have enough spacefor JTAG, then you should look at this project:
blackfin.uclinux.org/gf/project/stamp/frs/?action=FrsReleaseBrowse&frs_package_id=159
it's an example breakout board so you just have to bring out the pins for peripherals to a small surface connector and then a ribbon connected to the other side allows easy access to things like unused UART, JTAG, and SPI (and you can do ethernet over SPI).
QuoteReplyEditDelete
2010-07-26 10:07:06 Re: Debugging applications with gnICE+JTAGandgdbproxy
Robert Homann (GERMANY)
Message: 91730
So I've had some limited success running gdbserver over the Linux JTAG console.
My toolchain is trunk r4735 now. I first started bfin-gdbproxy, followed by gdb (as suggested by the output of gdbproxy) as follows:
$ bfin-uclinux-gdb
(gdb) set remotetimeout 999999
(gdb) target remote :2000
(gdb) continue
and left both programs alone. Then, I started the actual debugging session:
$ bfin-uclinux-gdb hello_uclinux_static.gdb
(gdb) set remotetimeout 999999
(gdb) target remote localhost:2001
Remote debugging using localhost:2001
I'm not sure if it is supposed to work this way, though. On the Blackfin I started gdbserver to use the JTAG console like this:
$ gdbserver /dev/ttyBFJC0 ./hello_uclinux_static
allowing the second gdb to continue:
_stext () at libc/sysdeps/linux/bfin/crt1.S:84
84 FP = 0;
Current language: auto; currently asm
(gdb) break main
Breakpoint 1 at 0x2b04160: file hello.c, line 5.
(gdb) cont
Continuing.
The program seems to continue running, but then I see checksum errors on the Blackfin side:
Bad checksum, sentsum=0x22, csum=0x20, buf=X2b04160,4:���
Bad checksum, sentsum=0x22, csum=0x9f, buf=X2b04160,4:!���
Bad checksum, sentsum=0x22, csum=0x9f, buf=X2b04160,4:!���
Bad checksum, sentsum=0x22, csum=0x9f, buf=X2b04160,4:!���
Nothing is happening thereafter (I've waited more than 10 minutes).
This is better than before, but then I've never tried running two gdb instances before. And now I'm stuck again.
Can I do anything to make gdbserver work over the JTAG console?