Minimum amount of files needed to upload a sketch

I am having a problem with avrdude. I am trying to upload a .bin file with avrdude. I made a folder with the following files.

avrdude.conf
avrdude.exe
avrdude.pdb
MyCode_1.1.hex

Then I compiled my program in the IDE and from verbose mode I copied the command. I shortened it because I don't need file paths.

avrdude -Cavrdude.conf -v  -patmega4809 -cjtag2updi -Pcom13  -b115200 -e -D "-Uflash:w:MyCode_1.1.ino.hex:i" "-Ufuse2:w:0x01:m" "-Ufuse5:w:0xC9:m" "-Ufuse8:w:0x00:m" {upload.extra_files}

When I run this command and many variations on the file paths I get this error.

avrdude: Version 7.3
         Copyright the AVRDUDE authors;
         see https://github.com/avrdudes/avrdude/blob/main/AUTHORS

         System wide configuration file is c:\MyFolder\avrdude.conf

         Using port            : com13
         Using programmer      : jtag2updi
         Programmer baud rate  : 115200
avrdude jtagmkII_recv_frame() error: timeout
avrdude jtagmkII_getsync() warning: attempt 1 of 10: sign-on command: status -1

I can upload from the IDE easily so I know the port number is correct and the cable and board are good. I have tried things like resetting the board, and rebooting. I am looking for any ideas of what might be going wrong.

I let it time out completely. Here is the output:

avrdude: Version 7.3
         Copyright the AVRDUDE authors;
         see https://github.com/avrdudes/avrdude/blob/main/AUTHORS

         System wide configuration file is c:\Orthos\avrdude.conf

         Using port            : com13
         Using programmer      : jtag2updi
         Programmer baud rate  : 115200
avrdude jtagmkII_recv_frame() error: timeout
avrdude jtagmkII_getsync() warning: attempt 1 of 10: sign-on command: status -1
avrdude jtagmkII_recv_frame() error: timeout
avrdude jtagmkII_getsync() warning: attempt 2 of 10: sign-on command: status -1
avrdude jtagmkII_recv_frame() error: timeout
avrdude jtagmkII_getsync() warning: attempt 3 of 10: sign-on command: status -1
avrdude jtagmkII_recv_frame() error: timeout
avrdude jtagmkII_getsync() warning: attempt 4 of 10: sign-on command: status -1
avrdude jtagmkII_recv_frame() error: timeout
avrdude jtagmkII_getsync() warning: attempt 5 of 10: sign-on command: status -1
avrdude jtagmkII_recv_frame() error: timeout
avrdude jtagmkII_getsync() warning: attempt 6 of 10: sign-on command: status -1
avrdude jtagmkII_recv_frame() error: timeout
avrdude jtagmkII_getsync() warning: attempt 7 of 10: sign-on command: status -1
avrdude jtagmkII_recv_frame() error: timeout
avrdude jtagmkII_getsync() warning: attempt 8 of 10: sign-on command: status -1
avrdude jtagmkII_recv_frame() error: timeout
avrdude jtagmkII_getsync() warning: attempt 9 of 10: sign-on command: status -1
avrdude jtagmkII_recv_frame() error: timeout
avrdude jtagmkII_getsync() warning: attempt 10 of 10: sign-on command: status -1
avrdude jtagmkII_getsync() error: timeout/error communicating with programmer (status -1)
avrdude main() error: unable to open port com13 for programmer jtag2updi
Possible candidate serial ports are:
  -P COM1
  -P COM7
  -P COM8
  -P COM13 or -P usb:2341:0058
Note that above ports might not be connected to a target board or an AVR programmer.
Also note there may be other direct serial ports not listed above.

avrdude done.  Thank you.


I know nothing about avrdude, but do you need to define the mcu/board in a make/conf file? I see it... atmega4809

I don't have 4809 based boards so can not check.

When you upload using the IDE, do you see a line like "Resetting board with baud rate 1200 bps"? You will need to have verbose output during upload enabled.

Yes, and I can access the com port with the mode command. I have tried mode and can open the port. It does not seem to help.

>mode com13: baud=12
Default to 7 data bits.
Default to even parity.

Status for device COM13:
------------------------
    Baud:            1200
    Parity:          Even
    Data Bits:       7
    Stop Bits:       1
    Timeout:         ON
    XON/XOFF:        OFF
    CTS handshaking: OFF
    DSR handshaking: OFF
    DSR sensitivity: OFF
    DTR circuit:     OFF
    RTS circuit:     OFF

Are you sure about that baud? I'd have to put my jtag2updi board back together again to check but I thought it used a much slower speed. Just for fun, try running the avrdude command without specifying the baud and see what happens.

Please disable verbose output during compilation and enable verbose output during upload and perform an upload using the IDE. Post the output here (please use code tags).

