04bbba6c12
Rename guhRF platform to osd-merkur-256, previous osd-merkur platform is now osd-merkur-128. Also check that everything is consistent. Add both platforms to the regression tests. Move redundant files in platform dev directory of both platforms to cpu/avr/dev. Note that this probably needs some rework. Already discovered some inconsistency in io definitions of both devices in the avr/io.h includes. Added a workaround in the obvious cases. The platform makefiles now set correct parameters for bootloader and for reading mac-address from flash memory. Factor the flash programming into cpu/avr and platform/osd-merkur* and rework *all* osd example makefiles to use the new settings. Also update all the flash.sh and run.sh to use the new settings. The suli ledstrip modules (and osd example) have also been removed.
231 lines
7.6 KiB
Text
231 lines
7.6 KiB
Text
# $Id: Makefile.avr,v 1.27 2010/12/22 21:13:09 dak664 Exp $
|
|
|
|
.SUFFIXES:
|
|
|
|
### Optimization setting. $make OPTI=0 for easier debugging of changed source file(s)
|
|
ifndef OPTI
|
|
OPTI=s
|
|
endif
|
|
|
|
### Define the CPU directory of the AVR port
|
|
CONTIKI_CPU=$(CONTIKI)/cpu/avr
|
|
|
|
### These directories will be searched for the specified source files
|
|
### TARGETLIBS are platform-specific routines in the contiki library path
|
|
CONTIKI_CPU_DIRS = . dev dev/arduino
|
|
AVR = clock.c mtarch.c eeprom.c flash.c rs232.c leds-arch.c \
|
|
watchdog.c rtimer-arch.c bootloader.c
|
|
ELFLOADER = elfloader.c elfloader-avr.c symtab-avr.c
|
|
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)
|
|
//AVR = clock.c mtarch.c eeprom.c flash.c leds-arch.c watchdog.c rtimer-arch.c
|
|
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 )))
|
|
CONTIKI_TARGET_SOURCEFILES += cfs-coffee.c cfs-coffee-arch.c
|
|
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
|
|
|
|
CONTIKI_TARGET_SOURCEFILES += $(AVR) $(SENSORS) \
|
|
$(SYSAPPS) $(ELFLOADER) \
|
|
$(TARGETLIBS)
|
|
|
|
CONTIKI_SOURCEFILES += $(CONTIKI_TARGET_SOURCEFILES)
|
|
|
|
|
|
### Compiler definitions
|
|
CC = avr-gcc
|
|
CXX = avr-g++
|
|
LD = avr-gcc
|
|
AS = avr-as
|
|
AR = avr-ar
|
|
ELF_SIZE = avr-size -C --mcu=$(MCU)
|
|
OBJCOPY = avr-objcopy
|
|
STRIP = avr-strip
|
|
CFLAGSNO = -Wall -mmcu=$(MCU) -gdwarf-2 -fno-strict-aliasing \
|
|
-I$(CONTIKI)/platform/$(TARGET) \
|
|
-I. -I$(CONTIKI)/core -I$(CONTIKI_CPU) $(USB_INCLUDES) \
|
|
$(CONTIKI_PLAT_DEFS)
|
|
CFLAGS += $(CFLAGSNO) -O$(OPTI)
|
|
ASFLAGS += -mmcu=$(MCU)
|
|
ifndef BOOTLOADER_START
|
|
BOOTLOADER_START = 0x1F800
|
|
endif
|
|
|
|
LDFLAGS += -mmcu=$(MCU) -Wl,-Map=contiki-$(TARGET).map \
|
|
-Wl,--section-start=.bootloader=$(BOOTLOADER_START)
|
|
|
|
SMALL ?= 1
|
|
|
|
### These flags help significantly reduce the code size
|
|
ifeq ($(SMALL),1)
|
|
CFLAGS += -ffunction-sections
|
|
CFLAGS += -fdata-sections
|
|
LDFLAGS += -Wl,--gc-sections
|
|
endif # SMALL
|
|
|
|
### Setup directory search path for source files
|
|
|
|
CONTIKI_TARGET_DIRS_CONCAT = ${addprefix $(CONTIKI)/platform/$(TARGET)/, \
|
|
$(CONTIKI_TARGET_DIRS)}
|
|
|
|
### Compilation rules
|
|
|
|
$(OBJECTDIR)/%.o: %.c | $(OBJECTDIR)
|
|
$(CC) $(CFLAGS) -c $< -o $@
|
|
|
|
%.o: %.c
|
|
$(CC) $(CFLAGS) -c $< -o $@
|
|
|
|
$(OBJECTDIR)/%.o: %.cpp | $(OBJECTDIR)
|
|
$(CXX) $(CFLAGS) -c $< -o $@
|
|
|
|
%.o: %.cpp
|
|
$(CXX) $(CFLAGS) -c $< -o $@
|
|
|
|
%.ko: %.o
|
|
$(STRIP) -K _init -K _fini --strip-unneeded -g -x $< -o $@
|
|
|
|
%.elf: %.co $(PROJECT_OBJECTFILES) contiki-$(TARGET).a symbols.o
|
|
$(CC) $(CFLAGS) $(LDFLAGS) -o $@ $(filter-out %.a,$^) $(filter %.a,$^) $(LDLIBS)
|
|
#Allow top-level makefile to always show size even when build is up to date
|
|
ifndef NOAVRSIZE
|
|
avr-size -C --mcu=$(MCU) $@
|
|
endif
|
|
|
|
%.hex: %.$(TARGET)
|
|
$(OBJCOPY) $^ -j .text -j .data -O ihex $@
|
|
|
|
%.ihex: %.$(TARGET)
|
|
$(OBJCOPY) $^ -O ihex $@
|
|
|
|
# Add a namelist to the kernel
|
|
%.out: %.co $(PROJECT_OBJECTFILES) contiki-$(TARGET).a
|
|
cp ${CONTIKI}/tools/empty-symbols.c symbols.c
|
|
cp ${CONTIKI}/tools/empty-symbols.h symbols.h
|
|
$(CC) $(LDFLAGS) $(CFLAGS) -o $@ $^ $(LIBC) symbols.c
|
|
ifdef SYMBOLS
|
|
$(CONTIKI)/tools/avr-make-symbols $@
|
|
$(CC) $(LDFLAGS) $(CFLAGS) -o $@ $^ $(LIBC) symbols.c
|
|
$(CONTIKI)/tools/avr-make-symbols $@
|
|
$(CC) $(LDFLAGS) $(CFLAGS) -o $@ $^ $(LIBC) symbols.c
|
|
endif
|
|
|
|
#%.hex: %.elf
|
|
# $(OBJCOPY) -R .eeprom -R .fuse -R .signature $^ -O ihex $@
|
|
|
|
%.eep: %.$(TARGET)
|
|
-$(OBJCOPY) -j .eeprom --set-section-flags=.eeprom="alloc,load" \
|
|
--change-section-lma .eeprom=0 -O ihex $^ $@
|
|
|
|
|
|
%-stripped.o: %.c
|
|
$(CC) $(CFLAGS) -c $< -o $@
|
|
$(STRIP) --strip-unneeded -g -x $@
|
|
|
|
#%.ce: %.c
|
|
# $(CC) $(CFLAGS) -c $< -o $@
|
|
# $(STRIP) --strip-unneeded -g -x $@
|
|
|
|
#%.ce: %.co
|
|
# $(LD) -i -r --unresolved-symbols=ignore-in-object-files -mavr5 -o $@ $^
|
|
# $(STRIP) --strip-unneeded -g -x $@
|
|
|
|
%.co: %.c
|
|
cp $(CONTIKI)/tools/empty-symbols.c symbols.c
|
|
cp $(CONTIKI)/tools/empty-symbols.h symbols.h
|
|
$(CC) $(CFLAGS) -DAUTOSTART_ENABLE -c $< -o $@
|
|
|
|
%-stripped.o: %.o
|
|
$(STRIP) --strip-unneeded -g -x -o $@ $<
|
|
|
|
%.o: ${CONTIKI_TARGET}/loader/%.S
|
|
$(AS) -o $(notdir $(<:.S=.o)) $<
|
|
|
|
%.srec: %.$(TARGET)
|
|
$(OBJCOPY) -O srec $< $@
|
|
|
|
### Upload image
|
|
#Let avrdude use defaults if port or programmer not defined
|
|
AVRDUDE ?= avrdude
|
|
ifdef AVRDUDE_MCU
|
|
DUDE_MCU:=-p $(AVRDUDE_MCU)
|
|
else
|
|
DUDE_MCU:=-p $(MCU)
|
|
endif
|
|
%.u: %.hex
|
|
$(AVRDUDE) $(DUDE_MCU) $(AVRDUDE_OPTIONS) -P $(AVRDUDE_PORT) \
|
|
-c $(AVRDUDE_PROGRAMMER) -U flash:w:$<:i
|
|
|
|
%.eu: %.eep
|
|
$(AVRDUDE) $(DUDE_MCU) ${AVRDUDE_OPTIONS} -P ${AVRDUDE_PORT} \
|
|
-c ${AVRDUDE_PROGRAMMER} -U eeprom:w:$<:i
|
|
|
|
symbols.c:
|
|
cp ${CONTIKI}/tools/empty-symbols.c symbols.c
|
|
cp ${CONTIKI}/tools/empty-symbols.h symbols.h
|
|
|
|
# Generic rules for .hex, .eep and .sz (size) file:
|
|
%.$(TARGET).hex: %.$(TARGET)
|
|
$(OBJCOPY) -j .text -j .data -O ihex $< $@
|
|
|
|
%.$(TARGET).eep: %.$(TARGET)
|
|
$(OBJCOPY) -j .eeprom --set-section-flags=.eeprom="alloc,load" \
|
|
--change-section-lma .eeprom=0 -O ihex $< $@
|
|
|
|
%.$(TARGET).sz: %.$(TARGET)
|
|
$(ELF_SIZE) $<
|