2011-01-19 07:30:31 +00:00
|
|
|
# $Id: Makefile.msp430,v 1.35 2011/01/19 07:30:31 adamdunkels Exp $
|
2006-06-17 22:41:10 +00:00
|
|
|
|
2017-10-06 12:58:08 +00:00
|
|
|
COOJA_PATH ?= $(CONTIKI)/tools/cooja
|
|
|
|
|
2006-10-09 09:15:48 +00:00
|
|
|
ifdef nodeid
|
|
|
|
CFLAGS += -DNODEID=$(nodeid)
|
|
|
|
endif
|
|
|
|
|
2014-10-09 07:02:09 +00:00
|
|
|
CFLAGS += -gstabs+
|
|
|
|
|
2006-06-17 22:41:10 +00:00
|
|
|
.SUFFIXES:
|
|
|
|
|
|
|
|
### Define the CPU directory
|
2017-06-28 13:57:13 +00:00
|
|
|
CONTIKI_CPU=$(CONTIKI)/arch/cpu/msp430
|
2006-06-17 22:41:10 +00:00
|
|
|
|
|
|
|
### Define the source files we have in the MSP430 port
|
|
|
|
|
2012-04-10 14:05:10 +00:00
|
|
|
ifndef CONTIKI_CPU_FAM_DIR
|
|
|
|
ifneq (,$(findstring msp430f1,$(MCU)))
|
|
|
|
CONTIKI_CPU_FAM_DIR = f1xxx
|
|
|
|
endif
|
|
|
|
endif
|
|
|
|
ifndef CONTIKI_CPU_FAM_DIR
|
|
|
|
ifneq (,$(findstring msp430f5,$(MCU)))
|
2011-11-21 15:14:22 +00:00
|
|
|
CONTIKI_CPU_FAM_DIR = f5xxx
|
2011-10-06 12:05:57 +00:00
|
|
|
endif
|
2011-09-23 13:01:13 +00:00
|
|
|
endif
|
2012-04-10 14:05:10 +00:00
|
|
|
ifndef CONTIKI_CPU_FAM_DIR
|
|
|
|
ifneq (,$(findstring msp430f2,$(MCU)))
|
|
|
|
CONTIKI_CPU_FAM_DIR = f2xxx f1xxx
|
|
|
|
endif
|
|
|
|
endif
|
|
|
|
ifndef CONTIKI_CPU_FAM_DIR
|
|
|
|
${error Unhandled MSP430 family: "$(MCU)"}
|
|
|
|
endif
|
2007-05-13 08:41:11 +00:00
|
|
|
|
2011-11-21 15:14:22 +00:00
|
|
|
CONTIKI_CPU_DIRS = $(CONTIKI_CPU_FAM_DIR) . dev
|
2011-10-06 12:05:57 +00:00
|
|
|
|
2006-12-19 09:22:25 +00:00
|
|
|
MSP430 = msp430.c flash.c clock.c leds.c leds-arch.c \
|
2017-11-22 23:14:43 +00:00
|
|
|
watchdog.c lpm.c rtimer-arch.c int-master.c
|
2017-06-19 07:38:18 +00:00
|
|
|
UIPDRIVERS = slip.c crc16.c
|
2006-06-17 22:41:10 +00:00
|
|
|
|
|
|
|
CONTIKI_TARGET_SOURCEFILES += $(MSP430) \
|
2017-05-13 11:09:58 +00:00
|
|
|
$(SYSAPPS) \
|
2009-11-19 17:33:05 +00:00
|
|
|
$(UIPDRIVERS)
|
2006-06-17 22:41:10 +00:00
|
|
|
|
|
|
|
CONTIKI_SOURCEFILES += $(CONTIKI_TARGET_SOURCEFILES)
|
|
|
|
|
|
|
|
### Compiler definitions
|
2011-12-19 17:13:40 +00:00
|
|
|
|
2017-06-21 09:11:09 +00:00
|
|
|
ifeq ($(WERROR),1)
|
|
|
|
CFLAGSWERROR= -Wall -Werror
|
2011-12-19 17:13:40 +00:00
|
|
|
endif
|
|
|
|
|
2011-04-06 18:08:48 +00:00
|
|
|
ifdef IAR
|
|
|
|
CC = icc430
|
|
|
|
LD = xlink
|
|
|
|
AS = iasm430
|
|
|
|
AR = xar
|
|
|
|
OBJCOPY = ielftool
|
|
|
|
STRIP = strip
|
|
|
|
|
|
|
|
ifndef IAR_PATH
|
|
|
|
# This works with cygwin...
|
2012-04-10 14:05:10 +00:00
|
|
|
IAR_BIN_PATH := $(shell dirname "`which $(CC)`")
|
|
|
|
IAR_PATH_C := $(shell dirname "$(IAR_BIN_PATH)")
|
|
|
|
IAR_PATH := $(shell cygpath -m "$(IAR_PATH_C)")
|
2011-04-06 18:08:48 +00:00
|
|
|
endif
|
|
|
|
|
2011-09-26 08:38:41 +00:00
|
|
|
CFLAGS += --diag_suppress=Pa050 --silent
|
|
|
|
|
2011-09-11 15:18:02 +00:00
|
|
|
#defaults on the MSP430X core include file here (xlfn.h)
|
|
|
|
ifndef CFLAGSNO
|
2011-06-04 22:21:47 +00:00
|
|
|
CFLAGSNO = --dlib_config "$(IAR_PATH)/LIB/DLIB/dl430xlfn.h" $(CFLAGSWERROR)
|
2011-05-02 13:19:28 +00:00
|
|
|
# CFLAGSNO = --dlib_config $(IAR_PATH)/LIB/DLIB/dl430xlfn.h -Ohz --multiplier=32 --multiplier_location=4C0 --hw_workaround=CPU40 --core=430X $(CFLAGSWERROR) --data_model large --double=32
|
2011-09-11 15:18:02 +00:00
|
|
|
endif
|
|
|
|
|
2018-03-30 19:12:31 +00:00
|
|
|
LDFLAGSNO += -B -l $(CONTIKI_NG_PROJECT_MAP) -s __program_start
|
2012-09-19 20:49:19 +00:00
|
|
|
# Stack and heap size in hex
|
|
|
|
ifndef IAR_STACK_SIZE
|
|
|
|
IAR_STACK_SIZE=300
|
|
|
|
endif
|
|
|
|
# Set this to a positive number (hex) to enable malloc/free with IAR compiler
|
|
|
|
ifndef IAR_DATA16_HEAP_SIZE
|
|
|
|
IAR_DATA16_HEAP_SIZE=100
|
|
|
|
endif
|
2012-09-20 12:01:56 +00:00
|
|
|
ifndef IAR_DATA20_HEAP_SIZE
|
|
|
|
IAR_DATA20_HEAP_SIZE=0
|
2012-09-19 20:49:19 +00:00
|
|
|
endif
|
2012-09-20 12:01:56 +00:00
|
|
|
LDFLAGSNO += -D_STACK_SIZE=$(IAR_STACK_SIZE) -D_DATA16_HEAP_SIZE=$(IAR_DATA16_HEAP_SIZE) -D_DATA20_HEAP_SIZE=$(IAR_DATA20_HEAP_SIZE)
|
2012-09-19 20:49:19 +00:00
|
|
|
|
2011-04-06 18:08:48 +00:00
|
|
|
CUSTOM_RULE_C_TO_O = 1
|
|
|
|
%.o: %.c
|
2014-04-11 15:36:42 +00:00
|
|
|
$(TRACE_CC)
|
|
|
|
$(Q)$(CC) $(CFLAGS) $< -o $@
|
2011-04-06 18:08:48 +00:00
|
|
|
|
2012-03-07 22:03:15 +00:00
|
|
|
define FINALIZE_CYGWIN_DEPENDENCY
|
|
|
|
sed -e 's/ \([A-Z]\):\\/ \/cygdrive\/\L\1\//' -e 's/\\/\//g' \
|
|
|
|
<$(@:.o=.P) >$(@:.o=.d); \
|
|
|
|
rm -f $(@:.o=.P)
|
|
|
|
endef
|
|
|
|
|
2011-04-06 18:08:48 +00:00
|
|
|
CUSTOM_RULE_C_TO_OBJECTDIR_O = 1
|
2013-06-20 22:45:41 +00:00
|
|
|
$(OBJECTDIR)/%.o: %.c | $(OBJECTDIR)
|
2014-04-11 15:36:42 +00:00
|
|
|
$(TRACE_CC)
|
|
|
|
$(Q)$(CC) $(CFLAGS) $< --dependencies=m $(@:.o=.P) -o $@
|
2012-03-07 22:03:15 +00:00
|
|
|
ifeq ($(HOST_OS),Windows)
|
|
|
|
@$(FINALIZE_CYGWIN_DEPENDENCY)
|
|
|
|
endif
|
|
|
|
|
2011-04-06 18:08:48 +00:00
|
|
|
AROPTS = -o
|
|
|
|
|
|
|
|
else
|
2012-03-07 22:03:15 +00:00
|
|
|
|
2011-04-06 18:08:48 +00:00
|
|
|
GCC = 1
|
2006-06-17 22:41:10 +00:00
|
|
|
CC = msp430-gcc
|
2007-01-24 16:11:48 +00:00
|
|
|
LD = msp430-gcc
|
2006-06-17 22:41:10 +00:00
|
|
|
AS = msp430-as
|
|
|
|
AR = msp430-ar
|
2007-03-22 23:57:33 +00:00
|
|
|
NM = msp430-nm
|
2006-06-17 22:41:10 +00:00
|
|
|
OBJCOPY = msp430-objcopy
|
|
|
|
STRIP = msp430-strip
|
|
|
|
BSL = msp430-bsl
|
2012-04-10 14:05:10 +00:00
|
|
|
|
|
|
|
# From version 4.6.x, mspgcc does not support generic MCU identifiers such as
|
|
|
|
# msp430x1611 in contrast to msp430f1611
|
|
|
|
ifndef CC_MCU
|
|
|
|
ifndef MSPGCC_VERSION
|
|
|
|
MSPGCC_VERSION := ${shell $(CC) -dumpversion}
|
|
|
|
endif
|
|
|
|
endif
|
|
|
|
ifndef CC_MCU
|
|
|
|
ifneq (,$(findstring 4.4.,$(MSPGCC_VERSION)))
|
|
|
|
CC_MCU := ${subst msp430f,msp430x,$(MCU)}
|
|
|
|
endif
|
|
|
|
endif
|
|
|
|
ifndef CC_MCU
|
|
|
|
ifneq (,$(findstring 3.2.,$(MSPGCC_VERSION)))
|
|
|
|
CC_MCU := ${subst msp430f,msp430x,$(MCU)}
|
|
|
|
endif
|
|
|
|
endif
|
|
|
|
ifndef CC_MCU
|
|
|
|
CC_MCU := $(MCU)
|
|
|
|
endif
|
|
|
|
|
2014-04-14 08:30:39 +00:00
|
|
|
### Checks for compiler version to enable 20-bit support
|
|
|
|
ifndef IAR
|
|
|
|
ifneq (,$(findstring 4.7.,$(shell msp430-gcc -dumpversion)))
|
|
|
|
ifdef CPU_HAS_MSP430X
|
2015-05-07 17:17:41 +00:00
|
|
|
ifeq ($(TARGET_MEMORY_MODEL),large)
|
|
|
|
CFLAGS += -mmemory-model=$(TARGET_MEMORY_MODEL)
|
|
|
|
CFLAGS += -mcode-region=far -mdata-region=far -msr20 -mc20 -md20
|
|
|
|
LDFLAGS += -mmemory-model=$(TARGET_MEMORY_MODEL) -mcode-region=far -mdata-region=far -msr20 -mc20 -md20
|
|
|
|
else
|
|
|
|
TARGET_MEMORY_MODEL = medium
|
2014-04-14 08:30:39 +00:00
|
|
|
CFLAGS += -mmemory-model=$(TARGET_MEMORY_MODEL)
|
2014-11-03 21:40:51 +00:00
|
|
|
CFLAGS += -ffunction-sections -fdata-sections -mcode-region=any
|
2014-04-14 08:30:39 +00:00
|
|
|
LDFLAGS += -mmemory-model=$(TARGET_MEMORY_MODEL) -Wl,-gc-sections
|
2015-05-07 17:17:41 +00:00
|
|
|
endif
|
2014-04-14 08:30:39 +00:00
|
|
|
endif
|
|
|
|
endif
|
|
|
|
endif
|
|
|
|
|
2011-12-19 17:13:40 +00:00
|
|
|
ifndef CFLAGSNO
|
2012-10-04 14:49:42 +00:00
|
|
|
CFLAGSNO = -Wall -mmcu=$(CC_MCU) $(CFLAGSWERROR)
|
2011-04-06 18:08:48 +00:00
|
|
|
endif
|
2011-12-19 17:13:40 +00:00
|
|
|
CFLAGS += -Os -fno-strict-aliasing
|
2018-03-30 19:12:31 +00:00
|
|
|
LDFLAGS += -mmcu=$(CC_MCU) -Wl,-Map=$(CONTIKI_NG_PROJECT_MAP)
|
2011-01-19 07:24:37 +00:00
|
|
|
|
|
|
|
### These flags can reduce the code size and RAM usage with up to 10%
|
2017-05-16 15:09:58 +00:00
|
|
|
SMALL ?= 1
|
2012-03-06 14:29:31 +00:00
|
|
|
ifeq ($(SMALL),1)
|
2011-01-19 07:24:37 +00:00
|
|
|
CFLAGS += -ffunction-sections
|
2011-09-21 18:02:04 +00:00
|
|
|
# CFLAGS += -fdata-sections
|
2011-01-19 07:24:37 +00:00
|
|
|
LDFLAGS += -Wl,--gc-sections,--undefined=_reset_vector__,--undefined=InterruptVectors,--undefined=_copy_data_init__,--undefined=_clear_bss_init__,--undefined=_end_of_init__
|
|
|
|
endif # SMALL
|
|
|
|
|
2011-12-19 17:13:40 +00:00
|
|
|
endif # IAR
|
|
|
|
|
2017-11-22 17:48:39 +00:00
|
|
|
# Define the `_stack` symbol used by the stack check library to be equal to `_end`
|
|
|
|
LDFLAGS += -Wl,--defsym=_stack=_end
|
|
|
|
|
2011-12-19 17:13:40 +00:00
|
|
|
CFLAGS += $(CFLAGSNO)
|
2011-01-19 07:24:37 +00:00
|
|
|
|
2006-06-17 22:41:10 +00:00
|
|
|
PROJECT_OBJECTFILES += ${addprefix $(OBJECTDIR)/,$(CONTIKI_TARGET_MAIN:.c=.o)}
|
|
|
|
|
2018-03-30 19:20:28 +00:00
|
|
|
### CPU-dependent cleanup files
|
|
|
|
CLEAN += *.firmware *.ihex
|
|
|
|
|
2006-06-17 22:41:10 +00:00
|
|
|
### Compilation rules
|
|
|
|
|
|
|
|
%-stripped.o: %.c
|
|
|
|
$(CC) $(CFLAGS) -c $< -o $@
|
|
|
|
$(STRIP) --strip-unneeded -g -x $@
|
|
|
|
|
|
|
|
%-stripped.o: %.o
|
|
|
|
$(STRIP) --strip-unneeded -g -x -o $@ $<
|
|
|
|
|
2008-12-16 13:54:25 +00:00
|
|
|
%.firmware: %.${TARGET}
|
|
|
|
mv $< $@
|
2006-06-17 22:41:10 +00:00
|
|
|
|
2012-03-07 22:03:15 +00:00
|
|
|
ifdef IAR
|
2018-03-30 19:14:33 +00:00
|
|
|
%.ihex: %.o $(PROJECT_OBJECTFILES) $(PROJECT_LIBRARIES) $(CONTIKI_NG_TARGET_LIB)
|
2012-04-10 13:27:44 +00:00
|
|
|
$(LD) $(LDFLAGSNO) -Fintel-extended $(TARGET_STARTFILES) ${filter-out %.a,$^} ${filter %.a,$^} $(TARGET_LIBFILES) -o $@
|
2012-03-07 22:03:15 +00:00
|
|
|
else
|
2008-07-02 14:11:34 +00:00
|
|
|
%.ihex: %.$(TARGET)
|
2006-06-17 22:41:10 +00:00
|
|
|
$(OBJCOPY) $^ -O ihex $@
|
2012-03-07 22:03:15 +00:00
|
|
|
endif
|
2006-06-17 22:41:10 +00:00
|
|
|
|
2017-10-06 12:58:08 +00:00
|
|
|
$(COOJA_PATH)/build.xml:
|
|
|
|
@echo '----------------'
|
|
|
|
@echo 'Could not find the COOJA build file. Did you run "git submodule update --init --recursive"?'
|
|
|
|
@echo '----------------'
|
|
|
|
|
|
|
|
$(COOJA_PATH)/mspsim/build.xml: $(COOJA_PATH)/build.xml
|
2014-03-18 10:21:19 +00:00
|
|
|
@echo '----------------'
|
2017-10-06 12:58:08 +00:00
|
|
|
@echo 'Could not find the MSPSim build file. Did you run "git submodule update --init --recursive"?'
|
2014-03-18 10:21:19 +00:00
|
|
|
@echo '----------------'
|
|
|
|
|
2017-10-06 12:58:08 +00:00
|
|
|
$(COOJA_PATH)/mspsim/mspsim.jar: $(COOJA_PATH)/mspsim/build.xml
|
|
|
|
(cd $(COOJA_PATH)/mspsim && ant jar)
|
2014-03-18 10:21:19 +00:00
|
|
|
|
2017-10-06 12:58:08 +00:00
|
|
|
%.mspsim: %.${TARGET} ${COOJA_PATH}/mspsim/mspsim.jar
|
|
|
|
java -jar ${COOJA_PATH}/mspsim/mspsim.jar -platform=${TARGET} $<
|
2008-11-24 11:09:36 +00:00
|
|
|
|
2018-03-30 19:15:44 +00:00
|
|
|
%.mspsim-maptable: %.$(TARGET)
|
2018-03-30 19:12:31 +00:00
|
|
|
java -classpath ${COOJA_PATH}/mspsim/mspsim.jar se.sics.mspsim.util.MapTable $(CONTIKI_NG_PROJECT_MAP)
|
2010-04-20 15:38:09 +00:00
|
|
|
|
2008-12-16 13:54:25 +00:00
|
|
|
core-labels.o: core.${TARGET}
|
|
|
|
${CONTIKI}/tools/msp430-make-labels core.${TARGET} > core-labels.S
|
2006-06-17 22:41:10 +00:00
|
|
|
$(AS) -o $@ core-labels.S
|
|
|
|
# cp core-labels.o app/
|
|
|
|
|
2008-12-16 13:54:25 +00:00
|
|
|
core-globals.o: core.${TARGET}
|
|
|
|
${CONTIKI}/tools/msp430-make-globals core.${TARGET} > core-globals.S
|
2006-06-17 22:41:10 +00:00
|
|
|
$(AS) -o $@ core-globals.S
|