Sketch uses 16784 bytes (34%) of program storage space. Maximum is 49152 bytes.
Global variables use 938 bytes (15%) of dynamic memory, leaving 5206 bytes for local variables. Maximum is 6144 bytes.
Performing 1200-bps touch reset on serial port COM13
"C:\Users\XXXX\AppData\Local\Arduino15\packages\arduino\tools\avrdude\6.3.0-arduino17/bin/avrdude" "-CC:\Users\XXXX\AppData\Local\Arduino15\packages\arduino\tools\avrdude\6.3.0-arduino17/etc/avrdude.conf" -v  -patmega4809 -cjtag2updi -PCOM13  -b115200 -e -D "-Uflash:w:C:\Users\XXXXAppData\Local\Temp\arduino\sketches\37ECFFAF87C165F9C8347C410B954009/MyCode.ino.hex:i" "-Ufuse2:w:0x01:m" "-Ufuse5:w:0xC9:m" "-Ufuse8:w:0x00:m" {upload.extra_files}

avrdude: Version 6.3-20190619
         Copyright (c) 2000-2005 Brian Dean, http://www.bdmicro.com/
         Copyright (c) 2007-2014 Joerg Wunsch

         System wide configuration file is "C:\Users\XXXX\AppData\Local\Arduino15\packages\arduino\tools\avrdude\6.3.0-arduino17/etc/avrdude.conf"

         Using Port                    : COM13
         Using Programmer              : jtag2updi
         Overriding Baud Rate          : 115200
JTAG ICE mkII sign-on message:
Communications protocol version: 1
M_MCU:
  boot-loader FW version:        1
  firmware version:              1.07
  hardware version:              1
S_MCU:
  boot-loader FW version:        1
  firmware version:              6.07
  hardware version:              1
Serial number:                   00:00:00:00:00:00
Device ID:                       JTAGICE mkII
         AVR Part                      : ATmega4809
         Chip Erase delay              : 0 us
         PAGEL                         : P00
         BS2                           : P00
         RESET disposition             : dedicated
         RETRY pulse                   : SCK
         serial program mode           : yes
         parallel program mode         : yes
         Timeout                       : 0
         StabDelay                     : 0
         CmdexeDelay                   : 0
         SyncLoops                     : 0
         ByteDelay                     : 0
         PollIndex                     : 0
         PollValue                     : 0x00
         Memory Detail                 :

                                  Block Poll               Page                       Polled
           Memory Type Mode Delay Size  Indx Paged  Size   Size #Pages MinW  MaxW   ReadBack
           ----------- ---- ----- ----- ---- ------ ------ ---- ------ ----- ----- ---------
           signature      0     0     0    0 no          3    0      0     0     0 0x00 0x00
           prodsig        0     0     0    0 no         61   61      0     0     0 0x00 0x00
           fuses          0     0     0    0 no          9    0      0     0     0 0x00 0x00
           fuse0          0     0     0    0 no          1    0      0     0     0 0x00 0x00
           fuse1          0     0     0    0 no          1    0      0     0     0 0x00 0x00
           fuse2          0     0     0    0 no          1    0      0     0     0 0x00 0x00
           fuse4          0     0     0    0 no          1    0      0     0     0 0x00 0x00
           fuse5          0     0     0    0 no          1    0      0     0     0 0x00 0x00
           fuse6          0     0     0    0 no          1    0      0     0     0 0x00 0x00
           fuse7          0     0     0    0 no          1    0      0     0     0 0x00 0x00
           fuse8          0     0     0    0 no          1    0      0     0     0 0x00 0x00
           lock           0     0     0    0 no          1    0      0     0     0 0x00 0x00
           data           0     0     0    0 no          0    0      0     0     0 0x00 0x00
           usersig        0     0     0    0 no         64   64      0     0     0 0x00 0x00
           flash          0     0     0    0 no      49152  128      0     0     0 0x00 0x00
           eeprom         0     0     0    0 no        256   64      0     0     0 0x00 0x00

         Programmer Type : JTAGMKII_PDI
         Description     : JTAGv2 to UPDI bridge
         M_MCU hardware version: 1
         M_MCU firmware version: 1.07
         S_MCU hardware version: 1
         S_MCU firmware version: 6.07
         Serial number:          00:00:00:00:00:00
         Vtarget         : 5.0 V

avrdude: jtagmkII_initialize(): Cannot locate "flash" and "boot" memories in description
avrdude: AVR device initialized and ready to accept instructions

Reading | ################################################## | 100% 0.27s

avrdude: Device signature = 0x1e9651 (probably m4809)
avrdude: erasing chip
avrdude: reading input file "C:\Users\XXXX\AppData\Local\Temp\arduino\sketches\37ECFFAF87C165F9C8347C410B954009/MyCode.ino.hex"
avrdude: writing flash (16784 bytes):

Writing | ################################################## | 100% 12.38s

