Uploading .hex files to ATtiny using Arduino UNO as ISP

The Experiment: How to Upload a .hex file using the Arduino IDE and the ArduinoISP sketch. Why doesn’t the Arduino IDE have an Upload .hex file option.  A lot of micro project on the internet only supply the .hex file. Not wanting to install another program to upload .hex code “though” the Arduino IDE uses (Avrdude) to Upload the .hex file.  So why not launched an external .bat file to Upload .hex code though the ArduinoISP.

The challenge, figure out how to use the Arduino UNO COM port to Upload a .hex code through the ArduinoISP sketch.

How to program ATtiny from Arduino ISP with .hex file

Required Software Arduino IDE
If  Arduino IDE already installed, then  skip Step1.

Step1: Download and Install the Arduino IDE (Latest Arduino IDE Download) follow the installation instruction on the Arduino web site.

Step2: Locate the Arduino IDE folder and create a new folder called (hexFiles).

Step3: Launch the Arduino IDE

Step4: For testing load the Blink sketch (File>Examples>Basic>Blink) don’t forget to select the correct board in Tools.

 Step5: Click the (Check) icon to Verify and Compile the sketch.

Step6: Locate the Blink.cpp.hex usually located in the user Temp folder. Copy the Blink.cpp.hex to the (hexFile) folder.

Step7: Load the ArduinoISP to the Arduino UNO (File>Examples>ArduinoISP) don’t forget to select the correct board/com port in Tools.

Step8: Click (check) icon Verify sketch

Step9: Click (arrow) icon compile sketch

Step10: Close the Arduino IDE (File>Close)

Step11: Unplug the Arduino UNO ISP from the USB port.

How to Upload a .hex file using Arduino IDE / Arduino ISP

Step1: Create a (hexUpload.bat) file copy and past the following to the .bat file:

C:\arduino-1.0.3\hardware/tools/avr/bin/avrdude -CC:\arduino-1.0.3\
hardware/tools/avr/etc/avrdude.conf -v -v -v -v -pattiny85 -cstk500v1
 -P\\.\COM11 -b19200 -Uflash:w:C:\arduino-1.0.3\hexFiles\
Blink.cpp.hex:i

pause

Caution when coping/pasting command is one line with blank line between pause
Update: parameters in Italic to Arduino IDE installed path/folders

C:\arduino-1.0.3\hardware/tools/avr/bin/avrdude -CC:\arduino-1.0.3\hardware/tools/avr/etc/avrdude.conf -v -v -v -v -pattiny85 -cstk500v1 -P\\.\COM11 -b19200 -Uflash:w:C:\arduino-1.0.3\hexFiles\Blink.cpp.hex:i

 Verify path to avrdude.exe :
C:\arduino-1.0.3\hardware/tools/avr/bin/avrdude
Verify path to avrdude.conf:
C:\arduino-1.0.3\hardware/tools/avr/etc/avrdude.conf
Verify Micro:
attiny85  (see -p avrdude documentation)
stk500v1 (see -c avrdude documentation)
Verify COM-Port:
COM11
Verify path to hex file Path\HEX  file name
C:\arduino-1.0.3\hexFiles\Blink.cpp.hex

Step2: (if all information is correct) Save the hexUpload.bat file

Step3: Launch the Arduino IDE.

Step4: Verify the Board (tools>Board)

Step5: Verify the COM-Port (tools>Serial Port)

Step6: Plug the Micro into programming shield

Step7: Connect the  Arduino UNO / ArduinoISP / Programming shield to the USB port

Step8: Launch the hexUpload.bat batch file

If all is correct .hex code will upload to the Micro.

Notes:
Watch TX/RX LED should flash during upload.
Only tested process with Arduino UNO

On a side note:

Here is a .bat file that Cleans up temporary Arduino files & folders.

rem Clean up temporary Arduino files & folders.
rem First change directory to location
rem of temporary folders...
rem Created By John Owen

cd c:\users\xxxxx\appdata\local\temp

for /d %%a in (build*.tmp) do rmdir /s /q %%a
for /d %%a in (console*.tmp) do rmdir /s /q %%a
for /d %%a in (untitled*.tmp) do rmdir /s /q %%a
Advertisements