The ramblings of one home-brew electronics, firmware engineer and pilot.

Sunday, April 10, 2011

Working with new tool chain

As the Arduino beacon project has progressed, I have spent some time trying to minimize the code size. For one thing, there are a number of components that the beacon project does not need that are drug into the final image. To do this I have moved away from the Arduino IDE for development of this project. I am using the GNU AVR tool chain now. I copied all the headers and code files from Arduino install and have been modifying them to eliminate components that I do not need. For example I don't need the serial port stuff, string classes, interrupt classes, etc. Rather than use generic port libraries, I am moving to talk directly to the ports instead. These kinds of changes have netted me 6-8 kb of space savings. I need to hack on the wire libraries to eliminate the stuff I am not using. Lastly, the Arduino boot loader is no longer necessary as I am using an in-circuit programmer (usbTinyISP) from the good folks at AdaFruit. This saves another 0.5 kb at the upper end of flash. The optiboot boot loader is pretty small, but others are not so compact. All things considered, the savings in code size are significant. Lastly, the tool chain is available for Windows, Linux and Mac platforms, so I think I will stick with it.

Converting from Arduino IDE is pretty straight forward:

1. Add #include "WProgram.h" to the top of your sketch.2. Add a main() function at the bottom that calls setup() and loops calling loop() infinitely.3. Provide forward declarations for all of your functions.4. Create a Makefile to drive the build process if desired (recommended).

I copied all the components from my project into a new folder and built a Makefile to compile and link everything. Now I can hack on the Arduino components referenced in my Beacon project without affecting my Arduino IDE environment.