I am trying to load a hex file onto a nano.
I am reading arduino as ISP and arduino bootloaders.
I have set my uno and nano up so the uno is the programmer and the nano the target. I think I have successfully loaded the bootloader onto my nano, just to test the wiring and connection.
Below the heading the page then says
"Arduino ISP turns your Arduino into an in-circuit programmer to re-program AtMega chips.
It stops at the bootloader and doesn't tell how to go any further.
Is it possible to load hex files using this method and if so how do I do it?
First enable Show verbose output during upload in file → preferences in the IDE.
Next I suggest that you first upload an innocent sketch like blink via ICSP. This will give you the avrdude command that is executed when uploading via ICSP. Below for a Windows system
It will overwrite the bootloader but that is not a problem; the only purpose of burning the bootloader is to set the fuses correctly for the 328P and that will be maintained.
thank you sterretje,
I am not quite sure about how to do this.
I have enabled show verbose output during compile as well as upload and I am getting a long list of commands when I compile the blink sketch, none that include ones similar to your lines.
I assume I have got your instructions wrong.
I assume my hex file has to be in the same directory as the other files
Where do I put this command so it loads the file into the nano?
Is it loading 3 files avrdude, avrdude.conf and my hex file?
You would select Arduino as ISP as the Programmer, and select its COM port. Then at the upper right, select ATmega328P as the MCU. Enter the hex file you want to upload in the Flash box, and select Intel Hex as the Format. Then select Write, then Go.
The picture shows Bandgap.ino as my sketch, including the location of the file. I had to know the location. After Verifying your sketch in the IDE for the Nano and its appropriate old or new bootloader, but before shutting down the IDE, you will find the hex file in your AppData\Local\Temp\Arduino_build_xxxxxx.
Included in that folder is, in my case, the file Bandgap.ino.with_bootloader.hex. I haven't ever tried it, but I think if you upload that file, you will have both your sketch and the bootloader, if that's what you want. So the question is - do you want the bootloader to still be there after you've uploaded your hex file?
I should add that this works for IDE v1.8. I don't know about v2.
AVRDudess can also be used to read and set the fuses, as shown in the picture, as well as read and write EEPROM data. It's quite a useful program.
mikedb, putting it in capitals doesn't make it any clearer and I assume it is 'upload using programmer' in the sketch tab.
I assume I have the 'arduinoISP' sketch in the UNO?
Where do I put the lines "C:\Users\bugge\AppData\Local\Arduino15\packages\arduino\tools\avrdude\6.3.0-arduino17/bin/avrdude" "-CC:\Users\bugge\AppData\Local\Arduino15\packages\arduino\tools\avrdude\6.3.0-arduino17/etc/avrdude.conf" -v -patmega328p -cstk500v1 -PCOM4 -b19200 "-Uflash:w:pathTo\myHex:i"
or at least my version of them so that the hex file goes into the nano?
Thank you for bearing with me sterretje, I really would like to succeed with this.
I am using windows 10 and the IDE version 2.3.4.
I now have a hex file called nano_file.hex in the c:directory (the root directory) and the other files avrdude.exe and avrdude.conf in the files pointed to in the following entry, now bearing in mind that some of the slashes are forward and some are back the same as yours in post 2 does this look about right
I think my COM is 20 but that will depend on which lead I use and hence which com port is connected so I will alter PCOM4 to PCOM20.
Do I need the UNO set up connected to the computer on COM 20 if it is relevant with the ISP sketch in it, set to 'programmer Arduino as ISP' and the nano connected to the UNO via ISP?
Or am I loading direct into the nano with no UNO connected?
You need to upload the ArduinoISP sketch to the Uno using the IDE; use the Uno's COM port. That will make the Uno a programmer.
Next you can run the avrdude command, again using the Uno's port.
Sorry guys, I still can't get the dam thing to work.
I have an Uno containing the Arduino ISP, a nano connected to pins 10,11,12 and 13 of the UNO into the isp socket of the nano and a capacitor inserted in the UNO reset as it should be.
The full line I have been quoting above seemed to be too long for the command prompt so I have moved the /bin and the /etc directories down to the c: drive.
I now have two directories in the root directory.
/bin contains the 7 files that are present in the /bin directory when it is so far in the drive and the /etc directory contains avrdude.conf so I should be able to call it with
"C:\bin\avrdude” -C "C:\etc/avrdude.conf” -v -patmega328p -cstk500v1 -PCOM10 -b19200 -Uflash:w: "C:/nano_file.hex:i”
The hex file to load is in the root directrory.
When I put the instruction above in the command prompt and press enter I get
I have tried changing the slashes \ for / and vice versa (does it matter which way round they are?) but with no improvement.
Can you see what I am doing wrong?
The problem is caused by the use of "curly quotes" (”) in the command. You can use these characters in prose, but you should never use them in machine syntax. You must always use straight quotes " in that application.
Word processors often have a "smart quotes" feature where it will automatically use curly quotes. You must avoid ever using such word processors with command lines or code.
Probably not. Although \ is the native Windows path separator, the POSIX / is also supported by Windows in most contexts.
?
I have altered the " to straight ones and it looks to have gone in?
"C:\bin\avrdude" -C "C:\etc\avrdude.conf" -v -patmega328p -cstk500v1 -PCOM10 -b19200 -Uflash:w: "C:\nano_file.hex:i"
I have set up the test with 3 leds as shown in https://docs.arduino.cc/built-in-examples/arduino-isp/ArduinoISP/
that indicate a heartbeat, error and programming and they flashed so it looks as if it worked, I now have to try to build a bit more of the unit before I can confirm it.
Thanks for the advice I do appreciate it and will return when I get some indication that it worked or otherwise.