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

Example for nRF5 platform #319

Merged
merged 12 commits into from
Apr 14, 2020
Merged
23 changes: 12 additions & 11 deletions build/nrf5/nrf5-chip.mk
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,6 @@ CHIP_CONFIGURE_OPTIONS = \
--with-lwip=internal \
--with-lwip-target=nrf5 \
--with-inet-endpoint="tcp udp" \
--with-openssl=no \
--with-logging-style=external \
--with-chip-project-includes=$(CHIP_PROJECT_CONFIG) \
--with-chip-system-project-includes=$(CHIP_PROJECT_CONFIG) \
Expand Down Expand Up @@ -135,19 +134,20 @@ STD_INC_DIRS += \
$(CHIP_ROOT)/src/include \
$(CHIP_ROOT)/third_party/lwip/repo/lwip/src/include \
$(CHIP_ROOT)/src/lwip \
$(CHIP_ROOT)/src/lwip/nrf5 \
$(CHIP_ROOT)/src/lwip/freertos
$(CHIP_ROOT)/src/lwip/nrf5 \
$(CHIP_ROOT)/src/lwip/freertos

# Add the location of CHIP libraries to application link action.
STD_LDFLAGS += -L$(CHIP_OUTPUT_DIR)/lib

# Add CHIP libraries to standard libraries list.
STD_LIBS += \
-lDeviceLayer \
-lInetLayer \
-lnlfaultinjection \
-lSystemLayer \
-llwip
-lCHIP \
-lInetLayer \
-lnlfaultinjection \
-lSystemLayer \
-llwip

# Add the appropriate CHIP target as a prerequisite to all application
# compilation targets to ensure that CHIP gets built and its header
Expand All @@ -157,10 +157,11 @@ STD_COMPILE_PREREQUISITES += install-chip
# Add the CHIP libraries as prerequisites for linking the application.
STD_LINK_PREREQUISITES += \
$(CHIP_OUTPUT_DIR)/lib/libDeviceLayer.a \
$(CHIP_OUTPUT_DIR)/lib/libInetLayer.a \
$(CHIP_OUTPUT_DIR)/lib/libnlfaultinjection.a \
$(CHIP_OUTPUT_DIR)/lib/libSystemLayer.a \
$(CHIP_OUTPUT_DIR)/lib/liblwip.a
$(CHIP_OUTPUT_DIR)/lib/libCHIP.a \
$(CHIP_OUTPUT_DIR)/lib/libInetLayer.a \
$(CHIP_OUTPUT_DIR)/lib/libnlfaultinjection.a \
$(CHIP_OUTPUT_DIR)/lib/libSystemLayer.a \
$(CHIP_OUTPUT_DIR)/lib/liblwip.a


# ==================================================
Expand Down
218 changes: 218 additions & 0 deletions examples/lock-app/nrf5/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,218 @@
#
#
# Copyright (c) 2020 Project CHIP Authors
# Copyright (c) 2019 Google LLC.
# All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#

#
# @file
# Makefile for building the CHIP nRF52840 Lock Example Application.
#

PROJECT_ROOT := $(realpath .)

CHIP_ROOT ?= $(realpath $(PROJECT_ROOT)/third_party/connectedhomeip)
BUILD_SUPPORT_DIR = $(CHIP_ROOT)/build/nrf5

include $(BUILD_SUPPORT_DIR)/nrf5-app.mk
include $(BUILD_SUPPORT_DIR)/nrf5-chip.mk

APP = chip-nrf52840-lock-example

