Flashing a new firmware from the command line with Windows

The Arduino IDE is very easy to use and ensures quick and reliable success in programming embedded applications. But for some tasks it is easier and more straight forward to skip the fancy GUI and access the underlying tools directly.

The Arduino package combines four main components:

  • The IDE itself
  • The Arduino libraries of proven AVR source code
  • The GNU C/C++-Compiler gcc
  • The uploading tool avrdude

using avrdude

avrdude.exe is used for communication with the bootloader. The binary is located at hardware/tools/avr/bin/avrdude.exe inside the Arduino folder, the corresponding configuration file is hardware/tools/avr/etc/avrdude.conf.

The bootloader is stored in a special write-protected memory region of the ATmega CPU. Using only the serial connection over the USB cable it is not possible to erase or modify the bootloader. Thus, there is no danger of bricking the board. Even a full erase command can’t lock you out of your Arduino-compatible board.

reading the flash

Start a command line window inside the Arduino folder. To read the current flash content (replace com5 by the actual com port you are using):

cd hardware\tools\avr
bin\avrdude -C etc\avrdude.conf -c arduino -P com5 -b 115200 -p m1284p -U flash:r:filename.hex:i

Depending on your serial port configuration the auto reset function might not work and and you have to press the reset button on the board to start the communication.

Instead of repeating the communication options over and over again it is possible to set some default values by editing the avrdude.conf file. Add these lines somewhere at the beginning:

default_serial = "com5"; # insert the port you are using
default_programmer = "arduino";

and extend the programmer definition for arduino boards to look like this:

programmer
id = "arduino";
desc = "Arduino";
type = arduino;
baudrate = 115200;
;

Now reading the flash looks like this:

cd hardware\tools\avr
bin\avrdude -C etc\avrdude.conf -p m1284p -U flash:r:filename.hex:i

writing the flash

Start a command line window inside the Arduino folder. To read the current flash content (replace com5 by the actual com port you are using):

cd hardware\tools\avr
bin\avrdude -C etc\avrdude.conf -c arduino -P com5 -b 115200 -p m1284p -U flash:w:filename.hex

If you have changed the avrdude.conf as described above, you can leave out the -c, -P and -b options. Depending on your serial port configuration the auto reset function might not work and and you have to press the reset button on the board to start the communication.

Tagged with:
Posted in Product support

Leave a Reply

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

Ready to Buy?
MaKr3d products are currently in production and will be available for delivery by the end of the year.

Please contact us at info@makr3d.de if you would like to place your pre-order now.

Contact Us
Have a question, comment or suggestion for us? Send us an email!