Flashing Arduino with avrdude using Raspberry Pi shell

Recently, I found a method to flash a "hex" file into Arduino Nano, by using "avrdude" running on a Raspberry Pi. In my case, I have an Arduino Nano connected, via USB, to a Raspberry Pi 3 B. The Raspberry Pi is connected to my home network using an Ethernet cable. I am developing the software using Arduino IDE, on my PC running Windows. But when I want to flash the software,

The first step is to set Arduino IDE preferences to verbose the "compilation" and "upload" commands (it is necessary to check the 2 options shown below).

After that, when compiling the sketch, Arduino IDE shows the following info. You need to find out what is the folder in which Arduino IDE stores the "hex" file. In my case, the "hex" file is stored at path "C:\Users\Kishi\AppData\Local\Temp\arduino_build_521698/efi_davide_nano.ino.hex".

The following file "hex" file has to be copied on the Raspberry Pi, for example using Samba.

The next step is to find out which is the "avrdude" command used by Arduino IDE to flash the "hex" file into Arduino. We also need to find out the location in which the "avrdude.conf" file is located.

After that, I copied the file "avrdude.conf" from my PC into the Raspberry Pi, using Samba.

Then, connect Arduino to the Raspberry Pi, and check the USB serial device name which has been given to Arduino Uno/Nano. In my case, the device name is ttyUSB0.

cd /dev/
ls

Before flashing the "hex" file, it is necessary to have avrdude installed on the Raspberry Pi. To do that, just type the following.

sudo apt-get install avrdude

In order to flash the "hex" file into Arduino Nano, I used the following command. Basically, I just revised the Arduino IDE command by modifying the name of the serial port (/dev/ttyUSB0) and the file paths. It is important that you place the hex file and avrdude.conf in the same folder, and launch the command from the same path.

In case everything was correct, you should see these messages on the shell. Avrdude is at first flashing the software (writing) and then reading the data which was flashed in the microcontroller.

Author: Davide Cavaliere

I am an Italian Electrical Engineer graduated at Politecnico di Milano.
My interests are motorcycles and cars, electronics, programming, Internet of Things, and Japanese culture.
View all posts by Davide Cavaliere