SRCS = \
$(PROJECT_ROOT)/main/main.cpp \
$(PROJECT_ROOT)/main/AppTask.cpp \
$(PROJECT_ROOT)/main/LEDWidget.cpp \
$(PROJECT_ROOT)/main/BoltLockManager.cpp \
$(PROJECT_ROOT)/main/support/CXXExceptionStubs.cpp \
$(PROJECT_ROOT)/main/support/nRF5Sbrk.c \
$(PROJECT_ROOT)/main/support/FreeRTOSNewlibLockSupport.c \
$(NRF5_SDK_ROOT)/components/ble/common/ble_advdata.c \
$(NRF5_SDK_ROOT)/components/ble/common/ble_srv_common.c \
$(NRF5_SDK_ROOT)/components/ble/nrf_ble_gatt/nrf_ble_gatt.c \
$(NRF5_SDK_ROOT)/components/boards/boards.c \
$(NRF5_SDK_ROOT)/components/libraries/atomic/nrf_atomic.c \
$(NRF5_SDK_ROOT)/components/libraries/atomic_fifo/nrf_atfifo.c \
$(NRF5_SDK_ROOT)/components/libraries/balloc/nrf_balloc.c \
$(NRF5_SDK_ROOT)/components/libraries/button/app_button.c \
$(NRF5_SDK_ROOT)/components/libraries/crc16/crc16.c \
$(NRF5_SDK_ROOT)/components/libraries/experimental_section_vars/nrf_section_iter.c \
$(NRF5_SDK_ROOT)/components/libraries/fds/fds.c \
$(NRF5_SDK_ROOT)/components/libraries/fstorage/nrf_fstorage.c \
$(NRF5_SDK_ROOT)/components/libraries/fstorage/nrf_fstorage_sd.c \
$(NRF5_SDK_ROOT)/components/libraries/log/src/nrf_log_backend_rtt.c \
$(NRF5_SDK_ROOT)/components/libraries/log/src/nrf_log_backend_serial.c \
$(NRF5_SDK_ROOT)/components/libraries/log/src/nrf_log_default_backends.c \
$(NRF5_SDK_ROOT)/components/libraries/log/src/nrf_log_frontend.c \
$(NRF5_SDK_ROOT)/components/libraries/log/src/nrf_log_str_formatter.c \
$(NRF5_SDK_ROOT)/components/libraries/mem_manager/mem_manager.c \
$(NRF5_SDK_ROOT)/components/libraries/memobj/nrf_memobj.c \
$(NRF5_SDK_ROOT)/components/libraries/queue/nrf_queue.c \
$(NRF5_SDK_ROOT)/components/libraries/ringbuf/nrf_ringbuf.c \
$(NRF5_SDK_ROOT)/components/libraries/strerror/nrf_strerror.c \
$(NRF5_SDK_ROOT)/components/libraries/timer/app_timer_freertos.c \
$(NRF5_SDK_ROOT)/components/libraries/uart/retarget.c \
$(NRF5_SDK_ROOT)/components/libraries/util/app_error.c \
$(NRF5_SDK_ROOT)/components/libraries/util/app_error_handler_gcc.c \
$(NRF5_SDK_ROOT)/components/libraries/util/app_error_weak.c \
$(NRF5_SDK_ROOT)/components/libraries/util/app_util_platform.c \
$(NRF5_SDK_ROOT)/components/libraries/util/nrf_assert.c \
$(NRF5_SDK_ROOT)/components/softdevice/common/nrf_sdh.c \
$(NRF5_SDK_ROOT)/components/softdevice/common/nrf_sdh_ble.c \
$(NRF5_SDK_ROOT)/components/softdevice/common/nrf_sdh_soc.c \
$(NRF5_SDK_ROOT)/external/fprintf/nrf_fprintf.c \
$(NRF5_SDK_ROOT)/external/fprintf/nrf_fprintf_format.c \
$(NRF5_SDK_ROOT)/external/freertos/portable/CMSIS/nrf52/port_cmsis.c \
$(NRF5_SDK_ROOT)/external/freertos/portable/CMSIS/nrf52/port_cmsis_systick.c \
$(NRF5_SDK_ROOT)/external/freertos/portable/GCC/nrf52/port.c \
$(NRF5_SDK_ROOT)/external/freertos/source/croutine.c \
$(NRF5_SDK_ROOT)/external/freertos/source/event_groups.c \
$(NRF5_SDK_ROOT)/external/freertos/source/list.c \
$(NRF5_SDK_ROOT)/external/freertos/source/portable/MemMang/heap_3.c \
$(NRF5_SDK_ROOT)/external/freertos/source/queue.c \
$(NRF5_SDK_ROOT)/external/freertos/source/stream_buffer.c \
$(NRF5_SDK_ROOT)/external/freertos/source/tasks.c \
$(NRF5_SDK_ROOT)/external/freertos/source/timers.c \
$(NRF5_SDK_ROOT)/external/segger_rtt/SEGGER_RTT.c \
$(NRF5_SDK_ROOT)/external/segger_rtt/SEGGER_RTT_printf.c \
$(NRF5_SDK_ROOT)/external/segger_rtt/SEGGER_RTT_Syscalls_GCC.c \
$(NRF5_SDK_ROOT)/integration/nrfx/legacy/nrf_drv_clock.c \
$(NRF5_SDK_ROOT)/integration/nrfx/legacy/nrf_drv_rng.c \
$(NRF5_SDK_ROOT)/modules/nrfx/drivers/src/nrfx_clock.c \
$(NRF5_SDK_ROOT)/modules/nrfx/drivers/src/nrfx_gpiote.c \
$(NRF5_SDK_ROOT)/modules/nrfx/drivers/src/nrfx_uart.c \
$(NRF5_SDK_ROOT)/modules/nrfx/drivers/src/nrfx_uarte.c \
$(NRF5_SDK_ROOT)/modules/nrfx/drivers/src/prs/nrfx_prs.c \
$(NRF5_SDK_ROOT)/modules/nrfx/mdk/gcc_startup_nrf52840.S \
$(NRF5_SDK_ROOT)/modules/nrfx/mdk/system_nrf52840.c

