JTAG Problems

dspau1
Posts: 13
Joined: Sat Jan 14, 2017 9:25 am

JTAG Problems

Postby dspau1 » Tue Jun 06, 2017 12:39 pm

Hi all,

I'm trying to get JTAG programming up and running and having no success. The error appears to be "esp32.cpu1: target not halted".

The setup is:

- Espressif ESP32 Dev Kit C
- TIAO TUMPA JTAG Adapter (v2)
- VisualGDB v5.2r9 for programming / debugging

I have connected the following JTAG pins:

- JTAG TDI (5) -> GPIO12
- JTAG TCK (9) -> GPIO13
- JTAG TMS (7) -> GPIO14
- JTAG TDO (13) -> GPIO15
- JTAG GND (4) -> GND


Full OpenOCD output is:

Code: Select all

Open On-Chip Debugger 0.9.0 (2017-05-09)
Licensed under GNU GPL v2
For bug reports, read
        http://openocd.org/doc/doxygen/bugs.html
none separate
Info : auto-selecting first available session transport "jtag". To override use 'transport select <tra
nsport>'.
adapter speed: 3000 kHz
Error: libusb_open() failed with LIBUSB_ERROR_NOT_SUPPORTED
Info : clock speed 3000 kHz
Info : JTAG tap: esp32.cpu0 tap/device found: 0x120034e5 (mfg: 0x272 (Tensilica), part: 0x2003, ver: 0
x1)
Info : JTAG tap: esp32.cpu1 tap/device found: 0x120034e5 (mfg: 0x272 (Tensilica), part: 0x2003, ver: 0
x1)
Info : esp32.cpu0: Target halted, pc=0x40090DF8
Error: The 'mww' command must be used after 'init'.
in procedure 'init' 
in procedure 'ocd_bouncer' 
in procedure 'flash' 
in procedure 'ocd_bouncer'

Info : accepting 'gdb' connection on tcp/3333
Interrupt suppression during single-stepping is now enabled
Info : JTAG tap: esp32.cpu0 tap/device found: 0x120034e5 (mfg: 0x272 (Tensilica), part: 0x2003, ver: 0
x1)
Info : JTAG tap: esp32.cpu1 tap/device found: 0x120034e5 (mfg: 0x272 (Tensilica), part: 0x2003, ver: 0
x1)
Info : esp32.cpu0: Core was reset (pwrstat=0x1F, after clear 0x0F).
Info : esp32.cpu0: Target halted, pc=0x40000400
Warn : esp32.cpu1: target not halted
in procedure 'reset' 
in procedure 'ocd_bouncer' 
in procedure 'ocd_process_reset' 
in procedure 'ocd_process_reset_inner' called at file "embedded:startup.tcl", line 248
in procedure 'esp32.cpu0' called at file "embedded:startup.tcl", line 349
in procedure 'ocd_bouncer'

esp32.cpu0: target state: halted
Target did not halt within 5000 msec

Info : esp32.cpu0: Target halted, pc=0x40090DF8
esp32.cpu0: target state: halted
Info : JTAG tap: esp32.cpu0 tap/device found: 0x120034e5 (mfg: 0x272 (Tensilica), part: 0x2003, ver: 0
x1)
Info : JTAG tap: esp32.cpu1 tap/device found: 0x120034e5 (mfg: 0x272 (Tensilica), part: 0x2003, ver: 0
x1)
Info : esp32.cpu0: Core was reset (pwrstat=0x1F, after clear 0x0F).
Info : esp32.cpu0: Target halted, pc=0x40000400
Warn : esp32.cpu1: target not halted
in procedure 'reset' 
in procedure 'ocd_bouncer' 
in procedure 'ocd_process_reset' 
in procedure 'ocd_process_reset_inner' called at file "embedded:startup.tcl", line 248
in procedure 'esp32.cpu0' called at file "embedded:startup.tcl", line 349
in procedure 'ocd_bouncer'

esp32.cpu0: target state: halted
Target did not halt within 5000 msec
Any suggestions?

User avatar
ESP_krzychb
Posts: 400
Joined: Sat Oct 01, 2016 9:05 am
Contact:

Re: JTAG Problems

Postby ESP_krzychb » Tue Jun 06, 2017 1:16 pm

While not familiar with VisualGDB, I would verify commands issued on start up of your debugging application to halt CPUs.

The command sequence I use is as follows:

Code: Select all

mon reset halt
hb app_main
x $pc=0x40000400
c

dspau1
Posts: 13
Joined: Sat Jan 14, 2017 9:25 am

Re: JTAG Problems

