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 / Topics / How to generate hex file using avr-gcc commands

How to generate hex file using avr-gcc commands

|

Microcontroller › AVR › How to generate hex file using avr-gcc commands

  • This topic has 1 reply, 1 voice, and was last updated 12 years, 10 months ago by Shashank Rao.C.
Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • June 12, 2013 at 10:37 am #2478
    Shashank Rao.C
    Participant

    hello,

               I have written a coding for some project. I have compiled in avr-gcc commands for ATmega16. Till here its ok.. no error nothing…

    from here i don’t knw how to continue and how to create .hex file and all…

    please any one tell me….

    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.

  • Author
    Posts
Viewing 2 posts - 1 through 2 (of 2 total)
  • You must be logged in to reply to this topic.
Log In

RSS Recent Posts

  • Voltage comparator circuit verification April 10, 2026
  • Help with a coffee machine circuitboard April 10, 2026
  • DS3231 RTC + 24C32 EEPROM I²C Module (PIC18) April 9, 2026
  • Bot checks April 9, 2026
  • Heltec V3 GPS repeater. April 9, 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