Modifying Optiboot to Upload Sketches over RS485

Hi,

How have you done it?

Yes, that was not easy to find out. You cannot use the 'normal' way via a watchdog reset because of the way that optiboot works.
So I searched for another solution.
This is how it has to be done (it is more explaining then coding...)

In my sketch file I wrote this:

// next lines are for jumping to the correct place in the bootloader
// 0x3F07 comes from 7e0e out of the .lst file after compilation customized optiboot
// via 'omake atmega328' in directory C:\arduino-1.0.2\hardware\arduino\bootloaders\optiboot
// 0x3F07 = 7e0e/2 (words, bytes)
// 7e0e is the place AFTER the appstart via a watchdog reset
// (omake van optiboot maybe max. 512 dec or else you can't burn it
// you see the size as output with omake)

typedef void (*AppPtr_t) (void);
AppPtr_t GoToBootloader = (AppPtr_t)0x3F07; 

void setup() 
{
...
}

void loop()
{
...
  case 'R': // RESET TO BOOTLOADER
        noInterrupts();
        GoToBootloader();
        break;
...
}

I hope you understand it...

Good luck.

Korstiaan