Unusual status report/error when reflashing

#5 · closed · 1 comments

View on GitHub ↗

cefn

I can flash ATMEGA328-PU devices (note, not ATMEGA328P-PU) using the current Optiloader sketch quite well. I'm using your approach to prepare kits for the #Shrimp radically affordable Arduino-compatible breadboard layout at http://shrimping.it Unfortunately if I ever try to reflash a -PU which has already been flashed by Optiloader, I get an error report (I seem to remember something like 0x0) which suggests something is going wrong. In fact this normally just suggests it's already been flashed, and the chip is still fine when actually placed in a circuit and can be programmed perfectly. My suspicion is that it's to do with the chip identification which may change after being flashed. I've only tested this behaviour of Optiloader with -PU and haven't yet tested it with P-PU. As a result of this behaviour I find it really difficult to ensure the chips are good if I haven't kept a close track of whether I've already flashed a chip or not (I do them 100 at a time). I keep wondering whether a chip is actually borked, or whether I've just already flashed it. It would be fantastic to see a different behaviour, and a meaningful status report, if it's already been successfully flashed (better still, that Optiloader would just reflash it again). Let me know if this is a known behaviour and what might be done, otherwise I'll set up the Optiloader circuit again and get you a more detailed report to get you what you need for triage. If needed I'll send through a pre-flashed kit.

Comments

cefn

I think it's dawned on me what is happening here. Since the flashing process changes the fuses for the ATMEGA to make it use a 16MHz crystal, (instead of its internal clock), then it is unresponsive after flashing, since it needs the crystal, whereas before it was fine running on its 8MHz internal (and was configured properly to do so). I'll investigate in more detail, but I think adding a crystal and two 22pF caps as per a Minimal Shrimp layout would mean you could very likely reflash the bootloader a second time, rather than having this 'non-responsive' error.