2010-11-12 17:15:00 +00:00
|
|
|
# $Id: Makefile.avr,v 1.26 2010/11/12 17:15:00 dak664 Exp $
|
2010-05-04 14:14:49 +00:00
|
|
|
|
2006-06-18 07:44:59 +00:00
|
|
|
### Check if we are running under Windows
|
|
|
|
|
|
|
|
ifndef WINDIR
|
|
|
|
ifdef OS
|
|
|
|
ifneq (,$(findstring Windows,$(OS)))
|
|
|
|
WINDIR := Windows
|
|
|
|
endif
|
|
|
|
endif
|
|
|
|
endif
|
|
|
|
|
|
|
|
.SUFFIXES:
|
|
|
|
|
2009-07-23 16:13:48 +00:00
|
|
|
### Optimization setting. $make OPTI=0 for easier debugging of changed source file(s)
|
|
|
|
ifndef OPTI
|
|
|
|
OPTI=s
|
|
|
|
endif
|
2008-10-14 09:44:12 +00:00
|
|
|
|
2009-07-23 16:13:48 +00:00
|
|
|
### Define the CPU directory of the AVR port
|
2006-06-18 07:44:59 +00:00
|
|
|
CONTIKI_CPU=$(CONTIKI)/cpu/avr
|
|
|
|
|
2009-07-23 16:13:48 +00:00
|
|
|
### These directories will be searched for the specified source files
|
|
|
|
### TARGETLIBS are platform-specific routines in the contiki library path
|
|
|
|
CONTIKI_CPU_DIRS = . dev
|
2010-09-17 21:59:09 +00:00
|
|
|
AVR = clock.c mtarch.c eeprom.c flash.c rs232.c leds-arch.c watchdog.c rtimer-arch.c bootloader.c settings.c
|
2006-12-22 16:54:36 +00:00
|
|
|
ELFLOADER = elfloader.c elfloader-avr.c symtab-avr.c
|
2009-07-23 16:13:48 +00:00
|
|
|
TARGETLIBS = random.c leds.c
|
|
|
|
|
|
|
|
ifdef USB
|
|
|
|
### Add the directories for the USB stick and remove the default rs232 driver
|
|
|
|
CONTIKI_CPU_DIRS += dev/usb dev/usb/serial dev/usb/rndis dev/usb/storage
|
|
|
|
CONTIKI_TARGET_SOURCEFILES += $(USB)
|
2010-03-15 18:52:55 +00:00
|
|
|
//AVR = clock.c mtarch.c eeprom.c flash.c leds-arch.c watchdog.c rtimer-arch.c
|
2009-07-23 16:13:48 +00:00
|
|
|
endif
|
|
|
|
|
|
|
|
#For a coffee file system, the application makefile can define COFFEE_FILES=n
|
|
|
|
#to select the type and COFFEE_ADDRESS=0xaaaaaaaa as the starting byte address.
|
|
|
|
#If only one is define the other will use the (Raven webserver 1284p) defaults
|
|
|
|
#of a static file system in program flash starting at 0x10000 (word address=0x8000)
|
|
|
|
#For program flash the starting address is rounded down to a page boundary in cfs-coffee-arch.h
|
|
|
|
#It should be rounded down here too if someone can figure out how :)
|
|
|
|
|
|
|
|
ifdef COFFEE_ADDRESS #if address is passed force definition of COFFEE_FILES
|
|
|
|
ifndef COFFEE_FILES #use program flash for static file system if not specified
|
|
|
|
COFFEE_FILES=3
|
|
|
|
endif
|
|
|
|
endif
|
|
|
|
|
|
|
|
ifdef COFFEE_FILES #if files are defined force definition of COFFEE_ADDRESS
|
|
|
|
ifndef COFFEE_ADDRESS
|
|
|
|
ifeq ($(COFFEE_FILES), 1) #1=eeprom static
|
|
|
|
COFFEE_ADDRESS=DEFAULT
|
|
|
|
else ifeq ($(COFFEE_FILES), 2) #2=eeprom dynamic
|
|
|
|
COFFEE_ADDRESS=DEFAULT
|
|
|
|
else ifeq ($(COFFEE_FILES), 3) #3=program flash static
|
|
|
|
COFFEE_ADDRESS=0x14000
|
|
|
|
else ifeq ($(COFFEE_FILES), 4) #4=program flash dynamic
|
|
|
|
COFFEE_ADDRESS=0x10000
|
|
|
|
else
|
|
|
|
print "Unsupported coffee file type!"
|
|
|
|
endif
|
|
|
|
endif
|
|
|
|
COFFEE_ADDRESS1 = $(shell echo $$(( $(COFFEE_ADDRESS) + 1 )))
|
2010-02-07 07:43:35 +00:00
|
|
|
CONTIKI_TARGET_SOURCEFILES += cfs-coffee.c cfs-coffee-arch.c
|
2009-07-23 16:13:48 +00:00
|
|
|
CFLAGS += -DCOFFEE_FILES=$(COFFEE_FILES) -DCOFFEE_ADDRESS=$(COFFEE_ADDRESS)
|
|
|
|
ifneq ($(COFFEE_ADDRESS), DEFAULT)
|
|
|
|
LDFLAGS+= -Wl,--section-start=.coffeefiles=$(COFFEE_ADDRESS)
|
|
|
|
endif
|
|
|
|
|
|
|
|
#If $make invokation passed starting address use phony target to force synchronization of source to .coffeefiles section
|
|
|
|
#Warning: recompilation will not be forced if the starting address is then dropped, with dire consequences:
|
|
|
|
# -->Source that uses COFFEE_FILES and read macros for conditional compilation will be left hanging!
|
|
|
|
# -->Object modules that used .coffeesection will overlap the .data section.
|
|
|
|
# -->$make clean is safest.
|
|
|
|
#ifeq ($(origin COFFEE_ADDRESS), command line)
|
|
|
|
# ifeq ($(COFFEE_FILES), 2) #safest to force recompilation even if eeprom address is changed, might have been switched from flash
|
|
|
|
.PHONY : coffee
|
|
|
|
coffee:
|
|
|
|
$(OBJECTDIR)/cfs-coffee-arch.o : coffee #cfs-coffee-arch uses COFFEE_FILES, COFFEE_ADDRESS
|
|
|
|
$(OBJECTDIR)/contiki-raven-main.o : coffee #Raven Webserver uses COFFEE_FILES
|
|
|
|
$(OBJECTDIR)/httpd-fs.o : coffee #this file contains httpd-fsdata.c which has the .coffeesection data
|
|
|
|
$(OBJECTDIR)/httpd.c.o : coffee #uses defines to read from file system
|
|
|
|
$(OBJECTDIR)/httpd-cgi.o : coffee #uses defines to read from file system
|
|
|
|
$(OBJECTDIR)/cfs-coffee.o : coffee #core routine requires recompilation
|
|
|
|
|
|
|
|
#endif
|
|
|
|
#endif
|
|
|
|
|
|
|
|
endif
|
2006-06-18 07:44:59 +00:00
|
|
|
|
2009-07-23 16:13:48 +00:00
|
|
|
CONTIKI_TARGET_SOURCEFILES += $(AVR) $(SENSORS) \
|
2006-06-18 07:44:59 +00:00
|
|
|
$(SYSAPPS) $(ELFLOADER) \
|
2007-11-16 09:19:22 +00:00
|
|
|
$(TARGETLIBS)
|
2006-06-18 07:44:59 +00:00
|
|
|
|
|
|
|
CONTIKI_SOURCEFILES += $(CONTIKI_TARGET_SOURCEFILES)
|
|
|
|
|
|
|
|
|
|
|
|
### Compiler definitions
|
|
|
|
CC = avr-gcc
|
2007-11-01 16:26:31 +00:00
|
|
|
LD = avr-gcc
|
2006-06-18 07:44:59 +00:00
|
|
|
AS = avr-as
|
|
|
|
AR = avr-ar
|
|
|
|
OBJCOPY = avr-objcopy
|
|
|
|
STRIP = avr-strip
|
2009-07-23 16:13:48 +00:00
|
|
|
CFLAGSNO = -Wall -mmcu=$(MCU) -gdwarf-2 \
|
|
|
|
-I. -I$(CONTIKI)/core -I$(CONTIKI_CPU) $(USB_INCLUDES) \
|
2006-06-18 07:44:59 +00:00
|
|
|
-I$(CONTIKI)/platform/$(TARGET) \
|
2009-07-23 16:13:48 +00:00
|
|
|
$(CONTIKI_PLAT_DEFS)
|
2008-10-14 09:44:12 +00:00
|
|
|
CFLAGS += $(CFLAGSNO) -O$(OPTI)
|
2009-07-23 16:13:48 +00:00
|
|
|
ifndef BOOTLOADER_START
|
2010-05-04 14:14:49 +00:00
|
|
|
BOOTLOADER_START = 0x1F800
|
2009-07-23 16:13:48 +00:00
|
|
|
endif
|
2006-12-22 16:54:36 +00:00
|
|
|
|
2009-07-23 16:13:48 +00:00
|
|
|
LDFLAGS += -mmcu=$(MCU) -Wl,-Map=contiki-$(TARGET).map \
|
|
|
|
-Wl,--section-start=.bootloader=$(BOOTLOADER_START)
|
2006-06-18 07:44:59 +00:00
|
|
|
|
|
|
|
### Setup directory search path for source files
|
|
|
|
|
|
|
|
CONTIKI_TARGET_DIRS_CONCAT = ${addprefix $(CONTIKI)/platform/$(TARGET)/, \
|
|
|
|
$(CONTIKI_TARGET_DIRS)}
|
|
|
|
|
|
|
|
### Compilation rules
|
|
|
|
|
|
|
|
$(OBJECTDIR)/%.o: %.c
|
|
|
|
$(CC) $(CFLAGS) -c $< -o $@
|
|
|
|
|
|
|
|
%.o: %.c
|
|
|
|
$(CC) $(CFLAGS) -c $< -o $@
|
|
|
|
|
2006-12-22 16:54:36 +00:00
|
|
|
%.ko: %.o
|
|
|
|
$(STRIP) -K _init -K _fini --strip-unneeded -g -x $< -o $@
|
|
|
|
|
2007-11-16 09:19:22 +00:00
|
|
|
%.elf: %.co $(PROJECT_OBJECTFILES) contiki-$(TARGET).a symbols.o
|
2006-06-18 07:44:59 +00:00
|
|
|
$(CC) $(CFLAGS) $(LDFLAGS) -o $@ $(filter-out %.a,$^) $(filter %.a,$^) $(LDLIBS)
|
2010-11-12 17:15:00 +00:00
|
|
|
avr-size -C --mcu=$(MCU) $@
|
2006-12-22 16:54:36 +00:00
|
|
|
|
|
|
|
%.hex: %.out
|
2006-06-18 07:44:59 +00:00
|
|
|
$(OBJCOPY) $^ -O ihex $@
|
|
|
|
|
2009-09-07 12:02:58 +00:00
|
|
|
%.ihex: %.out
|
|
|
|
$(OBJCOPY) $^ -O ihex $@
|
|
|
|
|
2006-12-22 16:54:36 +00:00
|
|
|
# Add a namelist to the kernel
|
2007-11-29 02:44:05 +00:00
|
|
|
%.out: %.co $(PROJECT_OBJECTFILES) contiki-$(TARGET).a
|
2006-12-22 16:54:36 +00:00
|
|
|
$(CONTIKI)/tools/make-empty-symbols
|
|
|
|
$(CC) $(LDFLAGS) $(CFLAGS) -o $@ $^ $(LIBC) symbols.c
|
2007-11-23 06:22:52 +00:00
|
|
|
ifdef SYMBOLS
|
2006-12-22 16:54:36 +00:00
|
|
|
$(CONTIKI)/tools/avr-make-symbols $@
|
|
|
|
$(CC) $(LDFLAGS) $(CFLAGS) -o $@ $^ $(LIBC) symbols.c
|
|
|
|
$(CONTIKI)/tools/avr-make-symbols $@
|
|
|
|
$(CC) $(LDFLAGS) $(CFLAGS) -o $@ $^ $(LIBC) symbols.c
|
2007-11-23 06:22:52 +00:00
|
|
|
endif
|
2006-12-22 16:54:36 +00:00
|
|
|
|
|
|
|
#%.hex: %.elf
|
2010-05-04 14:14:49 +00:00
|
|
|
# $(OBJCOPY) -R .eeprom -R .fuse -R .signature $^ -O ihex $@
|
2006-12-22 16:54:36 +00:00
|
|
|
|
|
|
|
%.eep: %.out
|
|
|
|
-$(OBJCOPY) -j .eeprom --set-section-flags=.eeprom="alloc,load" \
|
|
|
|
--change-section-lma .eeprom=0 -O ihex $^ $@
|
|
|
|
|
|
|
|
|
2006-06-18 07:44:59 +00:00
|
|
|
%-stripped.o: %.c
|
|
|
|
$(CC) $(CFLAGS) -c $< -o $@
|
|
|
|
$(STRIP) --strip-unneeded -g -x $@
|
|
|
|
|
2006-12-22 16:54:36 +00:00
|
|
|
#%.ce: %.c
|
2008-02-07 19:56:56 +00:00
|
|
|
# $(CC) $(CFLAGS) -c $< -o $@
|
2007-11-16 09:19:22 +00:00
|
|
|
# $(STRIP) --strip-unneeded -g -x $@
|
2006-06-18 07:44:59 +00:00
|
|
|
|
2007-11-16 09:19:22 +00:00
|
|
|
#%.ce: %.co
|
|
|
|
# $(LD) -i -r --unresolved-symbols=ignore-in-object-files -mavr5 -o $@ $^
|
|
|
|
# $(STRIP) --strip-unneeded -g -x $@
|
2006-06-18 07:44:59 +00:00
|
|
|
|
|
|
|
%.co: %.c
|
2007-11-16 09:19:22 +00:00
|
|
|
$(CONTIKI)/tools/make-empty-symbols
|
2006-06-20 21:23:09 +00:00
|
|
|
$(CC) $(CFLAGS) -DAUTOSTART_ENABLE -c $< -o $@
|
2006-06-18 07:44:59 +00:00
|
|
|
|
|
|
|
%-stripped.o: %.o
|
|
|
|
$(STRIP) --strip-unneeded -g -x -o $@ $<
|
|
|
|
|
|
|
|
%.o: ${CONTIKI_TARGET}/loader/%.S
|
|
|
|
$(AS) -o $(notdir $(<:.S=.o)) $<
|
|
|
|
|
|
|
|
%.srec: %.$(TARGET)
|
|
|
|
$(OBJCOPY) -O srec $< $@
|
|
|
|
|
2006-12-22 16:54:36 +00:00
|
|
|
### Upload image
|
|
|
|
%.u: %.hex
|
|
|
|
avrdude ${AVRDUDE_OPTIONS} -P ${AVRDUDE_PORT} -c ${AVRDUDE_PROGRAMMER} -p ${MCU} -U flash:w:$<
|
|
|
|
|
2006-06-18 07:44:59 +00:00
|
|
|
symbols.c:
|
2007-11-16 09:19:22 +00:00
|
|
|
@${CONTIKI}/tools/make-empty-symbols
|