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

Support building DeviceLayer library for EFR32 #125

Merged
merged 3 commits into from
Mar 26, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions Makefile-Standalone
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ else
configure_OPTIONS +=
endif

# If the user has woble over bluez peripheral, alter the configuration options
# If the user has chipoble over bluez peripheral, alter the configuration options
Copy link
Contributor

Choose a reason for hiding this comment

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

Should probably be CHIPoBLE for consistency elsewhere.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I was trying to stick to the case format from the original instances. As you'll see elsewhere, it follows woble. "woble" -> "chipoble", "WoBle" -> "CHIPoBLE" and so on.
Should I not do that?

Copy link
Contributor

Choose a reason for hiding this comment

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

Probably fine for now to stick with what was there. It's a low priority clean-up to make it consistent—at least in comments—later.

# accordingly.
ifeq ($(BLUEZ),1)
configure_OPTIONS += --enable-experimental --enable-deprecated --enable-testing --enable-tools --disable-systemd --enable-debug
Expand All @@ -211,8 +211,8 @@ ifeq ($(LONG_TESTS),1)
configure_OPTIONS += --enable-long-tests=yes
endif

ifeq ($(ENABLE_WOBLE_TEST),1)
configure_OPTIONS += --enable-woble-test=yes
ifeq ($(ENABLE_CHIPOBLE_TEST),1)
configure_OPTIONS += --enable-chipoble-test=yes
endif

ifndef BuildJobs
Expand Down
39 changes: 2 additions & 37 deletions build/efr32/efr32-app.mk
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
# limitations under the License.
#

#
#
# @file
# Common makefile definitions for building applications based
# on the Silicon Labs EFR32 SDK.
Expand Down Expand Up @@ -74,9 +74,6 @@ endif
ifndef FREERTOS_ROOT
$(error ENVIRONMENT ERROR: FREERTOS_ROOT not set)
endif
ifndef OPENTHREAD_ROOT
$(error ENVIRONMENT ERROR: OPENTHREAD_ROOT not set)
endif



Expand Down Expand Up @@ -121,16 +118,6 @@ EXTRA_SRCS += \
$(EFR32_SDK_ROOT)/platform/emdrv/nvm3/src/nvm3_default.c \
$(EFR32_SDK_ROOT)/platform/emdrv/nvm3/src/nvm3_hal_flash.c \
$(EFR32_SDK_ROOT)/platform/emdrv/sleep/src/sleep.c \
$(EFR32_SDK_ROOT)/util/third_party/mbedtls/library/ecp.c \
$(EFR32_SDK_ROOT)/util/third_party/mbedtls/library/ecdh.c \
$(EFR32_SDK_ROOT)/util/third_party/mbedtls/library/sha1.c \
$(EFR32_SDK_ROOT)/util/third_party/mbedtls/library/sha256.c \
$(EFR32_SDK_ROOT)/util/third_party/mbedtls/sl_crypto/src/crypto_aes.c \
$(EFR32_SDK_ROOT)/util/third_party/mbedtls/sl_crypto/src/crypto_ble.c \
$(EFR32_SDK_ROOT)/util/third_party/mbedtls/sl_crypto/src/crypto_ecp.c \
$(EFR32_SDK_ROOT)/util/third_party/mbedtls/sl_crypto/src/crypto_sha.c \
$(EFR32_SDK_ROOT)/util/third_party/mbedtls/sl_crypto/src/shax.c \
$(EFR32_SDK_ROOT)/util/third_party/mbedtls/sl_crypto/src/crypto_management.c

STD_INC_DIRS += \
$(CHIP_ROOT)/src/include/platform/EFR32 \
Expand Down Expand Up @@ -178,9 +165,6 @@ STD_INC_DIRS += \
$(OPENTHREAD_ROOT)/examples/platforms/$(EFR32FAMILY)/crypto

ifeq ($(EFR32FAMILY), efr32mg12)
EXTRA_SRCS += \
$(EFR32_SDK_ROOT)/util/third_party/mbedtls/sl_crypto/src/trng.c

STD_INC_DIRS += \
$(EFR32_SDK_ROOT)/hardware/kit/EFR32MG12_$(BOARD)/config \
$(EFR32_SDK_ROOT)/platform/Device/SiliconLabs/EFR32MG12P/Include \
Expand Down Expand Up @@ -259,8 +243,6 @@ STD_LDFLAGS = \
-ffunction-sections \
-Wl,--gc-sections \
-specs=nosys.specs \
$(foreach dir,$(LINKER_SCRIPT_INC_DIRS),-L$(dir)) \
-T$(LINKER_SCRIPT)

