Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[platforms] new platform Qorvo GP712. #1942

Merged
merged 15 commits into from Jul 11, 2017
Merged
14 changes: 11 additions & 3 deletions configure.ac
Expand Up @@ -1053,11 +1053,11 @@ AC_DEFINE_UNQUOTED([OPENTHREAD_ENABLE_BORDER_ROUTER],[${OPENTHREAD_ENABLE_BORDER

AC_ARG_WITH(examples,
[AS_HELP_STRING([--with-examples=TARGET],
[Specify the examples from one of: none, posix, cc2538, cc2650, da15000, efr32, emsk, kw41z, nrf52840 @<:@default=none@:>@.])],
[Specify the examples from one of: none, posix, cc2538, cc2650, da15000, efr32, emsk, gp712, kw41z, nrf52840 @<:@default=none@:>@.])],
[
case "${with_examples}" in

none|posix|cc2538|cc2650|da15000|efr32|emsk|kw41z|nrf52840)
none|posix|cc2538|cc2650|da15000|efr32|emsk|gp712|kw41z|nrf52840)
;;
*)
AC_MSG_ERROR([Invalid value ${with_examples} for --with-examples])
Expand Down Expand Up @@ -1100,6 +1100,11 @@ case ${with_examples} in
AC_DEFINE_UNQUOTED([OPENTHREAD_EXAMPLES_EMSK],[${OPENTHREAD_EXAMPLES_EMSK}],[Define to 1 if you want to use emsk examples])
;;

gp712)
OPENTHREAD_EXAMPLES_GP712=1
AC_DEFINE_UNQUOTED([OPENTHREAD_EXAMPLES_GP712],[${OPENTHREAD_EXAMPLES_GP712}],[Define to 1 if you want to use gp712 examples])
;;

kw41z)
OPENTHREAD_EXAMPLES_KW41Z=1
AC_DEFINE_UNQUOTED([OPENTHREAD_EXAMPLES_KW41Z],[${OPENTHREAD_EXAMPLES_KW41Z}],[Define to 1 if you want to use kw41z examples])
Expand All @@ -1109,7 +1114,6 @@ case ${with_examples} in
OPENTHREAD_EXAMPLES_NRF52840=1
AC_DEFINE_UNQUOTED([OPENTHREAD_EXAMPLES_NRF52840],[${OPENTHREAD_EXAMPLES_NRF52840}],[Define to 1 if you want to use nrf52840 examples])
;;

esac

