jlink dmi access using script apis

147 views
Skip to first unread message

Gnanasekar Rajakumar

unread,
Sep 24, 2018, 1:02:00 AM9/24/18
to de...@groups.riscv.org

what is sequence for writing and reading DMI (debug module interface) register using Jlink Script APIS?

 

I’m able read JTAG Id, DTMCS registers using JLink Script APIs (DTM registers). But to access DM registers, we have to write 66-bits of data in to DMI (debug module interface access) register.

 I followed below sequence. but it is not working.

 

 

void JTAG_DMI_WRITE(unsigned int addr, unsigned int val) {

                  int BitPos;

                 

                  JTAG_WriteIR(0x11);

                 

                  JLINK_JTAG_StartDR();

                  JLINK_JTAG_WriteDRCont(2, 2);

                  BitPos = JLINK_JTAG_WriteDRCont(val, 32);

                  JLINK_JTAG_WriteDREnd(addr, 32);

 

}

 

unsigned int JTAG_DMI_READ(unsigned int addr) {

                  int BitPos;

                  unsigned int val0;

                  unsigned int val1;

                  unsigned int val2;

 

                  JTAG_WriteIR(0x11);

                 

                  JLINK_JTAG_StartDR();

                  BitPos = JLINK_JTAG_WriteDRCont(1, 2);

                  JLINK_JTAG_WriteDRCont(0, 32);

                  JLINK_JTAG_WriteDREnd(addr, 32);

 

                  val0 = JTAG_GetU32(BitPos);

                  val1 = JTAG_GetU32(BitPos+32);

                  val2 = JTAG_GetU32(BitPos+64);

 

                  return val0;

}

Tommy Murphy

unread,
Sep 24, 2018, 3:55:13 AM9/24/18
to Gnanasekar Rajakumar, de...@groups.riscv.org
Have you looked at the RISC-V OpenOCD implementation? That should clarify what JTAG sequences you need. Specifically in src/target/riscv/riscv-013.c assuming that your target implements the debug spec v0.13 draft standard interface.


Hope this helps.

Tim Newsome

unread,
Sep 24, 2018, 2:02:22 PM9/24/18
to Gnanasekar...@wdc.com, RISC-V Debug Group
I'm not familiar with JLINK, but it looks like you're writing a 32-bit value, followed by a 32-bit address. That could be right if your target has abits=32, but I think that's pretty unusual. 5 or 6 would be more likely. You can read the actual value in dtmcs.

Tim

--
You received this message because you are subscribed to the Google Groups "RISC-V Debug Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email to debug+un...@groups.riscv.org.
To post to this group, send email to de...@groups.riscv.org.
Visit this group at https://groups.google.com/a/groups.riscv.org/group/debug/.
To view this discussion on the web visit https://groups.google.com/a/groups.riscv.org/d/msgid/debug/BL2PR04MB206756726CC86DCC6CA974779A170%40BL2PR04MB2067.namprd04.prod.outlook.com.

SEGGER - Alex Gruener

unread,
Oct 2, 2018, 4:49:27 AM10/2/18
to Tommy Murphy, Gnanasekar Rajakumar, de...@groups.riscv.org
Hi all,

Sorry for the late response...

Please find attached a sample script file which demonstrates how to shift more than 32-bit via J-Link script files.
I enter Shift-DR with IDCODE being the current instruction.
Then I shift in 32-bit: 0x55555555 this shifts out the IDCODE (0x20000913)
Then I shift in 32-bit: 0x00000000 this shifts out the previously shifted in 0x55555555 (See JTAG behavior for TDI & TDO that allows chaining JTAG devices)
I do the same test afterwards with a different value to make sure that neither the device got confused nor it worked by chance the 1st time.

It produces the expected output on a SiFive FE310 device:


  Alex Gruener
  Product Manager
  T +49-2173-99312-0
  www.segger.com
SEGGER - The
              Embedded Experts
SEGGER Microcontroller GmbH  *  Ecolab-Allee 5  *  40789 Monheim am Rhein  *  Germany  *  Tel. +49-2173-99312-0  *  Fax. +49-2173-99312-28
Amtsgericht Düsseldorf, HRB-Nr.: 57453  *  Managing Director: Ivo Geilenbruegge
--
You received this message because you are subscribed to the Google Groups "RISC-V Debug Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email to debug+un...@groups.riscv.org.
To post to this group, send email to de...@groups.riscv.org.
Visit this group at https://groups.google.com/a/groups.riscv.org/group/debug/.
Test64BitShift.JLinkScript
Reply all
Reply to author
Forward
0 new messages