Makefile rework

This commit is contained in:
Edvard Pettersen 2018-07-25 10:21:54 +02:00
parent 0c17a1a7ee
commit 7002309c23
6 changed files with 137 additions and 57 deletions

View File

@ -1,36 +1,43 @@
################################################################################
# CC13xx/CC26xx CPU makefile
### CC13xx/CC26xx CPU makefile
CC13x2_CC26x2_PRE_RTM ?= 1
# Core SDK is placed as a submodule under the arch/cpu/cc13xx-cc26xx/lib.
# Core SDK is placed as a submodule under arch/cpu/cc13xx-cc26xx/lib.
# Do a sanity check that Core SDK submodule has been initialized.
ifeq ($(CORE_SDK),)
CORE_SDK := $(CONTIKI_CPU)/lib/coresdk_cc13xx_cc26xx
CORE_SDK_INIT := $(shell [ -f $(CORE_SDK)/.git ] && echo 1)
ifeq ($(CORE_SDK_INIT),)
$(error The Core SDK submodule is not available. Please run 'git submodule update --init --recursive')
endif
# Note that Core SDK can be overriden with a user-specified SimpleLink SDK.
# As long as the SimpleLink SDK matches the device in use and is of a reasonable
# newer version, then it should be no different than using Core SDK.
ifeq ($(CORE_SDK),)
CORE_SDK := $(CONTIKI_CPU)/lib/coresdk_cc13xx_cc26xx
CORE_SDK_INIT := $(shell [ -f $(CORE_SDK)/.git ]; echo $$?)
ifeq ($(CORE_SDK_INIT),1)
$(error The Core SDK submodule is not available. Please run 'git submodule update --init --recursive')
endif
else
# Core SDK was overriden. Do a sanity check the path exists.
CORE_SDK_VALID := $(shell [ -d $(CORE_SDK) ]; echo $$?)
ifeq ($(CORE_SDK_VALID),1)
# Do a sanity check the path exists.
CORE_SDK_VALID := $(shell [ -d $(CORE_SDK) ] && echo 1)
ifeq ($(CORE_SDK_VALID),)
$(error Supplied CORE_SDK is not a valid path.)
endif
endif
# Clean up the path.
CORE_SDK := ${realpath $(CORE_SDK)}
# ccfg.c comes from the device-specific startp_files folder,
# and startup_cc13xx_cc26xx_gcc.c comes from NoRTOS startup folder
# Clean up the path.
CORE_SDK := $(realpath $(CORE_SDK))
# Both ccfg.c and startup_cc13xx_cc26xx_gcc.c is located locally in
# the arch/cpu/cc13xx-cc26xx folder.
CPU_START_SOURCEFILES += ccfg.c startup_cc13xx_cc26xx_gcc.c
################################################################################
# Device Family
### Device Family
# CC13x2/CC26x2 has to differentiate both pre-RTM and RTM devices. As of now,
# pre-RTM is suffixed with _v1 while RTM is suffixed with _v2. This will be
# removed when CC13x2/CC26x2 RTMs. For now, provide a switch to choose
# either pre-RTM or RTM.
# Also note that the devices name is cc13x2_cc26x2 for all CC13x2/CC26x2
# devices, while the library name is individual for each device family.
ifeq ($(SUBFAMILY),cc13x2-cc26x2)
ifeq ($(CC13x2_CC26x2_PRE_RTM),1)
SDK_DEVICES_NAME := cc13x2_cc26x2_v1
@ -39,36 +46,37 @@ ifeq ($(SUBFAMILY),cc13x2-cc26x2)
SDK_DEVICES_NAME := cc13x2_cc26x2_v2
SDK_LIB_NAME := $(DEVICE_FAMILY_LC)_v2
endif
# CC13x0/CC26x0 does not have this, with both its devices name and library
# name he same as its own device family name.
else
SDK_DEVICES_NAME := $(DEVICE_FAMILY_LC)
SDK_LIB_NAME := $(DEVICE_FAMILY_LC)
endif
################################################################################
# Simplelink SDK paths
### Core SDK paths
SDK_KERNEL := $(CORE_SDK)/kernel/nortos
SDK_SOURCE := $(CORE_SDK)/source
SDK_BOARDS := $(SDK_SOURCE)/ti/boards
SDK_DRIVERS := $(SDK_SOURCE)/ti/drivers
SDK_DEVICE := $(SDK_SOURCE)/ti/devices/$(SDK_DEVICES_NAME)
SDK_NORTOS := $(CORE_SDK)/kernel/nortos
SDK_SOURCE := $(CORE_SDK)/source
SDK_DRIVERS := $(CORE_SDK)/source/ti/drivers
SDK_DEVICES := $(CORE_SDK)/source/ti/devices/$(SDK_DEVICES_NAME)
EXTERNALDIRS += $(SDK_SOURCE)
EXTERNALDIRS += $(SDK_KERNEL)
EXTERNALDIRS += $(SDK_KERNEL)/startup
EXTERNALDIRS += $(SDK_DEVICE)
EXTERNALDIRS += $(SDK_DEVICE)/startup_files
EXTERNALDIRS += $(SDK_NORTOS)
### CPU-dependent source files
CONTIKI_CPU_SOURCEFILES += rtimer-arch.c clock-arch.c
CONTIKI_CPU_SOURCEFILES += watchdog-arch.c dbg-arch.c
CONTIKI_CPU_SOURCEFILES += uart0-arch.c slip-arch.c
CONTIKI_CPU_SOURCEFILES += gpio-hal-arch.c int-master-arch.c
CONTIKI_CPU_SOURCEFILES += random.c trng-arch.c
################################################################################
### CC13xx/CC26xx CPU files
### RF source files
CONTIKI_CPU_SOURCEFILES += sched.c data-queue.c
CONTIKI_CPU_SOURCEFILES += ieee-addr.c ble-addr.c
# CPU-dependent source files
CONTIKI_CPU_SOURCEFILES += rtimer-arch.c clock-arch.c
CONTIKI_CPU_SOURCEFILES += watchdog-arch.c dbg-arch.c
CONTIKI_CPU_SOURCEFILES += uart0-arch.c slip-arch.c
CONTIKI_CPU_SOURCEFILES += gpio-hal-arch.c int-master-arch.c
CONTIKI_CPU_SOURCEFILES += random.c trng-arch.c
# RF source files
CONTIKI_CPU_SOURCEFILES += sched.c data-queue.c
CONTIKI_CPU_SOURCEFILES += ieee-addr.c ble-addr.c
CONTIKI_CPU_SOURCEFILES += ble-beacond.c
ifeq ($(SUPPORTS_PROP_MODE),1)
@ -83,33 +91,43 @@ ifeq ($(SUPPORTS_BLE_BEACON),1)
CONTIKI_CPU_SOURCEFILES += ble-settings.c ble-tx-power.c
endif
### CPU-dependent debug source files
################################################################################
### Modules and paths
# CPU-dependent debug source files
MODULES += os/lib/dbg-io
### CPU-dependent directories
# CPU-dependent directories
CONTIKI_CPU_DIRS += . dev $(SUBFAMILY)
CONTIKI_CPU_DIRS += rf rf-settings rf-settings/$(DEVICE_FAMILY_LC)
CONTIKI_SOURCEFILES += $(CONTIKI_CPU_SOURCEFILES) $(DEBUG_IO_SOURCEFILES)
### Linker flag
################################################################################
### Linker configuration
# Linker flag
LDFLAGS += --entry resetISR
LDFLAGS += -static
LDFLAGS += --specs=nano.specs
LDSCRIPT := $(CONTIKI_CPU)/$(SUBFAMILY)/$(SUBFAMILY).lds
### Always re-build ieee-addr.o in case the command line passes a new NODEID
################################################################################
### Specialized build targets
# 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 $@
### Always re-build ccfg.c so changes to ccfg-conf.h will apply without having
### to make clean first
# 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)
$(Q)$(CC) $(CFLAGS) -include "ccfg-conf.h" -c $< -o $@
$(Q)$(CC) $(CFLAGS) -c $< -o $@
# Include the Sub-family specific Makefile
include $(CONTIKI_CPU)/$(SUBFAMILY)/Makefile.$(SUBFAMILY)

