ATtiny85/45/25 I2C bootloader
This bootloader version size, with its current configurations, is ~1.3 kB. That's ~20 pages of 64 bytes.
The ATtiny85 has a total of 128 pages (8 kB), of which 107 are available for the application when the bootloader makes the trampoline calculation internally (as is currently set up).
This bootloader version size, with its current configurations, is ~1.3 kB. That's ~20 pages of 64 bytes.
The ATtiny85 has a total of 128 pages (8 kB), of which 107 are available for the application when the bootloader makes the trampoline calculation internally (as is currently set up).
If this function gets off-loaded to the I2C master, there is extra page gain, so there would be a total of 108 pages available for the application.
See it working ...
In this version, the first-page garbage issue after a writing retry when an I2C transmission error occurs is solved. The temporary page buffer is cleared in a way that works before writing the application to flash memory again.
The ATtiny85 datasheet is confusing on how to clear this buffer. Setting CTBP in the SPMCSR register:
SPMCSR |= (1 << CTPB);
is not enough. So this code (or similar) has to be implemented to properly clearing the temporary buffer:
__SPM_REG = (_BV(CTPB) | _BV(__SPM_ENABLE));
asm volatile("spm");
This issue was spotted and its solution suggested by Joey Morin @ AVRFreaks.net