AC_MSG_CHECKING([whether to enable examples])
Expand Down Expand Up @@ -1137,6 +1141,9 @@ AM_CONDITIONAL([OPENTHREAD_EXAMPLES_EFR32], [test "${OPENTHREAD_EXAMPLES}" = "ef
AC_SUBST(OPENTHREAD_EXAMPLES_EMSK)
AM_CONDITIONAL([OPENTHREAD_EXAMPLES_EMSK], [test "${OPENTHREAD_EXAMPLES}" = "emsk"])

AC_SUBST(OPENTHREAD_EXAMPLES_GP712)
AM_CONDITIONAL([OPENTHREAD_EXAMPLES_GP712], [test "${OPENTHREAD_EXAMPLES}" = "gp712"])

AC_SUBST(OPENTHREAD_EXAMPLES_KW41Z)
AM_CONDITIONAL([OPENTHREAD_EXAMPLES_KW41Z], [test "${OPENTHREAD_EXAMPLES}" = "kw41z"])

Expand Down Expand Up @@ -1304,6 +1311,7 @@ examples/platforms/cc2650/Makefile
examples/platforms/da15000/Makefile
examples/platforms/efr32/Makefile
examples/platforms/emsk/Makefile
examples/platforms/gp712/Makefile
examples/platforms/kw41z/Makefile
examples/platforms/nrf52840/Makefile
examples/platforms/posix/Makefile
Expand Down
274 changes: 274 additions & 0 deletions examples/Makefile-gp712
@@ -0,0 +1,274 @@
#
# Copyright (c) 2017, The OpenThread Authors.
# 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.
#

.NOTPARALLEL:

TARGET = arm-bcm2708hardfp-linux-gnueabi
PPREFIX = gp712
INFO = GP712
#CROSS_COMPILE = $(TARGET)-

AR = $(CROSS_COMPILE)ar
AS = $(CROSS_COMPILE)as
CPP = $(CROSS_COMPILE)cpp
CC = $(CROSS_COMPILE)gcc
CXX = $(CROSS_COMPILE)g++
LD = $(CROSS_COMPILE)ld
STRIP = $(CROSS_COMPILE)strip
NM = $(CROSS_COMPILE)nm
RANLIB = $(CROSS_COMPILE)ranlib
OBJCOPY = $(CROSS_COMPILE)objcopy

BuildJobs ?= 9

configure_OPTIONS = \
--enable-cli-app=ftd \
--enable-diag \
--with-examples=$(PPREFIX) \
--with-platform-info=$(INFO) \
$(NULL)

DEFAULT_LOGGING ?= 1
include $(dir $(abspath $(lastword $(MAKEFILE_LIST))))/common-switches.mk

ifeq ($(CLI_LOGGING),1)
configure_OPTIONS += --enable-cli-logging
endif

GP712_CONFIG_FILE_CPPFLAGS = -DOPENTHREAD_PROJECT_CORE_CONFIG_FILE='\"openthread-core-gp712-config.h\"'
GP712_CONFIG_FILE_CPPFLAGS += -I$(PWD)/examples/platforms/gp712/

COMMONCFLAGS := \
-fdata-sections \
-ffunction-sections \
-Os \
-g \
$(GP712_CONFIG_FILE_CPPFLAGS) \
-W \
-Wall \
$(NULL)

CPPFLAGS += \
$(COMMONCFLAGS) \
$(target_CPPFLAGS) \
$(NULL)

CFLAGS += \
$(COMMONCFLAGS) \
$(target_CFLAGS) \
$(NULL)

CXXFLAGS += \
$(COMMONCFLAGS) \
$(target_CXXFLAGS) \
-fno-exceptions \
-fno-rtti \
$(NULL)

LDFLAGS += \
$(COMMONCFLAGS) \
$(target_LDFLAGS) \
-Wl,--gc-sections \
-Wl,-Map=map.map \
-lrt \
-lpthread \
$(NULL)


ECHO := @echo
MAKE := make
MKDIR_P := mkdir -p
LN_S := ln -s
RM_F := rm -f

INSTALL := /usr/bin/install
INSTALLFLAGS := -p

TopSourceDir := $(dir $(shell readlink $(firstword $(MAKEFILE_LIST))))..
AbsTopSourceDir := $(dir $(realpath $(firstword $(MAKEFILE_LIST))))..

BuildPath = build
TopBuildDir = $(BuildPath)
AbsTopBuildDir = $(PWD)/$(TopBuildDir)

ResultPath = output
TopResultDir = $(ResultPath)
AbsTopResultDir = $(PWD)/$(TopResultDir)

TargetTuple = $(PPREFIX)
ARCHS = $(PPREFIX)

TopTargetLibDir = $(TopResultDir)/$(if $(1),$(1)-,)$(TargetTuple)/lib

ifndef BuildJobs
BuildJobs := $(shell getconf _NPROCESSORS_ONLN)
endif
JOBSFLAG := -j$(BuildJobs)

PREFIX = $(PPREFIX)

#
# configure-arch <arch>
#
# Configure OpenThread for the specified architecture.
#
# arch - The architecture to configure.
#
define configure-arch
$(ECHO) " CONFIG $(1)-$(TargetTuple)..."
(cd $(BuildPath)/$(1)-$(TargetTuple) && $(AbsTopSourceDir)/configure \
INSTALL="$(INSTALL) $(INSTALLFLAGS)" \
CPP="$(CPP)" CC="$(CC)" CXX="$(CXX)" OBJC="$(OBJC)" OBJCXX="$(OBJCXX)" AR="$(AR)" RANLIB="$(RANLIB)" NM="$(NM)" STRIP="$(STRIP)" CPPFLAGS="$(CPPFLAGS)" CFLAGS="$(CFLAGS)" CXXFLAGS="$(CXXFLAGS)" LDFLAGS="$(LDFLAGS)" \
--prefix=/$(PREFIX) \
--host=$(TARGET) \
--target=$(TARGET) \
--exec-prefix=/$(PREFIX) \
--program-prefix=$(PREFIX)- \
$(configure_OPTIONS))
endef # configure-arch

#
# build-arch <arch>
#
# Build the OpenThread intermediate build products for the specified
# architecture.
#
# arch - The architecture to build.
#
define build-arch
$(ECHO) " BUILD $(1)-$(TargetTuple)"
$(MAKE) $(JOBSFLAG) -C $(BuildPath)/$(1)-$(TargetTuple) -w \
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The other examples Makefiles have $(BuildPath)/$(TargetTuple). Was having $(BuildPath)/$(1)-$(TargetTuple) a conscious decision?

all
endef # build-arch

#
# stage-arch <arch>
#
# Stage (install) the OpenThread final build products for the specified
# architecture.
#
# arch - The architecture to stage.
#
define stage-arch
$(ECHO) " STAGE $(1)-$(TargetTuple)"
$(MAKE) $(JOBSFLAG) -C $(BuildPath)/$(1)-$(TargetTuple) -w \
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See comment above.

DESTDIR=$(AbsTopResultDir) \
install
endef # stage-arch

#
# ARCH_template <arch>
#
# Define macros, targets and rules to configure, build, and stage the
# OpenThread for a single architecture.
#
# arch - The architecture to instantiate the template for.
#
define ARCH_template
CONFIGURE_TARGETS += configure-$(1)
BUILD_TARGETS += do-build-$(1)
STAGE_TARGETS += stage-$(1)
BUILD_DIRS += $(BuildPath)/$(1)-$(TargetTuple)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See comment above.

DIRECTORIES += $(BuildPath)/$(1)-$(TargetTuple)

configure-$(1): target_CPPFLAGS=$($(1)_target_CPPFLAGS)
configure-$(1): target_CFLAGS=$($(1)_target_CFLAGS)
configure-$(1): target_CXXFLAGS=$($(1)_target_CXXFLAGS)
configure-$(1): target_LDFLAGS=$($(1)_target_LDFLAGS)

configure-$(1): $(BuildPath)/$(1)-$(TargetTuple)/config.status

$(BuildPath)/$(1)-$(TargetTuple)/config.status: | $(BuildPath)/$(1)-$(TargetTuple)
$$(call configure-arch,$(1))

do-build-$(1): configure-$(1)

do-build-$(1):
+$$(call build-arch,$(1))

stage-$(1): do-build-$(1)

stage-$(1): | $(TopResultDir)
$$(call stage-arch,$(1))

$(1): stage-$(1)
endef # ARCH_template

.DEFAULT_GOAL := all

all: stage

#
# rpi_bcm2708
#

rpi_bcm2708_target_ABI = rpi_bcm2708
rpi_bcm2708_target_CPPFLAGS = -march=armv6j -fomit-frame-pointer -fno-strict-aliasing -fno-pic -ffreestanding -mfloat-abi=hard -mfpu=vfp -pipe
rpi_bcm2708_target_CFLAGS = -march=armv6j -fomit-frame-pointer -fno-strict-aliasing -fno-pic -ffreestanding -mfloat-abi=hard -mfpu=vfp -pipe
rpi_bcm2708_target_CXXFLAGS = -march=armv6j -fomit-frame-pointer -fno-strict-aliasing -fno-pic -ffreestanding -mfloat-abi=hard -mfpu=vfp -pipe
rpi_bcm2708_target_LDFLAGS = -march=armv6j -fomit-frame-pointer -fno-strict-aliasing -fno-pic -ffreestanding -mfloat-abi=hard -mfpu=vfp -pipe

# Instantiate an architecture-specific build template for each target
# architecture.

$(foreach arch,$(ARCHS),$(eval $(call ARCH_template,$(arch))))

#
# Common / Finalization
#

configure: $(CONFIGURE_TARGETS)

build: $(BUILD_TARGETS)

stage: $(STAGE_TARGETS)

DIRECTORIES = $(TopResultDir) $(TopResultDir)/$(TargetTuple)/lib $(BUILD_DIRS)

CLEAN_DIRS = $(TopResultDir) $(BUILD_DIRS)

all: stage

$(DIRECTORIES):
$(ECHO) " MKDIR $@"
@$(MKDIR_P) "$@"

clean:
$(ECHO) " CLEAN"
@$(RM_F) -r $(CLEAN_DIRS)

help:
$(ECHO) "Simply type 'make -f $(firstword $(MAKEFILE_LIST))' to build OpenThread for the following "
$(ECHO) "architectures: "
$(ECHO) ""
$(ECHO) " $(ARCHS)"
$(ECHO) ""
$(ECHO) "To build only a particular architecture, specify: "
$(ECHO) ""
$(ECHO) " make -f $(firstword $(MAKEFILE_LIST)) <architecture>"
$(ECHO) ""
8 changes: 8 additions & 0 deletions examples/apps/cli/Makefile.am
Expand Up @@ -123,6 +123,14 @@ LDFLAGS_COMMON += \
$(NULL)
endif # OPENTHREAD_EXAMPLES_EMSK

if OPENTHREAD_EXAMPLES_GP712
LDADD_COMMON += \
$(top_builddir)/examples/platforms/gp712/libopenthread-gp712.a \
$(top_srcdir)/third_party/Qorvo/gp712/libQorvoRPi.a \
$(NULL)

endif # OPENTHREAD_EXAMPLES_GP712

if OPENTHREAD_EXAMPLES_NRF52840
LDADD_COMMON += \
$(top_builddir)/examples/platforms/nrf52840/libopenthread-nrf52840.a \
Expand Down
6 changes: 6 additions & 0 deletions examples/platforms/Makefile.am
Expand Up @@ -36,6 +36,7 @@ DIST_SUBDIRS = \
da15000 \
efr32 \
emsk \
gp712 \
kw41z \
nrf52840 \
posix \
Expand Down Expand Up @@ -68,6 +69,10 @@ if OPENTHREAD_EXAMPLES_EMSK
SUBDIRS += emsk
endif

if OPENTHREAD_EXAMPLES_GP712
SUBDIRS += gp712
endif

if OPENTHREAD_EXAMPLES_KW41Z
SUBDIRS += kw41z
endif
Expand All @@ -88,6 +93,7 @@ PRETTY_SUBDIRS = \
da15000 \
efr32 \
emsk \
gp712 \
kw41z \
nrf52840 \
posix \
Expand Down