Home › Forums › snickerdoodle › • General › Debugging via JTAG
Tagged: JTAG
-
AuthorPosts
-
-
Hi Guys.
I’m trying to track down what appears to be a kernel-space bug. I tried using the console-based kernel gdb facility, but of course the console stops working when the problem occurs. Now I’m trying to establish a GDB connection through a JTAG (Digilent JTAG-HS3) cable. Here’s what I’ve done:
- (Establish VirtualHere (IP over USB) connection – only required for VM, but included here for completeness).
- Run Xilinx hw_server
- Note the URL in the “connect to” message.
- Run xsdb
- Connect
xsdb% connect -url <URL from step 2 above> - List JTAG targets
xsdb% jtag targets
1 Digilent JTAG-HS3 210299B71583 (closed) - Select jtag target
xsdb% jtag targets 1 - Attempt to open target
xsdb% jtag targets -open
sync failed: got 2: fa aa iteration 0
- Connect
And that’s all she wrote. The failure details occasionally vary. I’ve tried looking the other way and running “xsdbserver start,” but gdb reports a timeout when trying to connect via the “target remote” command.
Is there some magic I’m missing? Is it the USB plumbing? Do I have to prepare the Zynq in some way before it will talk over the JTAG connection?
The board is currently in the state that I need to investigate, so I don’t want to reset/restart anything if at all possible.
Thanks,
-Nick
-
Nick,
If I’m understanding correctly, you’re looking for JTAG over USB? If so, the current snickerdoodle firmware isn’t running the Xilinx Virtual Cable (XVC) stack. We’ve experimented with that, but ran into some constraints on the microcontroller. Do you have JTAG (from J2) exposed on your PCBA? If not, that will make JTAG debugging…tricky.
-Ryan
-
Hi Ryan.
No, I’m using a Digilent JTAG-HS3 connected to our baseboard, which exposes the Zynq JTAG signals from connector J2. I’ve used a similar setup previously with the Vivado ILA, but never with GDB.
Documentation is scarce, and I’m not sure I’ve taken all the steps required, or if there’s a communication problem.
Thanks,
-Nick
-
Ah, sorry I misunderstood your original post. I see now. That’s not something we’ve ever tried and I don’t see any documentation showing it’s supported by the tools. This would typically be done via Ethernet, but we can poke around a bit to see what we can find.
-
Unfortunately, I’m not sure this will ever work… GDB requires a server to be running on the target and is really meant for network-based debugging: https://docs.kernel.org/dev-tools/gdb-kernel-debugging.html
I’m guessing you already referenced this Xilinx documentation: https://docs.xilinx.com/r/en-US/ug1400-vitis-embedded/Debugging-an-Application-on-Hardware-Using-GDB
This isn’t really for kernel debugging, though. Did you find something suggesting this was supported or was it more something you were experimenting with?
-RC
-
Hi Ryan.
The GDB server is provided by xsdb, which connects to hw_server, which connects to the JTAG cable. Or at least that’s how I think it’s supposed to work. Unfortunately, xsdb won’t “open” the Digilent JTAG-HS3, although it lists it as a JTAG target:
xsdb% connect -url TCP:<my server>:3121
tcfchan#2
xsdb% jtag targets
1* Digilent JTAG-HS3 210299B71583 (closed)
xsdb% jtag targets -open
sync failed: got 2: fa aa iteration 0Although trying it just now gave a different result:
xsdb% jtag targets -open
xsdb% jtag targets
1* Digilent JTAG-HS3 210299B71583 (error DR shift through all ones)Although it still won’t show any “targets” (as opposed to “JTAG targets”). It may well be that there is still some piece missing, or that the whole concept is off-target (no pun intended).
What I’m trying to do is interrogate the current state of the kernel, which is currently in its error state and unresponsive to console input. I had previously set up gdb over the console UART, but breaking execution requires that the console be functional (to perform “echo g > /proc/sysrq-trigger”), or knowledge of where the problem lies in order to set a breakpoint.
When the system fails, the console becomes inoperative. The JTAG interface presumably should have the ability to halt processor execution and interrogate registers at the least, but so far that has eluded me as well.
There must be a way to debug the kernel without requiring that the kernel be functional. No?
Thanks,
-Nick
-
Well, it was an adventure. I’ll spare you the details, but I have Vitis up and running and looking at my crashed kernel. Unfortunately, even with an obvious smoking gun, I still can’t figure out exactly where the root cause lies. For fun, here are the call stacks for the two CPUs:
ARM Cortex-A9 MPCore #0 (Suspended)
0x807564d4 __timer_delay(): arch/arm/lib/delay.c, line 50
0x80756530 __timer_const_udelay(): arch/arm/lib/delay.c, line 57
0x80121c2c panic(): kernel/panic.c, line 350
0x80211fdc out_of_memory(): mm/oom_kill.c, line 1108
0x80248c10: mm/page_alloc.c, line 3862
0x80248c10: mm/page_alloc.c, line 4606
0x80248c10 __alloc_pages_nodemask(): mm/page_alloc.c, line 4776
0x80254664: ./include/linux/gfp.h, line 496
0x80254664: ./include/linux/gfp.h, line 509
0x80254664: mm/slab.c, line 1366
0x80254664: mm/slab.c, line 2599
0x80254664: mm/slab.c, line 2971
0x80254664 ____cache_alloc(): mm/slab.c, line 3054
0x80254e18: mm/slab.c, line 3293
0x80254e18: mm/slab.c, line 3311
0x80254e18 kmem_cache_alloc_trace(): mm/slab.c, line 3548
0x801ae0b0: ./include/linux/slab.h, line 556
0x801ae0b0 proc_cgroup_show(): kernel/cgroup/cgroup.c, line 5864
0x802c7c0c proc_single_show(): fs/proc/base.c, line 756
0x80281b18 seq_read(): fs/seq_file.c, line 229
0x8025dd1c __vfs_read(): fs/read_write.c, line 425
0x8025de60 vfs_read(): fs/read_write.c, line 461
0x8025e088 ksys_read(): fs/read_write.c, line 587
0x8025e0ec: fs/read_write.c, line 597
0x8025e0ec __se_sys_read(): fs/read_write.c, line 595
0x80101000 __idmap_text_end()
0x76ec07e6
0x76d097ea
…ARM Cortex-A9 MPCore #1 (Suspended)
0x8010f164 ipi_cpu_stop(): arch/arm/kernel/smp.c, line 644
0x8010fce0 handle_IPI(): arch/arm/kernel/smp.c, line 679
0x8010232c gic_handle_irq(): drivers/irqchip/irq-gic.c, line 399
0x80101a70 __irq_svc(): arch/arm/kernel/entry-armv.S, line 212
0x80586d88 cpuidle_enter_state(): …/arch/arm/include/asm/irqflags.h, line 39
0x80586fa0 cpuidle_enter(): drivers/cpuidle/cpuidle.c, line 344
0x8014ecf0: kernel/sched/idle.c, line 117
0x8014ecf0: kernel/sched/idle.c, line 201
0x8014ecf0 do_idle(): kernel/sched/idle.c, line 263
0x8014eeac cpu_startup_entry(): kernel/sched/idle.c, line 355
0x8010f9c8 secondary_start_kernel(): arch/arm/kernel/smp.c, line 445
0x0010278c
0x0010278cObviously, the “out of memory” and “panic” frames are why things have stopped responding. But how did we get there?
In proc_cgroup_show(), we get as far as calling kmalloc(PATH_MAX, GFP_KERNEL), which is what ends in the OOM condition.
So, something is trying to read 1 KB from…/proc/<pid>/cgroup? And can’t allocate 4 KB to do it?
I’m afraid it’s all a bit above my pay grade. Does anything jump out as particularly significant?
Thanks,
-Nick
-
-
AuthorPosts
- You must be logged in to reply to this topic.