When trying to flash my genuine arduino micro with avrdude from cmd on a Manjaro system I get the infamous error

avrdude: stk500_getsync() attempt x of 10 ...

Im adding this post to the many other that ask about this error because all of them are trying to use the IDE to flash the arduino, whereas I can use it no problem on both Linux and Windows, but when using avrdude from cmd on Linux I get this error. This confirms that the board is fine and there are no shorts on the reset pin or any other possible physical cause of this issue, something appears to be wrong in the avrdude configuration.

This is my Makefile:

default: build

    avr-gcc -mmcu=atmega32u4 main.c -o main

    avr-objcopy -O ihex -R .eeprom main main.hex
    avrdude -F -V -c arduino -p m32u4 -P /dev/ttyACM0 -b 115200 -U flash:w:main.hex

Can you suggest anyway to fix this?

EDIT: Problem Solved!

The error was in the -c parameter, for the atmega 32u4 it's supposed to be avr109 and not arduino.

  • 1
    In the IDE you can set the preference for verbose output on upload, and then watch the log. It might show all commands that the IDE uses. May 5, 2022 at 6:01

1 Answer 1


There are two common ways of resetting an Arduino into the bootloader:

  1. For UART based boards (Uno, Mega2560 etc) just opening the port resets the board
  2. For USB based boards (Micro, etc with the 32u4 chip) you have to manually tell it to reset

Yours is option 2 - unless you tell it to reset the board it won't do anything. The IDE normally handles that for you.

But it's simple: just cause the CDC/ACM port to be opened at 1200 baud and closed again. The simplest method is to use stty to do it for you:

stty -F /dev/ttyACM0 speed 1200

You should find that it then resets the board. Adding a short delay to allow the USB to reset would be good too. So your whole programming routine could look something like:

    avr-objcopy -O ihex -R .eeprom main main.hex
    stty -F /dev/ttyACM0 speed 1200
    sleep 1
    avrdude -F -V -c arduino -p m32u4 -P /dev/ttyACM0 -b 115200 -U flash:w:main.hex

In Makefiles I find it useful to set the port as an overridable variable:


Then use ${PORT} everywhere instead of /dev/ttyACM0 - then you can use make PORT=/dev/ttyACM1 if you need to without having to edit the Makefile. Great if you have multiple boards.

  • I was indeed thinking about the reset, thanks for the explanation! When I run the flash command the I get the following and then it stucks without going any further: avr-objcopy -O ihex -R .eeprom main main.hex \n stty -F /dev/ttyACM0 speed 1200 \n 9600 \n What is this about?
    – StefanoN
    May 4, 2022 at 13:04
  • This Arduino Makefile comes with a small script that does exactly this on a Micro, and has different logic for other board types. May 4, 2022 at 13:12
  • @EdgarBonet I'm trying to learn low level programming, thats why I'm doing it with a MakeFile, I don't want to use a python script.
    – StefanoN
    May 4, 2022 at 13:26

Your Answer

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

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