Closed MCUdude closed 1 year ago
Wow, that is fast to find the root cause. We should be able to fix this. At least @stefanrueger should be able to find the problems. :-)
The root cause is pgm->pgm->hvupdi_support
. For PICkit4, this is a list that contains 0, 1, 2
. For some reason, the for loop only "detects" one field
for (support = lfirst(pgm->hvupdi_support); support != NULL; support = lnext(support))
However, when I "manually" print the contents of pgm->hvupdi_support
, I'm getting the full list:
msg_info("support: %d, %d, %d\n",
*(int *)ldata(lfirst(pgm->hvupdi_support)),
*(int *)ldata(lnext(lfirst(pgm->hvupdi_support))),
*(int *)ldata(lnext(lnext(lfirst(pgm->hvupdi_support)))));
support: 0, 1, 2
Sorry, there's nothing wrong with the list. It's the last if statement in the for-loop that causes an early exit. I'll see if I can come up with a solution and submit a PR!
Yes I can confirm that #1164 fixed the issue.
Thanks to @mcuee for discovering this bug.
It turns out that the logic for determining if a target supports HV UPDI is broken, at least for type 2 devices (AVR-DD and AVR-EA).
Here's the HV UPDI logic in jtag3.c where I've added two print statements to show what's going on:
And here's the output:
It happens to work with ATtinys, because these are using HVUPDI type 0. To me, it appears that the linked list isn't being filled, but I don't know enough about linked lists to trace down the bug myself.