mraardvark / pyupdi

Python UPDI driver for programming "new" tinyAVR and megaAVR devices
MIT License
212 stars 73 forks source link

Refactor AVR DA support #54

Open mraardvark opened 4 years ago

mraardvark commented 4 years ago

right now its a mess, and should use subclasses for the 16 and 24 bit UPDI modes as well as the two NVM controllers

SpenceKonde commented 4 years ago

By the way, if you weren't aware, you have to always use 24-bit commands on these parts. Once you do a 24-bit ST ptr, if you do then do a 16-bit STS/LDS, the high byte of the pointer gets used! We ran into that on jtag2updi, It would write a page of flash, then try to write a NOOP to NVMCTRL.CTRLA with a 16-bit STS..... instead writing to a byte of flash at 0x1000 in the flash address space.... and then it would check NVMCTRL.STATUS and see the 0xFF of empty flash.... I was going crazy, heh...

mraardvark commented 4 years ago

yes, this is by design, and is also the case with xmega PDI...

SpenceKonde commented 4 years ago

It would have been really nice if the datasheet said as much... I spent weeks trying to figure that out....