| 1 | #MCU=at90s2313 |
| 2 | MCU=attiny2313 |
| 3 | PORT=/dev/ttyUSB0 |
| 4 | CC=avr-gcc |
| 5 | OBJCOPY=avr-objcopy |
| 6 | PROJECT=helloworld |
| 7 | RESET=false |
| 8 | # optimize for size: |
| 9 | CFLAGS=-g -mmcu=$(MCU) -Wall -Wstrict-prototypes -Os -mcall-prologues |
| 10 | #------------------- |
| 11 | all: $(PROJECT).hex |
| 12 | #------------------- |
| 13 | $(PROJECT).hex : $(PROJECT).out |
| 14 | $(OBJCOPY) -R .eeprom -O ihex $(PROJECT).out $(PROJECT).hex |
| 15 | $(PROJECT).out : $(PROJECT).o |
| 16 | $(CC) $(CFLAGS) -o $(PROJECT).out -Wl,-Map,$(PROJECT).map $(PROJECT).o |
| 17 | $(PROJECT).o : $(PROJECT).c |
| 18 | $(CC) $(CFLAGS) -Os -c $(PROJECT).c |
| 19 | asm : $(PROJECT).c |
| 20 | $(CC) $(CFLAGS) -O -S $(PROJECT).c |
| 21 | # you need to erase first before loading the program. |
| 22 | # load (program) the software into the eeprom: |
| 23 | load: $(PROJECT).hex |
| 24 | $(RESET) && stty -F $(PORT) 19200 hupcl && sleep 2 && stty -F $(PORT) 19200 -hupcl && sleep 2 || true |
| 25 | avrdude -cstk500v1 -P$(PORT) -b19200 -p $(MCU) -Uflash:w:$(PROJECT).hex:i || $(MAKE) RESET=true MAKE=true load |
| 26 | # uisp -dlpt=/dev/parport0 --erase --upload --verify if=$(PROJECT).hex -dprog=dapa -v=3 --hash=12 |
| 27 | #------------------- |
| 28 | clean: |
| 29 | rm -f *.o *.map *.out *.hex |
| 30 | #------------------- |