Hi, I have a hex file and I want to program the hex file into a standalone atmega2560 microcontroller by using a USB AVR programmer. Can anyone explain step by step to me in detail how to do it? Thank you.
Generate model command
First, we’re going to do a dummy upload in the Arduino IDE in order to get it to help us generate the
avrdude command used to write the program to the Arduino board.
Note: It doesn't matter whether the upload will succeed or fail. You get the command either way.
- Plug the Arduino board you want to write to into your computer.
- Select your board from the Arduino IDE’s Tools > Board menu.
- Select your board’s port from the Tools > Port menu.
- Select File > Preferences from the Arduino IDE's menus.
- Check the box next to "Show verbose output during:  upload".
- Click the OK button.
- Select Sketch > Upload from the Arduino IDE's menus.
- Wait for the upload to finish/fail.
- Scroll up the black console window at the bottom of the Arduino IDE window until you see the avrdude command that was generated for the upload. It will look something like this:
E:\Arduino\hardware\tools\avr\avrdude -CE:\Arduino\hardware\tools\avr/etc/avrdude.conf -v -patmega328p -carduino -PCOM17 -b115200 -D -Uflash:w:C:\Users\per\AppData\Local\Temp\arduino_build_91864/sketch_jan22b.ino.hex:i
- Select the full text of the upload command.
- Press Ctrl+C. This will copy the upload command to the clipboard.
Next, you need to modify the upload command to write the hex file you read from your other Arduino board:
- Start a text editor program.
- In the text editor window, press Ctrl+V. This will paste the command into the text editor. The end of the command will look something like this:
That is the part of the command that tells it to write.
- Replace the filename in that part of the command with the name of the file you read:
So now the full command looks something like this:
If the paths in the command contain spaces, wrap the paths in quotes.
E:\Arduino\hardware\tools\avr\avrdude -CE:\Arduino\hardware\tools\avr/etc/avrdude.conf -v -patmega328p -carduino -PCOM17 -b115200 -D -Uflash:w:readfile.hex:i
Now the write command is all prepared. It's time to run it!
- Plug your Arduino board into your computer.
- Select the full text of the write command in your text editor.
- Press Ctrl+C. This will copy the write command to the clipboard.
- Open a command line terminal. On Windows, you can use the Run dialog, PowerShell, or cmd.
- In the command line, press Ctrl+V. This will paste the
- Press Enter to run the command.
- Wait for the writing process to finish successfully.
This topic was automatically closed 120 days after the last reply. New replies are no longer allowed.