brmpuk initial commit
[brmpuk.git] / Makefile
blobf478efb7744af901a2501b8a6bb24d02c0bdf3ff
1 #PRG = brmpuk
2 #OBJ = brmpuk.o sabertooth.o lcd.o serial.o
4 PRG = motor_test
5 OBJ = motor_test.o sabertooth.o lcd.o serial.o
7 MCU_TARGET = atmega128 #at90s2313
8 OPTIMIZE = -O2
10 DEFS =
11 LIBS =
13 # You should not have to change anything below here.
15 CC = avr-gcc
17 # Override is only needed by avr-lib build system.
19 override CFLAGS = -g -Wall $(OPTIMIZE) -mmcu=$(MCU_TARGET) $(DEFS)
20 override LDFLAGS = -Wl,-Map,$(PRG).map
22 OBJCOPY = avr-objcopy
23 OBJDUMP = avr-objdump
25 all: $(PRG).elf lst text eeprom
27 $(PRG).elf: $(OBJ)
28 $(CC) $(CFLAGS) $(LDFLAGS) -o $@ $^ $(LIBS)
30 clean:
31 rm -rf *.o $(PRG).elf *.eps *.png *.pdf *.bak
32 rm -rf *.lst *.map $(EXTRA_CLEAN_FILES)
34 lst: $(PRG).lst
36 %.lst: %.elf
37 $(OBJDUMP) -h -S $< > $@
39 # Rules for building the .text rom images
41 text: hex bin srec
43 hex: $(PRG).hex
44 bin: $(PRG).bin
45 srec: $(PRG).srec
47 %.hex: %.elf
48 $(OBJCOPY) -j .text -j .data -O ihex $< $@
50 %.srec: %.elf
51 $(OBJCOPY) -j .text -j .data -O srec $< $@
53 %.bin: %.elf
54 $(OBJCOPY) -j .text -j .data -O binary $< $@
56 # Rules for building the .eeprom rom images
58 eeprom: ehex ebin esrec
60 ehex: $(PRG)_eeprom.hex
61 ebin: $(PRG)_eeprom.bin
62 esrec: $(PRG)_eeprom.srec
64 %_eeprom.hex: %.elf
65 $(OBJCOPY) -j .eeprom --change-section-lma .eeprom=0 -O ihex $< $@
67 %_eeprom.srec: %.elf
68 $(OBJCOPY) -j .eeprom --change-section-lma .eeprom=0 -O srec $< $@
70 %_eeprom.bin: %.elf
71 $(OBJCOPY) -j .eeprom --change-section-lma .eeprom=0 -O binary $< $@
73 # Every thing below here is used by avr-libc's build system and can be ignored
74 # by the casual user.
76 FIG2DEV = fig2dev
77 EXTRA_CLEAN_FILES = *.hex *.bin *.srec
79 dox: eps png pdf
81 eps: $(PRG).eps
82 png: $(PRG).png
83 pdf: $(PRG).pdf
85 %.eps: %.fig
86 $(FIG2DEV) -L eps $< $@
88 %.pdf: %.fig
89 $(FIG2DEV) -L pdf $< $@
91 %.png: %.fig
92 $(FIG2DEV) -L png $< $@
94 program: $(PRG).hex
95 uisp -dprog=stk200 --erase --upload --verify if=$< -dlpt=0x378 -v=3 --hash=12
97 load_raw: $(PRG).hex
98 avrdude -c pony-stk200 -E noreset -P /dev/parport0 -p m128 -U flash:w:$<
99 load: $(PRG).hex
100 avrdude -v -c avr109 -P /dev/ttyUSB0 -b 38400 -p m128 -U flash:w:$<
103 read_fuse:
104 avrdude -c pony-stk200 -E noreset -P /dev/parport0 -p m128 -U lfuse:r:lfuse:b -U hfuse:r:hfuse:b -U efuse:r:efuse:b
108 fuse:
109 avrdude -U lfuse:w:0xe4:m