INC_DIRS = \
$(PROJECT_ROOT) \
$(PROJECT_ROOT)/main \
$(PROJECT_ROOT)/main/include \
$(PROJECT_ROOT)/main/traits/include \
$(PROJECT_ROOT)/main/schema/include \
$(PROJECT_ROOT)/third_party/printf \
$(CHIP_ROOT)/src/include/ \
$(CHIP_ROOT)/src/lib \
$(CHIP_ROOT)/src/ \
$(CHIP_ROOT)/src/system \
$(NRF5_SDK_ROOT)/components \
$(NRF5_SDK_ROOT)/components/boards \
$(NRF5_SDK_ROOT)/components/ble/ble_advertising \
$(NRF5_SDK_ROOT)/components/ble/common \
$(NRF5_SDK_ROOT)/components/ble/nrf_ble_gatt \
$(NRF5_SDK_ROOT)/components/libraries/atomic \
$(NRF5_SDK_ROOT)/components/libraries/atomic_fifo \
$(NRF5_SDK_ROOT)/components/libraries/balloc \
$(NRF5_SDK_ROOT)/components/libraries/bsp \
$(NRF5_SDK_ROOT)/components/libraries/button \
$(NRF5_SDK_ROOT)/components/libraries/crc16 \
$(NRF5_SDK_ROOT)/components/libraries/delay \
$(NRF5_SDK_ROOT)/components/libraries/experimental_section_vars \
$(NRF5_SDK_ROOT)/components/libraries/fds \
$(NRF5_SDK_ROOT)/components/libraries/fstorage \
$(NRF5_SDK_ROOT)/components/libraries/log \
$(NRF5_SDK_ROOT)/components/libraries/log/src \
$(NRF5_SDK_ROOT)/components/libraries/memobj \
$(NRF5_SDK_ROOT)/components/libraries/mem_manager \
$(NRF5_SDK_ROOT)/components/libraries/mutex \
$(NRF5_SDK_ROOT)/components/libraries/queue \
$(NRF5_SDK_ROOT)/components/libraries/ringbuf \
$(NRF5_SDK_ROOT)/components/libraries/stack_info \
$(NRF5_SDK_ROOT)/components/libraries/strerror \
$(NRF5_SDK_ROOT)/components/libraries/timer \
$(NRF5_SDK_ROOT)/components/libraries/util \
$(NRF5_SDK_ROOT)/components/softdevice/common \
$(NRF5_SDK_ROOT)/components/softdevice/s140/headers \
$(NRF5_SDK_ROOT)/components/softdevice/s140/headers/nrf52 \
$(NRF5_SDK_ROOT)/components/softdevice/mbr/nrf52840/headers \
$(NRF5_SDK_ROOT)/components/thread/freertos_mbedtls_mutex \
$(NRF5_SDK_ROOT)/components/toolchain/cmsis/include \
$(NRF5_SDK_ROOT)/config/nrf52840/config \
$(NRF5_SDK_ROOT)/external/fprintf \
$(NRF5_SDK_ROOT)/external/freertos/config \
$(NRF5_SDK_ROOT)/external/freertos/portable/CMSIS/nrf52 \
$(NRF5_SDK_ROOT)/external/freertos/portable/GCC/nrf52 \
$(NRF5_SDK_ROOT)/external/freertos/source/include \
$(NRF5_SDK_ROOT)/external/mbedtls/include \
$(NRF5_SDK_ROOT)/external/segger_rtt \
$(NRF5_SDK_ROOT)/integration/nrfx \
$(NRF5_SDK_ROOT)/integration/nrfx/legacy \
$(NRF5_SDK_ROOT)/modules/nrfx \
$(NRF5_SDK_ROOT)/modules/nrfx/drivers/include \
$(NRF5_SDK_ROOT)/modules/nrfx/hal \
$(NRF5_SDK_ROOT)/modules/nrfx/mdk

DEFINES = \
NRF52840_XXAA \
BOARD_PCA10056 \
BSP_DEFINES_ONLY \
CONFIG_GPIO_AS_PINRESET \
FLOAT_ABI_HARD \
USE_APP_CONFIG \
__HEAP_SIZE=40960 \
__STACK_SIZE=8192 \
SOFTDEVICE_PRESENT \
PRINTF_DISABLE_SUPPORT_EXPONENTIAL \
S140

CFLAGS = \
--specs=nano.specs

LDFLAGS = \
--specs=nano.specs

ifdef DEVICE_FIRMWARE_REVISION
DEFINES += \
CHIP_DEVICE_CONFIG_DEVICE_FIRMWARE_REVISION=\"$(DEVICE_FIRMWARE_REVISION)\"
endif

# A product's firmware usually comes with two build "flavors":
# 1) a "development" build which typically enables debugging artifacts along with logging,
# and disables security and optimizations and
# 2) a "release" build which targets end-user devices
# and disables debugging artifacts and logging, and enables security and optimizations.
#
# To facilitate supporting these two build flavors, the sample app source code supports
# the build configuration option BUILD_RELEASE. By default, BUILD_RELEASE is not defined
# and a development build is produced. If make is invoked with BUILD_RELEASE=1, then
# a "pseudo-release" build is produced.
#
# We say "pseudo-release" build because the sample app is never to be used as-is
# as the firmware for an end-user device. However, since real products may start off with
# the sample app source code, we show how the BUILD_RELEASE build configuration option
# can be used to produce two build flavors (development and release) of the firmware.
#
# IMPORTANT: By no means does the use of BUILD_RELEASE in the sample app cover all key aspects that
# one should be concerned with (e.g. security, performance) when targeting real world end-user
# devices. This is simply provided for guidance on how to support two build flavors.

ifdef BUILD_RELEASE
DEFINES += BUILD_RELEASE=1
# Disable Thread logging.
CHIP_DEFINES += CHIP_CONFIG_LOG_LEVEL=OT_LOG_LEVEL_NONE
else
DEFINES += BUILD_RELEASE=0
# Increase Tread logging level to INFO.
CHIP_DEFINES += CHIP_CONFIG_LOG_LEVEL=OT_LOG_LEVEL_INFO
endif

CHIP_PROJECT_CONFIG = $(PROJECT_ROOT)/main/include/CHIPProjectConfig.h

LINKER_SCRIPT = $(PROJECT_ROOT)/main/ldscripts/chip-nrf52840-lock-example.ld

$(call GenerateBuildRules)
Loading