ifeq ($(EFR32FAMILY), efr32mg21)
STD_LDFLAGS += \
Expand All @@ -270,7 +252,6 @@ endif
STD_LIBS = \
-lc \
-lstdc++ \
-lfreertos \
-lnosys \
-lm

Expand All @@ -292,29 +273,13 @@ endif
STD_DEFINES = \
__STARTUP_CLEAR_BSS \
$(MCU)

STD_COMPILE_PREREQUISITES =

STD_LINK_PREREQUISITES += $(OUTPUT_DIR)/freertos/libfreertos.a
STD_COMPILE_PREREQUISITES =

DEFINE_FLAGS = $(foreach def,$(STD_DEFINES) $(DEFINES),-D$(def))

INC_FLAGS = $(foreach dir,$(INC_DIRS) $(STD_INC_DIRS),-I$(dir))


# Default EFR32 linker script defines a section at top of Flash for NVM3 support.
ifeq ($(EFR32FAMILY), efr32mg12)
ifndef LINKER_SCRIPT
LINKER_SCRIPT = $(APP)-MG12P.ld
endif
else
ifeq ($(EFR32FAMILY), efr32mg21)
ifndef LINKER_SCRIPT
LINKER_SCRIPT = $(APP)-MG21.ld
endif
endif
endif

LINKER_SCRIPT_INC_DIRS = $(PROJECT_ROOT) $(OUTPUT_DIR)/freertos

# ==================================================
Expand Down
8 changes: 1 addition & 7 deletions build/efr32/efr32-chip.mk
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ CHIP_HOST_ARCH := armv7-unknown-linux-gnu
CHIP_OUTPUT_DIR = $(OUTPUT_DIR)/chip

# An optional file containing application-specific configuration overrides.
CHIP_PROJECT_CONFIG = $(wildcard $(PROJECT_ROOT)/CHIPProjectConfig.h)
CHIP_PROJECT_CONFIG = $(wildcard $(PROJECT_ROOT)/include/CHIPProjectConfig.h)

# Architcture on which CHIP is being built.
CHIP_BUILD_ARCH = $(shell $(CHIP_ROOT)/third_party/nlbuild-autotools/repo/third_party/autoconf/config.guess | sed -e 's/[[:digit:].]*$$//g')
Expand Down Expand Up @@ -154,12 +154,9 @@ STD_LDFLAGS += -L$(CHIP_OUTPUT_DIR)/lib
STD_LIBS += \
-lDeviceLayer \
-lchip \
-lWarm \
-lInetLayer \
-lmincrypt \
-lnlfaultinjection \
-lSystemLayer \
-luECC \
-llwip

# Add the appropriate CHIP target as a prerequisite to all application
Expand All @@ -171,12 +168,9 @@ STD_COMPILE_PREREQUISITES += install-chip
STD_LINK_PREREQUISITES += \
$(CHIP_OUTPUT_DIR)/lib/libDeviceLayer.a \
$(CHIP_OUTPUT_DIR)/lib/libchip.a \
$(CHIP_OUTPUT_DIR)/lib/libWarm.a \
$(CHIP_OUTPUT_DIR)/lib/libInetLayer.a \
$(CHIP_OUTPUT_DIR)/lib/libmincrypt.a \
$(CHIP_OUTPUT_DIR)/lib/libnlfaultinjection.a \
$(CHIP_OUTPUT_DIR)/lib/libSystemLayer.a \
$(CHIP_OUTPUT_DIR)/lib/libuECC.a \
$(CHIP_OUTPUT_DIR)/lib/liblwip.a


Expand Down
2 changes: 1 addition & 1 deletion configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -825,7 +825,7 @@ if test "${enable_chipoble_test}" = "yes"; then
else
CHIP_ENABLE_BTP_CODEC_TEST=0
fi
AC_DEFINE_UNQUOTED([CHIP_ENABLE_BTP_CODEC_TEST],[${CHIP_ENABLE_BTP_CODEC_TEST}],[Define to 1 if you want to enable WoBle Control Path and Throughput Test.])
AC_DEFINE_UNQUOTED([CHIP_ENABLE_BTP_CODEC_TEST],[${CHIP_ENABLE_BTP_CODEC_TEST}],[Define to 1 if you want to enable CHIPoBle Control Path and Throughput Test.])
Copy link
Contributor

Choose a reason for hiding this comment

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

See comment above "CHIPoBLE" vs. "chipoble" vs. "CHIPoBle".

