reduce arduino code size

If your arduino environment tells you that your sketch is oversized try this patch, you will save up to 1 Kbyte.

Enjoy it!!!

Note for Linux and OsX users : Has only been tested on windows, you will have to modify a little bit the distribution in order to see it working.
Let me know if that patch is working on your platform.

Nicolas

Hey Nicolas,

I just tried your patch on my project, and it went down from over 7100 bytes (just barely fitting inside the Atmega8) to 5854 bytes! Wow! I'm at work so I will not be able to download the code and make sure it still works until I get home.

This is on Windows XP with Arduino-0006.

I will post again when I get home and verify whether the code still works or not. Assuming it does, I think this patch should be worked into the next release of Arduino.

Thanks!

  • Don

OK, I just got home and the verdict is... it still works!

Thanks again Nicolas... I think this will be of great value to everyone who uses Arduino.

  • Don

Can anyone vouch for this under os x, or at least linux? I don't have an ICSP programmer if anything goes wrong and I have no clue what this actually does :confused: Maybe you could explain the modification a little?

Thanks. Big up for the patch :smiley:

the patch should be cross platform
expect this to be included in arduino 7

Can anyone vouch for this under os x,

Yes, works on Mac OS X. It's AVR code, not host OS code, so it's platform independent.

Maybe you could explain the modification a little?

There used to be a different API for accessing the serial port. That code was left for backwards compatibility purposes. If you don't need that backwards compatibility you can remove that code and save the space.

-j

Well it doesn't seem to work :confused:

Here is there error I get when I try to build a program (any of them)

/Users/mlalonde/Applications/Development/Arduino/arduino-0006/tools/avr/bin/../lib/gcc/avr/4.0.3/../../../../avr/lib/avr4/crtm8.o: In function `__bad_interrupt':

../../../../crt1/gcrt1.S:123: undefined reference to `main'

Couldn't determine program size: tools/avr/bin/avr-size: '/tmp/build17823.tmp/program_template.hex': No such file

I moved the files lib/arduino/ and the lib/processing/ directory.

Any ideas?

There used to be a different API for accessing the serial port. That code was left for backwards compatibility purposes. If you don't need that backwards compatibility you can remove that code and save the space.

Thank you, that's what I wanted to know. I take it this is the "Old serial library (deprecated)" ?

  • beginSerial(speed)
  • serialWrite(c)
  • int serialAvailable()- ...