0

The OS I am using is Windows 10, and I already installed avr-gcc and avr-dude, with a bit of search on the internet I found the commands to convert my C program (written for ATMEGA328-P), to the object file and then to the hex file using avr-objcopy, but now I want to know the command to burn this hex file via the Command Prompt. I used

avrdude -v -V -patmega328p -carduino -PCOM* -b115200 -D -Uflash:w:hexfilename.hex

this command in response I got the following:-

C:\Users\AshishHJog\Desktop\Arduino\Bare Metal\Try>avrdude -v -V -patmega328p -carduino -PCOM6 -b115200 -D -Uflash:w:myhex.hex

avrdude: Version 5.11-Patch#7610, compiled on Aug 31 2011 at 08:02:19
         Copyright (c) 2000-2005 Brian Dean, http://www.bdmicro.com/
         Copyright (c) 2007-2009 Joerg Wunsch

         System wide configuration file is "C:\Users\AshishHJog\Desktop\Arduino\Bare Metal\avrdude-5.11-Patch7610-win32\avrdude.conf"

         Using Port                    : COM6
         Using Programmer              : arduino
         Overriding Baud Rate          : 115200
         AVR Part                      : ATMEGA328P
         Chip Erase delay              : 9000 us
         PAGEL                         : PD7
         BS2                           : PC2
         RESET disposition             : dedicated
         RETRY pulse                   : SCK
         serial program mode           : yes
         parallel program mode         : yes
         Timeout                       : 200
         StabDelay                     : 100
         CmdexeDelay                   : 25
         SyncLoops                     : 32
         ByteDelay                     : 0
         PollIndex                     : 3
         PollValue                     : 0x53
         Memory Detail                 :

                                  Block Poll               Page                       Polled
           Memory Type Mode Delay Size  Indx Paged  Size   Size #Pages MinW  MaxW   ReadBack
           ----------- ---- ----- ----- ---- ------ ------ ---- ------ ----- ----- ---------
           eeprom        65    20     4    0 no       1024    4      0  3600  3600 0xff 0xff
           flash         65     6   128    0 yes     32768  128    256  4500  4500 0xff 0xff
           lfuse          0     0     0    0 no          1    0      0  4500  4500 0x00 0x00
           hfuse          0     0     0    0 no          1    0      0  4500  4500 0x00 0x00
           efuse          0     0     0    0 no          1    0      0  4500  4500 0x00 0x00
           lock           0     0     0    0 no          1    0      0  4500  4500 0x00 0x00
           calibration    0     0     0    0 no          1    0      0     0     0 0x00 0x00
           signature      0     0     0    0 no          3    0      0     0     0 0x00 0x00

         Programmer Type : Arduino
         Description     : Arduino
         Hardware Version: 3
         Firmware Version: 4.4
         Vtarget         : 0.3 V
         Varef           : 0.3 V
         Oscillator      : 28.800 kHz
         SCK period      : 3.3 us

avrdude: AVR device initialized and ready to accept instructions

Reading | ################################################## | 100% 0.01s

avrdude: Device signature = 0x1e950f
avrdude: safemode: lfuse reads as 0
avrdude: safemode: hfuse reads as 0
avrdude: safemode: efuse reads as 0
avrdude: reading input file "myhex.hex"
avrdude: input file myhex.hex auto detected as Intel Hex
avrdude: writing flash (124 bytes):

Writing | ################################################## | 100% 0.03s

avrdude: 124 bytes of flash written

avrdude: safemode: lfuse reads as 0
avrdude: safemode: hfuse reads as 0
avrdude: safemode: efuse reads as 0
avrdude: safemode: Fuses OK

avrdude done.  Thank you.

**It seems the hex is flashed from the response but I am not getting the expected output, (expected output:- I wrote a very simple c program to blink the led on digital pin 3 same code when uploaded via microchip studio or Arduino ide works but when I upload it using the above command it doesn't work as expected ). **

6
  • 2
    in arduino IDE, turn on verbose output during upload ... the status panel in the IDE will display the command line
    – jsotola
    Sep 6 '21 at 17:55
  • Have you got any messages from the avrdude? Maybe errors?
    – gbg
    Sep 6 '21 at 17:56
  • @jsotola Okay cool got it, I have updated it, please check
    – Ashish Jog
    Sep 6 '21 at 18:12
  • something is uploading ... maybe a hex file from the wrong directory ... get the avrdude command line from the arduino IDE as a starting point
    – jsotola
    Sep 6 '21 at 21:17
  • @jaotola , no hex file is correct.
    – Ashish Jog
    Sep 7 '21 at 6:14
0

I use such a command for one of my projects, which I copied from the IDE. The very first thing I would do is to use the IDE to upload your hex file and make a copy/past of the command it used (which is how I made mine). That should be the quickest route to a working command.

Otherwise, here are the differences I see between my command and yours. Note that use macOS and there will be some differences in format to an equivalent Windows command:

/Applications/Arduino.app/Contents/Java/hardware/tools/avr/bin/avrdude -C/Applications/Arduino.app/Contents/Java/hardware/tools/avr/etc/avrdude.conf -v -patmega328p -carduino -P/dev/cu.usbserial-A703BVIL -b115200 -D -Uflash:w:$1:i

The differences I see between our two commands are:

  • The -C switch provides a path to the default avrdude config file. I don't see one in your command, and I don't know where the config file lives under windows but maybe this will help you know what to look for.
  • The -V switch tells avrdude to verify after upload. Leaving it off is probably not causing any issues.
  • My -U switch has four arguments; our first three are the same: 'flash' names the memory area to be used, 'w' specifies writing to it, the third argument is the path the hex file to upload (your command is more general and takes its value from the first argument to your command-file, while mine is hard-coded). None of these should be a problem. The fourth argument is an optional format argument, 'i' in my case, unspecified in yours. This is my first guess as to the problem. I've found no more documentation than the Usage panel provides ('avrdude --help') so I don't know what the format argument is for or what the choices are - my command was copy/pasted right out of the IDE.

The first thing I'd try (because it's the easiest! :-) would be adding the ':i' to your -U switch. If that doesn't fix the issue, I'd search for where avrdude stores its config file under Windows and insert -U<config/file/path> in your command.

Hope that helps!

1
  • 1
    is the command in the answer different than the command int the question? did you read the question to the end?
    – Juraj
    Sep 7 '21 at 4:45

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.