#
# Documentation
#
Expand Down
2 changes: 2 additions & 0 deletions src/include/platform/CHIPDeviceConfig.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@
#ifndef CHIP_DEVICE_CONFIG_H
#define CHIP_DEVICE_CONFIG_H

#include <core/CHIPConfig.h>

/* Include a project-specific configuration file, if defined.
*
* An application or module that incorporates the chip Device Layer can define a project
Expand Down
2 changes: 1 addition & 1 deletion src/include/platform/ConfigurationManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ class ConfigurationManager
friend CHIP_ERROR ::chip::Platform::PersistedStorage::Read(::chip::Platform::PersistedStorage::Key key, uint32_t & value);
friend CHIP_ERROR ::chip::Platform::PersistedStorage::Write(::chip::Platform::PersistedStorage::Key key, uint32_t value);

using ImplClass = ConfigurationManagerImpl;
using ImplClass = ::chip::DeviceLayer::ConfigurationManagerImpl;

CHIP_ERROR Init();
CHIP_ERROR ConfigureChipStack();
Expand Down
26 changes: 14 additions & 12 deletions src/include/platform/EFR32/BLEManagerImpl.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
#ifndef BLE_MANAGER_IMPL_H
#define BLE_MANAGER_IMPL_H

#if CHIP_DEVICE_CONFIG_ENABLE_WOBLE
#if CHIP_DEVICE_CONFIG_ENABLE_CHIPOBLE

#include "bg_types.h"
#include "rtos_gecko.h"
Expand All @@ -34,11 +34,13 @@ namespace chip {
namespace DeviceLayer {
namespace Internal {

using namespace chip::Ble;

/**
* Concrete implementation of the NetworkProvisioningServer singleton object for the EFR32 platforms.
*/
class BLEManagerImpl final : public BLEManager,
private ::chip::Ble::BleLayer,
private BleLayer,
private BlePlatformDelegate,
private BleApplicationDelegate
{
Expand All @@ -49,8 +51,8 @@ class BLEManagerImpl final : public BLEManager,
// ===== Members that implement the BLEManager internal interface.

CHIP_ERROR _Init(void);
WoBLEServiceMode _GetWoBLEServiceMode(void);
CHIP_ERROR _SetWoBLEServiceMode(WoBLEServiceMode val);
CHIPoBLEServiceMode _GetCHIPoBLEServiceMode(void);
CHIP_ERROR _SetCHIPoBLEServiceMode(CHIPoBLEServiceMode val);
bool _IsAdvertisingEnabled(void);
CHIP_ERROR _SetAdvertisingEnabled(bool val);
bool _IsFastAdvertisingEnabled(void);
Expand All @@ -60,7 +62,7 @@ class BLEManagerImpl final : public BLEManager,
CHIP_ERROR _SetDeviceName(const char *deviceName);
uint16_t _NumConnections(void);
void _OnPlatformEvent(const ChipDeviceEvent *event);
::chip::Ble::BleLayer *_GetBleLayer(void) const;
BleLayer *_GetBleLayer(void) const;

// ===== Members that implement virtual methods on BlePlatformDelegate.

Expand Down Expand Up @@ -119,7 +121,7 @@ class BLEManagerImpl final : public BLEManager,
kUnusedIndex = 0xFF,
};

struct WoBLEConState
struct CHIPoBLEConState
{
bd_addr address;
uint16_t mtu : 10;
Expand All @@ -130,9 +132,9 @@ class BLEManagerImpl final : public BLEManager,
uint8_t bondingHandle;
};

WoBLEConState mBleConnections[kMaxConnections];
CHIPoBLEConState mBleConnections[kMaxConnections];
uint8_t mIndConfId[kMaxConnections];
WoBLEServiceMode mServiceMode;
CHIPoBLEServiceMode mServiceMode;
uint16_t mFlags;
char mDeviceName[kMaxDeviceNameLength + 1];

Expand All @@ -152,7 +154,7 @@ class BLEManagerImpl final : public BLEManager,
void HandleSoftTimerEvent(volatile struct gecko_cmd_packet *evt);
bool RemoveConnection(uint8_t connectionHandle);
void AddConnection(uint8_t connectionHandle, uint8_t bondingHandle);
WoBLEConState *GetConnectionState(uint8_t conId, bool allocate = false);
CHIPoBLEConState *GetConnectionState(uint8_t conId, bool allocate = false);
uint8_t GetTimerHandle(uint8_t connectionHandle, bool allocate = false);
static void DriveBLEState(intptr_t arg);
static void bluetoothStackEventHandler(void *p_arg);
Expand Down Expand Up @@ -180,12 +182,12 @@ inline BLEManagerImpl &BLEMgrImpl(void)
return BLEManagerImpl::sInstance;
}

