From ff7a977dc7804e4a1da3bb1f2c1a438ef54d3d2a Mon Sep 17 00:00:00 2001 From: Niclas Finne Date: Wed, 7 Mar 2012 23:03:15 +0100 Subject: [PATCH] Improved support for the IAR compiler for the MSP430 platforms --- cpu/msp430/Makefile.msp430 | 19 +++++++++++++++++-- platform/esb/Makefile.esb | 9 +++++++-- platform/jcreate/platform-jcreate-conf.h | 2 -- .../sentilla-usb/platform-sentilla-usb-conf.h | 2 -- platform/sky/Makefile.common | 10 +++------- platform/wismote/Makefile.wismote | 8 ++------ platform/z1/Makefile.common | 3 ++- 7 files changed, 31 insertions(+), 22 deletions(-) diff --git a/cpu/msp430/Makefile.msp430 b/cpu/msp430/Makefile.msp430 index c173730f8..7d71d4029 100644 --- a/cpu/msp430/Makefile.msp430 +++ b/cpu/msp430/Makefile.msp430 @@ -71,10 +71,19 @@ CUSTOM_RULE_C_TO_O = 1 %.o: %.c $(CC) $(CFLAGS) $< -o $@ +define FINALIZE_CYGWIN_DEPENDENCY +sed -e 's/ \([A-Z]\):\\/ \/cygdrive\/\L\1\//' -e 's/\\/\//g' \ + <$(@:.o=.P) >$(@:.o=.d); \ +rm -f $(@:.o=.P) +endef + CUSTOM_RULE_C_TO_OBJECTDIR_O = 1 $(OBJECTDIR)/%.o: %.c - $(CC) $(CFLAGS) $< -o $@ -# @$(FINALIZE_DEPENDENCY) + $(CC) $(CFLAGS) $< --dependencies=m $(@:.o=.P) -o $@ +ifeq ($(HOST_OS),Windows) + @$(FINALIZE_CYGWIN_DEPENDENCY) +endif + CUSTOM_RULE_C_TO_CO = 1 %.co: %.c $(CC) $(CFLAGS) -DAUTOSTART_ENABLE $< -o $@ @@ -82,6 +91,7 @@ CUSTOM_RULE_C_TO_CO = 1 AROPTS = -o else + GCC = 1 CC = msp430-gcc LD = msp430-gcc @@ -129,8 +139,13 @@ PROJECT_OBJECTFILES += ${addprefix $(OBJECTDIR)/,$(CONTIKI_TARGET_MAIN:.c=.o)} %.firmware: %.${TARGET} mv $< $@ +ifdef IAR +%.ihex: %.co $(PROJECT_OBJECTFILES) $(PROJECT_LIBRARIES) contiki-$(TARGET).a + $(LD) $(LDFLAGSNO) -Fintel-extended -yn $(TARGET_STARTFILES) ${filter-out %.a,$^} ${filter %.a,$^} $(TARGET_LIBFILES) -o $@ +else %.ihex: %.$(TARGET) $(OBJCOPY) $^ -O ihex $@ +endif %.mspsim: %.${TARGET} java -jar ${CONTIKI}/tools/mspsim/mspsim.jar -platform=${TARGET} $< diff --git a/platform/esb/Makefile.esb b/platform/esb/Makefile.esb index 8aaf31edd..4fa71d2d3 100644 --- a/platform/esb/Makefile.esb +++ b/platform/esb/Makefile.esb @@ -17,7 +17,7 @@ endif CONTIKI_TARGET_SOURCEFILES += $(SENSORS) $(ESB) \ contiki-esb-default-init-lowlevel.c \ contiki-esb-default-init-apps.c \ - rs232.c rs232-putchar.c fader.c $(CONTIKI_TARGET_MAIN) + rs232.c rs232-putchar.c fader.c ifdef WITH_CODEPROP CONTIKI_TARGET_DIRS += ../../apps/codeprop @@ -30,7 +30,7 @@ CFLAGS+=-Os -g endif ifdef IAR -CFLAGS+=-e --vla -Ohz --multiplier=16s --core=430 --double=32 +CFLAGS += -D__MSP430F149__=1 -e --vla -Ohz --multiplier=16s --core=430 --double=32 CFLAGSNO = --dlib_config "$(IAR_PATH)/LIB/DLIB/dl430fn.h" $(CFLAGSWERROR) endif @@ -53,6 +53,11 @@ include $(CONTIKI)/platform/$(TARGET)/apps/Makefile.apps MCU=msp430x149 include $(CONTIKI)/cpu/msp430/Makefile.msp430 +ifdef IAR +LDFLAGSNO += -B -xm "$(IAR_PATH)/lib/dlib/dl430fn.r43" -f "$(IAR_PATH)/config/lnk430f149.xcl" -l contiki-$(TARGET).map -s __program_start -D_STACK_SIZE=80 -D_DATA16_HEAP_SIZE=80 -D_DATA20_HEAP_SIZE=80 +LDFLAGS += $(LDFLAGSNO) -Felf -yn +endif # IAR + contiki-$(TARGET).a: ${addprefix $(OBJECTDIR)/,symbols.o} # $(AR) rcf $@ $^ diff --git a/platform/jcreate/platform-jcreate-conf.h b/platform/jcreate/platform-jcreate-conf.h index 620127f6b..8344f4a1b 100644 --- a/platform/jcreate/platform-jcreate-conf.h +++ b/platform/jcreate/platform-jcreate-conf.h @@ -60,8 +60,6 @@ #define CCIF #define CLIF -#define CC_CONF_INLINE inline - #define HAVE_STDINT_H #include "msp430def.h" diff --git a/platform/sentilla-usb/platform-sentilla-usb-conf.h b/platform/sentilla-usb/platform-sentilla-usb-conf.h index 67bbee5a7..579c654a3 100644 --- a/platform/sentilla-usb/platform-sentilla-usb-conf.h +++ b/platform/sentilla-usb/platform-sentilla-usb-conf.h @@ -59,8 +59,6 @@ #define CCIF #define CLIF -#define CC_CONF_INLINE inline - #define HAVE_STDINT_H #include "msp430def.h" diff --git a/platform/sky/Makefile.common b/platform/sky/Makefile.common index 621ceaf36..77e13ee84 100644 --- a/platform/sky/Makefile.common +++ b/platform/sky/Makefile.common @@ -17,7 +17,6 @@ endif ifdef IAR CFLAGS += -D__MSP430F1611__=1 -e --vla -Ohz --multiplier=16s --core=430 --double=32 CFLAGSNO = --dlib_config "$(IAR_PATH)/LIB/DLIB/dl430fn.h" $(CFLAGSWERROR) - endif CONTIKI_TARGET_SOURCEFILES += $(ARCH) $(UIPDRIVERS) @@ -30,12 +29,9 @@ contiki-$(TARGET).a: ${addprefix $(OBJECTDIR)/,symbols.o} ifdef IAR -ifdef ELF -LDFLAGS += -B -xm "$(IAR_PATH)/lib/dlib/dl430fn.r43" -f "$(IAR_PATH)/config/lnk430f1611.xcl" -l contiki-$(TARGET).map -Felf -yn -s __program_start -D_STACK_SIZE=80 -D_DATA16_HEAP_SIZE=80 -D_DATA20_HEAP_SIZE=80 -else -LDFLAGS += -B -xm "$(IAR_PATH)/lib/dlib/dl430fn.r43" -f "$(IAR_PATH)/config/lnk430f1611.xcl" -l contiki-$(TARGET).map -Fintel-extended -s __program_start -D_STACK_SIZE=80 -D_DATA16_HEAP_SIZE=80 -D_DATA20_HEAP_SIZE=80 -endif -endif +LDFLAGSNO += -B -xm "$(IAR_PATH)/lib/dlib/dl430fn.r43" -f "$(IAR_PATH)/config/lnk430f1611.xcl" -l contiki-$(TARGET).map -s __program_start -D_STACK_SIZE=80 -D_DATA16_HEAP_SIZE=80 -D_DATA20_HEAP_SIZE=80 +LDFLAGS += $(LDFLAGSNO) -Felf -yn +endif # IAR NUMPAR=20 IHEXFILE=tmpimage.ihex diff --git a/platform/wismote/Makefile.wismote b/platform/wismote/Makefile.wismote index c3ead6982..1a675f7ad 100644 --- a/platform/wismote/Makefile.wismote +++ b/platform/wismote/Makefile.wismote @@ -34,19 +34,15 @@ MCU=msp430x5437 include $(CONTIKI)/cpu/msp430/Makefile.msp430 ifdef IAR -LDFLAGS += -B -xm "$(IAR_PATH)/lib/dlib/dl430xsfn.r43" -f "$(IAR_PATH)/config/lnk430f5437.xcl" -l contiki-$(TARGET).map -Fintel-extended -s __program_start -D_STACK_SIZE=80 -D_DATA16_HEAP_SIZE=80 -D_DATA20_HEAP_SIZE=80 +LDFLAGSNO += -B -xm "$(IAR_PATH)/lib/dlib/dl430xsfn.r43" -f "$(IAR_PATH)/config/lnk430f5437.xcl" -l contiki-$(TARGET).map -s __program_start -D_STACK_SIZE=80 -D_DATA16_HEAP_SIZE=80 -D_DATA20_HEAP_SIZE=80 +LDFLAGS += $(LDFLAGSNO) -Felf -yn endif contiki-$(TARGET).a: ${addprefix $(OBJECTDIR)/,symbols.o} # $(AR) rcf $@ $^ -ifdef IAR -%.hex: %.$(TARGET) - mv $< $@ -else %.hex: %.ihex mv $< $@ -endif %.upload: %.hex msp430flasher -n msp430x5437 -e ERASE_MAIN -w $< -v -z [VCC] diff --git a/platform/z1/Makefile.common b/platform/z1/Makefile.common index c6080da94..2c21dc75e 100644 --- a/platform/z1/Makefile.common +++ b/platform/z1/Makefile.common @@ -41,7 +41,8 @@ include $(CONTIKI)/cpu/msp430/Makefile.msp430 # Add LDFLAGS after IAR_PATH is set ifdef IAR -LDFLAGS += -B -xm "$(IAR_PATH)/lib/dlib/dl430xsfn.r43" -f "$(IAR_PATH)/config/lnk430f2617.xcl" -l contiki-$(TARGET).map -Fintel-extended -s __program_start -D_STACK_SIZE=80 -D_DATA16_HEAP_SIZE=80 -D_DATA20_HEAP_SIZE=80 +LDFLAGSNO += -B -xm "$(IAR_PATH)/lib/dlib/dl430xsfn.r43" -f "$(IAR_PATH)/config/lnk430f2617.xcl" -l contiki-$(TARGET).map -s __program_start -D_STACK_SIZE=80 -D_DATA16_HEAP_SIZE=80 -D_DATA20_HEAP_SIZE=80 +LDFLAGS += $(LDFLAGSNO) -Felf -yn endif contiki-$(TARGET).a: ${addprefix $(OBJECTDIR)/,symbols.o}