Subversion Repositories Projects

Rev

Rev 207 | Rev 234 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
2 dhylands 1
###########################################################################
2
#
3
# 	mkEnv-avr.mk
4
#
5
# 	This file contains AVR specific defines for the build environment.
6
#
7
# 	This file should only define variables and not have any rules in it.
8
#
9
###########################################################################
10
 
11
MK_CROSS_COMPILE		= avr-
12
 
13
ifeq ($(MK_AVR_MCU),)
14
$(error MK_AVR_MCU not specified)
15
endif
16
 
17 dhylands 17
MK_AVR_MCU_LONG = $(patsubst t%,attiny%,$(patsubst m%,atmega%,$(MK_AVR_MCU)))
2 dhylands 18
 
17 dhylands 19
$(info MK_AVR_MCU = $(MK_AVR_MCU))
20
$(info MK_AVR_MCU_LONG = $(MK_AVR_MCU_LONG))
21
 
2 dhylands 22
ifeq ($(MK_AVR_FREQ),)
23
$(error MK_AVR_FREQ not specified)
24
endif
25
 
26
MK_OS_DIR = avr-$(MK_AVR_MCU)-$(MK_AVR_FREQ)
9 dhylands 27
MK_AVR_FREQ_DEF = -DCFG_CPU_CLOCK=$(patsubst %MHz,%000000,$(MK_AVR_FREQ))
2 dhylands 28
 
29
MK_AVR_MCU_FLAGS	= -mmcu=$(MK_AVR_MCU_LONG)
30
 
31
MK_COMMON_AVR_DIR	= $(MK_COMMON_DIR)/avr
32
 
9 dhylands 33
CPPFLAGS += $(MK_AVR_MCU_FLAGS) -I $(MK_COMMON_AVR_DIR) $(MK_AVR_FREQ_DEF)
2 dhylands 34
LDFLAGS  += $(MK_AVR_MCU_FLAGS)
35
 
36
CXXFLAGS += -fno-exceptions -fno-rtti
37
 
38
# On the AVR, we always optimize
39
 
40
CFLAGS += -Os
41
CXXFLAGS += -Os
42
 
43
MK_PRINT_BIN_SIZE	= avr-mem.sh $@ $(MK_AVR_MCU_LONG)
146 dhylands 44
MK_OBJCOPY_SECTS	= -j .text -j .data
2 dhylands 45
 
46
vpath %.c   $(MK_COMMON_AVR_DIR)
47
vpath %.cpp $(MK_COMMON_AVR_DIR)
48
 
49
include $(MK_RULES_DIR)/mkEnv-gcc.mk
50
 
207 dhylands 51
# avr-gcc doesn't use rdynamic
52
LDFLAGS_RDYNAMIC =
53
 
51 dhylands 54
MK_avrdude	 		= avrdude
56 dhylands 55
MK_avrdude_PORT		?= usb
56
MK_avrdude_PROG    	?= avrispmkII
51 dhylands 57
MK_avrdude_CMD		= $(Q)$(MK_avrdude) -P $(MK_avrdude_PORT) -c $(MK_avrdude_PROG) -p $(MK_AVR_MCU_LONG) -U flash:w:$<:a
58
MK_avrdude_CMD_FUSE	= $(Q)$(MK_avrdude) -P $(MK_avrdude_PORT) -c $(MK_avrdude_PROG) -p $(MK_AVR_MCU_LONG) -U efuse:w:0x$(word 1,$(MK_AVR_FUSES)):m -U hfuse:w:0x$(word 2,$(MK_AVR_FUSES)):m -U lfuse:w:0x$(word 3,$(MK_AVR_FUSES)):m
57 dhylands 59
MK_avrdude_RD_FUSE	= $(Q)$(MK_avrdude) -P $(MK_avrdude_PORT) -c $(MK_avrdude_PROG) -p $(MK_AVR_MCU_LONG) -v
110 dhylands 60
 
61
MK_BootHost 		= boothost
51 dhylands 62
MK_BootHost_BAUD	?= 38400
63
MK_BootHost_PORT	?= ttyS0
213 dhylands 64
MK_BootHost_OPTS	?= --baud=$(MK_BootHost_BAUD) --port=$(MK_BootHost_PORT) -r
51 dhylands 65
MK_BootHost_CMD		= $(Q)$(MK_BootHost) $(MK_BootHost_OPTS) $<
66
 
67
MK_stk500	 		= "c:/Program Files/Atmel/AVR Tools/stk500/stk500.exe"
63 dhylands 68
MK_stk500_PORT		?= USB
51 dhylands 69
MK_stk500_CMD 		= $(Q)$(MK_stk500) -c$(MK_stk500_PORT) -d$(MK_AVR_MCU_LONG) -e -if$< -pf
70
MK_stk500_CMD_FUSE	= $(Q)$(MK_stk500) -c$(MK_stk500_PORT) -d$(MK_AVR_MCU_LONG) -E$(word 1,$(MK_AVR_FUSES)) -f$(word 2,$(MK_AVR_FUSES))$(word 3,$(MK_AVR_FUSES))
57 dhylands 71
MK_stk500_RD_FUSE	= $(Q)$(MK_stk500) -c$(MK_stk500_PORT) -d$(MK_AVR_MCU_LONG) -s -q
51 dhylands 72
 
73