inline ::chip::Ble::BleLayer *BLEManagerImpl::_GetBleLayer() const
inline BleLayer *BLEManagerImpl::_GetBleLayer() const
{
return (BleLayer *)(this);
}

inline BLEManager::WoBLEServiceMode BLEManagerImpl::_GetWoBLEServiceMode(void)
inline BLEManager::CHIPoBLEServiceMode BLEManagerImpl::_GetCHIPoBLEServiceMode(void)
{
return mServiceMode;
}
Expand All @@ -204,6 +206,6 @@ inline bool BLEManagerImpl::_IsFastAdvertisingEnabled(void)
} // namespace DeviceLayer
} // namespace chip

#endif // CHIP_DEVICE_CONFIG_ENABLE_WOBLE
#endif // CHIP_DEVICE_CONFIG_ENABLE_CHIPOBLE

#endif // BLE_MANAGER_IMPL_H
8 changes: 4 additions & 4 deletions src/include/platform/EFR32/CHIPDevicePlatformConfig.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,10 @@
#define CHIP_DEVICE_CONFIG_ENABLE_WIFI_STATION 0
#define CHIP_DEVICE_CONFIG_ENABLE_WIFI_AP 0

#define CHIP_DEVICE_CONFIG_ENABLE_THREAD 1
#define CHIP_DEVICE_CONFIG_ENABLE_WOBLE 1
#define CHIP_DEVICE_CONFIG_ENABLE_THREAD 0
#define CHIP_DEVICE_CONFIG_ENABLE_CHIPOBLE 1

#define CHIP_DEVICE_CONFIG_ENABLE_CHIP_TIME_SERVICE_TIME_SYNC 1
#define CHIP_DEVICE_CONFIG_ENABLE_CHIP_TIME_SERVICE_TIME_SYNC 0
#define CHIP_DEVICE_CONFIG_ENABLE_SERVICE_DIRECTORY_TIME_SYNC 0

#define CHIP_DEVICE_CONFIG_PERSISTED_STORAGE_CRIT_EIDC_KEY 2
Expand Down Expand Up @@ -122,7 +122,7 @@
#endif // CHIP_DEVICE_CONFIG_THREAD_TASK_STACK_SIZE

#define CHIP_DEVICE_CONFIG_ENABLE_WIFI_TELEMETRY 0
#define CHIP_DEVICE_CONFIG_ENABLE_THREAD_TELEMETRY 1
#define CHIP_DEVICE_CONFIG_ENABLE_THREAD_TELEMETRY 0
#define CHIP_DEVICE_CONFIG_ENABLE_THREAD_TELEMETRY_FULL 0
#define CHIP_DEVICE_CONFIG_ENABLE_TUNNEL_TELEMETRY 0

Expand Down
5 changes: 2 additions & 3 deletions src/include/platform/EFR32/ConfigurationManagerImpl.h
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,8 @@ class ConfigurationManagerImpl final : public ConfigurationManager,

CHIP_ERROR _Init(void);
CHIP_ERROR _GetPrimaryWiFiMACAddress(uint8_t *buf);
::chip::Profiles::Security::AppKeys::GroupKeyStoreBase *_GetGroupKeyStore(void);
bool _CanFactoryReset(void);
void _InitiateFactoryReset(void);
bool _CanFactoryReset(void);
void _InitiateFactoryReset(void);
CHIP_ERROR _ReadPersistedStorageValue(::chip::Platform::PersistedStorage::Key key, uint32_t &value);
CHIP_ERROR _WritePersistedStorageValue(::chip::Platform::PersistedStorage::Key key, uint32_t value);

Expand Down
4 changes: 2 additions & 2 deletions src/include/platform/EFR32/ConnectivityManagerImpl.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@

