mihaigalos / miniboot

🏗️ An I2C bootloader for Arduino.
GNU General Public License v3.0
65 stars 18 forks source link

Optimizing flash footprint #26

Closed nullstalgia closed 4 years ago

nullstalgia commented 4 years ago

After pondering on issue #25, I was wondering if there was any optimizations to be done.

After doing some experimenting, I found that we could save some flash space by removing un-needed passes of the I2C slave's address, as it remains constant throughout the whole program.

And even if it is changed during runtime, the program is still able to function properly, (an example of which I will post in the aforementioned issue later on).

My very unscientific tests showed that the original gave a total size of 17767

And after these changes, it lowered to 17728

I am running Manjaro Linux, avr-g++ version 9.2.0

nullstalgia commented 4 years ago

Except it just clicked when I was doing some other work that you claim "No global variables," when this is exactly what this pull would do. Well, crap.

Well, I can still use it to solve #25 quite gracefully, so not all was lost.

I will still send a pull request soon with the more cosmetic changes that were done with this. :)

mihaigalos commented 4 years ago

Awesome. Haha.