Pages: [1]   Go Down
Author Topic: reduce arduino code size  (Read 1973 times)
0 Members and 1 Guest are viewing this topic.
FR
Offline Offline
Full Member
***
Karma: 0
Posts: 105
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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

http://letateu.googlepages.com/Arduino-0006-optimization-patch20061128.zip

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
Logged

Florida, USA
Offline Offline
Full Member
***
Karma: 0
Posts: 146
meow!
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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
Logged

Florida, USA
Offline Offline
Full Member
***
Karma: 0
Posts: 146
meow!
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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
Logged

Montréal, Qc
Offline Offline
Full Member
***
Karma: 0
Posts: 185
Practice safe hex!
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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 :/ Maybe you could explain the modification a little?

Thanks. Big up for the patch smiley-grin
Logged

"Pilots believe in a clean living... they never drink wisky from a dirty glass."

Forum Administrator
Offline Offline
Newbie
*****
Karma: 3
Posts: 3
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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

0
Offline Offline
Faraday Member
**
Karma: 7
Posts: 2526
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
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.

Quote
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
Logged

Montréal, Qc
Offline Offline
Full Member
***
Karma: 0
Posts: 185
Practice safe hex!
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Well it doesn't seem to work :/

Here is there error I get when I try to build a program (any of them)
Quote
/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?
Logged

"Pilots believe in a clean living... they never drink wisky from a dirty glass."

Montréal, Qc
Offline Offline
Full Member
***
Karma: 0
Posts: 185
Practice safe hex!
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
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()
  • ...
Logged

"Pilots believe in a clean living... they never drink wisky from a dirty glass."

Pages: [1]   Go Up
Jump to: