<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://w.electrodragon.com/w/index.php?action=history&amp;feed=atom&amp;title=GCC-AVR</id>
	<title>GCC-AVR - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://w.electrodragon.com/w/index.php?action=history&amp;feed=atom&amp;title=GCC-AVR"/>
	<link rel="alternate" type="text/html" href="https://w.electrodragon.com/w/index.php?title=GCC-AVR&amp;action=history"/>
	<updated>2026-07-23T22:25:02Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.37.2</generator>
	<entry>
		<id>https://w.electrodragon.com/w/index.php?title=GCC-AVR&amp;diff=27390&amp;oldid=prev</id>
		<title>Chao at 03:18, 2 July 2020</title>
		<link rel="alternate" type="text/html" href="https://w.electrodragon.com/w/index.php?title=GCC-AVR&amp;diff=27390&amp;oldid=prev"/>
		<updated>2020-07-02T03:18:49Z</updated>

		<summary type="html">&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;== GCC-AVR ==&lt;br /&gt;
* reference page: http://avr-eclipse.sourceforge.net/wiki/index.php/The_AVR_GCC_Toolchain&lt;br /&gt;
* command for install: sudo apt-get install gcc-avr binutils-avr gdb-avr avr-libc avrdude&lt;br /&gt;
# gcc-avr： complier&lt;br /&gt;
# avr-libc：library used when compling&lt;br /&gt;
# gdb-avr ：gdb reverse debug tool, against complie&lt;br /&gt;
# avrdude：flash tool&lt;br /&gt;
=== Compile ===&lt;br /&gt;
* generate o file from c file: &lt;br /&gt;
* -c Compile or assemble the source files, but do not link.&lt;br /&gt;
* -Os Optimize for size, -O1, Optimize.-O2 Optimize even more.&lt;br /&gt;
* -g Generate debugging information that can be used by avr-gdb.&lt;br /&gt;
&amp;gt;avr-gcc -g -mmcu=atmega8 -Wall -Os -c ledtest.c&amp;lt;br /&amp;gt;&lt;br /&gt;
&amp;gt;avr-gcc -g -Os -mmcu=atmega8 -c flash.c&amp;lt;br /&amp;gt;&lt;br /&gt;
&amp;gt;avr-gcc –mmcu=at90s2313 –c demo1.c&amp;lt;br /&amp;gt;&lt;br /&gt;
* output .o .elf file for further use, for elf file, use when have more then one c file:&lt;br /&gt;
* -o put output into output file&lt;br /&gt;
&amp;gt;avr-gcc -g -mmcu=atmega8 -o flash.elf flash.o&amp;lt;br /&amp;gt;&lt;br /&gt;
&amp;gt;avr-gcc -g -mmcu=atmega8 -o ledtest.out -Wl,-Map,ledtest.map ledtest.o&amp;lt;br /&amp;gt;&lt;br /&gt;
* combined linked file into MCU read hex file&lt;br /&gt;
&amp;gt;avr-objcopy -j .text -j .data -O ihex flash.elf flash.hex&amp;lt;br /&amp;gt;&lt;br /&gt;
&amp;gt;avr-objcopy -R .eeprom -O ihex ledtest.out ledtest.hex&amp;lt;br /&amp;gt;&lt;br /&gt;
Above flash.elf and ledtest.out is the input file, and the second is the output file.&lt;br /&gt;
&amp;gt;avr-size ledtest.out&amp;lt;br /&amp;gt;&lt;br /&gt;
Complete commands:&lt;br /&gt;
* avr-gcc -Os -DF_CPU=8000000 -mmcu=attiny85 -c led_flash.c&lt;br /&gt;
* avr-gcc -DF_CPU=8000000 -mmcu=attiny85 -o led_flash.elf led_flash.o&lt;br /&gt;
* avr-objcopy -O ihex led_flash.elf led_flash.hex&lt;br /&gt;
* rm led_flash.o&lt;br /&gt;
* rm led_flash.elf&lt;br /&gt;
==== Note ====&lt;br /&gt;
* DDRC = 0xFF makes all pins on PORTC as output pins&lt;br /&gt;
* PORTC = 0xFF makes all pins on PORTC Logic High (5V)&lt;br /&gt;
* PORTC = 0x00 makes all pins on PORTC Logic Low (0V)&lt;br /&gt;
* _delay_ms(1000) provides 1000 milliseconds delay.&lt;br /&gt;
* while(1) makes an infinite loop&lt;br /&gt;
&lt;br /&gt;
=== Flash code ===&lt;br /&gt;
* Use [[avrdude]], command like: sudo avrdude -p m8 -c dragon_isp -P usb -e -U flash:w:flash.hex&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[category: AVR SDK]]&lt;br /&gt;
&lt;br /&gt;
[[category: Compiler]]&lt;/div&gt;</summary>
		<author><name>Chao</name></author>
	</entry>
</feed>