Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

JTAG capture of 32u4 fails on Atmel-ICE #105

Open
tlyu opened this issue Dec 28, 2023 · 0 comments · May be fixed by #108
Open

JTAG capture of 32u4 fails on Atmel-ICE #105

tlyu opened this issue Dec 28, 2023 · 0 comments · May be fixed by #108

Comments

@tlyu
Copy link

tlyu commented Dec 28, 2023

Target is an ATmega32U4 (Arduino Micro) over JTAG, with an Atmel-ICE. I don't know whether this also occurs with JTAGICE3.

avarice -d -C -4 -B 2M localhost:6000 exits with an error upon first contact by GDB, but avarice -d -4 -B 2M localhost:6000 seems to work.

I've traced this down to a failure to use CMD_AVR8_ATTACH (CMD3_START_DEBUG in jtag3.h) in capture mode. I have preliminary patches to fix this. The EDBG protocol reference can be quite helpful, even if it does seem inaccurate or incomplete in places.

jtag3::initJtagOnChipDebugging does use that attach command, but only on DebugWire or for XMEGA. Oddly enough, it turns out to be unnecessary there, because leaving progmode during a debug session implicitly does a reset and attach (if OCD is enabled). (On DebugWire, the attempt to enable OCD bypasses progmode, because DebugWire doesn't do that, but DebugWire implicitly attaches on activation of the physical interface, which I've determined experimentally, but isn't documented.)

GDB: <g>

GDB: (Registers)Read 32 bytes from 0x800000
jtagRead
command "read memory" [0x12, 0x21]
0E 00 08 00 12 21 00 20 00 00 00 00 20 00 00 00
Received 0x81 0x11 0x00 0x07 0x0e 0x08
read:  0e 08 00 12 a0 00 32

Got message seqno 8 (command_sequence == 8)
response: 12 A0 00 32

0x32 is AVR8_FAILURE_ILLEGAL_STATE, which avarice handles by attempting a stop command, which also fails:

command "stop" [0x12, 0x31]
0E 00 09 00 12 31 00 01
Received 0x81 0x11 0x00 0x07 0x0e 0x09
read:  0e 09 00 12 a0 00 23

Got message seqno 9 (command_sequence == 9)
response: 12 A0 00 23

0x23 is AVR8_FAILURE_NOT_ATTACHED.

Full log:

jtag-c-32u4.txt

@tlyu tlyu linked a pull request Dec 28, 2023 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant