Nick, that flash programmer is beautifully written. If you don't mind me asking, do you have some project in mind, or is this just something you've done for the hell of it?
Anyway I used it to write to an application to an 8U2 and it worked first time. No worries with 64 byte flash pages.
So now I can use a single Uno to update itself: Nick's sketch running on the 328 chip, to load my Arduino-serial/ArduinoISP mashup into the 8U2. Followed by avrdude plus the updated 8U2 to rewrite the 328's bootloader.
Just for interest, these are the changes I made:
1,5d0
< // Modified 9th May 2012 by Tim Giles
< // Added ISP application for 8U2 chip on Uno boards
< // Added "autonomous" mode for use in case no serial input is available:
< // This mode writes the binary indicated by the signature, verifies it, writes the fuses, and then stops
<
47,48c42
< #define INCLUDE_MD5SUM false // make false if you are running out of program memory
< #define AUTONOMOUS true // make true if running without user control (no serial input)
---
> #define INCLUDE_MD5SUM true // make false if you are running out of program memory
120d113
< #include "application_atmega8U2.h"
182,190c175
< { { 0x1E, 0x93, 0x89 }, "ATmega8U2", 8 * kb, 512,
< atmega8U2_usbisp, // loader image
< 0x0000, // start address
< 6060, // size of loader
< 64, // page size (for committing)
< 0xFF, // fuse low byte: external clock, max start-up time
< 0xDF, // fuse high byte: SPI enable, boot into bootloader, 8192 byte bootloader
< 0xF4, // fuse extended byte: brown-out detection at 2.7V
< 0x2F }, // lock bits: SPM is not allowed to write to the Boot Loader section.
---
> { { 0x1E, 0x93, 0x89 }, "ATmega8U2", 8 * kb, 512 },
376,378d360
< #if AUTONOMOUS
< // skip Lilypad option
< #else
403d384
< #endif // AUTONOMOUS
405,408d385
< char command='G';
< #if AUTONOMOUS
< // skip verify-only option
< #else
409a387
> char command;
414d391
< #endif // AUTONOMOUS
585,587d561
< #if AUTONOMOUS
< while(1); // wait forever
< #else
591d564
< #endif // AUTONOMOUS