Subversion Repositories Projects

Rev

Rev 279 | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
234 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
MK_AVR_MCU_LONG = $(patsubst t%,attiny%,$(patsubst m%,atmega%,$(MK_AVR_MCU)))
18
 
19
$(info MK_AVR_MCU = $(MK_AVR_MCU))
20
$(info MK_AVR_MCU_LONG = $(MK_AVR_MCU_LONG))
21
 
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)
279 dhylands 27
MK_AVR_FREQ_HZ  = $(patsubst %MHz,%000000,$(MK_AVR_FREQ))
28
MK_AVR_FREQ_DEF = -DCFG_CPU_CLOCK=$(MK_AVR_FREQ_HZ) -DF_CPU=$(MK_AVR_FREQ_HZ)
234 dhylands 29
 
30
MK_AVR_MCU_FLAGS	= -mmcu=$(MK_AVR_MCU_LONG)
31
 
32
MK_COMMON_AVR_DIR	= $(MK_COMMON_DIR)/avr
33
 
34
CPPFLAGS += $(MK_AVR_MCU_FLAGS) -I $(MK_COMMON_AVR_DIR) $(MK_AVR_FREQ_DEF)
35
LDFLAGS  += $(MK_AVR_MCU_FLAGS)
36
 
37
CXXFLAGS += -fno-exceptions -fno-rtti
38
 
39
# On the AVR, we always optimize for size
40
 
41
CFLAGS += -Os
42
CXXFLAGS += -Os
43
 
44
MK_PRINT_BIN_SIZE	= avr-mem.sh $@ $(MK_AVR_MCU_LONG)
45
MK_OBJCOPY_SECTS	= -j .text -j .data
46
 
47
vpath %.c   $(MK_COMMON_AVR_DIR)
48
vpath %.cpp $(MK_COMMON_AVR_DIR)
49
 
50
include $(MK_RULES_DIR)/mkEnv-gcc.mk
51
 
52
# avr-gcc doesn't use rdynamic
53
LDFLAGS_RDYNAMIC =
54
 
257 dhylands 55
# Note: MK_AVR_FUSES is XX HH LL
56
 
234 dhylands 57
MK_avrdude	 		= avrdude
58
MK_avrdude_PORT		?= usb
59
MK_avrdude_PROG    	?= avrispmkII
60
MK_avrdude_CMD		= $(Q)$(MK_avrdude) -P $(MK_avrdude_PORT) -c $(MK_avrdude_PROG) -p $(MK_AVR_MCU_LONG) -U flash:w:$<:a
61
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
62
MK_avrdude_RD_FUSE	= $(Q)$(MK_avrdude) -P $(MK_avrdude_PORT) -c $(MK_avrdude_PROG) -p $(MK_AVR_MCU_LONG) -v
295 dhylands 63
MK_avrdude_RD_PGM	= $(Q)$(MK_avrdude) -P $(MK_avrdude_PORT) -c $(MK_avrdude_PROG) -p $(MK_AVR_MCU_LONG) -U flash:r:flash.hex:i
64
MK_avrdude_RD_EEPROM= $(Q)$(MK_avrdude) -P $(MK_avrdude_PORT) -c $(MK_avrdude_PROG) -p $(MK_AVR_MCU_LONG) -U eeprom:r:eeprom.hex:i
234 dhylands 65
 
66
MK_BootHost 		= boothost
67
MK_BootHost_BAUD	?= 38400
68
MK_BootHost_PORT	?= ttyS0
69
MK_BootHost_OPTS	?= --baud=$(MK_BootHost_BAUD) --port=$(MK_BootHost_PORT) -r
70
MK_BootHost_CMD		= $(Q)$(MK_BootHost) $(MK_BootHost_OPTS) $<
71
 
72
MK_stk500	 		= "c:/Program Files/Atmel/AVR Tools/stk500/stk500.exe"
73
MK_stk500_PORT		?= USB
74
MK_stk500_CMD 		= $(Q)$(MK_stk500) -c$(MK_stk500_PORT) -d$(MK_AVR_MCU_LONG) -e -if$< -pf
75
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))
76
MK_stk500_RD_FUSE	= $(Q)$(MK_stk500) -c$(MK_stk500_PORT) -d$(MK_AVR_MCU_LONG) -s -q
77
 
279 dhylands 78
MK_teensy			= teensy_loader_cli
79
MK_teensy_CMD		= $(Q)$(MK_teensy) -mmcu=$(MK_AVR_MCU_LONG) -v -w $<
234 dhylands 80