2

I am trying to upload an hex file to my arduino pro micro using Avrdude . The thing is that I cannot upload any code using the Avrdude terminal commands , but when I use arduino IDE to upload any code it perfectly uploads the code to Arduino.

The command I am using on the terminal:

avrdude -C C:\Users\santi\AppData\Local\Arduino15\packages\arduino\tools\avrdude6円.3.0-arduino17/etc/avrdude.conf -v -V -patmega32u4 -cavr109 -PCOM15 -b57600 -D -U flash:w:C:\Users\santi\Documents\keyboard\corne\crkbd_rev1_layout_split_3x6_3_mine.hex:i

I already have avrdude on the environment variables on my windows 10 machine.

Output:

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\santi\AppData\Local\Arduino15\packages\arduino\tools\avrdude6円.3.0-arduino17/etc/avrdude.conf"
 Using Port : COM15
 Using Programmer : avr109
 Overriding Baud Rate : 57600
 AVR Part : ATmega32U4
 Chip Erase delay : 9000 us
 PAGEL : PD7
 BS2 : PA0
 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 9000 9000 0x00 0x00
 flash 65 6 128 0 yes 32768 128 256 4500 4500 0x00 0x00
 lfuse 0 0 0 0 no 1 0 0 9000 9000 0x00 0x00
 hfuse 0 0 0 0 no 1 0 0 9000 9000 0x00 0x00
 efuse 0 0 0 0 no 1 0 0 9000 9000 0x00 0x00
 lock 0 0 0 0 no 1 0 0 9000 9000 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 : butterfly
 Description : Atmel AppNote AVR109 Boot Loader
Connecting to programmer: .avrdude: butterfly_recv(): programmer is not responding
avrdude: butterfly_recv(): programmer is not responding

I keep waiting but it does not upload the code.

I added a push button for RST and GND pins to enter bootloader mode, and I am pressing the reset button. I even tried resetting twice quickly, but I get the same result.

I tried using the Arduino and the code gets uploaded.

I uploaded the following code:

int RXLED = 17; 
void setup(){
 pinMode(RXLED, OUTPUT); 
}
void loop() {
 digitalWrite(RXLED, LOW);
 delay(1500); 
 digitalWrite(RXLED, HIGH); 
 delay(1500); 
}

The command ran in the IDE is:

"C:\Users\santi\AppData\Local\Arduino15\packages\arduino\tools\avrdude6円.3.0-arduino17/bin/avrdude" "-CC:\Users\santi\AppData\Local\Arduino15\packages\arduino\tools\avrdude6円.3.0-arduino17/etc/avrdude.conf" -v -V -patmega32u4 -cavr109 -PCOM16 -b57600 -D "-Uflash:w:C:\Users\santi\AppData\Local\Temp\arduino-sketch-F0563C64AD4C1F392D3E71AA32E4F874/blink_nano.ino.hex:i"

Arduino IDE output:

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\santi\AppData\Local\Arduino15\packages\arduino\tools\avrdude6円.3.0-arduino17/etc/avrdude.conf"
 Using Port : COM16
 Using Programmer : avr109
 Overriding Baud Rate : 57600
 AVR Part : ATmega32U4
 Chip Erase delay : 9000 us
 PAGEL : PD7
 BS2 : PA0
 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 9000 9000 0x00 0x00
 flash 65 6 128 0 yes 32768 128 256 4500 4500 0x00 0x00
 lfuse 0 0 0 0 no 1 0 0 9000 9000 0x00 0x00
 hfuse 0 0 0 0 no 1 0 0 9000 9000 0x00 0x00
 efuse 0 0 0 0 no 1 0 0 9000 9000 0x00 0x00
 lock 0 0 0 0 no 1 0 0 9000 9000 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 : butterfly
 Description : Atmel AppNote AVR109 Boot Loader
Connecting to programmer: .
Found programmer: Id = "CATERIN"; type = S
 Software Version = 1.0; No Hardware Version given.
Programmer supports auto addr increment.
Programmer supports buffered memory access with buffersize=128 bytes.
Programmer supports the following devices:
 Device code: 0x44
