Used programmer HW: Arduino Nano (HW mod: capacitor from RESET to GND to suppress the bootloader activation when opening the serial connection) with original ScratchMonkey firmware from GitHub.
Error: After a 1st successful flash writing the 2nd write always fails (the error doesn't exist after eeprom writing):
Here's the point in the SPI debug where the error shows up with bad response ![0], regardless of the spi speed:
SPI AC [0] 53 [0] 0 ![0] 0 [0]
Retrying in limp mode 2 (62.50kHz).
SPI AC [0] 53 [0] 0 ![0] 0 [0]
Retrying in limp mode 3 (31.25kHz).
SPI AC [0] 53 [0] 0 ![0] 0 [0]
Retrying in limp mode 4 (15.63kHz).
SPI AC [0] 53 [0] 0 ![0] 0 [0]
Retrying in limp mode 5 (7.81kHz).
SPI AC [0] 53 [0] 0 ![0] 0 [0]
Retrying in limp mode 6 (3.91kHz).
SPI AC [0] 53 [0] 0 ![0] 0 [0]
Retrying in limp mode 7 (1.95kHz).
SPI AC [0] 53 [0] 0 ![0] 0 [0]
Affected AVR parts: My example uses a t85, but also a m328p behaves identical.
Error prevention: In the beginning I worked around this issue by pressing the reset button before each use of the programmer. So it looks to me that after a flash write the programmer is in a different internal state as before, and is not able to enter the prog mode again.
Desired fix: Initialise the programmer correctly before each switch to prog mode.
Current "fix": Reset the programmer automatically with the help of the watchdog timer (last line in SMoISP::LeaveProgmode(), this requires also #include <avr/wdt.h>):
void
SMoISP::LeaveProgmode()
{
SMoHWIF::ISP::StopClock();
SMoHWIF::ISP::StopSPI();
digitalWrite(ISP_RESET, HIGH);
SMoCommand::SendResponse();
wdt_enable( WDTO_8S ); // Ho-Ho: Reset with wd timeout after 8 s
}
Used programmer HW: Arduino Nano (HW mod: capacitor from RESET to GND to suppress the bootloader activation when opening the serial connection) with original ScratchMonkey firmware from GitHub.
Error: After a 1st successful flash writing the 2nd write always fails (the error doesn't exist after eeprom writing):
Both logs are identical up to the
CMD_ENTER_PROGMODE_ISP
, the 1st returnsSTATUS_CMD_OK
(0x00
), the 2nd fails withSTATUS_CMD_FAILED
(0xC0
):DEBUG output: Then I enabled the DEBUG_ISP and did the same test. The 1st line shows the correct response
![53]
toCMD_ENTER_PROGMODE_ISP
:Here's the point in the SPI debug where the error shows up with bad response
![0]
, regardless of the spi speed:Affected AVR parts: My example uses a t85, but also a m328p behaves identical.
Error prevention: In the beginning I worked around this issue by pressing the reset button before each use of the programmer. So it looks to me that after a flash write the programmer is in a different internal state as before, and is not able to enter the prog mode again. Desired fix: Initialise the programmer correctly before each switch to prog mode. Current "fix": Reset the programmer automatically with the help of the watchdog timer (last line in
SMoISP::LeaveProgmode()
, this requires also#include <avr/wdt.h>
):