avrdude: 16784 bytes of flash written
avrdude: verifying flash memory against C:\Users\XXXX\AppData\Local\Temp\arduino\sketches\37ECFFAF87C165F9C8347C410B954009/MyCode.ino.hex:
avrdude: load data flash data from input file C:\Users\XXXX\AppData\Local\Temp\arduino\sketches\37ECFFAF87C165F9C8347C410B954009/MyCode.ino.hex:
avrdude: input file C:\Users\XXXX\AppData\Local\Temp\arduino\sketches\37ECFFAF87C165F9C8347C410B954009/MyCode.ino.hex contains 16784 bytes
avrdude: reading on-chip flash data:

Reading | ################################################## | 100% 2.40s

avrdude: verifying ...
avrdude: 16784 bytes of flash verified
avrdude: reading input file "0x01"
avrdude: writing fuse2 (1 bytes):

Writing | ################################################## | 100% 0.01s

avrdude: 1 bytes of fuse2 written
avrdude: verifying fuse2 memory against 0x01:
avrdude: load data fuse2 data from input file 0x01:
avrdude: input file 0x01 contains 1 bytes
avrdude: reading on-chip fuse2 data:

Reading | ################################################## | 100% 0.00s

avrdude: verifying ...
avrdude: 1 bytes of fuse2 verified
avrdude: reading input file "0xC9"
avrdude: writing fuse5 (1 bytes):

Writing | ################################################## | 100% 0.01s

avrdude: 1 bytes of fuse5 written
avrdude: verifying fuse5 memory against 0xC9:
avrdude: load data fuse5 data from input file 0xC9:
avrdude: input file 0xC9 contains 1 bytes
avrdude: reading on-chip fuse5 data:

Reading | ################################################## | 100% 0.00s

avrdude: verifying ...
avrdude: 1 bytes of fuse5 verified
avrdude: reading input file "0x00"
avrdude: writing fuse8 (1 bytes):

Writing | ################################################## | 100% 0.01s

avrdude: 1 bytes of fuse8 written
avrdude: verifying fuse8 memory against 0x00:
avrdude: load data fuse8 data from input file 0x00:
avrdude: input file 0x00 contains 1 bytes
avrdude: reading on-chip fuse8 data:

Reading | ################################################## | 100% 0.00s

avrdude: verifying ...
avrdude: 1 bytes of fuse8 verified

avrdude done.  Thank you.


Are you sure about that baud? I'd have to put my jtag2updi board back together again to check but I thought it used a much slower speed. Just for fun, try running the avrdude command without specifying the baud and see what happens.

It defaulted to the same baud.

Hmm. I put my jtag2updi board back together and it didn't care what baud was specified either. So much for my memory. :slight_smile:

What happens if you execute the exact command that the IDE does, but from the command line?

"C:\Users\XXXX\AppData\Local\Arduino15\packages\arduino\tools\avrdude\6.3.0-arduino17/bin/avrdude" "-CC:\Users\XXXX\AppData\Local\Arduino15\packages\arduino\tools\avrdude\6.3.0-arduino17/etc/avrdude.conf" -v  -patmega4809 -cjtag2updi -PCOM13  -b115200 -e -D "-Uflash:w:C:\Users\XXXXAppData\Local\Temp\arduino\sketches\37ECFFAF87C165F9C8347C410B954009/MyCode.ino.hex:i" "-Ufuse2:w:0x01:m" "-Ufuse5:w:0xC9:m" "-Ufuse8:w:0x00:m" {upload.extra_files}

@colinsk
The command lines in posts #1 and #8 looks the same except for the paths. Are the avrdude.conf files the same in both cases?

1 Like

Ah, the executables are different.

IDE

avrdude: Version 6.3-20190619

Command line

avrdude: Version 7.3
2 Likes

Compiling it with 6.3.1 and the config file also fails in the same way. I really think the issue is the reset that the IDE performs just before uploading the code.

Performing 1200-bps touch reset on serial port COM13

Google is failing me at finding out how to replicate this command.

As far I know, the IDE does nothing except the fairing the avrdude. So, the reset will performed by avrdude itself...

I was able to solve the problem. I use the exact build command but I put it in a batch file. Just before the build command I executed this command:

mode COM13: BAUD=1200 parity=N data=8 stop=1

Thank you everyone for the ideas, I was beating my head against the wall before your input.

I should note, executing the two lines without being in a batch file didn't work.

Thanks, good to know.

You can mark your post #15 as the solution by clicking the little check box under that post. It might help others that encounter the same problem to know that there was a solution.

FYI, when using AVRDUDE 7.3, you can simply add an -r flag to the avrdude command and it will perform the "1200 bps touch" for you without any need to implement your own separate touch system:

https://avrdudes.github.io/avrdude/7.3/avrdude_4.html#index-Option-_002dr

2 Likes

That's not an AVR BOARD. try inserting arduino as isp

or a avrisp mkll

FYI, when using AVRDUDE 7.3, you can simply add an -r flag to the avrdude command and it will perform the "1200 bps touch" for you without any need to implement your own separate touch system:

AVRDUDE: 2.1 Option Descriptions

Thank you that is very helpful!

1 Like