how do you compile code in avrdude?

I do not understand how to compile c code in avrdude?

sort by: active | newest | oldest
gmoon8 years ago
The open source tools available for AVR programming are powerful, but there's a steep learning curve. Lets see if this this helps...

-- avrdude isn't the C compiler, it's a program that transfers the finished compiled code from your computer into the AVR. This type of utility is often called a "programmer," as it does physically "program" the chip. But it's not involved in the "programming" (code writing) at all...

-- The GNU open source C compiler is avr-gcc.

The original *nix (Linux, Unix, etc.) GCC project is portable compiler that works with many target architectures (AVR is only one.) Recompiled versions of avr-gcc should be available for any Linux distribution. There's also a Windows port of avr-gcc and for Macs, too.

Compiling with avr-gcc

The easiest way to use avr-gcc is from a IDE like Atmel's AVRstudio 4. Once written, the code is compiled by selecting an option on the Build menu (like "compile" or "build" for instance.)

IDEs exist, but are less common on Linux. Simple C programs are compiled by invoking the compiler directly from the shell (command line interface, like DOS.)

But most complex C projects use a Makefile, which does all the hard work. There are many options available when calling avr-gcc, and many dependencies, too. Since the dependencies are different for each target AVR, all this can be "hidden" in the Makefile.

The makefile itself is invoked simply by typing "make" in the shell...

But it's not easy to write a Makefile---they use a unique (and obtuse) programming language. For a first-timer, it's best to copy a functional Makefile from another AVR project that uses the same target chip you are programming.

Both AVRstudio 4 and Winavr can generate Makefiles. These enable programmers to distribute compilable source code that's usable from other platforms.
sotsirh194 (author)  gmoon8 years ago
What is programmers notepad and how do you use it?
It's just a text editor, kind of a "supercharged" version of Windoz's notepad. Use it to edit the C source files. You can associate C files (".c", ".cpp", ".h", etc.) or you can copy a shortcut to the "Send To" folder. Right-click on any file, the "Send to" -> "Programmers Notebook". I use it for all kinds of source files: HTML, PHP, scripting, etc.
sotsirh194 (author)  gmoon8 years ago
but how do you convert c files to hex?
Like how to compile a c source file?

Without knowing the OS or which AVR you're using, I answered as well as I could in the first msg...

So just guessing, if you're using Programmers Notepad, you probably have Windows. The easiest way under windows is to download AVRstudio 4, create a project, add the source files and use the Build menu. You will have added all the important information about chip type, etc, when you created the project.

If you don't have AVRstudio 4, but still are using Windows, use the MFile utility that came with WINAVR. Populate the Makefile by selecting all the appropriate options on the Makefile menu:

Prog name, MCU type, C source files, programmer type (as in hardware interface) would be the minimum. Then generate a Makefile, and type "make" in the command line.

For other OSs, just search for a Makefile you can edit. Here's an example Atmega8 Makefile, but you'd have to edit all the source and object file name references or it wouldn't work.
sotsirh194 (author)  gmoon8 years ago
I have the usbtiny and it is's not listed in the makefile menu.
I looks like whoever created mfile hasn't added that option (yet.)

In mfile, pick any programmer on the avrdude menu. It should popup, highlighted in yellow. Then, under the Makefile menu, choose "Enable Editing of Makefile" and change the highlighted line manually to:


You'll need to be sure avrdude is updated to at least version 5.5 to use with the usbtiny hardware.

If you have more trouble, I bet the best place to ask for help is the ladyada forums (like a whole bunch of threads dedicated to usbtiny...)
sotsirh194 (author)  gmoon8 years ago
What I mean is to compile c code into a hex file for avrdude.
Yes, absolutely.