EngineersGarage

  • Engineers Garage Main Site
  • Visit our active EE Forums
    • EDABoard.com
    • Electro-Tech-Online
  • Projects & Tutorials
    • Circuits
    • Electronic Projects
    • Tutorials
    • Components
  • Digi-Key Store
    • Cables, Wires
    • Connectors, Interconnect
    • Discrete
    • Electromechanical
    • Embedded Computers
    • Enclosures, Hardware, Office
    • Integrated Circuits (ICs)
    • Isolators
    • LED/Optoelectronics
    • Passive
    • Power, Circuit Protection
    • Programmers
    • RF, Wireless
    • Semiconductors
    • Sensors, Transducers
    • Test Products
    • Tools
  • Advertise
You are here: Home / Replies / hi,       at last i got how

hi,       at last i got how

|

Microcontroller › AVR › How to generate hex file using avr-gcc commands › hi,       at last i got how

June 13, 2013 at 11:16 am #9958
Shashank Rao.C
Participant

hi,

       at last i got how to generate .hex file and programing process in avr dude.

just follow these steps.

 

open a terminal and navigate to where the code is downloaded too. then run the following commands:

 

1.) avr-gcc -g -Os -mmcu=<mcu type> -c file_name.c

this produces an object file called flash.o which then needs to be linked using:

2.) avr-gcc -g -mmcu=<mcu type> -o file_name.elf file_name.o
this has now produced a binary file called flash.elf, which is a GNU executable file. we gotta mess with it a bit more and grab some bits out of it to make the hex file

3.) avr-objcopy -j .text -j .data -O ihex file_name.elf file_name.hex

 

Note:mcu type can be ATmega8,ATmega16,ATmega328 etc in code written as
atmega8,atmega16 etc.

In the home folder you wull get your .hex file

 

Now programing to ic using avr-dude

 

follow these step

 

4.)avrdude -p <microcontroller> -P /dev/ttyACM0 -c stk500v2 -u -U flash:w:filename.hex

 

Microcontroller can be ATmega8,ATmega16,ATmega32,ATmega328, etc..

and is written in code as atmega8,atmega16,atmega32,etc..

 

 

Note: I checked this only in ISP programmer. also this only for avrdude.

RSS Recent Posts

  • RC Electronic Speed Control Capacitors February 17, 2026
  • Annex32 / Annex RDS For ESP Micros - A Quick and Dirty Example February 16, 2026
  • Convenient audio FFT module? February 16, 2026
  • CR2/CR123A Batteries In Projects February 16, 2026
  • Harman Kardon radio module BMW noise February 16, 2026

Stay Up To Date

Newsletter Signup
EngineersGarage

Copyright © 2026 WTWH Media LLC. All Rights Reserved. The material on this site may not be reproduced, distributed, transmitted, cached or otherwise used, except with the prior written permission of WTWH Media
Privacy Policy | Advertising | About Us

Search Engineers Garage

  • Engineers Garage Main Site
  • Visit our active EE Forums
    • EDABoard.com
    • Electro-Tech-Online
  • Projects & Tutorials
    • Circuits
    • Electronic Projects
    • Tutorials
    • Components
  • Digi-Key Store
    • Cables, Wires
    • Connectors, Interconnect
    • Discrete
    • Electromechanical
    • Embedded Computers
    • Enclosures, Hardware, Office
    • Integrated Circuits (ICs)
    • Isolators
    • LED/Optoelectronics
    • Passive
    • Power, Circuit Protection
    • Programmers
    • RF, Wireless
    • Semiconductors
    • Sensors, Transducers
    • Test Products
    • Tools
  • Advertise