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.
In my case, the command was: "C:\Program Files (x86)\Arduino\hardware\tools\avr/bin/avrdude -CC:\Program Files (x86)\Arduino\hardware\tools\avr/etc/avrdude.conf -v -patmega328p -carduino -PCOM9 -b57600 -D -Uflash:w:C:\Users\Kishi\AppData\Local\Temp\arduino_build_521698/efi_davide_nano.ino.hex:i".
After that, I copied the file "avrdude.conf" from my PC into the Raspberry Pi, using Samba.
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.
avrdude -C avrdude.conf -v -p atmega328p -c arduino -P /dev/ttyUSB0 -b 57600 -D -U flash:w:efi_davide_nano.ino.hex:i