mirror of
https://github.com/oliverschmidt/contiki.git
synced 2024-09-09 23:54:32 +00:00
187 lines
4.9 KiB
Makefile
187 lines
4.9 KiB
Makefile
|
# Makefile for the STM32L152VB Cortex M3 medium-density microcontroller
|
||
|
# author Marcus Lunden <marcus@thingsquare.com>
|
||
|
|
||
|
.SUFFIXES:
|
||
|
|
||
|
# CPU folder
|
||
|
CONTIKI_CPU=$(CONTIKI)/cpu/arm/stm32l152
|
||
|
|
||
|
# Source folders for ST HAL libraries, ARM CMSIS and IAR conf files
|
||
|
CONTIKI_CPU_DIRS = . \
|
||
|
STM32L1xx_HAL_Driver \
|
||
|
STM32L1xx_HAL_Driver/Src \
|
||
|
CMSIS \
|
||
|
STM32L1xx_HAL_Driver/Inc
|
||
|
|
||
|
# source files: proprietary sources for startup. Refer to CMSIS docs.
|
||
|
PROP_SYS_ARCH_C = system_stm32l1xx.c
|
||
|
|
||
|
|
||
|
ifdef IAR
|
||
|
include $(CONTIKI_CPU)/Makefile.stm32l152.iar
|
||
|
else
|
||
|
include $(CONTIKI_CPU)/Makefile.stm32l152.gnu
|
||
|
endif
|
||
|
|
||
|
|
||
|
# source files: Contiki arch source files
|
||
|
CONTIKI_CPU_ARCH= watchdog.c \
|
||
|
rtimer-arch.c \
|
||
|
clock.c
|
||
|
|
||
|
ifdef GCC
|
||
|
CONTIKI_CPU_PORT= sysmem.c \
|
||
|
console.c \
|
||
|
crt.c \
|
||
|
uart.c
|
||
|
else
|
||
|
CONTIKI_CPU_PORT=
|
||
|
endif
|
||
|
|
||
|
|
||
|
|
||
|
UIPDRIVERS=
|
||
|
|
||
|
# to be implemented
|
||
|
ELFLOADER=
|
||
|
|
||
|
|
||
|
STM32L1XX_HAL =\
|
||
|
stm32l1xx_hal.c\
|
||
|
stm32l1xx_hal_adc_ex.c\
|
||
|
stm32l1xx_hal_adc.c\
|
||
|
stm32l1xx_hal_comp.c\
|
||
|
stm32l1xx_hal_cortex.c\
|
||
|
stm32l1xx_hal_crc.c\
|
||
|
stm32l1xx_hal_cryp_ex.c\
|
||
|
stm32l1xx_hal_cryp.c\
|
||
|
stm32l1xx_hal_dac_ex.c\
|
||
|
stm32l1xx_hal_dac.c\
|
||
|
stm32l1xx_hal_dma.c\
|
||
|
stm32l1xx_hal_flash_ex.c\
|
||
|
stm32l1xx_hal_flash.c\
|
||
|
stm32l1xx_hal_flash_ramfunc.c\
|
||
|
stm32l1xx_hal_gpio.c\
|
||
|
stm32l1xx_hal_i2c.c\
|
||
|
stm32l1xx_hal_i2s.c\
|
||
|
stm32l1xx_hal_irda.c\
|
||
|
stm32l1xx_hal_iwdg.c\
|
||
|
stm32l1xx_hal_lcd.c\
|
||
|
stm32l1xx_hal_nor.c\
|
||
|
stm32l1xx_hal_opamp_ex.c\
|
||
|
stm32l1xx_hal_opamp.c\
|
||
|
stm32l1xx_hal_pcd_ex.c\
|
||
|
stm32l1xx_hal_pcd.c\
|
||
|
stm32l1xx_hal_pwr_ex.c\
|
||
|
stm32l1xx_hal_pwr.c\
|
||
|
stm32l1xx_hal_rcc_ex.c\
|
||
|
stm32l1xx_hal_rcc.c\
|
||
|
stm32l1xx_hal_rtc_ex.c\
|
||
|
stm32l1xx_hal_rtc.c\
|
||
|
stm32l1xx_hal_sd.c\
|
||
|
stm32l1xx_hal_smartcard.c\
|
||
|
stm32l1xx_hal_spi_ex.c\
|
||
|
stm32l1xx_hal_spi.c\
|
||
|
stm32l1xx_hal_sram.c\
|
||
|
stm32l1xx_hal_tim_ex.c\
|
||
|
stm32l1xx_hal_tim.c\
|
||
|
stm32l1xx_hal_uart.c\
|
||
|
stm32l1xx_hal_usart.c\
|
||
|
stm32l1xx_hal_wwdg.c\
|
||
|
stm32l1xx_ll_fsmc.c\
|
||
|
stm32l1xx_ll_sdmmc.c
|
||
|
|
||
|
|
||
|
|
||
|
# add CPU folder to search path for .s (assembler) files
|
||
|
vpath %.s $(CONTIKI_CPU)
|
||
|
|
||
|
|
||
|
|
||
|
# include all files above
|
||
|
ssubst = ${patsubst %.s,%.o,${patsubst %.s79,%.o,$(1)}}
|
||
|
CONTIKI_TARGET_SOURCEFILES += $(PROP_SYS_ARCH_C) $(PROP_USB_ARCH) $(CONTIKI_CPU_ARCH) $(CONTIKI_CPU_PORT) $(ELFLOADER) $(UIPDRIVERS) $(STM32L1XX_HAL)
|
||
|
CONTIKI_SOURCEFILES += $(CONTIKI_TARGET_SOURCEFILES)
|
||
|
PROJECT_OBJECTFILES += ${addprefix $(OBJECTDIR)/,$(CONTIKI_TARGET_MAIN:.c=.o)}
|
||
|
PROJECT_OBJECTFILES += ${addprefix $(OBJECTDIR)/,${call ssubst, $(PROP_SYS_ARCH_S)}}
|
||
|
#CONTIKI_OBJECTFILES += ${addprefix $(OBJECTDIR)/,${call ssubst, $(PROP_SYS_ARCH_S)}}
|
||
|
|
||
|
#------------------------------------------------ defines common for IAR and GCC
|
||
|
# set CPU speed in Hz, NB this might have unexpected side-effects if not at 32
|
||
|
# Mhz as it is not immediately clear how specialized the startup code etc is.
|
||
|
# That being said, setting to 24MHz seems to work fine, looking at Contiki clocks
|
||
|
# at least.
|
||
|
F_CPU = 32000000
|
||
|
|
||
|
CFLAGS+=\
|
||
|
-DHSE_VALUE=$(F_CPU)ul \
|
||
|
-DUSE_STDPERIPH_DRIVER \
|
||
|
-DSTM32L1XX_MD \
|
||
|
-DIAR_ARM_CM3 \
|
||
|
-DVECT_TAB_FLASH \
|
||
|
-DWITH_UIP6
|
||
|
|
||
|
# ------------------------------------------------------------------ Build rules
|
||
|
CUSTOM_RULE_C_TO_CE=yes
|
||
|
CUSTOM_RULE_C_TO_CO=yes
|
||
|
CUSTOM_RULE_C_TO_O=yes
|
||
|
CUSTOM_RULE_S_TO_OBJECTDIR_O=yes
|
||
|
CUSTOM_RULE_LINK=yes
|
||
|
|
||
|
%.o: %.c
|
||
|
$(CC) $(CFLAGS) $< -o $@
|
||
|
|
||
|
%.o: %.s
|
||
|
$(AS) $(ASFLAGS) $< -o $@
|
||
|
|
||
|
define FINALIZE_CYGWIN_DEPENDENCY
|
||
|
sed -e 's/ \([A-Z]\):\\/ \/cygdrive\/\L\1\//' -e 's/\\\([^ ]\)/\/\1/g' \
|
||
|
<$(@:.o=.P) >$(@:.o=.d); \
|
||
|
rm -f $(@:.o=.P)
|
||
|
endef
|
||
|
|
||
|
$(OBJECTDIR)/%.o: %.s
|
||
|
$(AS) $(ASFLAGS) $< -o $@
|
||
|
|
||
|
%.ce: %.o
|
||
|
$(LD) $(LDFLAGS) --relocatable -T $(CONTIKI_CPU)/merge-rodata.ld $< -o $@ $(LDLIBS)
|
||
|
$(STRIP) -K _init -K _fini --strip-unneeded -g -x $@
|
||
|
|
||
|
%-stripped.o: %.c
|
||
|
$(CC) $(CFLAGS) $< -o $@
|
||
|
$(STRIP) --strip $@
|
||
|
|
||
|
%-stripped.o: %.o
|
||
|
$(STRIP) --strip $@ $<
|
||
|
|
||
|
%.o: ${CONTIKI_TARGET}/loader/%.S
|
||
|
$(AS) -o $(notdir $(<:.S=.o)) $<
|
||
|
|
||
|
ifdef IAR
|
||
|
%.$(TARGET): %.co $(PROJECT_OBJECTFILES) contiki-$(TARGET).a $(STARTUPFOLDER) # $(OBJECTDIR)/empty-symbols.o
|
||
|
$(LD) $(LDFLAGS) -o $@ $(filter-out %.a,$^) $(filter %.a,$^) $(LDLIBS)
|
||
|
else
|
||
|
#CONTIKI_CPU_OBJS=$(CONTIKI_CPU_PORT:%.c=obj_stm32nucleo-spirit1/%.o)
|
||
|
CONTIKI_CPU_OBJS=$(CONTIKI_CPU_PORT:%.c=$(OBJECTDIR)/%.o)
|
||
|
%.$(TARGET): %.co $(PROJECT_OBJECTFILES) $(PROJECT_LIBRARIES) contiki-$(TARGET).a $(OBJECTDIR)/symbols.o
|
||
|
$(TRACE_LD)
|
||
|
$(Q)$(LD) $(LDFLAGS) $(TARGET_STARTFILES) ${filter-out %.a,$^} -Wl,-\( ${filter %.a,$^} $(TARGET_LIBFILES) -Wl,-\) $(CONTIKI_CPU_OBJS) -o $@
|
||
|
@echo >> contiki-$(TARGET).map
|
||
|
@$(SIZE) $(SIZEFLAGS) $@ >> contiki-$(TARGET).map
|
||
|
endif
|
||
|
|
||
|
%.hex: %.ihex
|
||
|
# @rm $*.hex
|
||
|
@mv -f $*.ihex $*.hex
|
||
|
|
||
|
.PHONY: symbols.c
|
||
|
|
||
|
symbols.c:
|
||
|
cp ${CONTIKI}/tools/empty-symbols.c symbols.c
|
||
|
cp ${CONTIKI}/tools/empty-symbols.h symbols.h
|
||
|
|
||
|
# Don't use core/loader/elfloader.c, use elfloader-otf.c instead
|
||
|
$(OBJECTDIR)/elfloader.o:
|
||
|
echo -n >$@
|
||
|
|