3

I am using CLion as IDE. After building the output is an executable file example. What I would like to achieve is make .hex file from it and upload it to my AVR via avrdude. I read and tried some possible solutions here

xxd -p example | tr -d '\n' > example.hex

and

avrdude -u -c usbasp-clone -p atmega8 -P /dev/bus/usb/001/006 -U flash:w:example.hex

but avrdude outputs

avrdude: input file example.hex auto detected as invalid format
avrdude: invalid input file format: -1
avrdude: read from file 'example.hex' failed

Any ideas here?

Community
  • 1
  • 1
etilge
  • 85
  • 1
  • 9

1 Answers1

3

The tool for extracting sections from an executable and converting them into another format is objcopy.

avr-objcopy -j .text -j .data -O ihex example example.hex

Or if your avrdude is built with ELF support then you can use the executable directly.

avrdude -c usbasp-clone -p atmega8 -U flash:w:example
Ignacio Vazquez-Abrams
  • 776,304
  • 153
  • 1,341
  • 1,358