I'm still playing with my domesticated ER-X to try and see whether I can divert the limited accounting features of the mt7621 to acquire accurate netflow metrics.
Since I'm a total n00b to Linux networking, I'd like to be able to debug the code in action, to which end I'm trying to set up JTAG debugging on the ER-X, which in turn has been a little bit of an ordeal.
The JTAG port on the ER-X is the standard MIPS EJTAG pinout:
Pin | Signal | Signal | Pin |
---|---|---|---|
1 | nRST | GND | 2 |
3 | TDI | GND | 4 |
5 | TDO | GND | 6 |
7 | TMS | GND | 8 |
9 | TCK | GND | 10 |
11 | nSRST | 12 | |
13 | DINT | 3.3V | 14 |
though I haven't tried wiring up the DINT pin.
After some kerfuffle, I managed to get nice, speedy JTAG communication going through an inexpensive Adafruit FT232H board using the config file I found in this article.
This gave me the ability to reset the ER-X, to halt and resume, read registers and memory a bit of a ways into the boot of the Linux kernel. It turns out that the Linux kernel stomps the JTAG pins into GPIO mode because of this stanza in the device tree file:
&state_default {
gpio {
groups = "uart2", "uart3", "pcie", "jtag";
function = "gpio";
};
};
Removing the "jtag" allows me to debug the kernel past that point, but then I would get "spontaneous" reboots after I hung out for a bit on a break. Well, that's the watchdog doing its job as per another device tree entry:
wdt: watchdog@100 {
compatible = "mediatek,mt7621-wdt";
reg = <0x100 0x100>;
mediatek,sysctl = <&sysc>;
};
Now, having turned both of those down, I'm having another problem that's likely an OpenOCD issue, though I may well be holding it wrong.
The problem is that I can set breakpoints with gdb and I'll hit them just fine. If I then remove the breakpoint and continue, all is well.
However, if I step or continue without removing the breakpoint, I get stuck, and gdb keeps breaking at the same address each time I try to continue.
I've tried using hardware breakpoints, which doesn't change anything, though I suspect OpenOCD is using a software breakpoint on the successor instruction whether on step or continue. I've started digging into the OpenOCD sources to try and figure out what's going on, but this feels like a bit of an ordeal, and I'm hoping someone here can point me at how I'm holding it wrong .