2010-10-25 11:03:38 +02:00
|
|
|
|
|
|
|
.SUFFIXES:
|
|
|
|
|
|
|
|
ifdef IAR
|
|
|
|
${info Using IAR...}
|
|
|
|
#IAR_PATH = C:/Program\ Files/IAR\ Systems/Embedded\ Workbench\ 5.4\ Evaluation
|
|
|
|
ifeq ($(IAR_PATH),)
|
|
|
|
${error IAR_PATH not defined! You must specify IAR root directory}
|
|
|
|
endif
|
|
|
|
endif
|
|
|
|
|
|
|
|
### Define the CPU directory
|
|
|
|
CONTIKI_CPU=$(CONTIKI)/cpu/stm32w108
|
|
|
|
|
|
|
|
### Define the source files we have in the STM32W port
|
|
|
|
|
|
|
|
CONTIKI_CPU_DIRS = . dev hal simplemac hal/micro/cortexm3 hal/micro/cortexm3/stm32w108
|
|
|
|
|
2010-12-15 12:10:20 +01:00
|
|
|
STM32W_C = leds-arch.c leds.c clock.c watchdog.c uart1.c uart1-putchar.c slip_uart1.c slip.c\
|
2010-10-25 11:03:38 +02:00
|
|
|
stm32w-radio.c stm32w_systick.c uip_arch.c rtimer-arch.c adc.c micro.c sleep.c \
|
2011-04-08 13:38:16 +02:00
|
|
|
micro-common.c micro-common-internal.c clocks.c mfg-token.c nvm.c flash.c rand.c system-timer.c
|
2010-10-25 11:03:38 +02:00
|
|
|
|
|
|
|
STM32W_S = spmr.s79 context-switch.s79
|
|
|
|
|
|
|
|
ifdef IAR
|
|
|
|
STM32W_C += low_level_init.c
|
|
|
|
STM32W_S += cstartup_M.s
|
|
|
|
else
|
|
|
|
STM32W_C += crt_stm32w108.c
|
|
|
|
endif
|
|
|
|
|
2010-12-15 12:10:20 +01:00
|
|
|
ifdef ELF_LOADER
|
|
|
|
ELFLOADER = elfloader-arch.c symtab.c
|
|
|
|
endif
|
|
|
|
|
|
|
|
|
2010-10-25 11:03:38 +02:00
|
|
|
# .s and .s79 not specified here because in Makefile.include only .c and .S suffixes are replaced with .o.
|
|
|
|
CONTIKI_TARGET_SOURCEFILES += $(STM32W_C) \
|
|
|
|
$(SYSAPPS) $(ELFLOADER) \
|
|
|
|
$(TARGETLIBS)
|
|
|
|
|
|
|
|
CONTIKI_SOURCEFILES += $(CONTIKI_TARGET_SOURCEFILES)
|
|
|
|
|
|
|
|
ifdef IAR
|
|
|
|
TARGET_LIBFILES = $(CONTIKI_CPU)/simplemac/library/simplemac-library.a
|
|
|
|
else
|
|
|
|
ifdef PRINTF_FLOAT
|
2011-03-21 13:11:52 +01:00
|
|
|
TARGET_LIBFILES = $(CONTIKI_CPU)/simplemac/library/simplemac-library-gnu.a $(CONTIKI_CPU)/hal/micro/cortexm3/e_stdio_thumb2.a
|
2010-10-25 11:03:38 +02:00
|
|
|
else
|
2011-03-21 13:11:52 +01:00
|
|
|
TARGET_LIBFILES = $(CONTIKI_CPU)/simplemac/library/simplemac-library-gnu.a $(CONTIKI_CPU)/lib/e_stdio_intonly_thumb2.a
|
2010-10-25 11:03:38 +02:00
|
|
|
endif
|
|
|
|
endif
|
|
|
|
# `$(CC) -print-file-name=thumb2/libc.a` `$(CC) -print-file-name=thumb2/libgcc.a`
|
|
|
|
|
|
|
|
### Compiler definitions
|
|
|
|
ifdef IAR
|
|
|
|
CC = iccarm
|
|
|
|
LD = ilinkarm
|
|
|
|
AS = iasmarm
|
|
|
|
AR = iarchive
|
|
|
|
OBJCOPY = ielftool
|
|
|
|
STRIP = strip
|
2010-12-15 12:10:20 +01:00
|
|
|
ifndef DEBUG
|
2010-10-25 11:03:38 +02:00
|
|
|
OPTI = -Ohz --no_unroll
|
2010-12-15 12:10:20 +01:00
|
|
|
endif
|
2010-10-25 11:03:38 +02:00
|
|
|
CFLAGSNO = --endian=little --cpu=Cortex-M3 -e --diag_suppress Pa050 -D BOARD_HEADER=\"board.h\" \
|
|
|
|
-D BOARD_MB851 -D "PLATFORM_HEADER=\"hal/micro/cortexm3/compiler/iar.h\"" -D CORTEXM3 \
|
|
|
|
-D CORTEXM3_STM32W108 -D PHY_STM32W108XX -D DISABLE_WATCHDOG -D ENABLE_ADC_EXTENDED_RANGE_BROKEN \
|
|
|
|
-D __SOURCEFILE__=\"$*.c\" -lC $(OBJECTDIR) \
|
|
|
|
-I $(IAR_PATH)/arm/inc --dlib_config=DLib_Config_Normal.h
|
|
|
|
|
|
|
|
CFLAGS += $(CFLAGSNO) $(OPTI)
|
|
|
|
AROPTS = --create
|
|
|
|
ASFLAGS = -s+ -w+ --cpu Cortex-M3 -L$(OBJECTDIR)
|
2010-11-10 12:20:44 +01:00
|
|
|
LDFLAGS += --redirect _Printf=_PrintfSmall --redirect _Scanf=_ScanfSmall --map=contiki-$(TARGET).map
|
2011-01-17 10:41:47 +01:00
|
|
|
ifndef COFFEE
|
2011-03-21 13:11:52 +01:00
|
|
|
LDFLAGS+= --config $(CONTIKI_CPU)/iar-cfg.icf
|
2010-11-10 12:20:44 +01:00
|
|
|
endif
|
2010-10-25 11:03:38 +02:00
|
|
|
OBJOPTS = --bin
|
|
|
|
|
|
|
|
else
|
2010-11-10 12:20:44 +01:00
|
|
|
# GCC
|
2010-12-15 12:10:20 +01:00
|
|
|
CC = arm-none-eabi-gcc
|
2010-10-25 11:03:38 +02:00
|
|
|
LD = arm-none-eabi-gcc
|
2010-12-15 12:10:20 +01:00
|
|
|
AS = arm-none-eabi-gcc
|
|
|
|
NM = arm-none-eabi-nm
|
2010-10-25 11:03:38 +02:00
|
|
|
AR = arm-none-eabi-ar
|
|
|
|
OBJCOPY = arm-none-eabi-objcopy
|
|
|
|
STRIP = arm-none-eabi-strip
|
2010-12-15 12:10:20 +01:00
|
|
|
SIZE = arm-none-eabi-size
|
|
|
|
ifndef DEBUG
|
|
|
|
OPTI = -Os -ffunction-sections
|
|
|
|
endif
|
|
|
|
|
2011-04-01 08:53:05 +02:00
|
|
|
CFLAGSNO = -mthumb -mcpu=cortex-m3 -D "PLATFORM_HEADER=\"hal/micro/cortexm3/compiler/gnu.h\"" \
|
2010-10-25 11:03:38 +02:00
|
|
|
-D BOARD_HEADER=\"board.h\" -g -Wall -Wno-strict-aliasing -mlittle-endian \
|
|
|
|
-D BOARD_MB851 -D CORTEXM3 -D CORTEXM3_STM32W108 -D PHY_STM32W108XX -D DISABLE_WATCHDOG -D ENABLE_ADC_EXTENDED_RANGE_BROKEN \
|
|
|
|
-D __SOURCEFILE__=\"$*.c\"
|
|
|
|
CFLAGS += $(CFLAGSNO) $(OPTI)
|
2011-04-01 08:53:05 +02:00
|
|
|
ASFLAGS = -mthumb -mcpu=cortex-m3 -c -g -Wall -Os -ffunction-sections \
|
2010-10-25 11:03:38 +02:00
|
|
|
-mlittle-endian -fshort-enums -x assembler-with-cpp -Wa,-EL
|
|
|
|
LDFLAGS += -mcpu=cortex-m3 \
|
|
|
|
-mthumb \
|
2011-03-21 13:11:52 +01:00
|
|
|
-Wl,-T -Xlinker $(CONTIKI_CPU)/gnu.ld \
|
2010-10-25 11:03:38 +02:00
|
|
|
-Wl,-static \
|
|
|
|
-u Default_Handler \
|
|
|
|
-nostartfiles \
|
2010-12-15 12:10:20 +01:00
|
|
|
-Wl,-Map -Xlinker contiki-$(TARGET).map
|
|
|
|
|
|
|
|
ifndef ELF_LOADER
|
|
|
|
# Do not use garbage collection when the elfloader is used.
|
|
|
|
LDFLAGS += -Wl,--gc-sections
|
|
|
|
endif
|
|
|
|
|
2010-10-25 11:03:38 +02:00
|
|
|
SIZEFLAGS = -A
|
|
|
|
OBJOPTS = -O binary
|
|
|
|
|
|
|
|
endif
|
|
|
|
|
2010-11-10 12:20:44 +01:00
|
|
|
|
2010-12-15 12:10:20 +01:00
|
|
|
ifdef COFFEE_ADDRESS
|
|
|
|
COFFEE = 1
|
|
|
|
endif
|
2010-11-10 12:20:44 +01:00
|
|
|
|
2010-12-15 12:10:20 +01:00
|
|
|
# Default values for coffee section start.
|
|
|
|
ifndef COFFEE_ADDRESS
|
|
|
|
COFFEE_ADDRESS = 0x8010c00
|
|
|
|
endif
|
|
|
|
|
|
|
|
ifeq ($(COFFEE),1)
|
|
|
|
CONTIKI_TARGET_SOURCEFILES += cfs-coffee.c cfs-coffee-arch.c
|
|
|
|
CFLAGS += -DCOFFEE_ADDRESS=$(COFFEE_ADDRESS)
|
|
|
|
|
2010-11-10 12:20:44 +01:00
|
|
|
#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 .coffeefiles 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)/cfs-coffee.o : coffee #core routine requires recompilation
|
|
|
|
|
2010-12-15 12:10:20 +01:00
|
|
|
else
|
|
|
|
# Coffee starts at the end of the flash, before NVM section.
|
2011-03-21 13:11:52 +01:00
|
|
|
COFFEE_ADDRESS = 0x801F800
|
2010-12-15 12:10:20 +01:00
|
|
|
endif
|
|
|
|
|
2011-03-21 13:11:52 +01:00
|
|
|
|
|
|
|
ifndef IAR
|
|
|
|
|
2010-12-15 12:10:20 +01:00
|
|
|
LDFLAGS+= -Wl,--section-start=.coffee=$(COFFEE_ADDRESS)
|
|
|
|
|
|
|
|
else #IAR
|
2010-11-10 12:20:44 +01:00
|
|
|
|
2010-12-15 12:10:20 +01:00
|
|
|
ifeq ($(COFFEE),1)
|
2011-03-21 13:11:52 +01:00
|
|
|
LDFLAGS+= --config $(CONTIKI_CPU)/iar-cfg-coffee.icf
|
2010-12-15 12:10:20 +01:00
|
|
|
endif
|
|
|
|
|
2010-11-10 12:20:44 +01:00
|
|
|
endif
|
|
|
|
|
2010-12-15 12:10:20 +01:00
|
|
|
|
|
|
|
|
2011-05-10 15:16:13 +02:00
|
|
|
FLASHER = $(CONTIKI)/tools/stm32w/stm32w_flasher/stm32w_flasher
|
2010-10-25 11:03:38 +02:00
|
|
|
|
|
|
|
# Check if we are running under Windows
|
2012-02-22 00:57:22 +01:00
|
|
|
ifeq ($(HOST_OS),Windows)
|
|
|
|
FLASHER = $(CONTIKI)/tools/stm32w/stm32w_flasher/stm32w_flasher.exe
|
2010-10-25 11:03:38 +02:00
|
|
|
endif
|
|
|
|
|
|
|
|
|
|
|
|
ifndef PORT
|
|
|
|
# Flash with jlink
|
|
|
|
FLASHEROPTS = -f -r
|
|
|
|
else
|
|
|
|
# Flash on serial port with on-board bootloader
|
|
|
|
FLASHEROPTS = -f -i rs232 -p $(PORT) -r
|
2011-01-17 10:41:47 +01:00
|
|
|
ifdef BTM
|
|
|
|
#if already in bootloader mode
|
|
|
|
FLASHEROPTS += -b
|
|
|
|
endif
|
2010-10-25 11:03:38 +02:00
|
|
|
endif
|
|
|
|
|
|
|
|
|
|
|
|
### Custom rules
|
|
|
|
|
|
|
|
OBJECTDIR = obj_$(TARGET)
|
|
|
|
|
|
|
|
ssubst = ${patsubst %.s,%.o,${patsubst %.s79,%.o,$(1)}}
|
|
|
|
|
|
|
|
CONTIKI_OBJECTFILES += ${addprefix $(OBJECTDIR)/,${call ssubst, $(STM32W_S)}}
|
|
|
|
|
|
|
|
vpath %.s79 $(CONTIKI_CPU)/hal/micro/cortexm3
|
|
|
|
vpath %.s $(CONTIKI_CPU)/hal/micro/cortexm3
|
|
|
|
|
|
|
|
|
|
|
|
ifdef IAR
|
|
|
|
# Check if we are in cygwin environment, so we must have paths like /cygdrive/c/... (checking TERM doesn't always work.)
|
2010-10-26 09:26:40 +02:00
|
|
|
ifneq (,$(findstring cygdrive,$(shell pwd)))
|
2010-10-25 11:03:38 +02:00
|
|
|
${info Cygwin detected.}
|
|
|
|
SEDCOMMAND = sed -e '1s,\($(OBJECTDIR)\\$*\)\.o: \(.\):,\1.o : /cygdrive/\l\2,g' -e '1!s,\($(OBJECTDIR)\\$*\)\.o: \(.\):, /cygdrive/\l\2,g' -e 's,\\\([^ ]\),/\1,g' -e 's,$$, \\,' -e '$$s, \\$$,,' < $(@:.o=.P) > $(@:.o=.d)
|
|
|
|
else
|
|
|
|
SEDCOMMAND = sed -e '1s,\($(OBJECTDIR)\\$*\)\.o:,\1.o : ,g' -e '1!s,\($(OBJECTDIR)\\$*\)\.o:, ,g' -e 's,\\\([^ ]\),/\1,g' -e 's,$$, \\,' -e '$$s, \\$$,,' < $(@:.o=.P) > $(@:.o=.d)
|
|
|
|
endif
|
|
|
|
|
2010-12-15 12:10:20 +01:00
|
|
|
|
2010-10-25 11:03:38 +02:00
|
|
|
CUSTOM_RULE_C_TO_OBJECTDIR_O = 1
|
|
|
|
$(OBJECTDIR)/%.o: %.c
|
|
|
|
$(CC) $(CFLAGS) $< --dependencies=m $(@:.o=.P) -o $@
|
|
|
|
@$(SEDCOMMAND); rm -f $(@:.o=.P)
|
|
|
|
@$(FINALIZE_DEPENDENCY)
|
|
|
|
|
|
|
|
CUSTOM_RULE_C_TO_CO = 1
|
|
|
|
%.co: %.c
|
|
|
|
$(CC) $(CFLAGS) -DAUTOSTART_ENABLE $< -o $@
|
|
|
|
else #IAR
|
|
|
|
|
2010-12-15 12:10:20 +01:00
|
|
|
CUSTOM_RULE_C_TO_CE = 1
|
|
|
|
%.ce: %.c
|
|
|
|
$(CC) $(CFLAGS) -fno-merge-constants -fno-function-sections -DAUTOSTART_ENABLE -c $< -o $@
|
|
|
|
$(STRIP) --strip-unneeded -g -x $@
|
|
|
|
|
2010-10-25 11:03:38 +02:00
|
|
|
CUSTOM_RULE_LINK = 1
|
|
|
|
|
2010-12-15 12:10:20 +01:00
|
|
|
ifdef CORE
|
|
|
|
ifeq ($(wildcard $(CORE)),)
|
|
|
|
${error $(CORE) doesn't exist}
|
|
|
|
endif
|
2012-03-23 19:54:11 +01:00
|
|
|
.PHONY: symbols.c symbols.h
|
2010-12-15 12:10:20 +01:00
|
|
|
symbols.c:
|
|
|
|
$(NM) $(CORE) | awk -f $(CONTIKI)/tools/mknmlist > symbols.c
|
|
|
|
else
|
|
|
|
symbols.c symbols.h:
|
2011-04-03 13:24:58 +02:00
|
|
|
cp ${CONTIKI}/tools/empty-symbols.c symbols.c
|
|
|
|
cp ${CONTIKI}/tools/empty-symbols.h symbols.h
|
2010-12-15 12:10:20 +01:00
|
|
|
endif
|
|
|
|
|
|
|
|
%.$(TARGET): %.co $(PROJECT_OBJECTFILES) $(PROJECT_LIBRARIES) contiki-$(TARGET).a $(OBJECTDIR)/symbols.o
|
2010-10-25 11:03:38 +02:00
|
|
|
$(LD) $(LDFLAGS) $(TARGET_STARTFILES) ${filter-out %.a,$^} -Wl,-\( ${filter %.a,$^} $(TARGET_LIBFILES) -Wl,-\) -o $@
|
|
|
|
@echo >> contiki-$(TARGET).map
|
|
|
|
@$(SIZE) $(SIZEFLAGS) $@ >> contiki-$(TARGET).map
|
|
|
|
|
|
|
|
#%.$(TARGET): %.co $(PROJECT_OBJECTFILES) $(PROJECT_LIBRARIES) $(CONTIKI_OBJECTFILES)
|
|
|
|
# $(LD) $(LDFLAGS) $(TARGET_STARTFILES) ${filter-out %.a,$^} ${filter %.a,$^} $(TARGET_LIBFILES) -o $@
|
|
|
|
# @echo "\n" >> contiki-$(TARGET).map
|
|
|
|
# @$(SIZE) $(SIZEFLAGS) $@ >> contiki-$(TARGET).map
|
|
|
|
|
|
|
|
|
|
|
|
endif #IAR
|
|
|
|
|
|
|
|
$(OBJECTDIR)/%.o: %.s79
|
|
|
|
$(AS) $(ASFLAGS) -o $@ $<
|
|
|
|
|
|
|
|
$(OBJECTDIR)/%.o: %.s
|
|
|
|
$(AS) $(ASFLAGS) -o $@ $<
|
|
|
|
|
|
|
|
%.bin: %.$(TARGET)
|
|
|
|
$(OBJCOPY) $(OBJOPTS) $< $@
|
|
|
|
|
|
|
|
%.flash: %.bin
|
|
|
|
$(FLASHER) $(FLASHEROPTS) $<
|
|
|
|
|