2015-02-25 12:09:56 +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
|
|
|
|
OBJDUMP = arm-none-eabi-objdump
|
|
|
|
NM = arm-none-eabi-nm
|
|
|
|
SIZE = arm-none-eabi-size
|
2015-05-10 15:20:20 +00:00
|
|
|
SREC_CAT = srec_cat
|
2015-02-25 12:09:56 +00:00
|
|
|
|
2017-06-28 13:57:13 +00:00
|
|
|
CPU_ABS_PATH = arch/cpu/cc26xx-cc13xx
|
2015-08-16 15:30:04 +00:00
|
|
|
TI_XXWARE = $(CONTIKI_CPU)/$(TI_XXWARE_PATH)
|
2015-02-25 12:09:56 +00:00
|
|
|
|
2015-05-14 13:52:16 +00:00
|
|
|
### cc26xxware sources under driverlib will be added to the MODULES list
|
2015-08-16 15:30:04 +00:00
|
|
|
TI_XXWARE_SRC = $(CPU_ABS_PATH)/$(TI_XXWARE_PATH)/driverlib
|
2015-02-25 12:09:56 +00:00
|
|
|
|
|
|
|
### The directory with startup sources will be added to the CONTIKI_CPU_DIRS
|
|
|
|
### and the sources therein are added to the sources list explicitly. They are
|
|
|
|
### also listed explicitly in the linker command (through TARGET_STARTFILES),
|
|
|
|
### to make sure they always get linked in the image
|
2015-08-16 15:30:04 +00:00
|
|
|
TI_XXWARE_STARTUP_DIR = $(TI_XXWARE_PATH)/startup_files
|
|
|
|
TI_XXWARE_STARTUP_SRCS = ccfg.c startup_gcc.c
|
2015-02-25 12:09:56 +00:00
|
|
|
|
2015-05-14 13:52:16 +00:00
|
|
|
### MODULES will add some of these to the include path, but we need to add
|
2015-02-25 12:09:56 +00:00
|
|
|
### them earlier to prevent filename clashes with Contiki core files
|
2015-08-16 15:30:04 +00:00
|
|
|
CFLAGS += -I$(TI_XXWARE) -I$(CONTIKI)/$(TI_XXWARE_SRC)
|
|
|
|
CFLAGS += -I$(TI_XXWARE)/inc
|
|
|
|
MODULES += $(TI_XXWARE_SRC)
|
2015-02-25 12:09:56 +00:00
|
|
|
|
|
|
|
LDSCRIPT = $(CONTIKI_CPU)/cc26xx.ld
|
|
|
|
|
|
|
|
CFLAGS += -mcpu=cortex-m3 -mthumb -mlittle-endian
|
|
|
|
CFLAGS += -ffunction-sections -fdata-sections
|
|
|
|
CFLAGS += -fshort-enums -fomit-frame-pointer -fno-strict-aliasing
|
2017-11-25 18:57:56 +00:00
|
|
|
CFLAGS += -Wall -std=c99 -DCMSIS_DEV_HDR=\"cc13x0-cc26x0-cm3.h\"
|
2015-02-25 12:09:56 +00:00
|
|
|
|
|
|
|
LDFLAGS += -mcpu=cortex-m3 -mthumb -mlittle-endian -nostartfiles
|
|
|
|
LDFLAGS += -T $(LDSCRIPT)
|
|
|
|
LDFLAGS += -Wl,--gc-sections,--sort-section=alignment
|
|
|
|
LDFLAGS += -Wl,-Map=$(@:.elf=-$(TARGET).map),--cref,--no-warn-mismatch
|
|
|
|
OBJCOPY_FLAGS += -O binary --gap-fill 0xff
|
|
|
|
OBJDUMP_FLAGS += --disassemble --source --disassembler-options=force-thumb
|
|
|
|
|
2017-06-21 09:11:09 +00:00
|
|
|
ifeq ($(WERROR),1)
|
2015-09-26 09:19:22 +00:00
|
|
|
CFLAGS += -Werror
|
|
|
|
endif
|
|
|
|
|
2015-02-25 12:09:56 +00:00
|
|
|
### Are we building with code size optimisations?
|
2017-05-16 15:09:58 +00:00
|
|
|
SMALL ?= 1
|
2015-02-25 12:09:56 +00:00
|
|
|
ifeq ($(SMALL),1)
|
|
|
|
CFLAGS += -Os
|
|
|
|
else
|
|
|
|
CFLAGS += -O2
|
|
|
|
endif
|
|
|
|
|
|
|
|
### If the user-specified a Node ID, pass a define
|
|
|
|
ifdef NODEID
|
|
|
|
CFLAGS += -DIEEE_ADDR_NODE_ID=$(NODEID)
|
|
|
|
endif
|
|
|
|
|
|
|
|
### CPU-dependent cleanup files
|
2017-05-13 11:09:58 +00:00
|
|
|
CLEAN += *.d *.elf *.hex
|
2015-02-25 12:09:56 +00:00
|
|
|
|
|
|
|
### CPU-dependent directories
|
2017-11-25 18:57:56 +00:00
|
|
|
CONTIKI_CPU_DIRS += . dev rf-core rf-core/api $(TI_XXWARE_STARTUP_DIR)
|
2015-02-25 12:09:56 +00:00
|
|
|
|
2017-11-25 18:57:56 +00:00
|
|
|
### Use CMSIS and the existing debug I/O in arch/cpu/arm/common
|
|
|
|
CONTIKI_CPU_DIRS += ../arm/common/dbg-io ../arm/common/CMSIS
|
2015-02-25 12:09:56 +00:00
|
|
|
|
|
|
|
### CPU-dependent source files
|
2015-08-16 15:30:04 +00:00
|
|
|
CONTIKI_CPU_SOURCEFILES += clock.c rtimer-arch.c soc-rtc.c uart.c
|
2016-04-19 21:17:16 +00:00
|
|
|
CONTIKI_CPU_SOURCEFILES += contiki-watchdog.c aux-ctrl.c
|
2016-04-21 13:55:01 +00:00
|
|
|
CONTIKI_CPU_SOURCEFILES += putchar.c ieee-addr.c batmon-sensor.c adc-sensor.c
|
2015-02-25 12:09:56 +00:00
|
|
|
CONTIKI_CPU_SOURCEFILES += slip-arch.c slip.c cc26xx-uart.c lpm.c
|
2015-05-01 14:40:14 +00:00
|
|
|
CONTIKI_CPU_SOURCEFILES += gpio-interrupt.c oscillators.c
|
2015-08-16 15:30:04 +00:00
|
|
|
CONTIKI_CPU_SOURCEFILES += rf-core.c rf-ble.c ieee-mode.c
|
2016-06-14 19:02:35 +00:00
|
|
|
CONTIKI_CPU_SOURCEFILES += random.c soc-trng.c
|
2015-02-25 12:09:56 +00:00
|
|
|
|
|
|
|
DEBUG_IO_SOURCEFILES += dbg-printf.c dbg-snprintf.c dbg-sprintf.c strformat.c
|
|
|
|
|
|
|
|
CONTIKI_SOURCEFILES += $(CONTIKI_CPU_SOURCEFILES) $(DEBUG_IO_SOURCEFILES)
|
|
|
|
|
2015-08-16 15:30:04 +00:00
|
|
|
TARGET_START_SOURCEFILES += fault-handlers.c $(TI_XXWARE_STARTUP_SRCS)
|
2015-02-25 12:09:56 +00:00
|
|
|
TARGET_STARTFILES = $(addprefix $(OBJECTDIR)/,$(call oname, $(TARGET_START_SOURCEFILES)))
|
|
|
|
|
2016-05-14 18:16:43 +00:00
|
|
|
PYTHON = python
|
|
|
|
BSL_FLAGS += -e -w -v
|
|
|
|
|
|
|
|
ifdef PORT
|
|
|
|
BSL_FLAGS += -p $(PORT)
|
|
|
|
endif
|
|
|
|
|
|
|
|
BSL = $(CONTIKI)/tools/cc2538-bsl/cc2538-bsl.py
|
|
|
|
|
2015-02-25 12:09:56 +00:00
|
|
|
### Don't treat the .elf as intermediate
|
|
|
|
.PRECIOUS: %.elf %.hex %.bin
|
|
|
|
|
|
|
|
### Always re-build ieee-addr.o in case the command line passes a new NODEID
|
|
|
|
FORCE:
|
|
|
|
|
|
|
|
$(OBJECTDIR)/ieee-addr.o: ieee-addr.c FORCE | $(OBJECTDIR)
|
|
|
|
$(TRACE_CC)
|
|
|
|
$(Q)$(CC) $(CFLAGS) -c $< -o $@
|
|
|
|
|
2016-06-11 18:44:27 +00:00
|
|
|
### Always re-build ccfg.c so changes to ccfg-conf.h will apply without having
|
|
|
|
### to make clean first
|
|
|
|
$(OBJECTDIR)/ccfg.o: ccfg.c FORCE | $(OBJECTDIR)
|
|
|
|
$(TRACE_CC)
|
2017-11-26 17:27:22 +00:00
|
|
|
$(Q)$(CC) $(CFLAGS) -include "ccxxware-conf.h" -c $< -o $@
|
2016-06-11 18:44:27 +00:00
|
|
|
|
2015-02-25 12:09:56 +00:00
|
|
|
### Compilation rules
|
|
|
|
CUSTOM_RULE_LINK=1
|
|
|
|
|
|
|
|
%.elf: $(TARGET_STARTFILES) %.co $(PROJECT_OBJECTFILES) $(PROJECT_LIBRARIES) contiki-$(TARGET).a $(LDSCRIPT)
|
|
|
|
$(TRACE_LD)
|
|
|
|
$(Q)$(LD) $(LDFLAGS) ${filter-out $(LDSCRIPT) %.a,$^} ${filter %.a,$^} $(TARGET_LIBFILES) -lm -o $@
|
|
|
|
|
2015-05-10 15:20:20 +00:00
|
|
|
%.i16hex: %.elf
|
2015-02-25 12:09:56 +00:00
|
|
|
$(OBJCOPY) -O ihex $< $@
|
|
|
|
|
2015-05-10 15:20:20 +00:00
|
|
|
%.hex: %.i16hex
|
|
|
|
$(SREC_CAT) $< -intel -o $@ -intel
|
|
|
|
|
2015-02-25 12:09:56 +00:00
|
|
|
%.bin: %.elf
|
|
|
|
$(OBJCOPY) $(OBJCOPY_FLAGS) $< $@
|
|
|
|
|
|
|
|
%.lst: %.elf
|
|
|
|
$(OBJDUMP) $(OBJDUMP_FLAGS) $< > $@
|
|
|
|
|
|
|
|
### We don't really need the .hex and .bin for the .$(TARGET) but let's make
|
|
|
|
### sure they get built
|
|
|
|
%.$(TARGET): %.elf %.hex %.bin
|
|
|
|
cp $< $@
|
|
|
|
|
|
|
|
# a target that gives a user-friendly memory profile, taking into account the RAM
|
|
|
|
# that is statically occupied by the stack as defined in the linker script
|
|
|
|
# see $(LDSCRIPT)
|
|
|
|
RAM_SIZE = 0x00003E00
|
|
|
|
FLASH_SIZE = 0x0001E000
|
|
|
|
STACK_SIZE = 0
|
|
|
|
%.size: %.$(TARGET)
|
|
|
|
@$(SIZE) -A $< | egrep "data|bss" | awk '{s+=$$2} END {s=s+$(STACK_SIZE); f=$(RAM_SIZE)-s; printf "[RAM] used %6d, free %6d\n",s,f;}'
|
|
|
|
@$(SIZE) -A $< | egrep "text|isr_vector" | awk '{s+=$$2} END {f=$(FLASH_SIZE)-s; printf "[Flash] used %6d, free %6d\n",s,f;}'
|
|
|
|
|
2016-05-14 18:16:43 +00:00
|
|
|
ifeq ($(BOARD_SUPPORTS_BSL),1)
|
|
|
|
%.upload: %.bin
|
|
|
|
ifeq ($(wildcard $(BSL)), )
|
|
|
|
@echo "ERROR: Could not find the cc2538-bsl script. Did you run 'git submodule update --init' ?"
|
|
|
|
else
|
|
|
|
$(PYTHON) $(BSL) $(BSL_FLAGS) $<
|
|
|
|
endif
|
|
|
|
else
|
|
|
|
%.upload:
|
|
|
|
@echo "This board cannot be programmed through the ROM bootloader and therefore does not support the .upload target."
|
|
|
|
endif
|
2016-05-18 14:40:20 +00:00
|
|
|
|
|
|
|
# Check if we are running under Windows
|
|
|
|
ifeq ($(HOST_OS),Windows)
|
|
|
|
SERIALDUMP ?= $(CONTIKI)/tools/sky/serialdump-windows
|
|
|
|
else
|
|
|
|
ifeq ($(HOST_OS),Darwin)
|
|
|
|
SERIALDUMP ?= $(CONTIKI)/tools/sky/serialdump-macos
|
|
|
|
else
|
|
|
|
# Else assume Linux
|
|
|
|
SERIALDUMP ?= $(CONTIKI)/tools/sky/serialdump-linux
|
|
|
|
endif
|
|
|
|
endif
|
|
|
|
|
|
|
|
UART_BAUDRATE = 115200
|
|
|
|
|
|
|
|
login:
|
|
|
|
$(SERIALDUMP) -b$(UART_BAUDRATE) $(PORT)
|