View File

@ -1,10 +1,11 @@
################################################################################
# CC13x0/CC26x0 CPU makefile
### CC13x0/CC26x0 CPU makefile
### Simplelink SDK pre-compiled libraries
TARGET_LIBFILES += $(SDK_KERNEL)/lib/nortos_$(SDK_LIB_NAME).am3g
# Simplelink SDK pre-compiled libraries
TARGET_LIBFILES += $(SDK_NORTOS)/lib/nortos_$(SDK_LIB_NAME).am3g
TARGET_LIBFILES += $(SDK_DRIVERS)/rf/lib/rf_multiMode_$(SDK_LIB_NAME).am3g
TARGET_LIBFILES += $(SDK_DRIVERS)/lib/drivers_$(SDK_LIB_NAME).am3g
TARGET_LIBFILES += $(SDK_DEVICE)/driverlib/bin/gcc/driverlib.lib
TARGET_LIBFILES += $(SDK_DEVICES)/driverlib/bin/gcc/driverlib.lib
# CC13x0/CC26x0 is a Cortex-M3 architecture
include $(CONTIKI)/arch/cpu/arm/cortex-m/cm3/Makefile.cm3

View File

@ -1,10 +1,11 @@
################################################################################
# CC13x2/CC26x2 CPU makefile
### CC13x2/CC26x2 CPU makefile
### Simplelink SDK pre-compiled libraries
TARGET_LIBFILES += $(SDK_KERNEL)/lib/nortos_$(SDK_LIB_NAME).am4fg
# Simplelink SDK pre-compiled libraries
TARGET_LIBFILES += $(SDK_NORTOS)/lib/nortos_$(SDK_LIB_NAME).am4fg
TARGET_LIBFILES += $(SDK_DRIVERS)/rf/lib/rf_multiMode_$(SDK_LIB_NAME).am4fg
TARGET_LIBFILES += $(SDK_DRIVERS)/lib/drivers_$(SDK_LIB_NAME).am4fg
TARGET_LIBFILES += $(SDK_DEVICE)/driverlib/bin/gcc/driverlib.lib
TARGET_LIBFILES += $(SDK_DEVICES)/driverlib/bin/gcc/driverlib.lib
# CC13x0/CC26x0 is a Cortex-M4 architecture
include $(CONTIKI)/arch/cpu/arm/cortex-m/cm4/Makefile.cm4

