# attiny25 makefile
MCU = attiny25
+DEVICE = t25
F_CPU = 8000000UL
BAUD = 57600
PROGRAMMER_TYPE = usbasp
CC = avr-gcc
+GDB = avr-gdb
OBJCOPY = avr-objcopy
OBJDUMP = avr-objdump
AVRSIZE = avr-size
AVRDUDE = avrdude
+SIMAVR = simavr
CPPFLAGS = -DF_CPU=$(F_CPU) -DBAUD=$(BAUD) -I.
CFLAGS = -Os -g -Wall
%.elf: $(OBJ)
$(CC) $(CFLAGS) $(LDFLAGS) $(TARGET_ARCH) $^ -o $@
+# TODO: add fuse section with .j .fuse
%.hex: %.elf
$(OBJCOPY) -j .text -j .data -O ihex $< $@
rm -rf $(ODIR)/*.o *.hex *.elf *.map
check-dev:
- $(AVRDUDE) -p t25 -c $(PROGRAMMER_TYPE) -b $(BAUD)
+ $(AVRDUDE) -p $(DEVICE) -c $(PROGRAMMER_TYPE) -b $(BAUD)
flash:
- $(AVRDUDE) -p t25 -c $(PROGRAMMER_TYPE) -b $(BAUD) -U flash:w:hbc.hex:i
+ $(AVRDUDE) -p $(DEVICE) -c $(PROGRAMMER_TYPE) -b $(BAUD) -U flash:w:hbc.hex:i
read-flash-bin:
- $(AVRDUDE) -p t25 -c $(PROGRAMMER_TYPE) -b $(BAUD) -P /dev/ttyUSB0 -U flash:r:flash.bin:r
+ $(AVRDUDE) -p $(DEVICE) -c $(PROGRAMMER_TYPE) -b $(BAUD) -P /dev/ttyUSB0 -U flash:r:flash.bin:r
# simulator runs on localhost:1234
# load .elf file with avr-sim hex.elf
# and start debugging
sim:
- simavr -f $(F_CPU) -m $(MCU) -g -t hbc.hex
+ $(SIMAVR) -f $(F_CPU) -m $(MCU) -g -t hbc.hex
+gdb:
+ $(GDB) -x gdb-commands.txt hbc.elf