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