AVRDUDE = avrdude
CPPFLAGS = -DF_CPU=$(F_CPU) -DBAUD=$(BAUD) -I.
-CFLAGS = -Os -g -Wall
+CFLAGS = -O -g -Wall
CFLAGS += -funsigned-char -funsigned-bitfields -fpack-struct -fshort-enums
LDFLAGS = -Wl,-Map,hbc.map
$(CC) -c $(CFLAGS) $(CPPFLAGS) $(TARGET_ARCH) $< -o $@
%.elf: $(OBJ)
- $(CC) $(LDFLAGS) $(TARGET_ARCH) $^ -o $@
+ $(CC) $(CFLAGS) $(LDFLAGS) $(TARGET_ARCH) $^ -o $@
%.hex: %.elf
$(OBJCOPY) -j .text -j .data -O ihex $< $@
+#
+# for binary output
+#
+#%.bin: %.elf
+# $(OBJCOPY) -j .text -j .data -O binary $< $@
+
all: hbc.hex
.PHONY: clean
clean:
rm -rf $(ODIR)/*.o *.hex *.elf *.map
-
check-dev:
- $(AVRDUDE) -p t25 -c $(PROGRAMMER_TYPE) -b $(BAUD)
+ $(AVRDUDE) -p t25 -c $(PROGRAMMER_TYPE) -b $(BAUD)
flash:
$(AVRDUDE) -p t25 -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 t25 -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