-
Notifications
You must be signed in to change notification settings - Fork 137
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
Fix addresses for jtag3_pdi boot and apptable #1887
Conversation
It works, neat!
|
This PR seems to break flash writing when using the Xplained Pro and the ATmega256RFR2:
Without this PR writing to flash works just fine |
src/jtag3.c
Outdated
unsigned long addr) { | ||
|
||
return mem_is_boot(m)? MTYPE_BOOT_FLASH: | ||
(mem_is_flash(m) && is_pdi(p) && addr >= PDATA(pgm)->boot_start)? MTYPE_BOOT_FLASH: MTYPE_FLASH; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It looks like the write issue for classic parts is caused by this return statement. MTYPE_FLASH_PAGE
will never be returned.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No. My initial suggestion caused -cpowerdebugger_jtag -patxmega256a3bu -T 'write flash 0 "Hello"'
to fail.
return mem_is_boot(m)? MTYPE_BOOT_FLASH:
(mem_is_flash(m) && is_pdi(p) && addr >= PDATA(pgm)->boot_start)? MTYPE_FLASH: MTYPE_FLASH_PAGE;
Can't we just revert back to:
if (p->prog_modes & PM_PDI) {
if (addr >= PDATA(pgm)->boot_start)
return MTYPE_BOOT_FLASH;
else
return MTYPE_FLASH;
} else {
return MTYPE_FLASH_PAGE;
}
Since this works perfectly fine, and is IMO easier to read?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
On closer inspection, I think this return statement should be OK. Note the addr < PDATA(pgm)->boot_start
:
return mem_is_boot(m)? MTYPE_BOOT_FLASH:
(mem_is_flash(m) && is_pdi(p) && addr < PDATA(pgm)->boot_start)? MTYPE_FLASH: MTYPE_FLASH_PAGE;
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I feel like this is some kind of Whack-a-Mole game. Even with the return statement fixed, The powerdebugger_jtag flash write progress suddenly freezes at 97% when flashing an ATxmega256A3BU.
I suggest fixing the issue mentioned in my previous post and then we can look into what's going on this time.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Note the
addr < PDATA(pgm)->boot_start
Great find. What was I thinking?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have redone the fix in a different way and force-pushed that. Now all moles should be hiding incl tpi, isp, pdi, updi...
cb7960c
to
e4536c7
Compare
Might fix a bug discovered here.
@MCUdude The
jtag3.c
code looks like it would never have worked onapptable
andboot
memories what withjtag3_mtype()
not even considering the memory just the address andjtag3_memaddr()
making no distinction between aflash
and anapptable
/boot
memory.