Statistics
| Branch: | Revision:

root / arduino-1.0 / hardware / arduino / bootloaders / atmega8 / Makefile @ 58d82c77

History | View | Annotate | Download (1.79 KB)

1
# Makefile for ATmegaBOOT
2
# E.Lins, 2004-10-14
3

    
4
# program name should not be changed...
5
PROGRAM    = ATmegaBOOT
6

    
7
PRODUCT=atmega8
8

    
9
# enter the parameters for the UISP isp tool
10
ISPPARAMS  = -dprog=stk500 -dserial=$(SERIAL) -dspeed=115200
11

    
12

    
13
#DIRAVR = /usr/local/avr
14
DIRAVRBIN = $(DIRAVR)/bin
15
DIRAVRUTILS = $(DIRAVR)/utils/bin
16
DIRINC = $(DIRAVR)/include
17
DIRLIB = $(DIRAVR)/avr/lib
18

    
19

    
20
MCU_TARGET = atmega8
21
LDSECTION  = --section-start=.text=0x1c00
22
FUSE_L     = 0xdf
23
FUSE_H     = 0xca
24
ISPFUSES   = $(DIRAVRBIN)/uisp -dpart=ATmega8 $(ISPPARAMS) --wr_fuse_l=$(FUSE_L) --wr_fuse_h=$(FUSE_H)
25
ISPFLASH   = $(DIRAVRBIN)/uisp -dpart=ATmega8 $(ISPPARAMS) --erase --upload if=$(PROGRAM).hex -v
26

    
27

    
28
OBJ        = $(PROGRAM).o
29
OPTIMIZE   = -Os
30

    
31
DEFS       = -DF_CPU=16000000 -DBAUD_RATE=19200
32
LIBS       =
33

    
34
CC         = $(DIRAVRBIN)/avr-gcc
35

    
36

    
37
# Override is only needed by avr-lib build system.
38

    
39
override CFLAGS        = -g -Wall $(OPTIMIZE) -mmcu=$(MCU_TARGET) -D$(PRODUCT) $(DEFS) -I$(DIRINC)
40
override LDFLAGS       = -Wl,-Map,$(PROGRAM).map,$(LDSECTION)
41

    
42
OBJCOPY        = $(DIRAVRBIN)/avr-objcopy
43
OBJDUMP        = $(DIRAVRBIN)/avr-objdump
44
SIZE           = $(DIRAVRBIN)/avr-size
45

    
46
all: $(PROGRAM).elf lst text asm size
47

    
48
isp: $(PROGRAM).hex
49
	$(ISPFUSES)
50
	$(ISPFLASH)
51

    
52
$(PROGRAM).elf: $(OBJ)
53
	$(CC) $(CFLAGS) $(LDFLAGS) -o $@ $^ $(LIBS)
54

    
55
clean:
56
	rm -rf *.s
57
	rm -rf *.o *.elf
58
	rm -rf *.lst *.map
59

    
60
asm: $(PROGRAM).s
61

    
62
%.s: %.c
63
	$(CC) -S $(CFLAGS) -g1 $^
64

    
65
lst:  $(PROGRAM).lst
66

    
67
%.lst: %.elf
68
	$(OBJDUMP) -h -S $< > $@
69

    
70
size: $(PROGRAM).hex
71
	$(SIZE) $^
72

    
73
# Rules for building the .text rom images
74

    
75
text: hex bin srec
76

    
77
hex:  $(PROGRAM).hex
78
bin:  $(PROGRAM).bin
79
srec: $(PROGRAM).srec
80

    
81
%.hex: %.elf
82
	$(OBJCOPY) -j .text -j .data -O ihex $< $@
83

    
84
%.srec: %.elf
85
	$(OBJCOPY) -j .text -j .data -O srec $< $@
86

    
87
%.bin: %.elf
88
	$(OBJCOPY) -j .text -j .data -O binary $< $@