JTAG write to Node Config registers?

Technical questions regarding the XTC tools and programming with XMOS.
steveM
Junior Member
Posts: 7
Joined: Thu May 22, 2014 1:27 pm

JTAG write to Node Config registers?

Post by steveM »

I can use JTAG on a startkit to read/write tile configuration (pswitch) registers (giving access to debug etc), and can read from node configuration (sswitch) registers, but writing fails. I've also tried with the same outcome on a couple of G4s, and have tried (again unsuccessfully) using Segher's excellent jtag tools.Has anyone successfully written node configuration registers over JTAG? What does it require (other than changing the read command '0b01' to the write command '0b10' in the 10 bit IR register)? Read




User avatar
segher
XCore Expert
Posts: 844
Joined: Sun Jul 11, 2010 1:31 am

Post by segher »

Writing to the PLL config does not work properly (and
cannot really work, it causes resets); other regs should
work (via debug_write_sswitch in my code); I don't know
if I ever tested it though :-)

See the runxe code for how to write the PLL config (you
run a little program on the xcore).
steveM
Junior Member
Posts: 7
Joined: Thu May 22, 2014 1:27 pm

Post by steveM »

Thanks Segher. Yes, I thought regs other than the PLL should 'just work', but they seem not to, even using your debug_write_sswitch. I tried writing to the link initialisation registers just prior to reading all the regs in your sregs.c code, but no joy...
User avatar
segher
XCore Expert
Posts: 844
Joined: Sun Jul 11, 2010 1:31 am

Post by segher »

Hi again.

Have you tried with other JTAG programming software, or
only with mine? There could well be a bug in there.

On the other hand, the XMOS tools configure the fabric by
code as well, not directly via JTAG, although that would be
much simpler (during debug; it does not use the same code
as for "normal" runs either). So maybe the hardware is just
broken.

I don't quite remember, but I think writes simply don't
work? Or do they write wrong values for you?
steveM
Junior Member
Posts: 7
Joined: Thu May 22, 2014 1:27 pm

Post by steveM »

Yes, I've tried with my own software, as well as with yours - same result (which at least gave me confidence that I wasn't doing anything too silly ;-) ). In both cases writes to the node config registers have no effect.

As you say, a workaround is to configure the fabric from code - though this is less convenient. I don't know whether JTAG details are under NDA, but it would be good if someone at Xmos could confirm whether or not the hardware supports JTAG writes to the node config registers (without violating any non-disclosure!)
User avatar
XMatt
XCore Addict
Posts: 147
Joined: Tue Feb 23, 2010 6:55 pm

Post by XMatt »

The node configuration registers are read only via JTAG.

The only registers that can be written directly via JTAG are those used for interaction with the debug ROM and to put the device into debug by generating a debug interrupt.
steveM
Junior Member
Posts: 7
Joined: Thu May 22, 2014 1:27 pm

Post by steveM »

OK - thanks Matt.
User avatar
segher
XCore Expert
Posts: 844
Joined: Sun Jul 11, 2010 1:31 am

Post by segher »

Ah. Thanks Matt. Pity :-(

It would be nice if this were documented, hint hint.

So to write to the sswitch:

-- Put processor in debug mode;
-- read some RAM, save it;
-- put code there to do your thing;
-- run it;
-- put the original RAM contents back;
-- and release the processor again.

Anyone have a simpler idea?
steveM
Junior Member
Posts: 7
Joined: Thu May 22, 2014 1:27 pm

Post by steveM »

Seems a bit of a Catch-22. You can configure remote sswitches over channels, provided the appropriate link on the remote sswitch is enabled. You can enable the link on the remote sswitch by configuring remote sswitches. Doh!

On the startkit the OTP on the xscope tile (tile 0 on a U16) enables the link to the analogue node, and one internal link, but the OTP on the user tile (tile 1 on a U16) doesn't appear to enable any links at all (internal or external). There's some 'boot from channel' code in the boot rom that might be re-used through the debugger, but by the time one has set up registers appropriately I'm not sure that this is hugely easier than just loading configuration code, as you suggest.

Requires more investigation...
steveM
Junior Member
Posts: 7
Joined: Thu May 22, 2014 1:27 pm

Post by steveM »

Hi Segher

Don't know if this helps in your case, but I've put this function in my code:

int dbgExt() {
unsigned id, D3, D4, result;
id = get_local_tile_id();
result = read_pswitch_reg(id, 0x23,D3);
result = read_pswitch_reg(id,0x24,D4);
result = write_sswitch_reg(id,D3,D4);
return result;
}

and its then possible to call dbgExt using debug function 8 to write to sswitch without having to swap code back and forth.

Three minor gotchas which someone who understands the toolset better than I do might be able to sort out:
1) I need the address of dbgExt ( I pick that up using the xobjdump disassembly);
2) I need to call dbgExt once from the code to prevent it being removed by the compiler or linker (I've tried -O0 and --retain, but it still goes if I don't call it...);
3) I need to stop this code in debug mode overwriting the base of the stack (so I've put asm("extsp 0x20"); as the first line in main() ).

Of course, if Xmos were to revisit the debug rom at some time in the future, adding a 'write to sswitch' function would be very helpful ;-)