Postby dspau1 » Wed Jun 07, 2017 5:24 am

To be honest I don't know how to run OpenOCD commands directly. I have a more detailed log however, and I can see the "mon reset halt" command is being issued.

Google tells me that I'm not the only one seeing the cpu1 not halted error, so I'm hoping someone can jump in and help out.

Code: Select all

mon reset halt
&"mon reset halt\n"
@"JTAG tap: esp32.cpu0 tap/device found: 0x120034e5 (mfg: 0x272 (Tensilica), part: 0x2003, ver: 0x1)\n"
@"JTAG tap: esp32.cpu1 tap/device found: 0x120034e5 (mfg: 0x272 (Tensilica), part: 0x2003, ver: 0x1)\n"
@"esp32.cpu0: Core was reset (pwrstat=0x1F, after clear 0x0F).\n"
@"esp32.cpu0: Target halted, pc=0x40000400\n"
@"esp32.cpu1: target not halted\n"
@"in procedure 'reset' \n"
@"in procedure 'ocd_bouncer' \n"
@"in procedure 'ocd_process_reset' \n"
@"in procedure 'ocd_process_reset_inner' called at file \"embedded:startup.tcl\", line 248\n"
@"in procedure 'esp32.cpu0' called at file \"embedded:startup.tcl\", line 349\n"
@"in procedure 'ocd_bouncer'\n"
@"\n"
@"esp32.cpu0: target state: halted\n"
^done
restore C:/SysGCC/esp32/esp32-bsp/sysprogs/flashprog/ESP32FlashProg.bin binary 0x40090000 0 0xe14
&"restore C:/SysGCC/esp32/esp32-bsp/sysprogs/flashprog/ESP32FlashProg.bin binary 0x40090000 0 0xe14\n"
~"Restoring binary file C:/SysGCC/esp32/esp32-bsp/sysprogs/flashprog/ESP32FlashProg.bin into memory (0x40090000 to 0x40090e14)\n"
^done
mon esp108 run_alg 0x400902d0 0x40090df8 20000 a1=0x3ffd0404 a10=0 a11=4096 a12=0 a0 pc
&"mon esp108 run_alg 0x400902d0 0x40090df8 20000 a1=0x3ffd0404 a10=0 a11=4096 a12=0 a0 pc\n"
@"Target did not halt within 20000 msec\n"
@"\n"
@"esp32.cpu0: Target halted, pc=0x40090DF8\n"
@"esp32.cpu0: target state: halted\n"
^done
mon reset halt
&"mon reset halt\n"
@"JTAG tap: esp32.cpu0 tap/device found: 0x120034e5 (mfg: 0x272 (Tensilica), part: 0x2003, ver: 0x1)\n"
@"JTAG tap: esp32.cpu1 tap/device found: 0x120034e5 (mfg: 0x272 (Tensilica), part: 0x2003, ver: 0x1)\n"
@"esp32.cpu0: Core was reset (pwrstat=0x1F, after clear 0x0F).\n"
@"esp32.cpu0: Target halted, pc=0x40000400\n"
@"esp32.cpu1: target not halted\n"
@"in procedure 'reset' \n"
@"in procedure 'ocd_bouncer' \n"
@"in procedure 'ocd_process_reset' \n"
@"in procedure 'ocd_process_reset_inner' called at file \"embedded:startup.tcl\", line 248\n"
@"in procedure 'esp32.cpu0' called at file \"embedded:startup.tcl\", line 349\n"
@"in procedure 'ocd_bouncer'\n"
@"\n"
@"esp32.cpu0: target state: halted\n"
^done
restore C:/SysGCC/esp32/esp32-bsp/sysprogs/flashprog/ESP32FlashProg.bin binary 0x40090000 0 0xe14
&"restore C:/SysGCC/esp32/esp32-bsp/sysprogs/flashprog/ESP32FlashProg.bin binary 0x40090000 0 0xe14\n"
~"Restoring binary file C:/SysGCC/esp32/esp32-bsp/sysprogs/flashprog/ESP32FlashProg.bin into memory (0x40090000 to 0x40090e14)\n"
^done
mon esp108 run_alg 0x400902d0 0x40090df8 20000 a1=0x3ffd0404 a10=0 a11=4096 a12=0 a0 pc
&"mon esp108 run_alg 0x400902d0 0x40090df8 20000 a1=0x3ffd0404 a10=0 a11=4096 a12=0 a0 pc\n"
@"Target did not halt within 20000 msec\n"
@"\n"
@"esp32.cpu0: Target halted, pc=0x40090DF8\n"
@"esp32.cpu0: target state: halted\n"
^done
mon reset halt
&"mon reset halt\n"
@"JTAG tap: esp32.cpu0 tap/device found: 0x120034e5 (mfg: 0x272 (Tensilica), part: 0x2003, ver: 0x1)\n"
@"JTAG tap: esp32.cpu1 tap/device found: 0x120034e5 (mfg: 0x272 (Tensilica), part: 0x2003, ver: 0x1)\n"
@"esp32.cpu0: Core was reset (pwrstat=0x1F, after clear 0x0F).\n"
@"esp32.cpu0: Target halted, pc=0x40000400\n"
@"esp32.cpu1: target not halted\n"
@"in procedure 'reset' \n"
@"in procedure 'ocd_bouncer' \n"
@"in procedure 'ocd_process_reset' \n"
@"in procedure 'ocd_process_reset_inner' called at file \"embedded:startup.tcl\", line 248\n"
@"in procedure 'esp32.cpu0' called at file \"embedded:startup.tcl\", line 349\n"
@"in procedure 'ocd_bouncer'\n"
@"\n"
@"esp32.cpu0: target state: halted\n"
^done
restore C:/SysGCC/esp32/esp32-bsp/sysprogs/flashprog/ESP32FlashProg.bin binary 0x40090000 0 0xe14
&"restore C:/SysGCC/esp32/esp32-bsp/sysprogs/flashprog/ESP32FlashProg.bin binary 0x40090000 0 0xe14\n"
~"Restoring binary file C:/SysGCC/esp32/esp32-bsp/sysprogs/flashprog/ESP32FlashProg.bin into memory (0x40090000 to 0x40090e14)\n"
^done
mon esp108 run_alg 0x400902d0 0x40090df8 20000 a1=0x3ffd0404 a10=0 a11=4096 a12=0 a0 pc
&"mon esp108 run_alg 0x400902d0 0x40090df8 20000 a1=0x3ffd0404 a10=0 a11=4096 a12=0 a0 pc\n"
@"Target did not halt within 20000 msec\n"
@"\n"
@"esp32.cpu0: Target halted, pc=0x40090DF8\n"
@"esp32.cpu0: target state: halted\n"
^done