#include <platform/ConnectivityManager.h>
#include <platform/internal/GenericConnectivityManagerImpl.h>
#if CHIP_DEVICE_CONFIG_ENABLE_WOBLE
#if CHIP_DEVICE_CONFIG_ENABLE_CHIPOBLE
#include <platform/internal/GenericConnectivityManagerImpl_BLE.h>
#else
#include <platform/internal/GenericConnectivityManagerImpl_NoBLE.h>
Expand All @@ -46,7 +46,7 @@ namespace DeviceLayer {
*/
class ConnectivityManagerImpl final : public ConnectivityManager,
public Internal::GenericConnectivityManagerImpl<ConnectivityManagerImpl>,
#if CHIP_DEVICE_CONFIG_ENABLE_WOBLE
#if CHIP_DEVICE_CONFIG_ENABLE_CHIPOBLE
public Internal::GenericConnectivityManagerImpl_BLE<ConnectivityManagerImpl>,
#else
public Internal::GenericConnectivityManagerImpl_NoBLE<ConnectivityManagerImpl>,
Expand Down
2 changes: 1 addition & 1 deletion src/include/platform/EFR32/EFR32Config.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@

#include <functional>

#include <suport/internal/CHIPDeviceLayerInternal.h>
#include <platform/internal/CHIPDeviceLayerInternal.h>

#include "nvm3.h"
#include "nvm3_hal_flash.h"
Expand Down
2 changes: 1 addition & 1 deletion src/include/platform/EFR32/PlatformManagerImpl.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
#ifndef PLATFORM_MANAGER_IMPL_H
#define PLATFORM_MANAGER_IMPL_H

#include <platform/FreeRTOS/GenericPlatformManagerImpl_FreeRTOS.h>
#include <platform/internal/GenericPlatformManagerImpl_FreeRTOS.h>

namespace chip {
namespace DeviceLayer {
Expand Down
12 changes: 6 additions & 6 deletions src/include/platform/EFR32/gatt.xml
Original file line number Diff line number Diff line change
Expand Up @@ -76,19 +76,19 @@
</characteristic>
</service>

<!--WoBLE-->
<service advertise="false" name="WoBLE" requirement="mandatory" sourceId="custom.type" type="primary" uuid="feaf">
<!--CHIPoBLE-->
<service advertise="false" name="CHIPoBLE" requirement="mandatory" sourceId="custom.type" type="primary" uuid="feaf">
<informativeText>Custom service</informativeText>

<!--WoBLEChar_Rx-->
<characteristic id="WoBLEChar_Rx" name="WoBLEChar_Rx" sourceId="custom.type" uuid="18EE2EF5-263D-4559-959F-4F9C429F9D11">
<!--CHIPoBLEChar_Rx-->
<characteristic id="CHIPoBLEChar_Rx" name="CHIPoBLEChar_Rx" sourceId="custom.type" uuid="18EE2EF5-263D-4559-959F-4F9C429F9D11">
Copy link
Contributor

Choose a reason for hiding this comment

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

We should probably create a Github issue to create new, CHIP-specific UUIDs for the Rx/Tx characteristics. Otherwise, these will conflict with WoBLE and things may get confusing in the field.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'll file an issue for this. Thanks!

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is super important actually.

<informativeText>Custom characteristic</informativeText>
<value length="247" type="hex" variable_length="true">0x00</value>
<properties read="true" read_requirement="optional" write="true" write_requirement="optional"/>
</characteristic>

<!--WoBLEChar_Tx-->
<characteristic id="WoBLEChar_Tx" name="WoBLEChar_Tx" sourceId="custom.type" uuid="18EE2EF5-263D-4559-959F-4F9C429F9D12">
<!--CHIPoBLEChar_Tx-->
<characteristic id="CHIPoBLEChar_Tx" name="CHIPoBLEChar_Tx" sourceId="custom.type" uuid="18EE2EF5-263D-4559-959F-4F9C429F9D12">
<informativeText>Custom characteristic</informativeText>
<value length="247" type="hex" variable_length="true">0x00</value>
<properties indicate="true" indicate_requirement="optional" read="true" read_requirement="optional" write="true" write_no_response="true" write_no_response_requirement="optional" write_requirement="optional"/>
Expand Down
4 changes: 2 additions & 2 deletions src/include/platform/EFR32/gatt_db.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ extern const struct bg_gattdb_def bg_gattdb_data;
#define gattdb_client_support_features 8
#define gattdb_device_name 11
#define gattdb_ota_control 23
#define gattdb_WoBLEChar_Rx 26
#define gattdb_WoBLEChar_Tx 28
#define gattdb_CHIPoBLEChar_Rx 26
#define gattdb_CHIPoBLEChar_Tx 28

#if __cplusplus
}
Expand Down
2 changes: 1 addition & 1 deletion src/include/platform/internal/BLEManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ inline void BLEManager::OnPlatformEvent(const ChipDeviceEvent * event)
static_cast<ImplClass*>(this)->_OnPlatformEvent(event);
}

inline BleLayer * BLEManager::GetBleLayer(void) const
inline chip::Ble::BleLayer * BLEManager::GetBleLayer(void) const
{
return static_cast<const ImplClass*>(this)->_GetBleLayer();
}
Expand Down
Loading