View File

@ -0,0 +1,50 @@
/*
* Copyright (c) 2018, Texas Instruments Incorporated - http://www.ti.com/
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. Neither the name of the copyright holder nor the names of its
* contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
* COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
* OF THE POSSIBILITY OF SUCH DAMAGE.
*/
/**
* \addtogroup cc13xx-cc26xx-cpu
* @{
*
* \file
* Customer Configuration (CCFG).
* \author
* Edvard Pettersen <e.pettersen@ti.com>
*/
/*---------------------------------------------------------------------------*/
/**
* Customer Configuration for CC13xx/CC26xx devices. This file is used to
* configure Boot ROM, start-up code, and SW radio behaviour.
*
* Configuration is done in ccfg-conf.h.
*/
#include "ccfg-conf.h"
#include <ti/devices/DeviceFamily.h>
#include DeviceFamily_constructPath(startup_files/ccfg.c)
/*---------------------------------------------------------------------------*/

View File

@ -13,28 +13,38 @@ ifndef BOARD
endif
################################################################################
### Defines
### Resolve the SimpleLink Family
SIMPLELINK_FAMILIES := cc13xx-cc26xx
# Given a SimpleLink family as argument, check if it has the Board file and if so return itself.
# Given a SimpleLink family as argument, check if it has the Board file.
# If so, return itself; else, return empty string.
verify_family = $(shell [ -d $(CONTIKI)/arch/platform/simplelink/$(1)/$(BOARD) ] && echo $(1))
# Test each supported SimpleLink family and see if it contains the specified Board.
# Throw an error if it isn't found.
FAMILY := $(firstword $(foreach FAMILY, $(SIMPLELINK_FAMILIES), $(call verify_family,$(FAMILY))))
FAMILY := $(foreach FAMILY, $(SIMPLELINK_FAMILIES), $(call verify_family,$(FAMILY)))
ifeq ($(FAMILY),)
$(error Board '$(BOARD)' does not corresponding to any SimpleLink family. Make sure your BOARD variable is correct.)
endif
# If multiple families are found, only the first one is chosen. If this every
# happens something is not correct.
ifneq ($(words $(FAMILY)),1)
FAMILY := $(firstword $(FAMILY))
$(warning Multiple SimpleLink families found to support '$(BOARD)'. Resolve to '$(FAMILY)'.)
endif
# Remove any excess whitespace.
FAMILY := $(strip $(FAMILY))
FAMILY_PATH := $(realpath $(CONTIKI)/arch/platform/simplelink/$(FAMILY))
CLEAN += *.simplelink
### Include the Simplelink Family specific Makefile
# Include the Simplelink Family specific Makefile
include $(FAMILY_PATH)/Makefile.$(FAMILY)
################################################################################
# Display all supported SimpleLink Families
### SimpleLink targets
simplelink_families:
@echo "$(SIMPLELINK_FAMILIES) (current: $(FAMILY))"

View File

@ -5,7 +5,7 @@
# Board and BSP selection
BOARD_PLATFORMS = launchpad sensortag srf06
# Assigned lazily to avoid breaking environments which doesn't have cd and find
# All supported boards for this SimpleLink family
BOARDS := $(foreach BOARD_TYPE, $(BOARD_PLATFORMS), \
$(shell cd $(FAMILY_PATH); find $(BOARD_TYPE)/* -type d -print))