Go Down

Topic: ArduinoISP Arduino uno & blank atmega8 bootloader burn trouble (Read 8 times) previous topic - next topic

Nick Gammon

For a minute there I thought "oh yeah, PBCAK" but then I got exactly the same error! Blech.

I recently improved the sketch to support Atmega8 or something and in the process some extraneous trailing 0xFF crept in. Now unfortunately some bootloaders don't upload correctly if you have a run of 0xFF in the sketch. I've removed then (the memory is initialized to 0xFF anyway) and now it uploads.

New version:


Short version: Now you should be able to upload Atmega_Board_Programmer.


@Nick Gammon,

I tried using your bootloader programmer sketch for an Atmega8A device.  It did not work.  After some investigation I discovered that your sketch sends the Poll RDY/BSY* instruction in the pollUntilReady() function.  This instruction is not supported by the Atmega8A.   As a quick-and-dirty patch, I re-wrote pollUntilReady as follows:

Code: [Select]

// poll the target device until it is ready to be programmed
void pollUntilReady ()
  if (signatures[foundSig].pageSize < 128) {
  } else while ((program (pollReady) & 1) == 1) {
}  // end of pollUntilReady

With this change I was able to successfully program the Atmega8A.  Note that the delay value of 12ms is more than enough to cover the longest wait time specified in the datasheet.

Nick Gammon

Well spotted! I thought they would all support that (it seems such an obvious thing) but obviously not.

I'll adjust the original sketch shortly.

Nick Gammon

Well the whole thing turned out to be more complex than I expected. You must have been lucky. :)

With the fuses set for a 1 MHz internal oscillator I couldn't program it reliably at all. The amendments below not only add in the timed writes (as you suggested) but also fixes up the low fuse to make it use the 8 MHz oscillator, drops programming mode (to latch the change) and then presses on. It now seems to program OK.


Go Up