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.


  1. owen_b says:

    Wow its like a … makefile

  2. gp says:

    this is so advanced, like something a Makefile would do :S

    • Paul says:

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

  3. Bill says:

    This (good work btw) motivated me to add a feature request that has long annoyed me, the ability to have hex files saved in the project directory after compiling. I’ve hated having to go hunt them down in temp files. So be sure to vote for this one as well.

  4. I’ve read about this before but I don’t remember someone suggesting a fix. Thanks!

  5. KillerBug says:

    LoL…I read the headline and thought, “That could speed up Teensy programming”…all well. :)

  6. dude says:

    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 …

  7. Bernhard says:

    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.

  8. Precurse says:

    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?

  9. Paul says:

    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.

  10. ssssssz333333 says:

    Works !!! Great !!! Saves much of my time

  11. Paul says:

    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.

  12. Ken says:

    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

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s


Get every new post delivered to your Inbox.

Join 96,672 other followers