avrdude: devcode selected: 0x44
avrdude: AVR device initialized and ready to accept instructions
Reading | ################################################## | 100% 0.00s
avrdude: Device signature = 0x1e9587 (probably m32u4)
avrdude: reading input file "C:\Users\santi\AppData\Local\Temp\arduino-sketch-F0563C64AD4C1F392D3E71AA32E4F874/blink_nano.ino.hex"
avrdude: writing flash (3852 bytes):
Writing | ################################################## | 100% 0.29s
avrdude: 3852 bytes of flash written
avrdude done. Thank you.

I tried using the same Avrdude command in the terminal.

"C:\Users\santi\AppData\Local\Arduino15\packages\arduino\tools\avrdude6円.3.0-arduino17/bin/avrdude" "-CC:\Users\santi\AppData\Local\Arduino15\packages\arduino\tools\avrdude6円.3.0-arduino17/etc/avrdude.conf" -v -V -patmega32u4 -cavr109 -PCOM16 -b57600 -D "-Uflash:w:C:\Users\santi\AppData\Local\Temp\arduino-sketch-F0563C64AD4C1F392D3E71AA32E4F874/blink_nano.ino.hex:i"

Output:

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\santi\AppData\Local\Arduino15\packages\arduino\tools\avrdude6円.3.0-arduino17/etc/avrdude.conf"
 Using Port : COM16
 Using Programmer : avr109
 Overriding Baud Rate : 57600
avrdude: ser_open(): can't open device "\\.\COM16": El sistema no puede encontrar el archivo especificado.

I don ́t know why it uses a different port. I tried changing the port in that command but I get the same result as before

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\santi\AppData\Local\Arduino15\packages\arduino\tools\avrdude6円.3.0-arduino17/etc/avrdude.conf"
 Using Port : COM15
 Using Programmer : avr109
 Overriding Baud Rate : 57600
 AVR Part : ATmega32U4
 Chip Erase delay : 9000 us
 PAGEL : PD7
 BS2 : PA0
 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 9000 9000 0x00 0x00
 flash 65 6 128 0 yes 32768 128 256 4500 4500 0x00 0x00
 lfuse 0 0 0 0 no 1 0 0 9000 9000 0x00 0x00
 hfuse 0 0 0 0 no 1 0 0 9000 9000 0x00 0x00
 efuse 0 0 0 0 no 1 0 0 9000 9000 0x00 0x00
 lock 0 0 0 0 no 1 0 0 9000 9000 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 : butterfly
 Description : Atmel AppNote AVR109 Boot Loader
Connecting to programmer: .avrdude: butterfly_recv(): programmer is not responding

I could just use the arduino IDE to flash my device but the problem is that I only have the hex file. I am trying to flash my device with a hex file from QMK Configurator. I am trying to build a custom keyboard.

asked Jan 30, 2023 at 19:27
1
  • When you tried the same command as the IDE, did you close the IDE? There is a possibility that it has the port open, which will block other programs from accessing it. Commented Jan 31, 2023 at 8:33

1 Answer 1

2

You have to reset the Arduino using a very special procedure in order for it to accept being programmed. This involves opening the port at 1200 bps, toggling some control lines, and closing the port again. You may try using this ard-reset-arduino Python script with the option --caterina.

By the way, this script belongs a project called "Arduino-Makefile". You may want to take a look if you want to program your Arduino from the command line. Alternatively, you can use arduino-cli.

answered Jan 31, 2023 at 8:42
1
  • "I am trying to flash my device with a hex file from QMK Configurator." The arduino-cli does the 1200baud touch as part of the upload process, but it might not apply or may need clarification on how to apply. I'm not sure how you'd make use of it unless it has the ability to be supplied arbitrary hex files to upload, or has a stand-alone command for issuing a 1200 baud touch, or unless you can sneak your hex file over top of one the compile command had created. "I even tried resetting twice quickly" This should have given them 8 seconds of bootloader time, though the tool would help. Commented Feb 1, 2023 at 15:32

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.