Hi.
I am struggling with the problem for about 4 days so far, hence why I came here for help.
I need to modify Optiboot to reset into bootloader on watchdog timer event, in other words, to remove the Adaboot no wait mod (even including power loss etc.)
My setup is:
-
Target- Atmega328p on Arduino Uno board (which I will later use without UNO board)
-
Programmer- Arduino Leonardo.
-
Windows 7 x64 machine
-
Arduino IDE 1.6.5 (tried on 1.6.11 too)
In very, very short-
(you can skip this part)
I have never been able to program any bootloader using Arduino as ISP.
Leonardo is programmed with ArduinoISP sketch, Uno connected through ICSP, but reset on Leonardo connected to pin 10. In IDE, board selected "Arduino UNO", programmer "Arduino as ISP". Uno resets fine during programming but then I get some sync errors.
When trying to upload the latest Optiboot bootloader, downloaded from GitHub - Optiboot/optiboot: Small and Fast Bootloader for Arduino and other Atmel AVR chips, I select "Board- Optiboot (...)" and get other several java errors.
(ok now the real roblem)
Anyway, I found other method for programming Optiboot bootloader with no issues which is Nick Gammon's method GitHub - nickgammon/arduino_sketches: Publicly-released sketches for the Arduino microprocessor (you're awesome Nick BTW)
So now in short, how I'm trying to modify this bootloader.
-
Downloaded Optiboot from Bill Westfield (you're awesome too mate) GitHub - Optiboot/optiboot: Small and Fast Bootloader for Arduino and other Atmel AVR chips
-
edited optiboot.c, basically just commented these lines:
// if (ch & (_BV(WDRF) | _BV(BORF) | _BV(PORF)))
// appStart(ch);
-
Downloaded WinAVR-20100110-install.exe in order to compile in Windows
-
Copied the whole content of WesfW's optiboot folder to "arduino-1.6.5-r5\hardware\tools\avr\bin" to resolve issues with paths
-
executed omake atmega328
-
During compilation I got some baudrate check errors (2.1%) but the file compiled ok (I have no idea whether this was the issue). I finally got files "optiboot_atmega328.lst" and "optiboot_atmega328.hex"
-
Followed Nick's instruction to convert the hex file using MUSHclient with no issues.
-
Created new file, edited to convert windows CR, LR to Unix LR only in order to get exactly the same size. Here's the output:
// /arduino-1.6.9/hardware/arduino/avr/bootloaders/optiboot/optiboot_atmega328.hex
// MD5sum = E4 4C E4 E7 5B A8 53 EE DA DF C6 0D C7 67 4D 7B
// Original file MD5 sum = 19b917aeec553ea1e47333cd9b1bbc5a
// This file from Aduino IDE 1.6.9
const byte atmega328_optiboot [] PROGMEM = {
0x1F, 0x92, 0xCD, 0xB7, 0xDE, 0xB7, 0x11, 0x24, 0x84, 0xB7, 0x14, 0xBE, 0x85, 0xE0, 0x80, 0x93,
0x81, 0x00, 0x82, 0xE0, 0x80, 0x93, 0xC0, 0x00, 0x88, 0xE1, 0x80, 0x93, 0xC1, 0x00, 0x86, 0xE0,
0x80, 0x93, 0xC2, 0x00, 0x80, 0xE1, 0x80, 0x93, 0xC4, 0x00, 0x8E, 0xE0, 0xB1, 0xD0, 0x25, 0x9A,
0x26, 0xE0, 0x80, 0xE3, 0x9C, 0xEF, 0x31, 0xE0, 0x90, 0x93, 0x85, 0x00, 0x80, 0x93, 0x84, 0x00,
0x36, 0xBB, 0xB0, 0x9B, 0xFE, 0xCF, 0x1D, 0x9A, 0xA8, 0x95, 0x21, 0x50, 0xA9, 0xF7, 0x81, 0x2C,
0x91, 0x2C, 0x93, 0xE0, 0xF9, 0x2E, 0xEE, 0x24, 0xE3, 0x94, 0x25, 0xE0, 0xD2, 0x2E, 0x31, 0xE1,
0xC3, 0x2E, 0x8A, 0xD0, 0x81, 0x34, 0x79, 0xF4, 0x87, 0xD0, 0x89, 0x83, 0x97, 0xD0, 0x89, 0x81,
0x82, 0x38, 0x11, 0xF4, 0x82, 0xE0, 0x05, 0xC0, 0x81, 0x38, 0x11, 0xF4, 0x86, 0xE0, 0x01, 0xC0,
0x83, 0xE0, 0x73, 0xD0, 0x6F, 0xC0, 0x82, 0x34, 0x11, 0xF4, 0x84, 0xE1, 0x03, 0xC0, 0x85, 0x34,
0x19, 0xF4, 0x85, 0xE0, 0x8B, 0xD0, 0x66, 0xC0, 0x85, 0x35, 0x41, 0xF4, 0x6D, 0xD0, 0x88, 0x2E,
0x6B, 0xD0, 0x91, 0x2C, 0x98, 0x2A, 0x88, 0x0C, 0x99, 0x1C, 0x5B, 0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, 0xD0, 0x80, 0xE1, 0x01, 0xD0, 0x7C, 0xCF, 0x90, 0x91, 0xC0, 0x00, 0x95, 0xFF,
0xFC, 0xCF, 0x80, 0x93, 0xC6, 0x00, 0x08, 0x95, 0x80, 0x91, 0xC0, 0x00, 0x87, 0xFF, 0xFC, 0xCF,
0x80, 0x91, 0xC0, 0x00, 0x84, 0xFD, 0x01, 0xC0, 0xA8, 0x95, 0x80, 0x91, 0xC6, 0x00, 0x08, 0x95,
0xE0, 0xE6, 0xF0, 0xE0, 0x98, 0xE1, 0x90, 0x83, 0x80, 0x83, 0x08, 0x95, 0xED, 0xDF, 0x80, 0x32,
0x19, 0xF0, 0x88, 0xE0, 0xF5, 0xDF, 0xFF, 0xCF, 0x84, 0xE1, 0xDF, 0xCF, 0xCF, 0x93, 0xC8, 0x2F,
0xE3, 0xDF, 0xC1, 0x50, 0xE9, 0xF7, 0xCF, 0x91, 0xF1, 0xCF, 0x28, 0x2E, 0x80, 0xE0, 0xE8, 0xDF,
0xE0, 0xE0, 0xFF, 0x27, 0x09, 0x94, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x02, 0x06,
}; // end of optiboot_atmega328
didn't bother about MD5's and all commented stuff.
- saved as bootloader_atmega328.h in Nick's Atmega_Board_Programmer replacing the original file.
Uploaded the Atmega_Board_Programmer sketch to Leonardo, and programmed bootloader to UNO. No problems what so ever. Even verified the bootloader to make sure it uploaded ok.
Now my UNO with modified bootloader keeps blinking internal led 3 times, 2-3 seconds break and 3 blinks again. I read about similar issue on forum but it was due to no sketch in UNO. So I uploaded the blink sketch with no problems but it still acts the same. 3 blinks, break, 3 blinks... Seems that blink sketch doesn't work or the UNO keeps resetting, I'm not sure.
I'm willing to even pay Nick for modifying bootloader_atmega328.h for me as it's a bit urgent, but I know I will need that modification for other uC's like Attiny85 later on.
Thanks in advance.