Install avr-gcc, avr-libc, avr-binutils, avrdude:
$ sudo pacman -S avr-gcc avr-libc avr-binutils avrdudeBuild the hex file:
$ make hexFlash to the chip:
$ sudo make flash| #include <avr/io.h> | |
| #include <util/delay.h> | |
| int main() { | |
| DDRB = 0xFF; | |
| for (;;) { | |
| PORTB = 0xFF; | |
| _delay_ms(500); | |
| PORTB = 0x00; | |
| _delay_ms(500); | |
| } | |
| } | |
| MCU = atmega32 | |
| F_CPU = 16000000 | |
| PROGRAMMER = -c usbasp | |
| AVRDUDE = avrdude $(PROGRAMMER) -p $(MCU) | |
| CC = avr-gcc -Wall -Os -DF_CPU=$(F_CPU) -mmcu=$(MCU) | |
| .PHONY: hex flash clean | |
| hex: blink.hex | |
| %.hex: %.elf | |
| rm -f $@ | |
| avr-objcopy -j .text -j .data -O ihex $< $@ | |
| %.elf: %.o | |
| $(CC) $< -o $@ | |
| %.o: %.c | |
| $(CC) -c $< -o $@ | |
| flash: hex | |
| $(AVRDUDE) -U flash:w:blink.hex:i | |
| clean: | |
| rm -f blink.hex blink.elf blink.o |