Get The Lead Out Of The Arduino Compile Process

Relief is here from long compile times when developing firmware for your Arduino project. [Paul] was puzzled by the fact that every file used in a sketch is fully recompiled every time you hit upload–even if that file didn’t change. To make things more confusing, this behavior isn’t consistent across all Arduino compatible hardware. The Teensy has an additional feature not seen when working with other hardware boards in that it reuses previously compiled code if nothing has changed. It even tells you which files are being reused, as shown in the image above.

After the break we’ve embedded [Paul’s] video that walks us through the process of editing the Arduino IDE to reuse previously compiled files. It’s a one-liner addition to the boards.txt file. For example, if you’re working with the Arduino Uno all that needs to be added is ‘’. [Paul] had previously submitted a patch to roll this into the Arduino IDE source code, but it was not accepted citing a need for more testing. He’s asking for help with that testing and wants you to post your thoughts, or any bug information, on the new issue he’s opened regarding this feature.[youtube=]

23 thoughts on “Get The Lead Out Of The Arduino Compile Process

    1. Hi, Paul here… the guy who wrote this. I’m thrilled HaD decided to carry my story. I wasn’t sure if they would, since it’s software only.

      That first line should probably read “impatient” rather than “puzzled”. ;-)

      Sadly, this speedup isn’t nearly as advanced as a Makefile, though it does achieve much of the same time savings. While it does use gcc’s dependency output from previous compiles, and it checks the timestamps on all dependant sources, it doesn’t actually alter Arduino’s build system very much. The is_already_compiled() function just returns a boolean that tells the loop which compiles a set of files if it can skip a particular .o file.

      Make is capable of so much more, even if many projects don’t use of its power. One of the most awesome features of modern GNU Make is being able to run more than one compile job at a time! My machine is a quad core processor, and on largish projects with a lot of individually compiled components, running “make -j 4” really does give a substantial speedup (rare 4X as fast, but still good).

      Maybe someday I’ll adding that too, though most Arduino sketches are just a single source file (if multiple tabs are used, all the .pde and .ino files are concatenated, so only .cpp ones are compiled as separate files).

      But I’ve created so many improvements for Arduino, which are all in Teensyduino of course. It’s just so difficult contributing stuff to Arduino (eg, check out issue #140 – where I submitted code 2 years ago).

  1. I use a pentium 3, and a sketch that fills up the entire 32k takes a whole 20 seconds to compile. My tri core 2.8 ghz machine can do it in a blink of an eye, so my point is you might have other problems …

  2. What I would love are some shell scripts that compile and upload some arduino code, so I can use my favorite editor environment.
    The arduino editor is uncool IMHO, and having a dedicated editor and compile/upload window is messy.

    1. Have you tried Arduino’s “Use external editor” feature? It’s in the preferences. It disables Arduino’s simple but lame editor. Every time you click the upload button, Arduino re-reads the file from disk, compiles and uploads. Whenever I do anything more than a tiny example, I use it and do my editing with vim. Works great!

    2. Avr-gcc and Avr dude. . Im not sure what all it’s compatible with… All I know is I have never once used the arduino ide with my attiny85. Nano and shell commands. I’ve never even logged into the graphical environment on the pi fishing it

  3. Hey guys.. I just was given 30 AMD AM29F010B-90PC 1 Megabit (128 K x 8-bit)
    CMOS 5.0 Volt-only, Uniform Sector Flash Memory

    Would these be able to be used with Arduino or anything similar?

  4. Despite being shown on Hack-a-Day, Adafruit’s blog, Dangerous Prototypes, and the Arduino Forum – and now over 1000 views accourding to YouTube – it appears only a couple people have actually tried this speedup.

    As a final followup, I prepared a patch and posted it to issue 638.

    I’m not planning any more work to contribute this feature to Arduino. My effort appears to have stalled and failed.

    The source is there, if anyone wants to pick it up and do anything with it.

  5. Arduino 1.0.1-rc1 (release candidate #1) was published today, with this speedup.

    Mac OS X:
    Linux (32-bit):
    Linux (64-bit):

    Final release for Arduino 1.0.1 is planned for early April.

  6. I know this thread is a bit old but this update (Final release for Arduino 1.0.1) did not work for me until I moved the “arduino-1.0.1” directory to one without spaces in name(s).

    i.e. c:\arduino-1.0.1

    After that my compile/upload time went from 1 min. to less than 10 sec.

    I’m sure this is a windows issue only, I like to tweak code in small changes so this fix/update saves me a ton of time.

Leave a Reply

Please be kind and respectful to help make the comments section excellent. (Comment Policy)

This site uses Akismet to reduce spam. Learn how your comment data is processed.