A simple non-spammy trick to double the speed you upload to your Arduino board.
“Double your upload speed” sounds like a spammy internet site. There is however a really simple way to double the speed you upload to your Arduino.
Deselect Verify code after upload in the preferences window and click ok. That’s it. Don’t believe me? Open this big sketch that takes up ~30k of flash (nearly all the flash on a standard Uno). With the box checked it will take about 24 seconds to upload the file. With the box unchecked it will take about 13 seconds.
What’s going on here? By default the Arduino IDE verifies that everything was written correctly:
Arduino IDE: Hey Uno: Oh hi Arduino IDE: I've got some new code for you Uno: Great! Send it to me Arduino IDE: Here it is... [30k of bytes] Uno: Got it, thanks!
Arduino IDE: Hey Uno: Oh hi Arduino IDE: I'm not sure I trust you got everything correctly. Send your flash to me. Uno: Ok, here it is... [30k of bytes] Arduino IDE: [Compares Arduino bytes to original bytes] Hmm, looks ok. Please proceed.
This is how almost all programming routines work: send the code then verify if there were any errors during transmission. By skipping the verification step you reduce the number of bytes that have to be passed back and forth by half. What you may not realize is that there are at least two other error checks: one at the bootloader level (each frame of the STK500 bootloader has a cyclic redundancy check) and even lower at the USB to serial communication level (each USB frame has a CRC). If any communication gets corrupted it is caught and corrected at these levels. It is highly unlikely that your sketch will be recorded incorrectly to the Arduino when you hit
Why does this matter?
Many sketches are a few thousand bytes so turning off verification will only save you a few seconds per upload. But how many times do you upload a sketch when you’re working on a project? 10 times? 50? It’s more than you might like to admit. And how many projects might you work on? I’ve probably uploaded tens of thousands of sketches over the past few years. Now multiply by all the Arduino users out there and you end up with a tremendous amount of wasted time.
Nathan: 25 sketch uploads * 100 days a year * 6 years = 15,000 uploads Time wasted: Avg time savings of 5 seconds per upload * 15,000 uploads = 75,000s = 1250min = 20 hours Arduino users (wild guess): 3,000,000 * 20 hours = 60,000,000 hrs = 2.5m days = 6,849 years of wasted time
These numbers are obviously unscientific but you get the idea. We’ll all be better off by spending less time watching the TX and RX LEDs blink.
Times when you might want verification
What a failed verification looks like in Arduino IDE
There are times when you may want to verify your code. If you’re going to deploy your Arduino into a satellite or into a final project you may sleep better knowing the code is correct. If you’ve got an extraordinary connection to an Arduino like a 50ft USB cable or a 2km connection over RS485 you may want to verify after upload. It’s still unlikely an error will slip through the CRCs so use your own judgement.
What boards does this trick work on?
This works with any Arduino that uses a serial to USB IC (Uno, Pro Mini, LilyPad Simple, Fio, etc). These boards all use the same avrdude bootloader that use the verification flag by default.
Any board using the Catarina booloader (Leonardo, Micro, etc) or the Halfkay bootloader have much faster bootloaders that don’t see much, if any speed advantage.
It’s perhaps better than 1 in a million but I’m not sure how to calculate the odds so please let me know if it has been. In 11 years of hammering on microcontrollers with serial bootloaders I’ve never seen an incorrect record to flash. Any firmware errors were always because of my own fault or faulty bootloader design.
Save time, trust your toolchain, and uncheck the box!