2013-01-12 22:44:42 +00:00
|
|
|
CC = arm-none-eabi-gcc
|
|
|
|
CPP = arm-none-eabi-cpp
|
|
|
|
LD = arm-none-eabi-gcc
|
|
|
|
AR = arm-none-eabi-ar
|
|
|
|
OBJCOPY = arm-none-eabi-objcopy
|
2014-04-02 22:17:49 +00:00
|
|
|
OBJDUMP = arm-none-eabi-objdump
|
2013-01-12 22:44:42 +00:00
|
|
|
NM = arm-none-eabi-nm
|
|
|
|
|
2013-10-29 13:14:35 +00:00
|
|
|
ifndef SOURCE_LDSCRIPT
|
|
|
|
SOURCE_LDSCRIPT = $(CONTIKI_CPU)/cc2538.lds
|
|
|
|
endif
|
2013-01-12 22:44:42 +00:00
|
|
|
LDSCRIPT = $(OBJECTDIR)/cc2538.ld
|
|
|
|
|
2014-01-30 16:41:51 +00:00
|
|
|
CFLAGS += -mcpu=cortex-m3 -mthumb -mlittle-endian
|
2014-01-31 20:00:31 +00:00
|
|
|
CFLAGS += -ffunction-sections -fdata-sections
|
2013-01-12 22:44:42 +00:00
|
|
|
CFLAGS += -fshort-enums -fomit-frame-pointer -fno-strict-aliasing
|
|
|
|
CFLAGS += -Wall
|
|
|
|
LDFLAGS += -mcpu=cortex-m3 -mthumb -nostartfiles
|
|
|
|
LDFLAGS += -T $(LDSCRIPT)
|
2014-01-31 20:00:31 +00:00
|
|
|
LDFLAGS += -Wl,--gc-sections,--sort-section=alignment
|
2013-01-12 22:44:42 +00:00
|
|
|
LDFLAGS += -Wl,-Map=$(@:.elf=-$(TARGET).map),--cref,--no-warn-mismatch
|
|
|
|
OBJCOPY_FLAGS += -O binary --gap-fill 0xff
|
2014-04-02 22:17:49 +00:00
|
|
|
OBJDUMP_FLAGS += --disassemble --source --disassembler-options=force-thumb
|
2013-01-12 22:44:42 +00:00
|
|
|
|
|
|
|
### Are we building with code size optimisations?
|
|
|
|
ifeq ($(SMALL),1)
|
2014-01-31 20:00:31 +00:00
|
|
|
CFLAGS += -Os
|
2014-01-30 16:41:51 +00:00
|
|
|
else
|
|
|
|
CFLAGS += -O2
|
2013-01-12 22:44:42 +00:00
|
|
|
endif
|
|
|
|
|
|
|
|
### If the user-specified a Node ID, pass a define
|
|
|
|
ifdef NODEID
|
|
|
|
CFLAGS += -DIEEE_ADDR_NODE_ID=$(NODEID)
|
|
|
|
endif
|
|
|
|
|
|
|
|
### CPU-dependent cleanup files
|
2013-10-31 15:25:27 +00:00
|
|
|
CLEAN += symbols.c symbols.h *.d *.elf *.hex
|
2013-01-12 22:44:42 +00:00
|
|
|
|
|
|
|
### CPU-dependent directories
|
|
|
|
CONTIKI_CPU_DIRS = . dev usb
|
|
|
|
|
|
|
|
### Use the existing debug I/O in cpu/arm/common
|
|
|
|
CONTIKI_CPU_DIRS += ../arm/common/dbg-io
|
|
|
|
|
|
|
|
### Use usb core from cpu/cc253x/usb/common
|
|
|
|
CONTIKI_CPU_DIRS += ../cc253x/usb/common ../cc253x/usb/common/cdc-acm
|
|
|
|
|
|
|
|
### CPU-dependent source files
|
|
|
|
CONTIKI_CPU_SOURCEFILES += clock.c rtimer-arch.c uart.c watchdog.c
|
2013-11-04 19:39:56 +00:00
|
|
|
CONTIKI_CPU_SOURCEFILES += nvic.c cpu.c sys-ctrl.c gpio.c ioc.c spi.c adc.c
|
2013-01-12 22:44:42 +00:00
|
|
|
CONTIKI_CPU_SOURCEFILES += cc2538-rf.c udma.c lpm.c
|
|
|
|
CONTIKI_CPU_SOURCEFILES += dbg.c ieee-addr.c
|
|
|
|
CONTIKI_CPU_SOURCEFILES += slip-arch.c slip.c
|
2015-02-11 16:54:56 +00:00
|
|
|
CONTIKI_CPU_SOURCEFILES += i2c.c cc2538-temp-sensor.c vdd3-sensor.c
|
2013-01-12 22:44:42 +00:00
|
|
|
|
|
|
|
DEBUG_IO_SOURCEFILES += dbg-printf.c dbg-snprintf.c dbg-sprintf.c strformat.c
|
|
|
|
|
|
|
|
USB_CORE_SOURCEFILES += usb-core.c cdc-acm.c
|
|
|
|
USB_ARCH_SOURCEFILES += usb-arch.c usb-serial.c cdc-acm-descriptors.c
|
|
|
|
|
2015-02-09 15:23:36 +00:00
|
|
|
ifneq ($(TARGET_START_SOURCEFILES),)
|
|
|
|
CPU_START_SOURCEFILES = TARGET_START_SOURCEFILES
|
|
|
|
else
|
|
|
|
CPU_START_SOURCEFILES = startup-gcc.c
|
|
|
|
endif
|
|
|
|
CPU_STARTFILES = ${addprefix $(OBJECTDIR)/,${call oname, $(CPU_START_SOURCEFILES)}}
|
|
|
|
|
2013-01-12 22:44:42 +00:00
|
|
|
CONTIKI_SOURCEFILES += $(CONTIKI_CPU_SOURCEFILES) $(DEBUG_IO_SOURCEFILES)
|
|
|
|
CONTIKI_SOURCEFILES += $(USB_CORE_SOURCEFILES) $(USB_ARCH_SOURCEFILES)
|
|
|
|
|
|
|
|
### Don't treat the .elf as intermediate
|
2013-10-31 15:25:27 +00:00
|
|
|
.PRECIOUS: %.elf %.hex %.bin
|
2013-01-12 22:44:42 +00:00
|
|
|
|
|
|
|
### Always re-build ieee-addr.o in case the command line passes a new NODEID
|
|
|
|
FORCE:
|
|
|
|
|
2013-06-20 22:45:41 +00:00
|
|
|
$(OBJECTDIR)/ieee-addr.o: ieee-addr.c FORCE | $(OBJECTDIR)
|
2013-08-06 15:46:57 +00:00
|
|
|
$(TRACE_CC)
|
|
|
|
$(Q)$(CC) $(CFLAGS) -c $< -o $@
|
2013-01-12 22:44:42 +00:00
|
|
|
|
|
|
|
### Compilation rules
|
|
|
|
CUSTOM_RULE_LINK=1
|
|
|
|
|
2015-02-09 15:23:36 +00:00
|
|
|
%.elf: $(CPU_STARTFILES) %.co $(PROJECT_OBJECTFILES) $(PROJECT_LIBRARIES) contiki-$(TARGET).a $(LDSCRIPT)
|
2013-08-06 15:46:57 +00:00
|
|
|
$(TRACE_LD)
|
2014-01-27 17:01:37 +00:00
|
|
|
$(Q)$(LD) $(LDFLAGS) ${filter-out $(LDSCRIPT) %.a,$^} ${filter %.a,$^} $(TARGET_LIBFILES) -o $@
|
2013-01-12 22:44:42 +00:00
|
|
|
|
2013-10-31 15:25:27 +00:00
|
|
|
%.hex: %.elf
|
|
|
|
$(OBJCOPY) -O ihex $< $@
|
|
|
|
|
2013-01-12 22:44:42 +00:00
|
|
|
%.bin: %.elf
|
|
|
|
$(OBJCOPY) $(OBJCOPY_FLAGS) $< $@
|
|
|
|
|
2014-04-02 22:17:49 +00:00
|
|
|
%.lst: %.elf
|
|
|
|
$(OBJDUMP) $(OBJDUMP_FLAGS) $< > $@
|
|
|
|
|
2013-10-31 15:25:27 +00:00
|
|
|
### We don't really need the .hex and .bin for the .$(TARGET) but let's make
|
|
|
|
### sure they get built
|
|
|
|
%.$(TARGET): %.elf %.hex %.bin
|
2013-01-12 22:44:42 +00:00
|
|
|
cp $< $@
|
|
|
|
|
|
|
|
### This rule is used to generate the correct linker script
|
|
|
|
LDGENFLAGS += $(addprefix -D,$(subst $(COMMA), ,$(DEFINES)))
|
|
|
|
LDGENFLAGS += $(addprefix -I,$(SOURCEDIRS))
|
|
|
|
LDGENFLAGS += -imacros "contiki-conf.h"
|
2013-08-06 15:46:57 +00:00
|
|
|
LDGENFLAGS += -x c -P -E
|
2013-01-12 22:44:42 +00:00
|
|
|
|
2013-06-20 22:45:41 +00:00
|
|
|
# NB: Assumes LDSCRIPT was not overridden and is in $(OBJECTDIR)
|
2013-10-29 13:14:35 +00:00
|
|
|
$(LDSCRIPT): $(SOURCE_LDSCRIPT) FORCE | $(OBJECTDIR)
|
2013-08-06 15:46:57 +00:00
|
|
|
$(TRACE_CC)
|
|
|
|
$(Q)$(CC) $(LDGENFLAGS) $< -o $@
|