keyboardio / attiny_i2c_bootloader

An I2C bootloader for ATTiny devices based on AVR112.
16 stars 6 forks source link

make it fit on Model 01 again #5

Closed tlyu closed 2 years ago

tlyu commented 2 years ago

Help the optimizer in modern GCC a little more, so the bootloader can fit in 1k on the Model 01 again.

obra commented 2 years ago

There's some clever stuff in here. I'd like to test on actual hardware before I merge, but generally it all looks good

tlyu commented 2 years ago

Quick size comparison:

Before

avr-size --format=avr --mcu=attiny88 twi_slave.elf
AVR Memory Usage
----------------
Device: attiny88

Program:    1040 bytes (12.7% Full)
(.text + .data + .bootloader)

Data:         67 bytes (13.1% Full)
(.data + .bss + .noinit)

After

AVR Memory Usage
----------------
Device: attiny88

Program:     904 bytes (11.0% Full)
(.text + .data + .bootloader)

Data:         66 bytes (12.9% Full)
(.data + .bss + .noinit)

I had to tweak the start address for the "before" to get it to link, because it was just barely too big.

tlyu commented 2 years ago

There's some clever stuff in here. I'd like to test on actual hardware before I merge, but generally it all looks good

Thanks! Note if you test on actual Model 01 hardware, you might find the unconditional 8-second watchdog timer annoying. (I reduced it to 60ms for my testing, and unifying the bootloader trigger conditions across models might help as well.)