using leonardo to upload sketches to atmega168/328

In its simplest form it is no more than this:

// for now, the baud rate is hard coded
// it should match what the target's bootloader uses
static long baud = 57600;

void setup() {
  Serial.begin(baud);
  Serial1.begin(baud);
}

void loop() {
  if (Serial.available()) {
    char c = (char)Serial.read();
    Serial1.write(c);
  }
  if (Serial1.available()) {
    char c = (char)Serial1.read();
    Serial.write(c);
  }
}

I tested it uploading a blink sketch to an atmega328p with some duemilanove bootloader.
It requires some practice though: keep the target in reset. Hit the download icon. Release the reset button right after the compilation phase is done...

What we really need is autoreset support. I'll cook something...

What would also be nice is that the leo automatically sets Serial1's baud rate, when the pc sets the "baudrate" of the virtual com port.