BuddyCasino
Posts: 263
Joined: Sun Jun 19, 2016 12:00 am

Re: JTAG Problems

Postby BuddyCasino » Wed Jun 07, 2017 5:45 am

The routine I've settled in on looks like this:
  • connect JTAG
  • start debugging session via Eclipse (settings: inital reset disabled, load symbols enabled, load executable disabled, pre-run/restart reset enabled, type halt, continue enabled)
  • reset ESP32
  • JTAG halts the system, press "continue" in the debugger view
  • wait until the CPU throws an exception or it hits the breakpoint I've set
  • shake fists angrily because the interesting variables have been optimized away
Its annoying but at least it mostly works.

dspau1
Posts: 13
Joined: Sat Jan 14, 2017 9:25 am

Re: JTAG Problems

Postby dspau1 » Wed Jun 07, 2017 9:10 am

SOLVED:

If ESP32 is running in single core mode, cpu1 will fail to halt when attempting to program/debug via JTAG using VisualGDB. Not sure if this also impacts other OpenOCD environments.

The solution is to explicitly enable dual core mode in MAKE CONFIG tool, and flash the ESP32 with this config over serial before attempting to flash via JTAG. I have read that one must start at least one task pinned to each core or the scheduler won't start on that core, which may result in the same fault condition. I have not yet tested this to confirm.

Further info in this thread: https://sysprogs.com/w/forums/topic/pro ... post-11410

And this thread: viewtopic.php?t=1253

Thanks for the replies :)

User avatar
ESP_krzychb
Posts: 400
Joined: Sat Oct 01, 2016 9:05 am
Contact:

Re: JTAG Problems

Postby ESP_krzychb » Wed Jun 07, 2017 9:58 am

@dspau1,

Thank you for sharing your findings and the other thread with solution.
Sysprogs did great job putting together LIMITATIONS OF THE ESP32 DEBUGGING

f.h-f.s.
Posts: 214
Joined: Thu Dec 08, 2016 2:53 pm

Re: JTAG Problems

Postby f.h-f.s. » Wed Jun 07, 2017 10:01 am

I have succesfully flashed using visualgdb and a olimex jtag debugger.
I was using the flash cache section of CPU1 for extra memory, so CPU1 was disabled.
Might it be the thumpa?

I also had lots of other trouble debugging, flashing was about the only thing that worked consistently over JTAG.

Who is online

Users browsing this forum: Bing [Bot] and 63 guests