From f0b4e25025807785b5226f91812f899339297216 Mon Sep 17 00:00:00 2001 From: Wootak Jung Date: Wed, 21 Jul 2021 13:48:38 +0900 Subject: [PATCH 01/14] Add Tizen OS chip platform The platform supports the following features: - Bluetooth - WiFi - Mdns - Key/Value store The integration with network is made with the Tizen API --- src/platform/Tizen/BLEManagerImpl.cpp | 137 ++++++++++++++ src/platform/Tizen/BLEManagerImpl.h | 140 ++++++++++++++ src/platform/Tizen/BUILD.gn | 70 +++++++ src/platform/Tizen/BlePlatformConfig.h | 31 +++ src/platform/Tizen/CHIPDevicePlatformConfig.h | 54 ++++++ src/platform/Tizen/CHIPDevicePlatformEvent.h | 63 +++++++ src/platform/Tizen/CHIPPlatformConfig.h | 107 +++++++++++ .../Tizen/ConfigurationManagerImpl.cpp | 81 ++++++++ src/platform/Tizen/ConfigurationManagerImpl.h | 94 ++++++++++ .../Tizen/ConnectivityManagerImpl.cpp | 149 +++++++++++++++ src/platform/Tizen/ConnectivityManagerImpl.h | 176 ++++++++++++++++++ .../DeviceNetworkProvisioningDelegateImpl.cpp | 32 ++++ .../DeviceNetworkProvisioningDelegateImpl.h | 43 +++++ src/platform/Tizen/InetPlatformConfig.h | 39 ++++ .../Tizen/KeyValueStoreManagerImpl.cpp | 50 +++++ src/platform/Tizen/KeyValueStoreManagerImpl.h | 73 ++++++++ src/platform/Tizen/Logging.cpp | 70 +++++++ src/platform/Tizen/MdnsImpl.cpp | 71 +++++++ src/platform/Tizen/PlatformManagerImpl.cpp | 53 ++++++ src/platform/Tizen/PlatformManagerImpl.h | 86 +++++++++ src/platform/Tizen/PosixConfig.cpp | 169 +++++++++++++++++ src/platform/Tizen/PosixConfig.h | 124 ++++++++++++ src/platform/Tizen/SystemPlatformConfig.h | 49 +++++ src/platform/Tizen/SystemTimeSupport.cpp | 69 +++++++ 24 files changed, 2030 insertions(+) create mode 100644 src/platform/Tizen/BLEManagerImpl.cpp create mode 100644 src/platform/Tizen/BLEManagerImpl.h create mode 100644 src/platform/Tizen/BUILD.gn create mode 100644 src/platform/Tizen/BlePlatformConfig.h create mode 100644 src/platform/Tizen/CHIPDevicePlatformConfig.h create mode 100644 src/platform/Tizen/CHIPDevicePlatformEvent.h create mode 100644 src/platform/Tizen/CHIPPlatformConfig.h create mode 100644 src/platform/Tizen/ConfigurationManagerImpl.cpp create mode 100644 src/platform/Tizen/ConfigurationManagerImpl.h create mode 100644 src/platform/Tizen/ConnectivityManagerImpl.cpp create mode 100644 src/platform/Tizen/ConnectivityManagerImpl.h create mode 100644 src/platform/Tizen/DeviceNetworkProvisioningDelegateImpl.cpp create mode 100644 src/platform/Tizen/DeviceNetworkProvisioningDelegateImpl.h create mode 100644 src/platform/Tizen/InetPlatformConfig.h create mode 100644 src/platform/Tizen/KeyValueStoreManagerImpl.cpp create mode 100644 src/platform/Tizen/KeyValueStoreManagerImpl.h create mode 100644 src/platform/Tizen/Logging.cpp create mode 100644 src/platform/Tizen/MdnsImpl.cpp create mode 100644 src/platform/Tizen/PlatformManagerImpl.cpp create mode 100644 src/platform/Tizen/PlatformManagerImpl.h create mode 100644 src/platform/Tizen/PosixConfig.cpp create mode 100644 src/platform/Tizen/PosixConfig.h create mode 100644 src/platform/Tizen/SystemPlatformConfig.h create mode 100644 src/platform/Tizen/SystemTimeSupport.cpp diff --git a/src/platform/Tizen/BLEManagerImpl.cpp b/src/platform/Tizen/BLEManagerImpl.cpp new file mode 100644 index 00000000000000..23436edc439928 --- /dev/null +++ b/src/platform/Tizen/BLEManagerImpl.cpp @@ -0,0 +1,137 @@ +/* + * + * Copyright (c) 2020-2021 Project CHIP Authors + * Copyright (c) 2018 Nest Labs, Inc. + * + * 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 + * Provides an implementation of the BLEManager singleton object + * for Tizen platforms. + */ +#include + +#include +#include + +#if CHIP_DEVICE_CONFIG_ENABLE_CHIPOBLE + +using namespace ::chip; +using namespace ::chip::Ble; + +namespace chip { +namespace DeviceLayer { +namespace Internal { + +BLEManagerImpl BLEManagerImpl::sInstance; + +CHIP_ERROR BLEManagerImpl::_Init(void) +{ + CHIP_ERROR err = CHIP_NO_ERROR; + return err; +} + +CHIP_ERROR BLEManagerImpl::_SetCHIPoBLEServiceMode(CHIPoBLEServiceMode val) +{ + return CHIP_ERROR_NOT_IMPLEMENTED; +} + +CHIP_ERROR BLEManagerImpl::_SetAdvertisingEnabled(bool val) +{ + return CHIP_ERROR_NOT_IMPLEMENTED; +} + +CHIP_ERROR BLEManagerImpl::_SetAdvertisingMode(BLEAdvertisingMode mode) +{ + return CHIP_ERROR_NOT_IMPLEMENTED; +} + +CHIP_ERROR BLEManagerImpl::_GetDeviceName(char * buf, size_t bufSize) +{ + return CHIP_ERROR_NOT_IMPLEMENTED; +} + +CHIP_ERROR BLEManagerImpl::_SetDeviceName(const char * deviceName) +{ + return CHIP_ERROR_NOT_IMPLEMENTED; +} + +uint16_t BLEManagerImpl::_NumConnections(void) +{ + return 0; +} + +CHIP_ERROR BLEManagerImpl::ConfigureBle(uint32_t aAdapterId, bool aIsCentral) +{ + return CHIP_ERROR_NOT_IMPLEMENTED; +} + +void BLEManagerImpl::_OnPlatformEvent(const ChipDeviceEvent * event) +{ +} + +uint16_t BLEManagerImpl::GetMTU(BLE_CONNECTION_OBJECT conId) const +{ + return false; +} + +bool BLEManagerImpl::SubscribeCharacteristic(BLE_CONNECTION_OBJECT conId, const ChipBleUUID * svcId, const ChipBleUUID * charId) +{ + return false; +} + +bool BLEManagerImpl::UnsubscribeCharacteristic(BLE_CONNECTION_OBJECT conId, const ChipBleUUID * svcId, const ChipBleUUID * charId) +{ + return false; +} + +bool BLEManagerImpl::CloseConnection(BLE_CONNECTION_OBJECT conId) +{ + return false; +} + +bool BLEManagerImpl::SendIndication(BLE_CONNECTION_OBJECT conId, const ChipBleUUID * svcId, const Ble::ChipBleUUID * charId, + chip::System::PacketBufferHandle pBuf) +{ + return false; +} + +bool BLEManagerImpl::SendWriteRequest(BLE_CONNECTION_OBJECT conId, const Ble::ChipBleUUID * svcId, const Ble::ChipBleUUID * charId, + chip::System::PacketBufferHandle pBuf) +{ + return false; +} + +bool BLEManagerImpl::SendReadRequest(BLE_CONNECTION_OBJECT conId, const Ble::ChipBleUUID * svcId, const Ble::ChipBleUUID * charId, + chip::System::PacketBufferHandle pBuf) +{ + return false; +} + +bool BLEManagerImpl::SendReadResponse(BLE_CONNECTION_OBJECT conId, BLE_READ_REQUEST_CONTEXT requestContext, + const Ble::ChipBleUUID * svcId, const Ble::ChipBleUUID * charId) +{ + return false; +} + +void BLEManagerImpl::NotifyChipConnectionClosed(BLE_CONNECTION_OBJECT conId) +{ +} + +} // namespace Internal +} // namespace DeviceLayer +} // namespace chip + +#endif // CHIP_DEVICE_CONFIG_ENABLE_CHIPOBLE diff --git a/src/platform/Tizen/BLEManagerImpl.h b/src/platform/Tizen/BLEManagerImpl.h new file mode 100644 index 00000000000000..8db46b595c0288 --- /dev/null +++ b/src/platform/Tizen/BLEManagerImpl.h @@ -0,0 +1,140 @@ +/* + * + * Copyright (c) 2021 Project CHIP Authors + * + * 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 + * Provides an implementation of the BLEManager singleton object + * for the Tizen platforms. + */ + +#pragma once + +#if CHIP_DEVICE_CONFIG_ENABLE_CHIPOBLE + +namespace chip { +namespace DeviceLayer { +namespace Internal { + +using namespace chip::Ble; + +/** + * Concrete implementation of the BLEManagerImpl singleton object for the Tizen platforms. + */ +class BLEManagerImpl final : public BLEManager, + private Ble::BleLayer, + private Ble::BlePlatformDelegate, + private Ble::BleApplicationDelegate +{ + // Allow the BLEManager interface class to delegate method calls to + // the implementation methods provided by this class. + friend BLEManager; + +public: + CHIP_ERROR ConfigureBle(uint32_t aAdapterId, bool aIsCentral); + +private: + // ===== Members that implement the BLEManager internal interface. + + CHIP_ERROR _Init(void); + CHIPoBLEServiceMode _GetCHIPoBLEServiceMode(void); + CHIP_ERROR _SetCHIPoBLEServiceMode(CHIPoBLEServiceMode val); + bool _IsAdvertisingEnabled(void); + CHIP_ERROR _SetAdvertisingEnabled(bool val); + bool _IsAdvertising(void); + CHIP_ERROR _SetAdvertisingMode(BLEAdvertisingMode mode); + CHIP_ERROR _GetDeviceName(char * buf, size_t bufSize); + CHIP_ERROR _SetDeviceName(const char * deviceName); + uint16_t _NumConnections(void); + void _OnPlatformEvent(const ChipDeviceEvent * event); + BleLayer * _GetBleLayer(void); + + // ===== Members that implement virtual methods on BlePlatformDelegate. + + bool SubscribeCharacteristic(BLE_CONNECTION_OBJECT conId, const Ble::ChipBleUUID * svcId, + const Ble::ChipBleUUID * charId) override; + bool UnsubscribeCharacteristic(BLE_CONNECTION_OBJECT conId, const Ble::ChipBleUUID * svcId, + const Ble::ChipBleUUID * charId) override; + bool CloseConnection(BLE_CONNECTION_OBJECT conId) override; + uint16_t GetMTU(BLE_CONNECTION_OBJECT conId) const override; + bool SendIndication(BLE_CONNECTION_OBJECT conId, const Ble::ChipBleUUID * svcId, const Ble::ChipBleUUID * charId, + System::PacketBufferHandle pBuf) override; + bool SendWriteRequest(BLE_CONNECTION_OBJECT conId, const Ble::ChipBleUUID * svcId, const Ble::ChipBleUUID * charId, + System::PacketBufferHandle pBuf) override; + bool SendReadRequest(BLE_CONNECTION_OBJECT conId, const Ble::ChipBleUUID * svcId, const Ble::ChipBleUUID * charId, + System::PacketBufferHandle pBuf) override; + bool SendReadResponse(BLE_CONNECTION_OBJECT conId, BLE_READ_REQUEST_CONTEXT requestContext, const Ble::ChipBleUUID * svcId, + const Ble::ChipBleUUID * charId) override; + + // ===== Members that implement virtual methods on BleApplicationDelegate. + + void NotifyChipConnectionClosed(BLE_CONNECTION_OBJECT conId) override; + + // ===== Members for internal use by the following friends. + + friend BLEManager & BLEMgr(void); + friend BLEManagerImpl & BLEMgrImpl(void); + + static BLEManagerImpl sInstance; +}; + +/** + * Returns a reference to the public interface of the BLEManager singleton object. + * + * Internal components should use this to access features of the BLEManager object + * that are common to all platforms. + */ +inline BLEManager & BLEMgr(void) +{ + return BLEManagerImpl::sInstance; +} + +/** + * Returns the platform-specific implementation of the BLEManager singleton object. + * + * Internal components can use this to gain access to features of the BLEManager + * that are specific to the Tizen platforms. + */ +inline BLEManagerImpl & BLEMgrImpl(void) +{ + return BLEManagerImpl::sInstance; +} + +inline Ble::BleLayer * BLEManagerImpl::_GetBleLayer() +{ + return this; +} + +inline BLEManager::CHIPoBLEServiceMode BLEManagerImpl::_GetCHIPoBLEServiceMode() +{ + return ConnectivityManager::kCHIPoBLEServiceMode_NotSupported; +} + +inline bool BLEManagerImpl::_IsAdvertisingEnabled() +{ + return false; +} + +inline bool BLEManagerImpl::_IsAdvertising() +{ + return false; +} + +} // namespace Internal +} // namespace DeviceLayer +} // namespace chip + +#endif // CHIP_DEVICE_CONFIG_ENABLE_CHIPOBLE diff --git a/src/platform/Tizen/BUILD.gn b/src/platform/Tizen/BUILD.gn new file mode 100644 index 00000000000000..07db356fd7d15d --- /dev/null +++ b/src/platform/Tizen/BUILD.gn @@ -0,0 +1,70 @@ +# Copyright (c) 2021 Project CHIP Authors +# +# 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. + +import("//build_overrides/build.gni") +import("//build_overrides/chip.gni") +import("//build_overrides/tizen.gni") + +import("${build_root}/config/linux/pkg_config.gni") + +import("${chip_root}/src/platform/device.gni") + +assert(chip_device_platform == "tizen") + +static_library("Tizen") { + sources = [ + "../DeviceSafeQueue.cpp", + "../DeviceSafeQueue.h", + "BLEManagerImpl.cpp", + "BLEManagerImpl.h", + "BlePlatformConfig.h", + "CHIPDevicePlatformConfig.h", + "CHIPDevicePlatformEvent.h", + "CHIPPlatformConfig.h", + "ConfigurationManagerImpl.cpp", + "ConfigurationManagerImpl.h", + "ConnectivityManagerImpl.cpp", + "ConnectivityManagerImpl.h", + "DeviceNetworkProvisioningDelegateImpl.cpp", + "DeviceNetworkProvisioningDelegateImpl.h", + "InetPlatformConfig.h", + "KeyValueStoreManagerImpl.cpp", + "KeyValueStoreManagerImpl.h", + "Logging.cpp", + "PlatformManagerImpl.cpp", + "PlatformManagerImpl.h", + "PosixConfig.cpp", + "PosixConfig.h", + "SystemPlatformConfig.h", + "SystemTimeSupport.cpp", + ] + + deps = [ "${chip_root}/src/setup_payload" ] + + public_deps = [ + "${chip_root}/src/platform:platform_base", + ] + + public_deps += [ "${chip_root}/${tizen_root}:tizen" ] + + public_configs = [] + + if (chip_mdns != "none") { + sources += [ + "MdnsImpl.cpp", + ] + + deps += [ "${chip_root}/src/lib/mdns:platform_header" ] + } +} diff --git a/src/platform/Tizen/BlePlatformConfig.h b/src/platform/Tizen/BlePlatformConfig.h new file mode 100644 index 00000000000000..7877788afc5460 --- /dev/null +++ b/src/platform/Tizen/BlePlatformConfig.h @@ -0,0 +1,31 @@ +/* + * + * Copyright (c) 2021 Project CHIP Authors + * + * 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 + * Platform-specific configuration overrides for the CHIP BLE + * Layer on Tizen platforms. + * + */ + +#pragma once + +// ==================== Platform Adaptations ==================== + +// ========== Platform-specific Configuration Overrides ========= + +/* none so far */ diff --git a/src/platform/Tizen/CHIPDevicePlatformConfig.h b/src/platform/Tizen/CHIPDevicePlatformConfig.h new file mode 100644 index 00000000000000..dac49181253831 --- /dev/null +++ b/src/platform/Tizen/CHIPDevicePlatformConfig.h @@ -0,0 +1,54 @@ +/* + * + * Copyright (c) 2021 Project CHIP Authors + * 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 + * Platform-specific configuration overrides for the chip Device Layer + * on Tizen platforms. + */ + +#pragma once + +// ==================== Platform Adaptations ==================== + +#define CHIP_DEVICE_CONFIG_ENABLE_WIFI_STATION 0 +#define CHIP_DEVICE_CONFIG_ENABLE_WIFI_AP 0 + +#define CHIP_DEVICE_CONFIG_ENABLE_THREAD 0 + +#ifndef CHIP_DEVICE_CONFIG_ENABLE_CHIPOBLE +#define CHIP_DEVICE_CONFIG_ENABLE_CHIPOBLE 1 +#endif + +#define CHIP_DEVICE_CONFIG_ENABLE_CHIP_TIME_SERVICE_TIME_SYNC 0 + +#define CHIP_DEVICE_CONFIG_PERSISTED_STORAGE_CRIT_EIDC_KEY 2 +#define CHIP_DEVICE_CONFIG_PERSISTED_STORAGE_PROD_EIDC_KEY 3 +#define CHIP_DEVICE_CONFIG_PERSISTED_STORAGE_INFO_EIDC_KEY 4 +#define CHIP_DEVICE_CONFIG_PERSISTED_STORAGE_DEBUG_EIDC_KEY 5 + +// ========== Platform-specific Configuration ========= + +// These are configuration options that are unique to Tizen platforms. +// These can be overridden by the application as needed. + +#define CHIP_DEVICE_CONFIG_ENABLE_WIFI_TELEMETRY 0 +#define CHIP_DEVICE_CONFIG_ENABLE_THREAD_TELEMETRY 0 +#define CHIP_DEVICE_CONFIG_ENABLE_THREAD_TELEMETRY_FULL 0 + +#define CHIP_DEVICE_CONFIG_LOG_PROVISIONING_HASH 0 diff --git a/src/platform/Tizen/CHIPDevicePlatformEvent.h b/src/platform/Tizen/CHIPDevicePlatformEvent.h new file mode 100644 index 00000000000000..26deed4ca3a96c --- /dev/null +++ b/src/platform/Tizen/CHIPDevicePlatformEvent.h @@ -0,0 +1,63 @@ +/* + * + * Copyright (c) 2021 Project CHIP Authors + * + * 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 + * Defines platform-specific event types and data for the chip + * Device Layer on Tizen platforms. + */ + +#pragma once + +#include + +namespace chip { +namespace DeviceLayer { + +namespace DeviceEventType { + +/** + * Enumerates Tizen platform-specific event types that are visible to the application. + */ +enum PublicPlatformSpecificEventTypes +{ + /* None currently defined */ +}; + +/** + * Enumerates Tizen platform-specific event types that are internal to the chip Device Layer. + */ +enum InternalPlatformSpecificEventTypes +{ + /* None currently defined */ +}; + +} // namespace DeviceEventType + +/** + * Represents platform-specific event information for Tizen platforms. + */ +struct ChipDevicePlatformEvent +{ + union + { + /* None currently defined */ + }; +}; + +} // namespace DeviceLayer +} // namespace chip diff --git a/src/platform/Tizen/CHIPPlatformConfig.h b/src/platform/Tizen/CHIPPlatformConfig.h new file mode 100644 index 00000000000000..7067e0876fcded --- /dev/null +++ b/src/platform/Tizen/CHIPPlatformConfig.h @@ -0,0 +1,107 @@ +/* + * + * Copyright (c) 2021 Project CHIP Authors + * 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 + * Platform-specific configuration overrides for CHIP on + * Tizen platforms. + */ + +#pragma once + +// ==================== General Platform Adaptations ==================== + +#define ChipDie() abort() + +#define CHIP_CONFIG_ENABLE_FABRIC_STATE 0 + +#define CHIP_CONFIG_TIME_ENABLE_CLIENT 1 +#define CHIP_CONFIG_TIME_ENABLE_SERVER 0 + +// ==================== Security Adaptations ==================== + +#define CHIP_CONFIG_USE_OPENSSL_ECC 0 +#define CHIP_CONFIG_USE_MICRO_ECC 0 + +#define CHIP_CONFIG_HASH_IMPLEMENTATION_OPENSSL 0 +#define CHIP_CONFIG_HASH_IMPLEMENTATION_MINCRYPT 1 +#define CHIP_CONFIG_HASH_IMPLEMENTATION_MBEDTLS 0 +#define CHIP_CONFIG_HASH_IMPLEMENTATION_PLATFORM 0 + +#define CHIP_CONFIG_AES_IMPLEMENTATION_OPENSSL 0 +#define CHIP_CONFIG_AES_IMPLEMENTATION_AESNI 0 +#define CHIP_CONFIG_AES_IMPLEMENTATION_MBEDTLS 1 +#define CHIP_CONFIG_AES_IMPLEMENTATION_PLATFORM 0 + +#define CHIP_CONFIG_RNG_IMPLEMENTATION_OPENSSL 0 +#define CHIP_CONFIG_RNG_IMPLEMENTATION_CHIPDRBG 1 +#define CHIP_CONFIG_RNG_IMPLEMENTATION_PLATFORM 0 + +#define CHIP_CONFIG_ENABLE_PASE_INITIATOR 0 +#define CHIP_CONFIG_ENABLE_PASE_RESPONDER 1 +#define CHIP_CONFIG_ENABLE_CASE_INITIATOR 1 + +#define CHIP_CONFIG_SUPPORT_PASE_CONFIG0 0 +#define CHIP_CONFIG_SUPPORT_PASE_CONFIG1 0 +#define CHIP_CONFIG_SUPPORT_PASE_CONFIG2 0 +#define CHIP_CONFIG_SUPPORT_PASE_CONFIG3 0 +#define CHIP_CONFIG_SUPPORT_PASE_CONFIG4 1 + +#define CHIP_CONFIG_ENABLE_KEY_EXPORT_INITIATOR 0 + +#define CHIP_CONFIG_ENABLE_PROVISIONING_BUNDLE_SUPPORT 0 + +// ==================== General Configuration Overrides ==================== + +#ifndef CHIP_CONFIG_MAX_PEER_NODES +#define CHIP_CONFIG_MAX_PEER_NODES 16 +#endif // CHIP_CONFIG_MAX_PEER_NODES + +#ifndef CHIP_CONFIG_MAX_UNSOLICITED_MESSAGE_HANDLERS +#define CHIP_CONFIG_MAX_UNSOLICITED_MESSAGE_HANDLERS 16 +#endif // CHIP_CONFIG_MAX_UNSOLICITED_MESSAGE_HANDLERS + +#ifndef CHIP_CONFIG_MAX_EXCHANGE_CONTEXTS +#define CHIP_CONFIG_MAX_EXCHANGE_CONTEXTS 8 +#endif // CHIP_CONFIG_MAX_EXCHANGE_CONTEXTS + +#ifndef CHIP_CONFIG_RMP_TIMER_DEFAULT_PERIOD_SHIFT +#define CHIP_CONFIG_RMP_TIMER_DEFAULT_PERIOD_SHIFT 6 +#endif // CHIP_CONFIG_RMP_TIMER_DEFAULT_PERIOD_SHIFT + +#ifndef CHIP_LOG_FILTERING +#define CHIP_LOG_FILTERING 0 +#endif // CHIP_LOG_FILTERING + +#ifndef CHIP_CONFIG_BDX_MAX_NUM_TRANSFERS +#define CHIP_CONFIG_BDX_MAX_NUM_TRANSFERS 1 +#endif // CHIP_CONFIG_BDX_MAX_NUM_TRANSFERS + +// ==================== Security Configuration Overrides ==================== + +#ifndef CHIP_CONFIG_MAX_APPLICATION_GROUPS +#define CHIP_CONFIG_MAX_APPLICATION_GROUPS 4 +#endif // CHIP_CONFIG_MAX_APPLICATION_GROUPS + +#ifndef CHIP_CONFIG_DEBUG_CERT_VALIDATION +#define CHIP_CONFIG_DEBUG_CERT_VALIDATION 0 +#endif // CHIP_CONFIG_DEBUG_CERT_VALIDATION + +#ifndef CHIP_CONFIG_ENABLE_CASE_RESPONDER +#define CHIP_CONFIG_ENABLE_CASE_RESPONDER 1 +#endif // CHIP_CONFIG_ENABLE_CASE_RESPONDER diff --git a/src/platform/Tizen/ConfigurationManagerImpl.cpp b/src/platform/Tizen/ConfigurationManagerImpl.cpp new file mode 100644 index 00000000000000..aa201953f4f4a7 --- /dev/null +++ b/src/platform/Tizen/ConfigurationManagerImpl.cpp @@ -0,0 +1,81 @@ +/* + * + * Copyright (c) 2020 Project CHIP Authors + * Copyright (c) 2018 Nest Labs, Inc. + * 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 + * Provides the implementation of the Device Layer ConfigurationManager object + * for Tizen platforms. + */ + +#include + +#include +#include +#include +#include +#include +#include + +namespace chip { +namespace DeviceLayer { + +using namespace ::chip::DeviceLayer::Internal; + +/** Singleton instance of the ConfigurationManager implementation object. + */ +ConfigurationManagerImpl ConfigurationManagerImpl::sInstance; + +CHIP_ERROR ConfigurationManagerImpl::_Init(void) +{ + CHIP_ERROR err = CHIP_NO_ERROR; + + // Initialize the generic implementation base class. + err = Internal::GenericConfigurationManagerImpl::_Init(); + SuccessOrExit(err); + +exit: + return err; +} + +CHIP_ERROR ConfigurationManagerImpl::_GetPrimaryWiFiMACAddress(uint8_t * buf) +{ + return CHIP_ERROR_NOT_IMPLEMENTED; +} + +bool ConfigurationManagerImpl::_CanFactoryReset(void) +{ + return true; +} + +void ConfigurationManagerImpl::_InitiateFactoryReset(void) +{ +} + +CHIP_ERROR ConfigurationManagerImpl::_ReadPersistedStorageValue(::chip::Platform::PersistedStorage::Key key, uint32_t & value) +{ + return CHIP_ERROR_NOT_IMPLEMENTED; +} + +CHIP_ERROR ConfigurationManagerImpl::_WritePersistedStorageValue(::chip::Platform::PersistedStorage::Key key, uint32_t value) +{ + return CHIP_ERROR_NOT_IMPLEMENTED; +} + +} // namespace DeviceLayer +} // namespace chip diff --git a/src/platform/Tizen/ConfigurationManagerImpl.h b/src/platform/Tizen/ConfigurationManagerImpl.h new file mode 100644 index 00000000000000..8fdbf871bca607 --- /dev/null +++ b/src/platform/Tizen/ConfigurationManagerImpl.h @@ -0,0 +1,94 @@ +/* + * + * Copyright (c) 2021 Project CHIP Authors + * 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 + * Provides an implementation of the ConfigurationManager object + * for Tizen platforms. + */ + +#pragma once + +#include + +#include + +namespace chip { +namespace DeviceLayer { + +/** + * Concrete implementation of the ConfigurationManager singleton object for the Tizen platform. + */ +class ConfigurationManagerImpl final : public ConfigurationManager, + public Internal::GenericConfigurationManagerImpl, + private Internal::PosixConfig +{ + // Allow the ConfigurationManager interface class to delegate method calls to + // the implementation methods provided by this class. + friend class ConfigurationManager; + + // Allow the GenericConfigurationManagerImpl base class to access helper methods and types + // defined on this class. +#ifndef DOXYGEN_SHOULD_SKIP_THIS + friend class Internal::GenericConfigurationManagerImpl; +#endif + +private: + // ===== Members that implement the ConfigurationManager public interface. + + CHIP_ERROR _Init(void); + CHIP_ERROR _GetPrimaryWiFiMACAddress(uint8_t * buf); + 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); + + // NOTE: Other public interface methods are implemented by GenericConfigurationManagerImpl<>. + + // ===== Members for internal use by the following friends. + + friend ConfigurationManager & ConfigurationMgr(void); + friend ConfigurationManagerImpl & ConfigurationMgrImpl(void); + + static ConfigurationManagerImpl sInstance; +}; + +/** + * Returns the public interface of the ConfigurationManager singleton object. + * + * Chip applications should use this to access features of the ConfigurationManager object + * that are common to all platforms. + */ +inline ConfigurationManager & ConfigurationMgr(void) +{ + return ConfigurationManagerImpl::sInstance; +} + +/** + * Returns the platform-specific implementation of the ConfigurationManager singleton object. + * + * Chip applications can use this to gain access to features of the ConfigurationManager + * that are specific to the Tizen platform. + */ +inline ConfigurationManagerImpl & ConfigurationMgrImpl(void) +{ + return ConfigurationManagerImpl::sInstance; +} + +} // namespace DeviceLayer +} // namespace chip diff --git a/src/platform/Tizen/ConnectivityManagerImpl.cpp b/src/platform/Tizen/ConnectivityManagerImpl.cpp new file mode 100644 index 00000000000000..aae851785e14dd --- /dev/null +++ b/src/platform/Tizen/ConnectivityManagerImpl.cpp @@ -0,0 +1,149 @@ +/* + * + * Copyright (c) 2020-2021 Project CHIP Authors + * Copyright (c) 2019 Nest Labs, Inc. + * 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. + */ + +#include + +#include +#include + +#include + +#include +#include + +#if CHIP_DEVICE_CONFIG_ENABLE_CHIPOBLE +#include +#endif + +#if CHIP_DEVICE_CONFIG_ENABLE_THREAD +#include +#endif + +#if CHIP_DEVICE_CONFIG_ENABLE_WIFI +#include +#endif + +using namespace ::chip; +using namespace ::chip::TLV; +using namespace ::chip::DeviceLayer::Internal; + +namespace chip { +namespace DeviceLayer { + +ConnectivityManagerImpl ConnectivityManagerImpl::sInstance; + +CHIP_ERROR ConnectivityManagerImpl::_Init(void) +{ + CHIP_ERROR err = CHIP_NO_ERROR; + return err; +} + +void ConnectivityManagerImpl::_OnPlatformEvent(const ChipDeviceEvent * event) +{ +} + +#if CHIP_DEVICE_CONFIG_ENABLE_WIFI +bool ConnectivityManagerImpl::_HaveIPv4InternetConnectivity(void) +{ + return false; +} + +bool ConnectivityManagerImpl::_HaveIPv6InternetConnectivity(void) +{ + return false; +} + +ConnectivityManager::WiFiStationMode ConnectivityManagerImpl::_GetWiFiStationMode(void) +{ + return ConnectivityManager::kWiFiStationMode_NotSupported; +} + +CHIP_ERROR ConnectivityManagerImpl::_SetWiFiStationMode(ConnectivityManager::WiFiStationMode val) +{ + return CHIP_ERROR_NOT_IMPLEMENTED; +} + +uint32_t ConnectivityManagerImpl::_GetWiFiStationReconnectIntervalMS(void) +{ + return 0; +} + +CHIP_ERROR ConnectivityManagerImpl::_SetWiFiStationReconnectIntervalMS(uint32_t val) +{ + return CHIP_ERROR_NOT_IMPLEMENTED; +} + +bool ConnectivityManagerImpl::_IsWiFiStationEnabled(void) +{ + return false; +} + +bool ConnectivityManagerImpl::_IsWiFiStationConnected(void) +{ + return false; +} + +bool ConnectivityManagerImpl::_IsWiFiStationApplicationControlled(void) +{ + return false; +} + +bool ConnectivityManagerImpl::_IsWiFiStationProvisioned(void) +{ + return false; +} + +void ConnectivityManagerImpl::_ClearWiFiStationProvision(void) +{ +} + +bool ConnectivityManagerImpl::_CanStartWiFiScan(void) +{ + return false; +} + +CHIP_ERROR ConnectivityManagerImpl::_SetWiFiAPMode(WiFiAPMode val) +{ + return CHIP_ERROR_NOT_IMPLEMENTED; +} + +void ConnectivityManagerImpl::_DemandStartWiFiAP(void) +{ +} + +void ConnectivityManagerImpl::_StopOnDemandWiFiAP(void) +{ +} + +void ConnectivityManagerImpl::_MaintainOnDemandWiFiAP(void) +{ +} + +void ConnectivityManagerImpl::_SetWiFiAPIdleTimeoutMS(uint32_t val) +{ +} +#endif // CHIP_DEVICE_CONFIG_ENABLE_WIFI + +CHIP_ERROR ConnectivityManagerImpl::ProvisionWiFiNetwork(const char * ssid, const char * key) +{ + return CHIP_ERROR_NOT_IMPLEMENTED; +} + +} // namespace DeviceLayer +} // namespace chip diff --git a/src/platform/Tizen/ConnectivityManagerImpl.h b/src/platform/Tizen/ConnectivityManagerImpl.h new file mode 100644 index 00000000000000..cf88f4c0de1cf9 --- /dev/null +++ b/src/platform/Tizen/ConnectivityManagerImpl.h @@ -0,0 +1,176 @@ +/* + * + * Copyright (c) 2020-2021 Project CHIP Authors + * Copyright (c) 2018 Nest Labs, Inc. + * 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. + */ + +#pragma once + +#include +#include +#if CHIP_DEVICE_CONFIG_ENABLE_CHIPOBLE +#include +#else +#include +#endif +#if CHIP_DEVICE_CONFIG_ENABLE_THREAD +#include +#else +#include +#endif +#if CHIP_DEVICE_CONFIG_ENABLE_WIFI +#include +#else +#include +#endif + +namespace chip { +namespace Inet { +class IPAddress; +} // namespace Inet +} // namespace chip + +namespace chip { +namespace DeviceLayer { + +/** + * Concrete implementation of the ConnectivityManager singleton object for Tizen platforms. + */ +class ConnectivityManagerImpl final : public ConnectivityManager, +#if CHIP_DEVICE_CONFIG_ENABLE_CHIPOBLE + public Internal::GenericConnectivityManagerImpl_BLE, +#else + public Internal::GenericConnectivityManagerImpl_NoBLE, +#endif +#if CHIP_DEVICE_CONFIG_ENABLE_THREAD + public Internal::GenericConnectivityManagerImpl_Thread, +#else + public Internal::GenericConnectivityManagerImpl_NoThread, +#endif +#if CHIP_DEVICE_CONFIG_ENABLE_WIFI + public Internal::GenericConnectivityManagerImpl_WiFi, +#else + public Internal::GenericConnectivityManagerImpl_NoWiFi, +#endif + public Internal::GenericConnectivityManagerImpl +{ + // Allow the ConnectivityManager interface class to delegate method calls to + // the implementation methods provided by this class. + friend class ConnectivityManager; + +public: + CHIP_ERROR ProvisionWiFiNetwork(const char * ssid, const char * key); + +private: + // ===== Members that implement the ConnectivityManager abstract interface. + + bool _HaveIPv4InternetConnectivity(void); + bool _HaveIPv6InternetConnectivity(void); + bool _HaveServiceConnectivity(void); + CHIP_ERROR _Init(void); + void _OnPlatformEvent(const ChipDeviceEvent * event); + +#if CHIP_DEVICE_CONFIG_ENABLE_WIFI + WiFiStationMode _GetWiFiStationMode(void); + CHIP_ERROR _SetWiFiStationMode(ConnectivityManager::WiFiStationMode val); + uint32_t _GetWiFiStationReconnectIntervalMS(void); + CHIP_ERROR _SetWiFiStationReconnectIntervalMS(uint32_t val); + bool _IsWiFiStationEnabled(void); + bool _IsWiFiStationConnected(void); + bool _IsWiFiStationApplicationControlled(void); + bool _IsWiFiStationProvisioned(void); + void _ClearWiFiStationProvision(void); + bool _CanStartWiFiScan(void); + + WiFiAPMode _GetWiFiAPMode(void); + CHIP_ERROR _SetWiFiAPMode(WiFiAPMode val); + bool _IsWiFiAPActive(void); + bool _IsWiFiAPApplicationControlled(void); + void _DemandStartWiFiAP(void); + void _StopOnDemandWiFiAP(void); + void _MaintainOnDemandWiFiAP(void); + uint32_t _GetWiFiAPIdleTimeoutMS(void); + void _SetWiFiAPIdleTimeoutMS(uint32_t val); +#endif + + // ===== Members for internal use by the following friends. + + friend ConnectivityManager & ConnectivityMgr(void); + friend ConnectivityManagerImpl & ConnectivityMgrImpl(void); + + static ConnectivityManagerImpl sInstance; + + // ===== Private members reserved for use by this class only. + + ConnectivityManager::WiFiStationMode mWiFiStationMode; + ConnectivityManager::WiFiAPMode mWiFiAPMode; + WiFiAPState mWiFiAPState; + uint64_t mLastAPDemandTime; + uint32_t mWiFiStationReconnectIntervalMS; + uint32_t mWiFiAPIdleTimeoutMS; +}; + +#if CHIP_DEVICE_CONFIG_ENABLE_WIFI +inline ConnectivityManager::WiFiAPMode ConnectivityManagerImpl::_GetWiFiAPMode() +{ + return ConnectivityManager::kWiFiAPMode_NotSupported; +} + +inline bool ConnectivityManagerImpl::_IsWiFiAPActive() +{ + return false; +} + +inline bool ConnectivityManagerImpl::_IsWiFiAPApplicationControlled() +{ + return false; +} + +inline uint32_t ConnectivityManagerImpl::_GetWiFiAPIdleTimeoutMS() +{ + return 0; +} + +inline bool ConnectivityManagerImpl::_HaveServiceConnectivity() +{ + return _HaveServiceConnectivityViaThread(); +} +#endif + +/** + * Returns the public interface of the ConnectivityManager singleton object. + * + * chip applications should use this to access features of the ConnectivityManager object + * that are common to all platforms. + */ +inline ConnectivityManager & ConnectivityMgr() +{ + return ConnectivityManagerImpl::sInstance; +} + +/** + * Returns the platform-specific implementation of the ConnectivityManager singleton object. + * + * chip applications can use this to gain access to features of the ConnectivityManager + * that are specific to the ESP32 platform. + */ +inline ConnectivityManagerImpl & ConnectivityMgrImpl() +{ + return ConnectivityManagerImpl::sInstance; +} + +} // namespace DeviceLayer +} // namespace chip diff --git a/src/platform/Tizen/DeviceNetworkProvisioningDelegateImpl.cpp b/src/platform/Tizen/DeviceNetworkProvisioningDelegateImpl.cpp new file mode 100644 index 00000000000000..327f78f0865dbd --- /dev/null +++ b/src/platform/Tizen/DeviceNetworkProvisioningDelegateImpl.cpp @@ -0,0 +1,32 @@ +/* + * + * Copyright (c) 2021 Project CHIP Authors + * + * 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. + */ + +#include +#include + +#include "DeviceNetworkProvisioningDelegateImpl.h" + +namespace chip { +namespace DeviceLayer { + +CHIP_ERROR DeviceNetworkProvisioningDelegateImpl::_ProvisionWiFiNetwork(const char * ssid, const char * key) +{ + return CHIP_ERROR_NOT_IMPLEMENTED; +} + +} // namespace DeviceLayer +} // namespace chip diff --git a/src/platform/Tizen/DeviceNetworkProvisioningDelegateImpl.h b/src/platform/Tizen/DeviceNetworkProvisioningDelegateImpl.h new file mode 100644 index 00000000000000..b1d7d8d152dd1c --- /dev/null +++ b/src/platform/Tizen/DeviceNetworkProvisioningDelegateImpl.h @@ -0,0 +1,43 @@ +/* + * + * Copyright (c) 2021 Project CHIP Authors + * + * 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. + */ + +#pragma once + +#include + +namespace chip { +namespace DeviceLayer { + +namespace Internal { + +template +class GenericDeviceNetworkProvisioningDelegateImpl; + +} // namespace Internal + +class DeviceNetworkProvisioningDelegateImpl final + : public Internal::GenericDeviceNetworkProvisioningDelegateImpl +{ + friend class GenericDeviceNetworkProvisioningDelegateImpl; + +private: + CHIP_ERROR _ProvisionWiFiNetwork(const char * ssid, const char * passwd); + CHIP_ERROR _ProvisionThreadNetwork(ByteSpan threadData) { return CHIP_ERROR_NOT_IMPLEMENTED; } +}; + +} // namespace DeviceLayer +} // namespace chip diff --git a/src/platform/Tizen/InetPlatformConfig.h b/src/platform/Tizen/InetPlatformConfig.h new file mode 100644 index 00000000000000..4510d3e8638b11 --- /dev/null +++ b/src/platform/Tizen/InetPlatformConfig.h @@ -0,0 +1,39 @@ +/* + * + * Copyright (c) 2021 Project CHIP Authors + * + * 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 + * Platform-specific configuration overrides for the CHIP Inet + * Layer on Tizen platforms. + * + */ + +#pragma once + +// ==================== Platform Adaptations ==================== + +#define INET_CONFIG_ENABLE_IPV4 1 + +// ========== Platform-specific Configuration Overrides ========= + +#ifndef INET_CONFIG_NUM_TCP_ENDPOINTS +#define INET_CONFIG_NUM_TCP_ENDPOINTS 32 +#endif // INET_CONFIG_NUM_TCP_ENDPOINTS + +#ifndef INET_CONFIG_NUM_UDP_ENDPOINTS +#define INET_CONFIG_NUM_UDP_ENDPOINTS 32 +#endif // INET_CONFIG_NUM_UDP_ENDPOINTS diff --git a/src/platform/Tizen/KeyValueStoreManagerImpl.cpp b/src/platform/Tizen/KeyValueStoreManagerImpl.cpp new file mode 100644 index 00000000000000..bc2a82caceca04 --- /dev/null +++ b/src/platform/Tizen/KeyValueStoreManagerImpl.cpp @@ -0,0 +1,50 @@ +/* + * + * Copyright (c) 2021 Project CHIP Authors + * 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 + * Platform-specific key value storage implementation for Tizen. + */ + +#include + +namespace chip { +namespace DeviceLayer { +namespace PersistedStorage { + +KeyValueStoreManagerImpl KeyValueStoreManagerImpl::sInstance; + +CHIP_ERROR KeyValueStoreManagerImpl::_Get(const char * key, void * value, size_t value_size, size_t * read_bytes_size, + size_t offset_bytes) +{ + return CHIP_ERROR_NOT_IMPLEMENTED; +} + +CHIP_ERROR KeyValueStoreManagerImpl::_Put(const char * key, const void * value, size_t value_size) +{ + return CHIP_ERROR_NOT_IMPLEMENTED; +} + +CHIP_ERROR KeyValueStoreManagerImpl::_Delete(const char * key) +{ + return CHIP_ERROR_NOT_IMPLEMENTED; +} + +} // namespace PersistedStorage +} // namespace DeviceLayer +} // namespace chip diff --git a/src/platform/Tizen/KeyValueStoreManagerImpl.h b/src/platform/Tizen/KeyValueStoreManagerImpl.h new file mode 100644 index 00000000000000..e56fb37aca5bb5 --- /dev/null +++ b/src/platform/Tizen/KeyValueStoreManagerImpl.h @@ -0,0 +1,73 @@ +/* + * + * Copyright (c) 2021 Project CHIP Authors + * 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 + * Platform-specific key value storage implementation for Tizen. + */ + +#pragma once + +namespace chip { +namespace DeviceLayer { +namespace PersistedStorage { + +class KeyValueStoreManagerImpl final : public KeyValueStoreManager +{ + // Allow the KeyValueStoreManager interface class to delegate method calls to + // the implementation methods provided by this class. + friend class KeyValueStoreManager; + +public: + CHIP_ERROR _Get(const char * key, void * value, size_t value_size, size_t * read_bytes_size = nullptr, size_t offset = 0); + CHIP_ERROR _Delete(const char * key); + CHIP_ERROR _Put(const char * key, const void * value, size_t value_size); + +private: + // ===== Members for internal use by the following friends. + friend KeyValueStoreManager & KeyValueStoreMgr(); + friend KeyValueStoreManagerImpl & KeyValueStoreMgrImpl(); + + static KeyValueStoreManagerImpl sInstance; +}; + +/** + * Returns the public interface of the KeyValueStoreManager singleton object. + * + * Chip applications should use this to access features of the KeyValueStoreManager object + * that are common to all platforms. + */ +inline KeyValueStoreManager & KeyValueStoreMgr(void) +{ + return KeyValueStoreManagerImpl::sInstance; +} + +/** + * Returns the platform-specific implementation of the KeyValueStoreManager singleton object. + * + * Chip applications can use this to gain access to features of the KeyValueStoreManager + * that are specific to the Tizen platform. + */ +inline KeyValueStoreManagerImpl & KeyValueStoreMgrImpl(void) +{ + return KeyValueStoreManagerImpl::sInstance; +} + +} // namespace PersistedStorage +} // namespace DeviceLayer +} // namespace chip diff --git a/src/platform/Tizen/Logging.cpp b/src/platform/Tizen/Logging.cpp new file mode 100644 index 00000000000000..01bf77a4722f2e --- /dev/null +++ b/src/platform/Tizen/Logging.cpp @@ -0,0 +1,70 @@ +/* + * + * Copyright (c) 2021 Project CHIP Authors + * + * 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. + */ + +#include + +#include +#include + +#include +#include + +#ifdef LOG_TAG +#undef LOG_TAG +#endif +#define LOG_TAG "CHIP" + +#ifndef LOGD +#define LOGD(fmt, args...) dlog_print(DLOG_DEBUG, LOG_TAG, fmt, ##args) +#endif +#ifndef LOGE +#define LOGE(fmt, args...) dlog_print(DLOG_ERROR, LOG_TAG, fmt, ##args) +#endif +#ifndef LOGI +#define LOGI(fmt, args...) dlog_print(DLOG_INFO, LOG_TAG, fmt, ##args) +#endif + +namespace chip { +namespace Logging { +namespace Platform { + +/** + * CHIP log output functions. + */ +void LogV(const char * module, uint8_t category, const char * msg, va_list v) +{ + char msgBuf[CHIP_CONFIG_LOG_MESSAGE_MAX_SIZE] = { 0, }; + vsnprintf(msgBuf, sizeof(msgBuf), msg, v); + + switch (category) + { + case kLogCategory_Error: + LOGE("%s: %s", module, msgBuf); + break; + case kLogCategory_Detail: + LOGD("%s: %s", module, msgBuf); + break; + case kLogCategory_Progress: + default: + LOGI("%s: %s", module, msgBuf); + break; + } +} + +} // namespace Platform +} // namespace Logging +} // namespace chip diff --git a/src/platform/Tizen/MdnsImpl.cpp b/src/platform/Tizen/MdnsImpl.cpp new file mode 100644 index 00000000000000..ebfa9c71fe1d00 --- /dev/null +++ b/src/platform/Tizen/MdnsImpl.cpp @@ -0,0 +1,71 @@ +/* + * + * Copyright (c) 2021 Project CHIP Authors + * + * 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. + */ + +#include "lib/mdns/platform/Mdns.h" + +using namespace chip::Mdns; + +namespace { + +} // namespace + +namespace chip { +namespace Mdns { + +CHIP_ERROR ChipMdnsInit(MdnsAsyncReturnCallback successCallback, MdnsAsyncReturnCallback errorCallback, void * context) +{ + return CHIP_ERROR_NOT_IMPLEMENTED; +} + +CHIP_ERROR ChipMdnsSetHostname(const char * hostname) +{ + return CHIP_ERROR_NOT_IMPLEMENTED; +} + +CHIP_ERROR ChipMdnsPublishService(const MdnsService * service) +{ + return CHIP_ERROR_NOT_IMPLEMENTED; +} + +CHIP_ERROR ChipMdnsStopPublish() +{ + return CHIP_ERROR_NOT_IMPLEMENTED; +} + +CHIP_ERROR ChipMdnsBrowse(const char * type, MdnsServiceProtocol protocol, chip::Inet::IPAddressType addressType, + chip::Inet::InterfaceId interface, MdnsBrowseCallback callback, void * context) +{ + return CHIP_ERROR_NOT_IMPLEMENTED; +} + +CHIP_ERROR ChipMdnsResolve(MdnsService * service, chip::Inet::InterfaceId interface, MdnsResolveCallback callback, void * context) +{ + return CHIP_ERROR_NOT_IMPLEMENTED; +} + +void GetMdnsTimeout(timeval & timeout) +{ + +} + +void HandleMdnsTimeout() +{ + +} + +} // namespace Mdns +} // namespace chip diff --git a/src/platform/Tizen/PlatformManagerImpl.cpp b/src/platform/Tizen/PlatformManagerImpl.cpp new file mode 100644 index 00000000000000..e750035ce00c5e --- /dev/null +++ b/src/platform/Tizen/PlatformManagerImpl.cpp @@ -0,0 +1,53 @@ +/* + * + * Copyright (c) 2020 Project CHIP Authors + * Copyright (c) 2018 Nest Labs, Inc. + * 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 + * Provides an implementation of the PlatformManager object + * for Tizen platforms. + */ + +#include + +#include +#include + +namespace chip { +namespace DeviceLayer { + +PlatformManagerImpl PlatformManagerImpl::sInstance; + +CHIP_ERROR PlatformManagerImpl::_InitChipStack(void) +{ + CHIP_ERROR err; + + // Initialize the configuration system. + err = Internal::PosixConfig::Init(); + SuccessOrExit(err); + // Call _InitChipStack() on the generic implementation base class + // to finish the initialization process. + err = Internal::GenericPlatformManagerImpl_POSIX::_InitChipStack(); + SuccessOrExit(err); + +exit: + return err; +} + +} // namespace DeviceLayer +} // namespace chip diff --git a/src/platform/Tizen/PlatformManagerImpl.h b/src/platform/Tizen/PlatformManagerImpl.h new file mode 100644 index 00000000000000..f21cfeae29e565 --- /dev/null +++ b/src/platform/Tizen/PlatformManagerImpl.h @@ -0,0 +1,86 @@ +/* + * + * Copyright (c) 2020 Project CHIP Authors + * Copyright (c) 2018 Nest Labs, Inc. + * + * 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 + * Provides an implementation of the PlatformManager object. + */ + +#pragma once + +#include + +namespace chip { +namespace DeviceLayer { + +/** + * Concrete implementation of the PlatformManager singleton object for Tizen platforms. + */ +class PlatformManagerImpl final : public PlatformManager, public Internal::GenericPlatformManagerImpl_POSIX +{ + // Allow the PlatformManager interface class to delegate method calls to + // the implementation methods provided by this class. + friend PlatformManager; + + // Allow the generic implementation base class to call helper methods on + // this class. +#ifndef DOXYGEN_SHOULD_SKIP_THIS + friend Internal::GenericPlatformManagerImpl_POSIX; +#endif + +public: + // ===== Platform-specific members that may be accessed directly by the application. + +private: + // ===== Methods that implement the PlatformManager abstract interface. + + CHIP_ERROR _InitChipStack(void); + + // ===== Members for internal use by the following friends. + + friend PlatformManager & PlatformMgr(void); + friend PlatformManagerImpl & PlatformMgrImpl(void); + friend class Internal::BLEManagerImpl; + + static PlatformManagerImpl sInstance; +}; + +/** + * Returns the public interface of the PlatformManager singleton object. + * + * Chip applications should use this to access features of the PlatformManager object + * that are common to all platforms. + */ +inline PlatformManager & PlatformMgr(void) +{ + return PlatformManagerImpl::sInstance; +} + +/** + * Returns the platform-specific implementation of the PlatformManager singleton object. + * + * Chip applications can use this to gain access to features of the PlatformManager + * that are specific to Tizen platform. + */ +inline PlatformManagerImpl & PlatformMgrImpl(void) +{ + return PlatformManagerImpl::sInstance; +} + +} // namespace DeviceLayer +} // namespace chip diff --git a/src/platform/Tizen/PosixConfig.cpp b/src/platform/Tizen/PosixConfig.cpp new file mode 100644 index 00000000000000..c1019da0efed7e --- /dev/null +++ b/src/platform/Tizen/PosixConfig.cpp @@ -0,0 +1,169 @@ +/* + * + * Copyright (c) 2021 Project CHIP Authors + * Copyright (c) 2019-2020 Google LLC. + * Copyright (c) 2018 Nest Labs, Inc. + * 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 + * Utilities for interacting with multiple file partitions and maps + * key-value config calls to the correct partition. + */ + +#include +#include + +#include +#include +#include + +namespace chip { +namespace DeviceLayer { +namespace Internal { + +// *** CAUTION ***: Changing the names or namespaces of these values will *break* existing devices. + +// NVS namespaces used to store device configuration information. +const char PosixConfig::kConfigNamespace_ChipFactory[] = "chip-factory"; +const char PosixConfig::kConfigNamespace_ChipConfig[] = "chip-config"; +const char PosixConfig::kConfigNamespace_ChipCounters[] = "chip-counters"; + +// Keys stored in the Chip-factory namespace +const PosixConfig::Key PosixConfig::kConfigKey_SerialNum = { kConfigNamespace_ChipFactory, "serial-num" }; +const PosixConfig::Key PosixConfig::kConfigKey_MfrDeviceId = { kConfigNamespace_ChipFactory, "device-id" }; +const PosixConfig::Key PosixConfig::kConfigKey_MfrDeviceCert = { kConfigNamespace_ChipFactory, "device-cert" }; +const PosixConfig::Key PosixConfig::kConfigKey_MfrDeviceICACerts = { kConfigNamespace_ChipFactory, "device-ca-certs" }; +const PosixConfig::Key PosixConfig::kConfigKey_MfrDevicePrivateKey = { kConfigNamespace_ChipFactory, "device-key" }; +const PosixConfig::Key PosixConfig::kConfigKey_ProductRevision = { kConfigNamespace_ChipFactory, "product-rev" }; +const PosixConfig::Key PosixConfig::kConfigKey_ManufacturingDate = { kConfigNamespace_ChipFactory, "mfg-date" }; +const PosixConfig::Key PosixConfig::kConfigKey_SetupPinCode = { kConfigNamespace_ChipFactory, "pin-code" }; +const PosixConfig::Key PosixConfig::kConfigKey_SetupDiscriminator = { kConfigNamespace_ChipFactory, "discriminator" }; + +// Keys stored in the Chip-config namespace +const PosixConfig::Key PosixConfig::kConfigKey_FabricId = { kConfigNamespace_ChipConfig, "fabric-id" }; +const PosixConfig::Key PosixConfig::kConfigKey_ServiceConfig = { kConfigNamespace_ChipConfig, "service-config" }; +const PosixConfig::Key PosixConfig::kConfigKey_PairedAccountId = { kConfigNamespace_ChipConfig, "account-id" }; +const PosixConfig::Key PosixConfig::kConfigKey_ServiceId = { kConfigNamespace_ChipConfig, "service-id" }; +const PosixConfig::Key PosixConfig::kConfigKey_FabricSecret = { kConfigNamespace_ChipConfig, "fabric-secret" }; +const PosixConfig::Key PosixConfig::kConfigKey_GroupKeyIndex = { kConfigNamespace_ChipConfig, "group-key-index" }; +const PosixConfig::Key PosixConfig::kConfigKey_LastUsedEpochKeyId = { kConfigNamespace_ChipConfig, "last-ek-id" }; +const PosixConfig::Key PosixConfig::kConfigKey_FailSafeArmed = { kConfigNamespace_ChipConfig, "fail-safe-armed" }; +const PosixConfig::Key PosixConfig::kConfigKey_WiFiStationSecType = { kConfigNamespace_ChipConfig, "sta-sec-type" }; +const PosixConfig::Key PosixConfig::kConfigKey_OperationalDeviceId = { kConfigNamespace_ChipConfig, "op-device-id" }; +const PosixConfig::Key PosixConfig::kConfigKey_OperationalDeviceCert = { kConfigNamespace_ChipConfig, "op-device-cert" }; +const PosixConfig::Key PosixConfig::kConfigKey_OperationalDeviceICACerts = { kConfigNamespace_ChipConfig, "op-device-ca-certs" }; +const PosixConfig::Key PosixConfig::kConfigKey_OperationalDevicePrivateKey = { kConfigNamespace_ChipConfig, "op-device-key" }; +const PosixConfig::Key PosixConfig::kConfigKey_RegulatoryLocation = { kConfigNamespace_ChipConfig, "regulatory-location" }; +const PosixConfig::Key PosixConfig::kConfigKey_CountryCode = { kConfigNamespace_ChipConfig, "country-code" }; +const PosixConfig::Key PosixConfig::kConfigKey_Breadcrumb = { kConfigNamespace_ChipConfig, "breadcrumb" }; + +// Prefix used for NVS keys that contain Chip group encryption keys. +const char PosixConfig::kGroupKeyNamePrefix[] = "gk-"; + +CHIP_ERROR PosixConfig::Init() +{ + return CHIP_ERROR_NOT_IMPLEMENTED; +} + +CHIP_ERROR PosixConfig::ReadConfigValue(Key key, bool & val) +{ + return CHIP_ERROR_NOT_IMPLEMENTED; +} + +CHIP_ERROR PosixConfig::ReadConfigValue(Key key, uint32_t & val) +{ + return CHIP_ERROR_NOT_IMPLEMENTED; +} + +CHIP_ERROR PosixConfig::ReadConfigValue(Key key, uint64_t & val) +{ + return CHIP_ERROR_NOT_IMPLEMENTED; +} + +CHIP_ERROR PosixConfig::ReadConfigValueStr(Key key, char * buf, size_t bufSize, size_t & outLen) +{ + return CHIP_ERROR_NOT_IMPLEMENTED; +} + +CHIP_ERROR PosixConfig::ReadConfigValueBin(Key key, uint8_t * buf, size_t bufSize, size_t & outLen) +{ + return CHIP_ERROR_NOT_IMPLEMENTED; +} + +CHIP_ERROR PosixConfig::WriteConfigValue(Key key, bool val) +{ + return CHIP_ERROR_NOT_IMPLEMENTED; +} + +CHIP_ERROR PosixConfig::WriteConfigValue(Key key, uint32_t val) +{ + return CHIP_ERROR_NOT_IMPLEMENTED; +} + +CHIP_ERROR PosixConfig::WriteConfigValue(Key key, uint64_t val) +{ + return CHIP_ERROR_NOT_IMPLEMENTED; +} + +CHIP_ERROR PosixConfig::WriteConfigValueStr(Key key, const char * str) +{ + return CHIP_ERROR_NOT_IMPLEMENTED; +} + +CHIP_ERROR PosixConfig::WriteConfigValueStr(Key key, const char * str, size_t strLen) +{ + return CHIP_ERROR_NOT_IMPLEMENTED; +} + +CHIP_ERROR PosixConfig::WriteConfigValueBin(Key key, const uint8_t * data, size_t dataLen) +{ + return CHIP_ERROR_NOT_IMPLEMENTED; +} + +CHIP_ERROR PosixConfig::ClearConfigValue(Key key) +{ + return CHIP_ERROR_NOT_IMPLEMENTED; +} + +bool PosixConfig::ConfigValueExists(Key key) +{ + return false; +} + +CHIP_ERROR PosixConfig::EnsureNamespace(const char * ns) +{ + return CHIP_ERROR_NOT_IMPLEMENTED; +} + +CHIP_ERROR PosixConfig::ClearNamespace(const char * ns) +{ + return CHIP_ERROR_NOT_IMPLEMENTED; +} + +CHIP_ERROR PosixConfig::FactoryResetConfig() +{ + return CHIP_ERROR_NOT_IMPLEMENTED; +} + +void PosixConfig::RunConfigUnitTest() +{ + +} + +} // namespace Internal +} // namespace DeviceLayer +} // namespace chip diff --git a/src/platform/Tizen/PosixConfig.h b/src/platform/Tizen/PosixConfig.h new file mode 100644 index 00000000000000..3b52637b91546f --- /dev/null +++ b/src/platform/Tizen/PosixConfig.h @@ -0,0 +1,124 @@ +/* + * + * Copyright (c) 2021 Project CHIP Authors + * + * 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 + * Utilities for accessing persisted device configuration on + * Tizen platforms. + */ + +#pragma once + +#include +#include + +#include + +namespace chip { +namespace DeviceLayer { +namespace Internal { + +/** + * Provides functions and definitions for accessing device configuration information on the Posix. + * + * This class is designed to be mixed-in to concrete implementation classes as a means to + * provide access to configuration information to generic base classes. + */ +class PosixConfig +{ +public: + struct Key; + + // Maximum length of an NVS key name. + static constexpr size_t kMaxConfigKeyNameLength = 15; + + // NVS namespaces used to store device configuration information. + static const char kConfigNamespace_ChipFactory[]; + static const char kConfigNamespace_ChipConfig[]; + static const char kConfigNamespace_ChipCounters[]; + + // Key definitions for well-known keys. + static const Key kConfigKey_SerialNum; + static const Key kConfigKey_MfrDeviceId; + static const Key kConfigKey_MfrDeviceCert; + static const Key kConfigKey_MfrDeviceICACerts; + static const Key kConfigKey_MfrDevicePrivateKey; + static const Key kConfigKey_ProductRevision; + static const Key kConfigKey_ManufacturingDate; + static const Key kConfigKey_SetupPinCode; + static const Key kConfigKey_FabricId; + static const Key kConfigKey_ServiceConfig; + static const Key kConfigKey_PairedAccountId; + static const Key kConfigKey_ServiceId; + static const Key kConfigKey_FabricSecret; + static const Key kConfigKey_GroupKeyIndex; + static const Key kConfigKey_LastUsedEpochKeyId; + static const Key kConfigKey_FailSafeArmed; + static const Key kConfigKey_WiFiStationSecType; + static const Key kConfigKey_OperationalDeviceId; + static const Key kConfigKey_OperationalDeviceCert; + static const Key kConfigKey_OperationalDeviceICACerts; + static const Key kConfigKey_OperationalDevicePrivateKey; + static const Key kConfigKey_SetupDiscriminator; + static const Key kConfigKey_RegulatoryLocation; + static const Key kConfigKey_CountryCode; + static const Key kConfigKey_Breadcrumb; + + static const char kGroupKeyNamePrefix[]; + + static CHIP_ERROR Init(void); + + // Config value accessors. + static CHIP_ERROR ReadConfigValue(Key key, bool & val); + static CHIP_ERROR ReadConfigValue(Key key, uint32_t & val); + static CHIP_ERROR ReadConfigValue(Key key, uint64_t & val); + static CHIP_ERROR ReadConfigValueStr(Key key, char * buf, size_t bufSize, size_t & outLen); + static CHIP_ERROR ReadConfigValueBin(Key key, uint8_t * buf, size_t bufSize, size_t & outLen); + static CHIP_ERROR WriteConfigValue(Key key, bool val); + static CHIP_ERROR WriteConfigValue(Key key, uint32_t val); + static CHIP_ERROR WriteConfigValue(Key key, uint64_t val); + static CHIP_ERROR WriteConfigValueStr(Key key, const char * str); + static CHIP_ERROR WriteConfigValueStr(Key key, const char * str, size_t strLen); + static CHIP_ERROR WriteConfigValueBin(Key key, const uint8_t * data, size_t dataLen); + static CHIP_ERROR ClearConfigValue(Key key); + static bool ConfigValueExists(Key key); + static CHIP_ERROR FactoryResetConfig(void); + + static void RunConfigUnitTest(void); + +protected: + // NVS Namespace helper functions. + static CHIP_ERROR EnsureNamespace(const char * ns); + static CHIP_ERROR ClearNamespace(const char * ns); +}; + +struct PosixConfig::Key +{ + const char * Namespace; + const char * Name; + + bool operator==(const Key & other) const; +}; + +inline bool PosixConfig::Key::operator==(const Key & other) const +{ + return strcmp(Namespace, other.Namespace) == 0 && strcmp(Name, other.Name) == 0; +} + +} // namespace Internal +} // namespace DeviceLayer +} // namespace chip diff --git a/src/platform/Tizen/SystemPlatformConfig.h b/src/platform/Tizen/SystemPlatformConfig.h new file mode 100644 index 00000000000000..f895bff0b9c972 --- /dev/null +++ b/src/platform/Tizen/SystemPlatformConfig.h @@ -0,0 +1,49 @@ +/* + * + * Copyright (c) 2021 Project CHIP Authors + * + * 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 + * Platform-specific configuration overrides for the CHIP System + * Layer on Tizen platforms. + * + */ + +#pragma once + +#include + +namespace chip { +namespace DeviceLayer { +struct ChipDeviceEvent; +} // namespace DeviceLayer +} // namespace chip + +// ==================== Platform Adaptations ==================== + +#define CHIP_SYSTEM_CONFIG_POSIX_LOCKING 1 +#define CHIP_SYSTEM_CONFIG_FREERTOS_LOCKING 0 +#define CHIP_SYSTEM_CONFIG_NO_LOCKING 0 +#define CHIP_SYSTEM_CONFIG_PLATFORM_PROVIDES_EVENT_FUNCTIONS 1 +#define CHIP_SYSTEM_CONFIG_PLATFORM_PROVIDES_TIME 0 + +#define CHIP_SYSTEM_CONFIG_USE_POSIX_TIME_FUNCTS 1 + +// ========== Platform-specific Configuration Overrides ========= + +#ifndef CHIP_SYSTEM_CONFIG_NUM_TIMERS +#define CHIP_SYSTEM_CONFIG_NUM_TIMERS 16 +#endif // CHIP_SYSTEM_CONFIG_NUM_TIMERS diff --git a/src/platform/Tizen/SystemTimeSupport.cpp b/src/platform/Tizen/SystemTimeSupport.cpp new file mode 100644 index 00000000000000..9464485b1a7d55 --- /dev/null +++ b/src/platform/Tizen/SystemTimeSupport.cpp @@ -0,0 +1,69 @@ +/* + * + * Copyright (c) 2020 Project CHIP Authors + * Copyright (c) 2018 Nest Labs, Inc. + * 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 + * Provides implementations of the CHIP System Layer platform + * time/clock functions that are suitable for use on the Tizen platform. + */ + +#include + +#include +#include + +namespace chip { +namespace System { +namespace Platform { +namespace Layer { + +uint64_t GetClock_Monotonic() +{ + return static_cast(0); +} + +uint64_t GetClock_MonotonicMS() +{ + return static_cast(0); +} + +uint64_t GetClock_MonotonicHiRes() +{ + return static_cast(0); +} + +CHIP_ERROR GetClock_RealTime(uint64_t & curTime) +{ + return CHIP_ERROR_NOT_IMPLEMENTED; +} + +CHIP_ERROR GetClock_RealTimeMS(uint64_t & curTime) +{ + return CHIP_ERROR_NOT_IMPLEMENTED; +} + +CHIP_ERROR SetClock_RealTime(uint64_t newCurTime) +{ + return CHIP_ERROR_NOT_IMPLEMENTED; +} + +} // namespace Layer +} // namespace Platform +} // namespace System +} // namespace chip From 0253a5654146884188ac7004feb588ecf8d81207 Mon Sep 17 00:00:00 2001 From: Wootak Jung Date: Wed, 21 Jul 2021 13:55:20 +0900 Subject: [PATCH 02/14] Add Tizen OS target config/build files --- build_overrides/tizen.gni | 18 ++++++ config/tizen/chip-gn/BUILD.gn | 36 +++++++++++ config/tizen/chip-gn/args.gni | 28 ++++++++ config/tizen/chip-gn/platform/BUILD.gn | 84 ++++++++++++++++++++++++ config/tizen/scripts/install_sdk.sh | 90 ++++++++++++++++++++++++++ 5 files changed, 256 insertions(+) create mode 100644 build_overrides/tizen.gni create mode 100644 config/tizen/chip-gn/BUILD.gn create mode 100644 config/tizen/chip-gn/args.gni create mode 100644 config/tizen/chip-gn/platform/BUILD.gn create mode 100755 config/tizen/scripts/install_sdk.sh diff --git a/build_overrides/tizen.gni b/build_overrides/tizen.gni new file mode 100644 index 00000000000000..c98c7998f02fd5 --- /dev/null +++ b/build_overrides/tizen.gni @@ -0,0 +1,18 @@ +# Copyright (c) 2021 Project CHIP Authors +# +# 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. + +declare_args() { + # Root directory for tizen. + tizen_root = "//config/tizen/chip-gn/platform" +} diff --git a/config/tizen/chip-gn/BUILD.gn b/config/tizen/chip-gn/BUILD.gn new file mode 100644 index 00000000000000..d3b3cbf05345c6 --- /dev/null +++ b/config/tizen/chip-gn/BUILD.gn @@ -0,0 +1,36 @@ +# Copyright (c) 2021 Project CHIP Authors +# +# 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. + +import("//build_overrides/build.gni") +import("//build_overrides/chip.gni") + +import("${build_root}/chip/tests.gni") + +assert(current_os == "tizen") + +declare_args() { + chip_build_pw_rpc_lib = false +} + +group("tizen") { + deps = [ "${chip_root}/src/lib" ] + + if (chip_build_tests) { + deps += [ "${chip_root}/src:tests" ] + } +} + +group("default") { + deps = [ ":tizen" ] +} diff --git a/config/tizen/chip-gn/args.gni b/config/tizen/chip-gn/args.gni new file mode 100644 index 00000000000000..16eedd229e9ea2 --- /dev/null +++ b/config/tizen/chip-gn/args.gni @@ -0,0 +1,28 @@ +# Copyright (c) 2021 Project CHIP Authors +# +# 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. + +import("//build_overrides/chip.gni") + +declare_args() { + # Location of the Tizen SDK. + tizen_sdk_root = "" +} + +chip_device_platform = "tizen" + +chip_build_tests = false + + +chip_inet_config_enable_raw_endpoint = false +chip_inet_config_enable_dns_resolver = false diff --git a/config/tizen/chip-gn/platform/BUILD.gn b/config/tizen/chip-gn/platform/BUILD.gn new file mode 100644 index 00000000000000..0c300253b71807 --- /dev/null +++ b/config/tizen/chip-gn/platform/BUILD.gn @@ -0,0 +1,84 @@ +# Copyright (c) 2021 Project CHIP Authors +# +# 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. + +import("//build_overrides/build.gni") +import("//build_overrides/chip.gni") +import("//build_overrides/tizen.gni") +import("${chip_root}/config/tizen/chip-gn/args.gni") + +import("${build_root}/config/linux/pkg_config.gni") +import("${chip_root}/src/platform/device.gni") + +config("tizen_sdk_config") { + pkg_config("dlog") { + packages = [ "dlog" ] + } + + pkg_config("capi-appfw-preference") { + packages = [ "capi-appfw-preference" ] + } + + pkg_config("glib") { + packages = [ + "glib-2.0", + "gio-unix-2.0", + ] + } + + if (chip_mdns != "none") { + pkg_config("nsd-dns-sd") { + packages = [ "nsd-dns-sd" ] + } + } + + if (chip_enable_wifi) { + pkg_config("capi-network-wifi-manager") { + packages = [ "capi-network-wifi-manager" ] + } + pkg_config("capi-network-softap") { + packages = [ "capi-network-softap" ] + } + } + + if (chip_enable_ble) { + pkg_config("capi-network-bluetooth") { + packages = [ "capi-network-bluetooth" ] + } + } +} + +source_set("tizen") { + public_configs = [ ":tizen_sdk_config" ] + + public_configs += [ + ":dlog", + ":glib", + ":capi-appfw-preference", + ] + + if (chip_mdns != "none") { + public_configs += [ ":nsd-dns-sd" ] + } + + if (chip_enable_wifi) { + public_configs += [ + ":capi-network-wifi-manager", + ":capi-network-softap", + ] + } + + if (chip_enable_ble) { + public_configs += [ ":capi-network-bluetooth" ] + } +} diff --git a/config/tizen/scripts/install_sdk.sh b/config/tizen/scripts/install_sdk.sh new file mode 100755 index 00000000000000..a9aa3e2ef76416 --- /dev/null +++ b/config/tizen/scripts/install_sdk.sh @@ -0,0 +1,90 @@ +#!/bin/bash + +ROOTSTRAP_PATH="$1" +CHIPROOT=`git rev-parse --show-toplevel` + +NSD_DNS_LIBS="libnsd-dns-sd.so*" + +echo $ROOTSTRAP_PATH + +if [ -z "$ROOTSTRAP_PATH" ]; then + echo "ROOTSTRAP_PATH should be input" + exit 1 +fi + +if [[ ! -d $ROOTSTRAP_PATH ]]; then + echo "Can't find the rootstrap dir, please make dir and run this script again" + exit 1 +fi + +cd $ROOTSTRAP_PATH + +# Get Tizen rootstrap +if [[ ! -f mobile-6.0-rs-device.core_0.0.123_ubuntu-64.zip ]]; then + echo "Getting tizen rootstrap..." + wget http://download.tizen.org/sdk/tizenstudio/official/binary/mobile-6.0-rs-device.core_0.0.123_ubuntu-64.zip +fi +unzip mobile-6.0-rs-device.core_0.0.123_ubuntu-64.zip +mv data/platforms/tizen-6.0/mobile/rootstraps/mobile-6.0-device.core/usr . +mv data/platforms/tizen-6.0/mobile/rootstraps/mobile-6.0-device.core/lib . + +# Clean files +rm -rf data +rm -rf mobile-6.0-rs-device.* +rm pkginfo.manifest + +# Copy internal dns-sd header into rootstrap +# After finishing ACR for internal APIs, we will remove this. + +rm $ROOTSTRAP_PATH/usr/lib/$NSD_DNS_LIBS + +# Get tizen packages +function download_pkg { + if [ "$2" = "snapshots" ] + then + wget -r -nd --no-parent -A "$1" "http://download.tizen.org/snapshots/tizen/unified/latest/repos/standard/packages/armv7l/" + else + wget -r -nd --no-parent -A "$1" "http://download.tizen.org/releases/milestone/tizen/${2:-base}/latest/repos/standard/packages/armv7l/" + fi +} + +# Base package +for pkg in 'pcre-devel-*.armv7l.rpm' 'libffi-devel-*.armv7l.rpm' 'libmount-devel-*.armv7l.rpm' \ + 'libblkid-devel-*.armv7l.rpm' 'libcap-*.armv7l.rpm' 'liblzma-*.armv7l.rpm' ; do + download_pkg "$pkg" +done + +# Unified package +for pkg in 'vconf-compat-*.armv7l.rpm' 'libcynara-commons-*.armv7l.rpm' 'cynara-devel-*.armv7l.rpm' \ + 'libcynara-client-*.armv7l.rpm' 'dbus-1*.armv7l.rpm' 'dbus-devel-*.armv7l.rpm' \ + 'dbus-libs-1*.armv7l.rpm' 'glib2-devel-2*.armv7l.rpm' 'libdns_sd-*.armv7l.rpm' \ + 'buxton2-*.armv7l.rpm' 'libsystemd-*.armv7l.rpm'; do + download_pkg "$pkg" unified +done + +# Latest snapshots package (For nsd) +for pkg in 'capi-network-nsd-0*.armv7l.rpm' 'capi-network-nsd-devel*.armv7l.rpm' 'libnsd-dns-sd*.armv7l.rpm' 'libdns_sd-*.armv7l.rpm'; do + download_pkg "$pkg" snapshots +done + +unrpm *.rpm + +cp usr/lib/pkgconfig/openssl1.1.pc usr/lib/pkgconfig/openssl.pc + +rm usr/lib/libdns_sd.so +cp usr/lib/libdns_sd.so.878.* usr/lib/libdns_sd.so + +rm *.rpm + +# Get toolchain +wget http://download.tizen.org/sdk/tizenstudio/official/binary/cross-arm-gcc-9.2_0.1.9_ubuntu-64.zip +unzip cross-arm-gcc-9.2_0.1.9_ubuntu-64.zip + +cp -rf data/tools/arm-linux-gnueabi-gcc-9.2/* . + +rm pkginfo.manifest +rm changelog +rm -rf data + +rm cross-arm-gcc-9.2_0.1.9_ubuntu-64.zip + From 1587078ef89c0f0aa41e61f9c220faaab14ab568 Mon Sep 17 00:00:00 2001 From: Wootak Jung Date: Wed, 21 Jul 2021 13:57:27 +0900 Subject: [PATCH 03/14] Add example build files based on Tizen OS --- examples/build_overrides/tizen.gni | 18 ++++++ examples/lighting-app/linux/with_tizen.gni | 22 +++++++ scripts/examples/gn_tizen_example.sh | 74 ++++++++++++++++++++++ 3 files changed, 114 insertions(+) create mode 100644 examples/build_overrides/tizen.gni create mode 100644 examples/lighting-app/linux/with_tizen.gni create mode 100755 scripts/examples/gn_tizen_example.sh diff --git a/examples/build_overrides/tizen.gni b/examples/build_overrides/tizen.gni new file mode 100644 index 00000000000000..c98c7998f02fd5 --- /dev/null +++ b/examples/build_overrides/tizen.gni @@ -0,0 +1,18 @@ +# Copyright (c) 2021 Project CHIP Authors +# +# 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. + +declare_args() { + # Root directory for tizen. + tizen_root = "//config/tizen/chip-gn/platform" +} diff --git a/examples/lighting-app/linux/with_tizen.gni b/examples/lighting-app/linux/with_tizen.gni new file mode 100644 index 00000000000000..4df278857387ff --- /dev/null +++ b/examples/lighting-app/linux/with_tizen.gni @@ -0,0 +1,22 @@ +# Copyright (c) 2021 Project CHIP Authors +# +# 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. + +# add this gni as import in your build args to use tizen in the example +# 'import("//with_tizen.gni")' + +import("//build_overrides/chip.gni") + +import("${chip_root}/config/tizen/chip-gn/args.gni") + +current_os = "tizen" diff --git a/scripts/examples/gn_tizen_example.sh b/scripts/examples/gn_tizen_example.sh new file mode 100755 index 00000000000000..9ebc47da0bfe0d --- /dev/null +++ b/scripts/examples/gn_tizen_example.sh @@ -0,0 +1,74 @@ +#!/usr/bin/env bash + +# +# Copyright (c) 2021 Project CHIP Authors +# +# 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. +# + +set -e + +# Build script for GN examples GitHub workflow. + +source "$(dirname "$0")/../../scripts/activate.sh" + +if [ -z "$TIZEN_HOME" ]; then + echo "TIZEN_HOME not set!" + exit 1 +fi + +GN_ARGS=() + +EXAMPLE_DIR=$1 +shift +OUTPUT_DIR=$1 +shift + +NINJA_ARGS=() +for arg; do + case $arg in + -v) + NINJA_ARGS+=(-v) + ;; + *=*) + GN_ARGS+=("$arg") + ;; + *import*) + GN_ARGS+=("$arg") + ;; + *) + echo >&2 "invalid argument: $arg" + echo >&2 "You can use -v for ninja args, and '=' or 'import' for gn args" + exit 2 + ;; + esac +done + +set -x +env + +PKG_CONFIG_SYSROOT_DIR=$TIZEN_HOME \ +PKG_CONFIG_LIBDIR=$TIZEN_HOME/usr/lib/pkgconfig \ +PKG_CONFIG_PATH=$TIZEN_HOME/usr/lib/pkgconfig \ +gn gen --check --fail-on-unused-args --root="$EXAMPLE_DIR" "$OUTPUT_DIR" --args=''$GN_ARGS' + target_os="tizen" + target_cpu="arm" arm_arch="armv7-a" + import("//build_overrides/build.gni") + target_cflags=[ "--sysroot='$TIZEN_HOME'" ] + target_ldflags=[ "--sysroot='$TIZEN_HOME'" ] + custom_toolchain="${build_root}/toolchain/custom" + target_cc="'$TIZEN_HOME'/bin/arm-linux-gnueabi-gcc" + target_cxx="'$TIZEN_HOME'/bin/arm-linux-gnueabi-g++" + target_ar="'$TIZEN_HOME'/bin/arm-linux-gnueabi-ar"' + +ninja -C "$OUTPUT_DIR" "${NINJA_ARGS[@]}" From c7bfe8e013fe5a0a8d18ef0dfb81a1a3ef36b61a Mon Sep 17 00:00:00 2001 From: Wootak Jung Date: Wed, 21 Jul 2021 14:02:25 +0900 Subject: [PATCH 04/14] Integrate Tizen OS into chip build system --- build/config/compiler/BUILD.gn | 4 ++-- src/platform/BUILD.gn | 15 +++++++++++++-- src/platform/device.gni | 13 +++++++++---- 3 files changed, 24 insertions(+), 8 deletions(-) diff --git a/build/config/compiler/BUILD.gn b/build/config/compiler/BUILD.gn index 02794d900e991a..9101fbb69746ae 100644 --- a/build/config/compiler/BUILD.gn +++ b/build/config/compiler/BUILD.gn @@ -191,7 +191,7 @@ config("warnings_common") { } if (current_os != "mac" && current_os != "ios" && current_os != "linux" && - current_os != "win") { + current_os != "win" && current_os != "tizen") { cflags += [ "-Wstack-usage=8192" ] } } @@ -268,7 +268,7 @@ config("runtime_default") { "$dir_pw_toolchain/host_clang:xcode_sysroot", ] } - if (current_os == "linux") { + if (current_os == "linux" || current_os == "tizen") { libs = [ "dl", "pthread", diff --git a/src/platform/BUILD.gn b/src/platform/BUILD.gn index 922d501fe6212b..6851ea87de97d1 100644 --- a/src/platform/BUILD.gn +++ b/src/platform/BUILD.gn @@ -61,7 +61,7 @@ if (chip_device_platform != "none") { } if (chip_stack_lock_tracking == "auto") { - if (chip_device_platform == "linux") { + if (chip_device_platform == "linux" || chip_device_platform == "tizen") { # TODO: should be fatal for development. Change once bugs are fixed chip_stack_lock_tracking = "log" } else { @@ -102,7 +102,7 @@ if (chip_device_platform != "none") { "CHIP_ENABLE_ROTATING_DEVICE_ID=${chip_enable_rotating_device_id}", ] - if (chip_device_platform == "linux" || chip_device_platform == "darwin") { + if (chip_device_platform == "linux" || chip_device_platform == "darwin" || chip_device_platform == "tizen") { defines += [ "CHIP_DEVICE_CONFIG_ENABLE_CHIPOBLE=${chip_enable_ble}" ] } @@ -154,6 +154,15 @@ if (chip_device_platform != "none") { "CHIP_DEVICE_LAYER_TARGET_LINUX=1", "CHIP_DEVICE_LAYER_TARGET=Linux", ] + } else if (chip_device_platform == "tizen") { + defines += [ + "CHIP_DEVICE_LAYER_TARGET_TIZEN=1", + "CHIP_DEVICE_LAYER_TARGET=Tizen", + "CHIP_DEVICE_CONFIG_ENABLE_WIFI=${chip_enable_wifi}", + ] + defines -= [ + "CHIP_DEVICE_CONFIG_ENABLE_WPA=${chip_device_config_enable_wpa}" + ] } else if (chip_device_platform == "nrfconnect") { defines += [ "CHIP_DEVICE_LAYER_TARGET_NRFCONNECT=1", @@ -295,6 +304,8 @@ if (chip_device_platform != "none") { _platform_target = "telink" } else if (chip_device_platform == "mbed") { _platform_target = "mbed" + } else if (chip_device_platform == "tizen") { + _platform_target = "Tizen" } else if (chip_device_platform == "external") { _platform_target = chip_platform_target } else if (chip_device_platform == "p6") { diff --git a/src/platform/device.gni b/src/platform/device.gni index cf10cbd4f3d2b4..b4b0758c27e069 100644 --- a/src/platform/device.gni +++ b/src/platform/device.gni @@ -16,7 +16,7 @@ import("//build_overrides/chip.gni") import("${chip_root}/src/ble/ble.gni") declare_args() { - # Device platform layer: cc13x2_26x2, darwin, efr32, esp32, external, freertos, linux, nrfconnect, k32w, qpg, none. + # Device platform layer: cc13x2_26x2, darwin, efr32, esp32, external, freertos, linux, nrfconnect, k32w, qpg, tizen, none. chip_device_platform = "auto" chip_platform_target = "" @@ -31,6 +31,8 @@ if (chip_device_platform == "auto") { chip_device_platform = "darwin" } else if (current_os == "linux") { chip_device_platform = "linux" + } else if (current_os == "tizen") { + chip_device_platform = "tizen" } else { chip_device_platform = "none" } @@ -45,7 +47,7 @@ declare_args() { # Enable wifi support. chip_enable_wifi = chip_device_platform == "linux" || chip_device_platform == "esp32" || - chip_device_platform == "mbed" + chip_device_platform == "mbed" || chip_device_platform == "tizen" # Enable ble support. if (chip_device_platform == "fake") { @@ -63,7 +65,8 @@ declare_args() { chip_mdns = "minimal" } else if (chip_device_platform == "darwin" || chip_device_platform == "cc13x2_26x2" || current_os == "android" || - chip_device_platform == "fake") { + chip_device_platform == "fake" || + chip_device_platform == "tizen") { chip_mdns = "platform" } else { chip_mdns = "none" @@ -84,6 +87,8 @@ if (chip_device_platform == "cc13x2_26x2") { _chip_device_layer = "ESP32" } else if (chip_device_platform == "linux") { _chip_device_layer = "Linux" +} else if (chip_device_platform == "tizen") { + _chip_device_layer = "Tizen" } else if (chip_device_platform == "nrfconnect") { _chip_device_layer = "nrfconnect" } else if (chip_device_platform == "qpg") { @@ -133,7 +138,7 @@ assert( chip_device_platform == "cc13x2_26x2" || chip_device_platform == "darwin" || chip_device_platform == "efr32" || chip_device_platform == "esp32" || chip_device_platform == "external" || - chip_device_platform == "linux" || + chip_device_platform == "linux" || chip_device_platform == "tizen" || chip_device_platform == "nrfconnect" || chip_device_platform == "k32w" || chip_device_platform == "qpg" || chip_device_platform == "telink" || chip_device_platform == "mbed" || From 167de3d71b3d87a582ffe4ba9098c5a456eec598 Mon Sep 17 00:00:00 2001 From: Wootak Jung Date: Tue, 27 Jul 2021 11:53:04 +0900 Subject: [PATCH 05/14] Add workflow to build Tizen OS examples --- .github/workflows/examples-tizen.yaml | 44 +++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) create mode 100644 .github/workflows/examples-tizen.yaml diff --git a/.github/workflows/examples-tizen.yaml b/.github/workflows/examples-tizen.yaml new file mode 100644 index 00000000000000..21bd7d398b7fe3 --- /dev/null +++ b/.github/workflows/examples-tizen.yaml @@ -0,0 +1,44 @@ +# Copyright (c) 2021 Project CHIP Authors +# +# 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. + +name: Build example - Tizen + +on: + push: + pull_request: + +jobs: + tizen: + name: Tizen + env: + BUILD_TYPE: tizen + + runs-on: ubuntu-latest + if: github.actor != 'restyled-io[bot]' + + container: + image: connectedhomeip/chip-build-tizen:latest + volumes: + - "/tmp/bloat_reports:/tmp/bloat_reports" + - "/tmp/output_binaries:/tmp/output_binaries" + + steps: + - name: Checkout + uses: actions/checkout@v2 + with: + submodules: true + - name: Build example Tizen lighting app + run: + scripts/examples/gn_tizen_example.sh examples/lighting-app/linux + out/lighting_app_tizen 'import("//with_tizen.gni")' From 60583e7a20b7d50f716862fe213490d26f1de0c3 Mon Sep 17 00:00:00 2001 From: Wootak Jung Date: Tue, 27 Jul 2021 11:53:48 +0900 Subject: [PATCH 06/14] Add VSCode task to build Tizen OS examples --- .vscode/tasks.json | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/.vscode/tasks.json b/.vscode/tasks.json index e016cb92af88c6..b4b60cc3c1fc6a 100644 --- a/.vscode/tasks.json +++ b/.vscode/tasks.json @@ -137,6 +137,19 @@ ] } }, + { + "label": "Build Lighting App (Tizen)", + "type": "shell", + "command": "scripts/examples/gn_tizen_example.sh examples/lighting-app/linux out/lighting_app_tizen 'import(\"//with_tizen.gni\")'", + "group": "build", + "problemMatcher": { + "base": "$gcc", + "fileLocation": [ + "relative", + "${workspaceFolder}/out/lighting-app-tizen/" + ] + } + }, { "label": "Build Minimal MDNS Example", "type": "shell", From 01a46ced6ce0a40e7b212e45a534ddb29eb8b25e Mon Sep 17 00:00:00 2001 From: Wootak Jung Date: Tue, 17 Aug 2021 12:27:22 +0900 Subject: [PATCH 07/14] Add tizen.py to build Tizen OS examples replace gn_tizen_example.sh to build_exmaples.py remove unused gn_tizen_example.sh --- .github/workflows/examples-tizen.yaml | 4 +- .vscode/tasks.json | 5 +- scripts/build/build/factory.py | 4 + scripts/build/build/targets.py | 4 + scripts/build/builders/tizen.py | 80 +++++++++++++++++++ .../build/expected_all_platform_commands.txt | 6 ++ scripts/build/test.py | 1 + scripts/examples/gn_tizen_example.sh | 74 ----------------- 8 files changed, 101 insertions(+), 77 deletions(-) create mode 100644 scripts/build/builders/tizen.py delete mode 100755 scripts/examples/gn_tizen_example.sh diff --git a/.github/workflows/examples-tizen.yaml b/.github/workflows/examples-tizen.yaml index 21bd7d398b7fe3..879baa17101d22 100644 --- a/.github/workflows/examples-tizen.yaml +++ b/.github/workflows/examples-tizen.yaml @@ -29,6 +29,7 @@ jobs: container: image: connectedhomeip/chip-build-tizen:latest + options: --user root volumes: - "/tmp/bloat_reports:/tmp/bloat_reports" - "/tmp/output_binaries:/tmp/output_binaries" @@ -40,5 +41,4 @@ jobs: submodules: true - name: Build example Tizen lighting app run: - scripts/examples/gn_tizen_example.sh examples/lighting-app/linux - out/lighting_app_tizen 'import("//with_tizen.gni")' + scripts/run_in_build_env.sh "./scripts/build/build_examples.py --platform tizen build" diff --git a/.vscode/tasks.json b/.vscode/tasks.json index b4b60cc3c1fc6a..0a2a4a484795a8 100644 --- a/.vscode/tasks.json +++ b/.vscode/tasks.json @@ -140,7 +140,10 @@ { "label": "Build Lighting App (Tizen)", "type": "shell", - "command": "scripts/examples/gn_tizen_example.sh examples/lighting-app/linux out/lighting_app_tizen 'import(\"//with_tizen.gni\")'", + "command": "scripts/run_in_build_env.sh", + "args": [ + "./scripts/build/build_examples.py --platform tizen build" + ], "group": "build", "problemMatcher": { "base": "$gcc", diff --git a/scripts/build/build/factory.py b/scripts/build/build/factory.py index 5994e154481256..70bdf4735ae6b7 100644 --- a/scripts/build/build/factory.py +++ b/scripts/build/build/factory.py @@ -22,6 +22,7 @@ from builders.qpg import QpgBuilder from builders.infineon import InfineonBuilder, InfineonApp, InfineonBoard from builders.telink import TelinkApp, TelinkBoard, TelinkBuilder +from builders.tizen import TizenBuilder, TizenApp from .targets import Application, Board, Platform @@ -87,6 +88,7 @@ def Create(self, runner, __board_key: Board, __app_key: Application, Platform.ANDROID: Matcher(AndroidBuilder), Platform.INFINEON: Matcher(InfineonBuilder), Platform.TELINK: Matcher(TelinkBuilder), + Platform.TIZEN: Matcher(TizenBuilder), } # Matrix of what can be compiled and what build options are required @@ -150,6 +152,8 @@ def Create(self, runner, __board_key: Board, __app_key: Application, _MATCHERS[Platform.INFINEON].AcceptBoard( Board.P6BOARD, board=InfineonBoard.P6BOARD) +_MATCHERS[Platform.TIZEN].AcceptBoard(Board.TIZEN) +_MATCHERS[Platform.TIZEN].AcceptApplication(Application.LIGHT, app=TizenApp.LIGHT) class BuilderFactory: """Creates application builders.""" diff --git a/scripts/build/build/targets.py b/scripts/build/build/targets.py index b387b9b40ba5e4..ece875364851e3 100644 --- a/scripts/build/build/targets.py +++ b/scripts/build/build/targets.py @@ -25,6 +25,7 @@ class Platform(IntEnum): ANDROID = auto() INFINEON = auto() TELINK = auto() + TIZEN = auto() @property def ArgName(self): @@ -69,6 +70,9 @@ class Board(IntEnum): # Infineon board P6BOARD = auto() + # Tizen platform + TIZEN = auto() + @property def ArgName(self): return self.name.lower() diff --git a/scripts/build/builders/tizen.py b/scripts/build/builders/tizen.py new file mode 100644 index 00000000000000..e14aef49b84da2 --- /dev/null +++ b/scripts/build/builders/tizen.py @@ -0,0 +1,80 @@ +# Copyright (c) 2021 Project CHIP Authors +# +# 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. + +import logging +import os +from enum import Enum, auto + +from .gn import GnBuilder + + +class TizenApp(Enum): + LIGHT = auto() + + def ExampleName(self): + if self == TizenApp.LIGHT: + return 'lighting-app' + else: + raise Exception('Unknown app type: %r' % self) + + def AppNamePrefix(self): + if self == TizenApp.LIGHT: + return 'chip-tizen-lighting-example' + else: + raise Exception('Unknown app type: %r' % self) + + def FlashBundleName(self): + if self == TizenApp.LIGHT: + return 'lighting_app.flashbundle.txt' + else: + raise Exception('Unknown app type: %r' % self) + + +class TizenBuilder(GnBuilder): + + def __init__(self, + root, + runner, + output_prefix: str, + app: TizenApp = TizenApp.LIGHT): + super(TizenBuilder, self).__init__( + root=os.path.join(root, 'examples', app.ExampleName(), 'linux'), + runner=runner, + output_prefix=output_prefix) + + self.app = app + tizen_home = os.environ['TIZEN_HOME'] + os.environ['PKG_CONFIG_SYSROOT_DIR'] = tizen_home + os.environ['PKG_CONFIG_LIBDIR'] = tizen_home + '/usr/lib/pkgconfig' + os.environ['PKG_CONFIG_PATH'] = tizen_home + '/usr/lib/pkgconfig' + self.gn_build_args = ['target_os="tizen" target_cpu="arm" arm_arch="armv7-a" import("//build_overrides/build.gni") target_cflags=[ "--sysroot=' + tizen_home + '" ] target_ldflags=[ "--sysroot=' + tizen_home + '" ] custom_toolchain="${build_root}/toolchain/custom" target_cc="' + tizen_home + '/bin/arm-linux-gnueabi-gcc" target_cxx="' + tizen_home + '/bin/arm-linux-gnueabi-g++" target_ar="' + tizen_home + '/bin/arm-linux-gnueabi-ar"'] + + def build_outputs(self): + items = { + '%s.out' % self.app.AppNamePrefix(): + os.path.join(self.output_dir, '%s.out' % + self.app.AppNamePrefix()), + '%s.out.map' % self.app.AppNamePrefix(): + os.path.join(self.output_dir, + '%s.out.map' % self.app.AppNamePrefix()), + } + + # Figure out flash bundle files and build accordingly + with open(os.path.join(self.output_dir, self.app.FlashBundleName())) as f: + for line in f.readlines(): + name = line.strip() + items['flashbundle/%s' % + name] = os.path.join(self.output_dir, name) + + return items diff --git a/scripts/build/expected_all_platform_commands.txt b/scripts/build/expected_all_platform_commands.txt index ea46522dd91431..f9f3add3f2c693 100644 --- a/scripts/build/expected_all_platform_commands.txt +++ b/scripts/build/expected_all_platform_commands.txt @@ -132,6 +132,9 @@ export ZEPHYR_SDK_INSTALL_DIR="$ZEPHYR_BASE/../../zephyr-sdk-0.13.0" source "$ZEPHYR_BASE/zephyr-env.sh"; west build --cmake-only -d {out}/telink-tlsr9518adk80d-light -b tlsr9518adk80d {root}/examples/lighting-app/telink' +# Generating tizen-tizen-light +gn gen --check --fail-on-unused-args --root={root}/examples/lighting-app/linux '--args=target_os="tizen" target_cpu="arm" arm_arch="armv7-a" import("//build_overrides/build.gni") target_cflags=[ "--sysroot=TEST_TIZEN_HOME" ] target_ldflags=[ "--sysroot=TEST_TIZEN_HOME" ] custom_toolchain="${build_root}/toolchain/custom" target_cc="TEST_TIZEN_HOME/bin/arm-linux-gnueabi-gcc" target_cxx="TEST_TIZEN_HOME/bin/arm-linux-gnueabi-g++" target_ar="TEST_TIZEN_HOME/bin/arm-linux-gnueabi-ar"' {out}/tizen-tizen-light + # Building {real_platform}-native-all_clusters ninja -C {out}/{real_platform}-native-all_clusters @@ -255,4 +258,7 @@ ninja -C {out}/infineon-p6board-lock # Building telink-tlsr9518adk80d-light ninja -C {out}/telink-tlsr9518adk80d-light +# Building tizen-tizen-light +ninja -C {out}/tizen-tizen-light + diff --git a/scripts/build/test.py b/scripts/build/test.py index 2266e8fac5a4f5..b6f7a6d94a7ea6 100644 --- a/scripts/build/test.py +++ b/scripts/build/test.py @@ -46,6 +46,7 @@ def build_actual_output(root: str, out: str) -> List[str]: 'PW_PROJECT_ROOT': root, 'ANDROID_NDK_HOME': 'TEST_ANDROID_NDK_HOME', 'ANDROID_HOME': 'TEST_ANDROID_HOME', + 'TIZEN_HOME': 'TEST_TIZEN_HOME', }) retval = subprocess.run([ diff --git a/scripts/examples/gn_tizen_example.sh b/scripts/examples/gn_tizen_example.sh deleted file mode 100755 index 9ebc47da0bfe0d..00000000000000 --- a/scripts/examples/gn_tizen_example.sh +++ /dev/null @@ -1,74 +0,0 @@ -#!/usr/bin/env bash - -# -# Copyright (c) 2021 Project CHIP Authors -# -# 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. -# - -set -e - -# Build script for GN examples GitHub workflow. - -source "$(dirname "$0")/../../scripts/activate.sh" - -if [ -z "$TIZEN_HOME" ]; then - echo "TIZEN_HOME not set!" - exit 1 -fi - -GN_ARGS=() - -EXAMPLE_DIR=$1 -shift -OUTPUT_DIR=$1 -shift - -NINJA_ARGS=() -for arg; do - case $arg in - -v) - NINJA_ARGS+=(-v) - ;; - *=*) - GN_ARGS+=("$arg") - ;; - *import*) - GN_ARGS+=("$arg") - ;; - *) - echo >&2 "invalid argument: $arg" - echo >&2 "You can use -v for ninja args, and '=' or 'import' for gn args" - exit 2 - ;; - esac -done - -set -x -env - -PKG_CONFIG_SYSROOT_DIR=$TIZEN_HOME \ -PKG_CONFIG_LIBDIR=$TIZEN_HOME/usr/lib/pkgconfig \ -PKG_CONFIG_PATH=$TIZEN_HOME/usr/lib/pkgconfig \ -gn gen --check --fail-on-unused-args --root="$EXAMPLE_DIR" "$OUTPUT_DIR" --args=''$GN_ARGS' - target_os="tizen" - target_cpu="arm" arm_arch="armv7-a" - import("//build_overrides/build.gni") - target_cflags=[ "--sysroot='$TIZEN_HOME'" ] - target_ldflags=[ "--sysroot='$TIZEN_HOME'" ] - custom_toolchain="${build_root}/toolchain/custom" - target_cc="'$TIZEN_HOME'/bin/arm-linux-gnueabi-gcc" - target_cxx="'$TIZEN_HOME'/bin/arm-linux-gnueabi-g++" - target_ar="'$TIZEN_HOME'/bin/arm-linux-gnueabi-ar"' - -ninja -C "$OUTPUT_DIR" "${NINJA_ARGS[@]}" From 069a4f73ed0de2f7eaa3b764afb1d7fca85bc90c Mon Sep 17 00:00:00 2001 From: Wootak Jung Date: Fri, 20 Aug 2021 10:48:04 +0900 Subject: [PATCH 08/14] Apply restyle script --- config/tizen/chip-gn/args.gni | 1 - config/tizen/chip-gn/platform/BUILD.gn | 2 +- config/tizen/scripts/install_sdk.sh | 22 ++++++++--------- scripts/build/build/factory.py | 4 +++- scripts/build/builders/tizen.py | 3 ++- src/platform/BUILD.gn | 8 +++---- src/platform/Tizen/BLEManagerImpl.cpp | 8 ++----- src/platform/Tizen/BUILD.gn | 8 ++----- .../Tizen/ConfigurationManagerImpl.cpp | 4 +--- .../Tizen/ConnectivityManagerImpl.cpp | 24 +++++-------------- src/platform/Tizen/Logging.cpp | 6 +++-- src/platform/Tizen/MdnsImpl.cpp | 10 ++------ src/platform/Tizen/PosixConfig.cpp | 5 +--- 13 files changed, 38 insertions(+), 67 deletions(-) diff --git a/config/tizen/chip-gn/args.gni b/config/tizen/chip-gn/args.gni index 16eedd229e9ea2..b344bf8ff37db7 100644 --- a/config/tizen/chip-gn/args.gni +++ b/config/tizen/chip-gn/args.gni @@ -23,6 +23,5 @@ chip_device_platform = "tizen" chip_build_tests = false - chip_inet_config_enable_raw_endpoint = false chip_inet_config_enable_dns_resolver = false diff --git a/config/tizen/chip-gn/platform/BUILD.gn b/config/tizen/chip-gn/platform/BUILD.gn index 0c300253b71807..c669ba3e2577a3 100644 --- a/config/tizen/chip-gn/platform/BUILD.gn +++ b/config/tizen/chip-gn/platform/BUILD.gn @@ -33,7 +33,7 @@ config("tizen_sdk_config") { packages = [ "glib-2.0", "gio-unix-2.0", - ] + ] } if (chip_mdns != "none") { diff --git a/config/tizen/scripts/install_sdk.sh b/config/tizen/scripts/install_sdk.sh index a9aa3e2ef76416..7d9facad97a239 100755 --- a/config/tizen/scripts/install_sdk.sh +++ b/config/tizen/scripts/install_sdk.sh @@ -1,11 +1,11 @@ #!/bin/bash ROOTSTRAP_PATH="$1" -CHIPROOT=`git rev-parse --show-toplevel` +CHIPROOT=$(git rev-parse --show-toplevel) NSD_DNS_LIBS="libnsd-dns-sd.so*" -echo $ROOTSTRAP_PATH +echo "$ROOTSTRAP_PATH" if [ -z "$ROOTSTRAP_PATH" ]; then echo "ROOTSTRAP_PATH should be input" @@ -17,7 +17,7 @@ if [[ ! -d $ROOTSTRAP_PATH ]]; then exit 1 fi -cd $ROOTSTRAP_PATH +cd "$ROOTSTRAP_PATH" # Get Tizen rootstrap if [[ ! -f mobile-6.0-rs-device.core_0.0.123_ubuntu-64.zip ]]; then @@ -36,12 +36,11 @@ rm pkginfo.manifest # Copy internal dns-sd header into rootstrap # After finishing ACR for internal APIs, we will remove this. -rm $ROOTSTRAP_PATH/usr/lib/$NSD_DNS_LIBS +rm "$ROOTSTRAP_PATH/usr/lib/$NSD_DNS_LIBS" # Get tizen packages -function download_pkg { - if [ "$2" = "snapshots" ] - then +function download_pkg() { + if [ "$2" = "snapshots" ]; then wget -r -nd --no-parent -A "$1" "http://download.tizen.org/snapshots/tizen/unified/latest/repos/standard/packages/armv7l/" else wget -r -nd --no-parent -A "$1" "http://download.tizen.org/releases/milestone/tizen/${2:-base}/latest/repos/standard/packages/armv7l/" @@ -50,15 +49,15 @@ function download_pkg { # Base package for pkg in 'pcre-devel-*.armv7l.rpm' 'libffi-devel-*.armv7l.rpm' 'libmount-devel-*.armv7l.rpm' \ - 'libblkid-devel-*.armv7l.rpm' 'libcap-*.armv7l.rpm' 'liblzma-*.armv7l.rpm' ; do + 'libblkid-devel-*.armv7l.rpm' 'libcap-*.armv7l.rpm' 'liblzma-*.armv7l.rpm'; do download_pkg "$pkg" done # Unified package for pkg in 'vconf-compat-*.armv7l.rpm' 'libcynara-commons-*.armv7l.rpm' 'cynara-devel-*.armv7l.rpm' \ - 'libcynara-client-*.armv7l.rpm' 'dbus-1*.armv7l.rpm' 'dbus-devel-*.armv7l.rpm' \ - 'dbus-libs-1*.armv7l.rpm' 'glib2-devel-2*.armv7l.rpm' 'libdns_sd-*.armv7l.rpm' \ - 'buxton2-*.armv7l.rpm' 'libsystemd-*.armv7l.rpm'; do + 'libcynara-client-*.armv7l.rpm' 'dbus-1*.armv7l.rpm' 'dbus-devel-*.armv7l.rpm' \ + 'dbus-libs-1*.armv7l.rpm' 'glib2-devel-2*.armv7l.rpm' 'libdns_sd-*.armv7l.rpm' \ + 'buxton2-*.armv7l.rpm' 'libsystemd-*.armv7l.rpm'; do download_pkg "$pkg" unified done @@ -87,4 +86,3 @@ rm changelog rm -rf data rm cross-arm-gcc-9.2_0.1.9_ubuntu-64.zip - diff --git a/scripts/build/build/factory.py b/scripts/build/build/factory.py index 70bdf4735ae6b7..d4c93cba27ebc1 100644 --- a/scripts/build/build/factory.py +++ b/scripts/build/build/factory.py @@ -153,7 +153,9 @@ def Create(self, runner, __board_key: Board, __app_key: Application, Board.P6BOARD, board=InfineonBoard.P6BOARD) _MATCHERS[Platform.TIZEN].AcceptBoard(Board.TIZEN) -_MATCHERS[Platform.TIZEN].AcceptApplication(Application.LIGHT, app=TizenApp.LIGHT) +_MATCHERS[Platform.TIZEN].AcceptApplication( + Application.LIGHT, app=TizenApp.LIGHT) + class BuilderFactory: """Creates application builders.""" diff --git a/scripts/build/builders/tizen.py b/scripts/build/builders/tizen.py index e14aef49b84da2..2437e9dfdf63ed 100644 --- a/scripts/build/builders/tizen.py +++ b/scripts/build/builders/tizen.py @@ -58,7 +58,8 @@ def __init__(self, os.environ['PKG_CONFIG_SYSROOT_DIR'] = tizen_home os.environ['PKG_CONFIG_LIBDIR'] = tizen_home + '/usr/lib/pkgconfig' os.environ['PKG_CONFIG_PATH'] = tizen_home + '/usr/lib/pkgconfig' - self.gn_build_args = ['target_os="tizen" target_cpu="arm" arm_arch="armv7-a" import("//build_overrides/build.gni") target_cflags=[ "--sysroot=' + tizen_home + '" ] target_ldflags=[ "--sysroot=' + tizen_home + '" ] custom_toolchain="${build_root}/toolchain/custom" target_cc="' + tizen_home + '/bin/arm-linux-gnueabi-gcc" target_cxx="' + tizen_home + '/bin/arm-linux-gnueabi-g++" target_ar="' + tizen_home + '/bin/arm-linux-gnueabi-ar"'] + self.gn_build_args = ['target_os="tizen" target_cpu="arm" arm_arch="armv7-a" import("//build_overrides/build.gni") target_cflags=[ "--sysroot=' + tizen_home + '" ] target_ldflags=[ "--sysroot=' + tizen_home + + '" ] custom_toolchain="${build_root}/toolchain/custom" target_cc="' + tizen_home + '/bin/arm-linux-gnueabi-gcc" target_cxx="' + tizen_home + '/bin/arm-linux-gnueabi-g++" target_ar="' + tizen_home + '/bin/arm-linux-gnueabi-ar"'] def build_outputs(self): items = { diff --git a/src/platform/BUILD.gn b/src/platform/BUILD.gn index 6851ea87de97d1..9e1de6c6cd129e 100644 --- a/src/platform/BUILD.gn +++ b/src/platform/BUILD.gn @@ -102,7 +102,8 @@ if (chip_device_platform != "none") { "CHIP_ENABLE_ROTATING_DEVICE_ID=${chip_enable_rotating_device_id}", ] - if (chip_device_platform == "linux" || chip_device_platform == "darwin" || chip_device_platform == "tizen") { + if (chip_device_platform == "linux" || chip_device_platform == "darwin" || + chip_device_platform == "tizen") { defines += [ "CHIP_DEVICE_CONFIG_ENABLE_CHIPOBLE=${chip_enable_ble}" ] } @@ -160,9 +161,8 @@ if (chip_device_platform != "none") { "CHIP_DEVICE_LAYER_TARGET=Tizen", "CHIP_DEVICE_CONFIG_ENABLE_WIFI=${chip_enable_wifi}", ] - defines -= [ - "CHIP_DEVICE_CONFIG_ENABLE_WPA=${chip_device_config_enable_wpa}" - ] + defines -= + [ "CHIP_DEVICE_CONFIG_ENABLE_WPA=${chip_device_config_enable_wpa}" ] } else if (chip_device_platform == "nrfconnect") { defines += [ "CHIP_DEVICE_LAYER_TARGET_NRFCONNECT=1", diff --git a/src/platform/Tizen/BLEManagerImpl.cpp b/src/platform/Tizen/BLEManagerImpl.cpp index 23436edc439928..86c22200b6ada9 100644 --- a/src/platform/Tizen/BLEManagerImpl.cpp +++ b/src/platform/Tizen/BLEManagerImpl.cpp @@ -78,9 +78,7 @@ CHIP_ERROR BLEManagerImpl::ConfigureBle(uint32_t aAdapterId, bool aIsCentral) return CHIP_ERROR_NOT_IMPLEMENTED; } -void BLEManagerImpl::_OnPlatformEvent(const ChipDeviceEvent * event) -{ -} +void BLEManagerImpl::_OnPlatformEvent(const ChipDeviceEvent * event) {} uint16_t BLEManagerImpl::GetMTU(BLE_CONNECTION_OBJECT conId) const { @@ -126,9 +124,7 @@ bool BLEManagerImpl::SendReadResponse(BLE_CONNECTION_OBJECT conId, BLE_READ_REQU return false; } -void BLEManagerImpl::NotifyChipConnectionClosed(BLE_CONNECTION_OBJECT conId) -{ -} +void BLEManagerImpl::NotifyChipConnectionClosed(BLE_CONNECTION_OBJECT conId) {} } // namespace Internal } // namespace DeviceLayer diff --git a/src/platform/Tizen/BUILD.gn b/src/platform/Tizen/BUILD.gn index 07db356fd7d15d..383ea6c99c4562 100644 --- a/src/platform/Tizen/BUILD.gn +++ b/src/platform/Tizen/BUILD.gn @@ -52,18 +52,14 @@ static_library("Tizen") { deps = [ "${chip_root}/src/setup_payload" ] - public_deps = [ - "${chip_root}/src/platform:platform_base", - ] + public_deps = [ "${chip_root}/src/platform:platform_base" ] public_deps += [ "${chip_root}/${tizen_root}:tizen" ] public_configs = [] if (chip_mdns != "none") { - sources += [ - "MdnsImpl.cpp", - ] + sources += [ "MdnsImpl.cpp" ] deps += [ "${chip_root}/src/lib/mdns:platform_header" ] } diff --git a/src/platform/Tizen/ConfigurationManagerImpl.cpp b/src/platform/Tizen/ConfigurationManagerImpl.cpp index aa201953f4f4a7..2f1e1d730c7f7b 100644 --- a/src/platform/Tizen/ConfigurationManagerImpl.cpp +++ b/src/platform/Tizen/ConfigurationManagerImpl.cpp @@ -63,9 +63,7 @@ bool ConfigurationManagerImpl::_CanFactoryReset(void) return true; } -void ConfigurationManagerImpl::_InitiateFactoryReset(void) -{ -} +void ConfigurationManagerImpl::_InitiateFactoryReset(void) {} CHIP_ERROR ConfigurationManagerImpl::_ReadPersistedStorageValue(::chip::Platform::PersistedStorage::Key key, uint32_t & value) { diff --git a/src/platform/Tizen/ConnectivityManagerImpl.cpp b/src/platform/Tizen/ConnectivityManagerImpl.cpp index aae851785e14dd..5bb3e016532a89 100644 --- a/src/platform/Tizen/ConnectivityManagerImpl.cpp +++ b/src/platform/Tizen/ConnectivityManagerImpl.cpp @@ -54,9 +54,7 @@ CHIP_ERROR ConnectivityManagerImpl::_Init(void) return err; } -void ConnectivityManagerImpl::_OnPlatformEvent(const ChipDeviceEvent * event) -{ -} +void ConnectivityManagerImpl::_OnPlatformEvent(const ChipDeviceEvent * event) {} #if CHIP_DEVICE_CONFIG_ENABLE_WIFI bool ConnectivityManagerImpl::_HaveIPv4InternetConnectivity(void) @@ -109,9 +107,7 @@ bool ConnectivityManagerImpl::_IsWiFiStationProvisioned(void) return false; } -void ConnectivityManagerImpl::_ClearWiFiStationProvision(void) -{ -} +void ConnectivityManagerImpl::_ClearWiFiStationProvision(void) {} bool ConnectivityManagerImpl::_CanStartWiFiScan(void) { @@ -123,21 +119,13 @@ CHIP_ERROR ConnectivityManagerImpl::_SetWiFiAPMode(WiFiAPMode val) return CHIP_ERROR_NOT_IMPLEMENTED; } -void ConnectivityManagerImpl::_DemandStartWiFiAP(void) -{ -} +void ConnectivityManagerImpl::_DemandStartWiFiAP(void) {} -void ConnectivityManagerImpl::_StopOnDemandWiFiAP(void) -{ -} +void ConnectivityManagerImpl::_StopOnDemandWiFiAP(void) {} -void ConnectivityManagerImpl::_MaintainOnDemandWiFiAP(void) -{ -} +void ConnectivityManagerImpl::_MaintainOnDemandWiFiAP(void) {} -void ConnectivityManagerImpl::_SetWiFiAPIdleTimeoutMS(uint32_t val) -{ -} +void ConnectivityManagerImpl::_SetWiFiAPIdleTimeoutMS(uint32_t val) {} #endif // CHIP_DEVICE_CONFIG_ENABLE_WIFI CHIP_ERROR ConnectivityManagerImpl::ProvisionWiFiNetwork(const char * ssid, const char * key) diff --git a/src/platform/Tizen/Logging.cpp b/src/platform/Tizen/Logging.cpp index 01bf77a4722f2e..c77bde55ef13e8 100644 --- a/src/platform/Tizen/Logging.cpp +++ b/src/platform/Tizen/Logging.cpp @@ -20,8 +20,8 @@ #include #include -#include #include +#include #ifdef LOG_TAG #undef LOG_TAG @@ -47,7 +47,9 @@ namespace Platform { */ void LogV(const char * module, uint8_t category, const char * msg, va_list v) { - char msgBuf[CHIP_CONFIG_LOG_MESSAGE_MAX_SIZE] = { 0, }; + char msgBuf[CHIP_CONFIG_LOG_MESSAGE_MAX_SIZE] = { + 0, + }; vsnprintf(msgBuf, sizeof(msgBuf), msg, v); switch (category) diff --git a/src/platform/Tizen/MdnsImpl.cpp b/src/platform/Tizen/MdnsImpl.cpp index ebfa9c71fe1d00..db50f0b1c4295c 100644 --- a/src/platform/Tizen/MdnsImpl.cpp +++ b/src/platform/Tizen/MdnsImpl.cpp @@ -57,15 +57,9 @@ CHIP_ERROR ChipMdnsResolve(MdnsService * service, chip::Inet::InterfaceId interf return CHIP_ERROR_NOT_IMPLEMENTED; } -void GetMdnsTimeout(timeval & timeout) -{ - -} +void GetMdnsTimeout(timeval & timeout) {} -void HandleMdnsTimeout() -{ - -} +void HandleMdnsTimeout() {} } // namespace Mdns } // namespace chip diff --git a/src/platform/Tizen/PosixConfig.cpp b/src/platform/Tizen/PosixConfig.cpp index c1019da0efed7e..ebb5a8a1802b4e 100644 --- a/src/platform/Tizen/PosixConfig.cpp +++ b/src/platform/Tizen/PosixConfig.cpp @@ -159,10 +159,7 @@ CHIP_ERROR PosixConfig::FactoryResetConfig() return CHIP_ERROR_NOT_IMPLEMENTED; } -void PosixConfig::RunConfigUnitTest() -{ - -} +void PosixConfig::RunConfigUnitTest() {} } // namespace Internal } // namespace DeviceLayer From fbb71cc089d7ec38c632bab43dd125a0cefa3e36 Mon Sep 17 00:00:00 2001 From: Wootak Jung Date: Tue, 24 Aug 2021 11:05:45 +0900 Subject: [PATCH 09/14] Apply comments --- .vscode/tasks.json | 19 +------ config/tizen/chip-gn/platform/BUILD.gn | 4 +- scripts/build/builders/tizen.py | 57 ++++++++++++------- .../build/expected_all_platform_commands.txt | 5 +- src/platform/Tizen/BUILD.gn | 9 +-- .../Tizen/ConfigurationManagerImpl.cpp | 9 +-- src/platform/Tizen/Logging.cpp | 22 ++----- src/platform/Tizen/PlatformManagerImpl.cpp | 15 +---- 8 files changed, 56 insertions(+), 84 deletions(-) diff --git a/.vscode/tasks.json b/.vscode/tasks.json index 0a2a4a484795a8..198ae68b91685b 100644 --- a/.vscode/tasks.json +++ b/.vscode/tasks.json @@ -137,22 +137,6 @@ ] } }, - { - "label": "Build Lighting App (Tizen)", - "type": "shell", - "command": "scripts/run_in_build_env.sh", - "args": [ - "./scripts/build/build_examples.py --platform tizen build" - ], - "group": "build", - "problemMatcher": { - "base": "$gcc", - "fileLocation": [ - "relative", - "${workspaceFolder}/out/lighting-app-tizen/" - ] - } - }, { "label": "Build Minimal MDNS Example", "type": "shell", @@ -294,7 +278,8 @@ "nrf", "qpg", "infineon", - "telink" + "telink", + "tizen" ], "default": "build" }, diff --git a/config/tizen/chip-gn/platform/BUILD.gn b/config/tizen/chip-gn/platform/BUILD.gn index c669ba3e2577a3..06ce25bf91037b 100644 --- a/config/tizen/chip-gn/platform/BUILD.gn +++ b/config/tizen/chip-gn/platform/BUILD.gn @@ -36,7 +36,7 @@ config("tizen_sdk_config") { ] } - if (chip_mdns != "none") { + if (chip_mdns == "platform") { pkg_config("nsd-dns-sd") { packages = [ "nsd-dns-sd" ] } @@ -67,7 +67,7 @@ source_set("tizen") { ":capi-appfw-preference", ] - if (chip_mdns != "none") { + if (chip_mdns == "platform") { public_configs += [ ":nsd-dns-sd" ] } diff --git a/scripts/build/builders/tizen.py b/scripts/build/builders/tizen.py index 2437e9dfdf63ed..fcfd3c7a162044 100644 --- a/scripts/build/builders/tizen.py +++ b/scripts/build/builders/tizen.py @@ -14,9 +14,11 @@ import logging import os +import shlex + from enum import Enum, auto -from .gn import GnBuilder +from .builder import Builder class TizenApp(Enum): @@ -34,14 +36,8 @@ def AppNamePrefix(self): else: raise Exception('Unknown app type: %r' % self) - def FlashBundleName(self): - if self == TizenApp.LIGHT: - return 'lighting_app.flashbundle.txt' - else: - raise Exception('Unknown app type: %r' % self) - -class TizenBuilder(GnBuilder): +class TizenBuilder(Builder): def __init__(self, root, @@ -52,14 +48,38 @@ def __init__(self, root=os.path.join(root, 'examples', app.ExampleName(), 'linux'), runner=runner, output_prefix=output_prefix) - self.app = app - tizen_home = os.environ['TIZEN_HOME'] - os.environ['PKG_CONFIG_SYSROOT_DIR'] = tizen_home - os.environ['PKG_CONFIG_LIBDIR'] = tizen_home + '/usr/lib/pkgconfig' - os.environ['PKG_CONFIG_PATH'] = tizen_home + '/usr/lib/pkgconfig' - self.gn_build_args = ['target_os="tizen" target_cpu="arm" arm_arch="armv7-a" import("//build_overrides/build.gni") target_cflags=[ "--sysroot=' + tizen_home + '" ] target_ldflags=[ "--sysroot=' + tizen_home + - '" ] custom_toolchain="${build_root}/toolchain/custom" target_cc="' + tizen_home + '/bin/arm-linux-gnueabi-gcc" target_cxx="' + tizen_home + '/bin/arm-linux-gnueabi-g++" target_ar="' + tizen_home + '/bin/arm-linux-gnueabi-ar"'] + + def generate(self): + if not os.path.exists(self.output_dir): + if not self._runner.dry_run: + if 'TIZEN_HOME' not in os.environ: + raise Exception( + "Environment TIZEN_HOME missing, cannot build tizen libraries") + + tizen_home = os.environ['TIZEN_HOME'] + cmd = '''\ +export PKG_CONFIG_SYSROOT_DIR=$TIZEN_HOME; +export PKG_CONFIG_LIBDIR=$TIZEN_HOME/usr/lib/pkgconfig; +export PKG_CONFIG_PATH=$TIZEN_HOME/usr/lib/pkgconfig; +gn gen --check --fail-on-unused-args --root=%s '--args=target_os="tizen" \ +target_cpu="arm" arm_arch="armv7-a" import("//build_overrides/build.gni") \ +target_cflags=[ "--sysroot=%s", "-Wno-sign-compare" ] \ +target_ldflags=[ "--sysroot=%s" ] \ +custom_toolchain="${build_root}/toolchain/custom" \ +target_cc="%s/bin/arm-linux-gnueabi-gcc" \ +target_cxx="%s/bin/arm-linux-gnueabi-g++" \ +target_ar="%s/bin/arm-linux-gnueabi-ar"' %s''' % ( + self.root, tizen_home, tizen_home, tizen_home, tizen_home, tizen_home, self.output_dir) + + self._Execute(['bash', '-c', cmd], + title='Generating ' + self.identifier) + + def _build(self): + logging.info('Compiling Telink at %s', self.output_dir) + + self._Execute(['ninja', '-C', self.output_dir], + title='Building ' + self.identifier) def build_outputs(self): items = { @@ -71,11 +91,4 @@ def build_outputs(self): '%s.out.map' % self.app.AppNamePrefix()), } - # Figure out flash bundle files and build accordingly - with open(os.path.join(self.output_dir, self.app.FlashBundleName())) as f: - for line in f.readlines(): - name = line.strip() - items['flashbundle/%s' % - name] = os.path.join(self.output_dir, name) - return items diff --git a/scripts/build/expected_all_platform_commands.txt b/scripts/build/expected_all_platform_commands.txt index f9f3add3f2c693..f32894e13ff0c4 100644 --- a/scripts/build/expected_all_platform_commands.txt +++ b/scripts/build/expected_all_platform_commands.txt @@ -133,7 +133,10 @@ source "$ZEPHYR_BASE/zephyr-env.sh"; west build --cmake-only -d {out}/telink-tlsr9518adk80d-light -b tlsr9518adk80d {root}/examples/lighting-app/telink' # Generating tizen-tizen-light -gn gen --check --fail-on-unused-args --root={root}/examples/lighting-app/linux '--args=target_os="tizen" target_cpu="arm" arm_arch="armv7-a" import("//build_overrides/build.gni") target_cflags=[ "--sysroot=TEST_TIZEN_HOME" ] target_ldflags=[ "--sysroot=TEST_TIZEN_HOME" ] custom_toolchain="${build_root}/toolchain/custom" target_cc="TEST_TIZEN_HOME/bin/arm-linux-gnueabi-gcc" target_cxx="TEST_TIZEN_HOME/bin/arm-linux-gnueabi-g++" target_ar="TEST_TIZEN_HOME/bin/arm-linux-gnueabi-ar"' {out}/tizen-tizen-light +bash -c 'export PKG_CONFIG_SYSROOT_DIR=$TIZEN_HOME; +export PKG_CONFIG_LIBDIR=$TIZEN_HOME/usr/lib/pkgconfig; +export PKG_CONFIG_PATH=$TIZEN_HOME/usr/lib/pkgconfig; +gn gen --check --fail-on-unused-args --root={root}/examples/lighting-app/linux '"'"'--args=target_os="tizen" target_cpu="arm" arm_arch="armv7-a" import("//build_overrides/build.gni") target_cflags=[ "--sysroot=TEST_TIZEN_HOME", "-Wno-sign-compare" ] target_ldflags=[ "--sysroot=TEST_TIZEN_HOME" ] custom_toolchain="${build_root}/toolchain/custom" target_cc="TEST_TIZEN_HOME/bin/arm-linux-gnueabi-gcc" target_cxx="TEST_TIZEN_HOME/bin/arm-linux-gnueabi-g++" target_ar="TEST_TIZEN_HOME/bin/arm-linux-gnueabi-ar"'"'"' {out}/tizen-tizen-light' # Building {real_platform}-native-all_clusters ninja -C {out}/{real_platform}-native-all_clusters diff --git a/src/platform/Tizen/BUILD.gn b/src/platform/Tizen/BUILD.gn index 383ea6c99c4562..9a4caadaf3132d 100644 --- a/src/platform/Tizen/BUILD.gn +++ b/src/platform/Tizen/BUILD.gn @@ -52,13 +52,14 @@ static_library("Tizen") { deps = [ "${chip_root}/src/setup_payload" ] - public_deps = [ "${chip_root}/src/platform:platform_base" ] - - public_deps += [ "${chip_root}/${tizen_root}:tizen" ] + public_deps = [ + "${chip_root}/${tizen_root}:tizen", + "${chip_root}/src/platform:platform_base", + ] public_configs = [] - if (chip_mdns != "none") { + if (chip_mdns == "platform") { sources += [ "MdnsImpl.cpp" ] deps += [ "${chip_root}/src/lib/mdns:platform_header" ] diff --git a/src/platform/Tizen/ConfigurationManagerImpl.cpp b/src/platform/Tizen/ConfigurationManagerImpl.cpp index 2f1e1d730c7f7b..d3be56fde6cfdc 100644 --- a/src/platform/Tizen/ConfigurationManagerImpl.cpp +++ b/src/platform/Tizen/ConfigurationManagerImpl.cpp @@ -43,14 +43,7 @@ ConfigurationManagerImpl ConfigurationManagerImpl::sInstance; CHIP_ERROR ConfigurationManagerImpl::_Init(void) { - CHIP_ERROR err = CHIP_NO_ERROR; - - // Initialize the generic implementation base class. - err = Internal::GenericConfigurationManagerImpl::_Init(); - SuccessOrExit(err); - -exit: - return err; + return Internal::GenericConfigurationManagerImpl::_Init(); } CHIP_ERROR ConfigurationManagerImpl::_GetPrimaryWiFiMACAddress(uint8_t * buf) diff --git a/src/platform/Tizen/Logging.cpp b/src/platform/Tizen/Logging.cpp index c77bde55ef13e8..8a3826427d8b54 100644 --- a/src/platform/Tizen/Logging.cpp +++ b/src/platform/Tizen/Logging.cpp @@ -23,21 +23,6 @@ #include #include -#ifdef LOG_TAG -#undef LOG_TAG -#endif -#define LOG_TAG "CHIP" - -#ifndef LOGD -#define LOGD(fmt, args...) dlog_print(DLOG_DEBUG, LOG_TAG, fmt, ##args) -#endif -#ifndef LOGE -#define LOGE(fmt, args...) dlog_print(DLOG_ERROR, LOG_TAG, fmt, ##args) -#endif -#ifndef LOGI -#define LOGI(fmt, args...) dlog_print(DLOG_INFO, LOG_TAG, fmt, ##args) -#endif - namespace chip { namespace Logging { namespace Platform { @@ -47,6 +32,7 @@ namespace Platform { */ void LogV(const char * module, uint8_t category, const char * msg, va_list v) { + constexpr const char * kLogTag = "CHIP"; char msgBuf[CHIP_CONFIG_LOG_MESSAGE_MAX_SIZE] = { 0, }; @@ -55,14 +41,14 @@ void LogV(const char * module, uint8_t category, const char * msg, va_list v) switch (category) { case kLogCategory_Error: - LOGE("%s: %s", module, msgBuf); + dlog_print(DLOG_ERROR, kLogTag, "%s: %s", module, msgBuf); break; case kLogCategory_Detail: - LOGD("%s: %s", module, msgBuf); + dlog_print(DLOG_DEBUG, kLogTag, "%s: %s", module, msgBuf); break; case kLogCategory_Progress: default: - LOGI("%s: %s", module, msgBuf); + dlog_print(DLOG_INFO, kLogTag, "%s: %s", module, msgBuf); break; } } diff --git a/src/platform/Tizen/PlatformManagerImpl.cpp b/src/platform/Tizen/PlatformManagerImpl.cpp index e750035ce00c5e..f4a1dc50d08328 100644 --- a/src/platform/Tizen/PlatformManagerImpl.cpp +++ b/src/platform/Tizen/PlatformManagerImpl.cpp @@ -35,18 +35,9 @@ PlatformManagerImpl PlatformManagerImpl::sInstance; CHIP_ERROR PlatformManagerImpl::_InitChipStack(void) { - CHIP_ERROR err; - - // Initialize the configuration system. - err = Internal::PosixConfig::Init(); - SuccessOrExit(err); - // Call _InitChipStack() on the generic implementation base class - // to finish the initialization process. - err = Internal::GenericPlatformManagerImpl_POSIX::_InitChipStack(); - SuccessOrExit(err); - -exit: - return err; + ReturnErrorOnFailure(Internal::PosixConfig::Init()); + + return Internal::GenericPlatformManagerImpl_POSIX::_InitChipStack(); } } // namespace DeviceLayer From 1e8f77de0080757470e3dc1e98713cda2850dbbc Mon Sep 17 00:00:00 2001 From: Wootak Jung Date: Wed, 25 Aug 2021 13:08:46 +0900 Subject: [PATCH 10/14] Change tizen.py --- scripts/build/build/factory.py | 4 +- scripts/build/build/targets.py | 5 +- scripts/build/builders/tizen.py | 49 ++++++++++++++----- .../build/expected_all_platform_commands.txt | 8 +-- 4 files changed, 44 insertions(+), 22 deletions(-) diff --git a/scripts/build/build/factory.py b/scripts/build/build/factory.py index d4c93cba27ebc1..9e7f65da5d56b1 100644 --- a/scripts/build/build/factory.py +++ b/scripts/build/build/factory.py @@ -22,7 +22,7 @@ from builders.qpg import QpgBuilder from builders.infineon import InfineonBuilder, InfineonApp, InfineonBoard from builders.telink import TelinkApp, TelinkBoard, TelinkBuilder -from builders.tizen import TizenBuilder, TizenApp +from builders.tizen import TizenApp, TizenBoard, TizenBuilder from .targets import Application, Board, Platform @@ -152,7 +152,7 @@ def Create(self, runner, __board_key: Board, __app_key: Application, _MATCHERS[Platform.INFINEON].AcceptBoard( Board.P6BOARD, board=InfineonBoard.P6BOARD) -_MATCHERS[Platform.TIZEN].AcceptBoard(Board.TIZEN) +_MATCHERS[Platform.TIZEN].AcceptBoard(Board.ARM, board=TizenBoard.ARM) _MATCHERS[Platform.TIZEN].AcceptApplication( Application.LIGHT, app=TizenApp.LIGHT) diff --git a/scripts/build/build/targets.py b/scripts/build/build/targets.py index ece875364851e3..272f4efb477268 100644 --- a/scripts/build/build/targets.py +++ b/scripts/build/build/targets.py @@ -62,7 +62,7 @@ class Board(IntEnum): # Telink platform TLSR9518ADK80D = auto() - # Android platform + # Android, Tizen platform ARM = auto() ARM64 = auto() X64 = auto() @@ -70,9 +70,6 @@ class Board(IntEnum): # Infineon board P6BOARD = auto() - # Tizen platform - TIZEN = auto() - @property def ArgName(self): return self.name.lower() diff --git a/scripts/build/builders/tizen.py b/scripts/build/builders/tizen.py index fcfd3c7a162044..5d8bee5aca6574 100644 --- a/scripts/build/builders/tizen.py +++ b/scripts/build/builders/tizen.py @@ -14,7 +14,6 @@ import logging import os -import shlex from enum import Enum, auto @@ -37,18 +36,36 @@ def AppNamePrefix(self): raise Exception('Unknown app type: %r' % self) +class TizenBoard(Enum): + ARM = auto() + + def TargetCpuName(self): + if self == TizenBoard.ARM: + return 'arm' + else: + raise Exception('Unknown board type: %r' % self) + + def AbiName(self): + if self == TizenBoard.ARM: + return 'armv7-a' + else: + raise Exception('Unknown board type: %r' % self) + + class TizenBuilder(Builder): def __init__(self, root, runner, output_prefix: str, - app: TizenApp = TizenApp.LIGHT): + app: TizenApp = TizenApp.LIGHT, + board: TizenBoard = TizenBoard.ARM): super(TizenBuilder, self).__init__( root=os.path.join(root, 'examples', app.ExampleName(), 'linux'), runner=runner, output_prefix=output_prefix) self.app = app + self.board = board def generate(self): if not os.path.exists(self.output_dir): @@ -57,20 +74,28 @@ def generate(self): raise Exception( "Environment TIZEN_HOME missing, cannot build tizen libraries") - tizen_home = os.environ['TIZEN_HOME'] cmd = '''\ export PKG_CONFIG_SYSROOT_DIR=$TIZEN_HOME; export PKG_CONFIG_LIBDIR=$TIZEN_HOME/usr/lib/pkgconfig; export PKG_CONFIG_PATH=$TIZEN_HOME/usr/lib/pkgconfig; -gn gen --check --fail-on-unused-args --root=%s '--args=target_os="tizen" \ -target_cpu="arm" arm_arch="armv7-a" import("//build_overrides/build.gni") \ -target_cflags=[ "--sysroot=%s", "-Wno-sign-compare" ] \ -target_ldflags=[ "--sysroot=%s" ] \ -custom_toolchain="${build_root}/toolchain/custom" \ -target_cc="%s/bin/arm-linux-gnueabi-gcc" \ -target_cxx="%s/bin/arm-linux-gnueabi-g++" \ -target_ar="%s/bin/arm-linux-gnueabi-ar"' %s''' % ( - self.root, tizen_home, tizen_home, tizen_home, tizen_home, tizen_home, self.output_dir) +gn gen --check --fail-on-unused-args --root=%s \ +--args=\'import("//build_overrides/build.gni")''' % self.root + + tizen_home = os.environ['TIZEN_HOME'] + gn_args = {} + gn_args['target_os'] = '"tizen"' + gn_args['target_cpu'] = '"%s"' % self.board.TargetCpuName() + gn_args['arm_arch'] = '"%s"' % self.board.AbiName() + gn_args['target_cflags'] = '[ "--sysroot=%s" ]' % tizen_home + gn_args['target_ldflags'] = '[ "--sysroot=%s" ]' % tizen_home + gn_args['custom_toolchain'] = '"${build_root}/toolchain/custom"' + gn_args['target_cc'] = '"%s/bin/arm-linux-gnueabi-gcc"' % tizen_home + gn_args['target_cxx'] = '"%s/bin/arm-linux-gnueabi-g++"' % tizen_home + gn_args['target_ar'] = '"%s/bin/arm-linux-gnueabi-ar"' % tizen_home + + cmd += ' %s\' %s' % (' '.join([ + '%s=%s' % (key, value) + for key, value in gn_args.items()]), self.output_dir) self._Execute(['bash', '-c', cmd], title='Generating ' + self.identifier) diff --git a/scripts/build/expected_all_platform_commands.txt b/scripts/build/expected_all_platform_commands.txt index f32894e13ff0c4..fc202f881168d9 100644 --- a/scripts/build/expected_all_platform_commands.txt +++ b/scripts/build/expected_all_platform_commands.txt @@ -132,11 +132,11 @@ export ZEPHYR_SDK_INSTALL_DIR="$ZEPHYR_BASE/../../zephyr-sdk-0.13.0" source "$ZEPHYR_BASE/zephyr-env.sh"; west build --cmake-only -d {out}/telink-tlsr9518adk80d-light -b tlsr9518adk80d {root}/examples/lighting-app/telink' -# Generating tizen-tizen-light +# Generating tizen-arm-light bash -c 'export PKG_CONFIG_SYSROOT_DIR=$TIZEN_HOME; export PKG_CONFIG_LIBDIR=$TIZEN_HOME/usr/lib/pkgconfig; export PKG_CONFIG_PATH=$TIZEN_HOME/usr/lib/pkgconfig; -gn gen --check --fail-on-unused-args --root={root}/examples/lighting-app/linux '"'"'--args=target_os="tizen" target_cpu="arm" arm_arch="armv7-a" import("//build_overrides/build.gni") target_cflags=[ "--sysroot=TEST_TIZEN_HOME", "-Wno-sign-compare" ] target_ldflags=[ "--sysroot=TEST_TIZEN_HOME" ] custom_toolchain="${build_root}/toolchain/custom" target_cc="TEST_TIZEN_HOME/bin/arm-linux-gnueabi-gcc" target_cxx="TEST_TIZEN_HOME/bin/arm-linux-gnueabi-g++" target_ar="TEST_TIZEN_HOME/bin/arm-linux-gnueabi-ar"'"'"' {out}/tizen-tizen-light' +gn gen --check --fail-on-unused-args --root={root}/examples/lighting-app/linux --args='"'"'import("//build_overrides/build.gni") target_os="tizen" target_cpu="arm" arm_arch="armv7-a" target_cflags=[ "--sysroot=TEST_TIZEN_HOME" ] target_ldflags=[ "--sysroot=TEST_TIZEN_HOME" ] custom_toolchain="${build_root}/toolchain/custom" target_cc="TEST_TIZEN_HOME/bin/arm-linux-gnueabi-gcc" target_cxx="TEST_TIZEN_HOME/bin/arm-linux-gnueabi-g++" target_ar="TEST_TIZEN_HOME/bin/arm-linux-gnueabi-ar"'"'"' {out}/tizen-arm-light' # Building {real_platform}-native-all_clusters ninja -C {out}/{real_platform}-native-all_clusters @@ -261,7 +261,7 @@ ninja -C {out}/infineon-p6board-lock # Building telink-tlsr9518adk80d-light ninja -C {out}/telink-tlsr9518adk80d-light -# Building tizen-tizen-light -ninja -C {out}/tizen-tizen-light +# Building tizen-arm-light +ninja -C {out}/tizen-arm-light From 3dc18a44df81aafbd922bb7be36555a02d962bc5 Mon Sep 17 00:00:00 2001 From: Wootak Jung Date: Thu, 26 Aug 2021 11:13:08 +0900 Subject: [PATCH 11/14] Add tizen toolchain --- build/config/BUILDCONFIG.gn | 3 ++ build/config/compiler/BUILD.gn | 5 +++ build/toolchain/tizen/BUILD.gn | 22 ++++++++++++ build/toolchain/tizen/tizen_toolchain.gni | 36 +++++++++++++++++++ examples/build_overrides/tizen.gni | 1 + scripts/build/builders/tizen.py | 26 ++++---------- .../build/expected_all_platform_commands.txt | 2 +- 7 files changed, 74 insertions(+), 21 deletions(-) create mode 100644 build/toolchain/tizen/BUILD.gn create mode 100644 build/toolchain/tizen/tizen_toolchain.gni diff --git a/build/config/BUILDCONFIG.gn b/build/config/BUILDCONFIG.gn index 298bf1846f27f5..2592b62be53a49 100644 --- a/build/config/BUILDCONFIG.gn +++ b/build/config/BUILDCONFIG.gn @@ -96,6 +96,9 @@ if (_chip_defaults.custom_toolchain != "") { } else if (target_os == "ios") { _default_toolchain = "${_build_overrides.build_root}/toolchain/ios:ios_${target_cpu}" +} else if (target_os == "tizen") { + _default_toolchain = + "${_build_overrides.build_root}/toolchain/tizen:tizen_${target_cpu}" } else { assert(false, "No toolchain specified, please specify custom_toolchain") } diff --git a/build/config/compiler/BUILD.gn b/build/config/compiler/BUILD.gn index 9101fbb69746ae..c3cd1c2290a0d7 100644 --- a/build/config/compiler/BUILD.gn +++ b/build/config/compiler/BUILD.gn @@ -120,6 +120,11 @@ config("abi_default") { } config("target_default") { + if (current_os == "tizen") { + import("//build_overrides/tizen.gni") + target_cflags = [ "--sysroot=$tizen_home" ] + target_ldflags = [ "--sysroot=$tizen_home" ] + } if (current_toolchain == default_toolchain) { defines = target_defines cflags = target_cflags diff --git a/build/toolchain/tizen/BUILD.gn b/build/toolchain/tizen/BUILD.gn new file mode 100644 index 00000000000000..c8c80098f98d5d --- /dev/null +++ b/build/toolchain/tizen/BUILD.gn @@ -0,0 +1,22 @@ +# Copyright (c) 2021 Project CHIP Authors +# +# 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. + +import("tizen_toolchain.gni") + +tizen_toolchain("tizen_arm") { + toolchain_args = { + current_cpu = "arm" + arm_arch = "armv7-a" + } +} diff --git a/build/toolchain/tizen/tizen_toolchain.gni b/build/toolchain/tizen/tizen_toolchain.gni new file mode 100644 index 00000000000000..db98927a9563d9 --- /dev/null +++ b/build/toolchain/tizen/tizen_toolchain.gni @@ -0,0 +1,36 @@ +# Copyright (c) 2021 Project CHIP Authors +# +# 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. + +import("//build_overrides/build.gni") +import("//build_overrides/tizen.gni") + +import("${build_root}/toolchain/gcc_toolchain.gni") + +template("tizen_toolchain") { + _invoker_toolchain_args = invoker.toolchain_args + + _tizen_toolchain_args = { + current_os = "tizen" + is_clang = true + + forward_variables_from(_invoker_toolchain_args, "*") + } + + gcc_toolchain(target_name) { + toolchain_args = _tizen_toolchain_args + ar = "$tizen_home/bin/arm-linux-gnueabi-ar" + cc = "$tizen_home/bin/arm-linux-gnueabi-gcc" + cxx = "$tizen_home/bin/arm-linux-gnueabi-g++" + } +} diff --git a/examples/build_overrides/tizen.gni b/examples/build_overrides/tizen.gni index c98c7998f02fd5..172e0a5a86209c 100644 --- a/examples/build_overrides/tizen.gni +++ b/examples/build_overrides/tizen.gni @@ -15,4 +15,5 @@ declare_args() { # Root directory for tizen. tizen_root = "//config/tizen/chip-gn/platform" + tizen_home = "" } diff --git a/scripts/build/builders/tizen.py b/scripts/build/builders/tizen.py index 5d8bee5aca6574..33cdeac9161cad 100644 --- a/scripts/build/builders/tizen.py +++ b/scripts/build/builders/tizen.py @@ -45,12 +45,6 @@ def TargetCpuName(self): else: raise Exception('Unknown board type: %r' % self) - def AbiName(self): - if self == TizenBoard.ARM: - return 'armv7-a' - else: - raise Exception('Unknown board type: %r' % self) - class TizenBuilder(Builder): @@ -78,30 +72,22 @@ def generate(self): export PKG_CONFIG_SYSROOT_DIR=$TIZEN_HOME; export PKG_CONFIG_LIBDIR=$TIZEN_HOME/usr/lib/pkgconfig; export PKG_CONFIG_PATH=$TIZEN_HOME/usr/lib/pkgconfig; -gn gen --check --fail-on-unused-args --root=%s \ ---args=\'import("//build_overrides/build.gni")''' % self.root +gn gen --check --fail-on-unused-args --root=%s '--args=''' % self.root - tizen_home = os.environ['TIZEN_HOME'] gn_args = {} - gn_args['target_os'] = '"tizen"' - gn_args['target_cpu'] = '"%s"' % self.board.TargetCpuName() - gn_args['arm_arch'] = '"%s"' % self.board.AbiName() - gn_args['target_cflags'] = '[ "--sysroot=%s" ]' % tizen_home - gn_args['target_ldflags'] = '[ "--sysroot=%s" ]' % tizen_home - gn_args['custom_toolchain'] = '"${build_root}/toolchain/custom"' - gn_args['target_cc'] = '"%s/bin/arm-linux-gnueabi-gcc"' % tizen_home - gn_args['target_cxx'] = '"%s/bin/arm-linux-gnueabi-g++"' % tizen_home - gn_args['target_ar'] = '"%s/bin/arm-linux-gnueabi-ar"' % tizen_home + gn_args['target_os'] = 'tizen' + gn_args['target_cpu'] = self.board.TargetCpuName() + gn_args['tizen_home'] = os.environ['TIZEN_HOME'] cmd += ' %s\' %s' % (' '.join([ - '%s=%s' % (key, value) + '%s="%s"' % (key, value) for key, value in gn_args.items()]), self.output_dir) self._Execute(['bash', '-c', cmd], title='Generating ' + self.identifier) def _build(self): - logging.info('Compiling Telink at %s', self.output_dir) + logging.info('Compiling Tizen at %s', self.output_dir) self._Execute(['ninja', '-C', self.output_dir], title='Building ' + self.identifier) diff --git a/scripts/build/expected_all_platform_commands.txt b/scripts/build/expected_all_platform_commands.txt index fc202f881168d9..a5683dbeff347d 100644 --- a/scripts/build/expected_all_platform_commands.txt +++ b/scripts/build/expected_all_platform_commands.txt @@ -136,7 +136,7 @@ west build --cmake-only -d {out}/telink-tlsr9518adk80d-light -b tlsr9518adk80d { bash -c 'export PKG_CONFIG_SYSROOT_DIR=$TIZEN_HOME; export PKG_CONFIG_LIBDIR=$TIZEN_HOME/usr/lib/pkgconfig; export PKG_CONFIG_PATH=$TIZEN_HOME/usr/lib/pkgconfig; -gn gen --check --fail-on-unused-args --root={root}/examples/lighting-app/linux --args='"'"'import("//build_overrides/build.gni") target_os="tizen" target_cpu="arm" arm_arch="armv7-a" target_cflags=[ "--sysroot=TEST_TIZEN_HOME" ] target_ldflags=[ "--sysroot=TEST_TIZEN_HOME" ] custom_toolchain="${build_root}/toolchain/custom" target_cc="TEST_TIZEN_HOME/bin/arm-linux-gnueabi-gcc" target_cxx="TEST_TIZEN_HOME/bin/arm-linux-gnueabi-g++" target_ar="TEST_TIZEN_HOME/bin/arm-linux-gnueabi-ar"'"'"' {out}/tizen-arm-light' +gn gen --check --fail-on-unused-args --root={root}/examples/lighting-app/linux '"'"'--args= target_os="tizen" target_cpu="arm" tizen_home="TEST_TIZEN_HOME"'"'"' {out}/tizen-arm-light' # Building {real_platform}-native-all_clusters ninja -C {out}/{real_platform}-native-all_clusters From 4bf7166249869f093a33fdeb18b6fe7166424827 Mon Sep 17 00:00:00 2001 From: Wootak Jung Date: Tue, 31 Aug 2021 10:32:03 +0900 Subject: [PATCH 12/14] Rename tizen_home to tizen_sdk and apply comments --- build/config/compiler/BUILD.gn | 4 +- build/toolchain/tizen/tizen_toolchain.gni | 6 +- build_overrides/tizen.gni | 18 ------ config/tizen/chip-gn/platform/BUILD.gn | 58 +++++++++---------- examples/build_overrides/tizen.gni | 4 +- scripts/build/builders/tizen.py | 2 +- .../build/expected_all_platform_commands.txt | 2 +- src/platform/Tizen/BUILD.gn | 2 +- 8 files changed, 37 insertions(+), 59 deletions(-) delete mode 100644 build_overrides/tizen.gni diff --git a/build/config/compiler/BUILD.gn b/build/config/compiler/BUILD.gn index c3cd1c2290a0d7..bca41543763883 100644 --- a/build/config/compiler/BUILD.gn +++ b/build/config/compiler/BUILD.gn @@ -122,8 +122,8 @@ config("abi_default") { config("target_default") { if (current_os == "tizen") { import("//build_overrides/tizen.gni") - target_cflags = [ "--sysroot=$tizen_home" ] - target_ldflags = [ "--sysroot=$tizen_home" ] + target_cflags += [ "--sysroot=$tizen_sdk" ] + target_ldflags += [ "--sysroot=$tizen_sdk" ] } if (current_toolchain == default_toolchain) { defines = target_defines diff --git a/build/toolchain/tizen/tizen_toolchain.gni b/build/toolchain/tizen/tizen_toolchain.gni index db98927a9563d9..130f6848c84174 100644 --- a/build/toolchain/tizen/tizen_toolchain.gni +++ b/build/toolchain/tizen/tizen_toolchain.gni @@ -29,8 +29,8 @@ template("tizen_toolchain") { gcc_toolchain(target_name) { toolchain_args = _tizen_toolchain_args - ar = "$tizen_home/bin/arm-linux-gnueabi-ar" - cc = "$tizen_home/bin/arm-linux-gnueabi-gcc" - cxx = "$tizen_home/bin/arm-linux-gnueabi-g++" + ar = "$tizen_sdk/bin/arm-linux-gnueabi-ar" + cc = "$tizen_sdk/bin/arm-linux-gnueabi-gcc" + cxx = "$tizen_sdk/bin/arm-linux-gnueabi-g++" } } diff --git a/build_overrides/tizen.gni b/build_overrides/tizen.gni deleted file mode 100644 index c98c7998f02fd5..00000000000000 --- a/build_overrides/tizen.gni +++ /dev/null @@ -1,18 +0,0 @@ -# Copyright (c) 2021 Project CHIP Authors -# -# 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. - -declare_args() { - # Root directory for tizen. - tizen_root = "//config/tizen/chip-gn/platform" -} diff --git a/config/tizen/chip-gn/platform/BUILD.gn b/config/tizen/chip-gn/platform/BUILD.gn index 06ce25bf91037b..9a4b9f3c803173 100644 --- a/config/tizen/chip-gn/platform/BUILD.gn +++ b/config/tizen/chip-gn/platform/BUILD.gn @@ -20,48 +20,44 @@ import("${chip_root}/config/tizen/chip-gn/args.gni") import("${build_root}/config/linux/pkg_config.gni") import("${chip_root}/src/platform/device.gni") -config("tizen_sdk_config") { - pkg_config("dlog") { - packages = [ "dlog" ] - } +pkg_config("dlog") { + packages = [ "dlog" ] +} - pkg_config("capi-appfw-preference") { - packages = [ "capi-appfw-preference" ] - } +pkg_config("capi-appfw-preference") { + packages = [ "capi-appfw-preference" ] +} - pkg_config("glib") { - packages = [ - "glib-2.0", - "gio-unix-2.0", - ] - } +pkg_config("glib") { + packages = [ + "glib-2.0", + "gio-unix-2.0", + ] +} - if (chip_mdns == "platform") { - pkg_config("nsd-dns-sd") { - packages = [ "nsd-dns-sd" ] - } +if (chip_mdns == "platform") { + pkg_config("nsd-dns-sd") { + packages = [ "nsd-dns-sd" ] } +} - if (chip_enable_wifi) { - pkg_config("capi-network-wifi-manager") { - packages = [ "capi-network-wifi-manager" ] - } - pkg_config("capi-network-softap") { - packages = [ "capi-network-softap" ] - } +if (chip_enable_wifi) { + pkg_config("capi-network-wifi-manager") { + packages = [ "capi-network-wifi-manager" ] + } + pkg_config("capi-network-softap") { + packages = [ "capi-network-softap" ] } +} - if (chip_enable_ble) { - pkg_config("capi-network-bluetooth") { - packages = [ "capi-network-bluetooth" ] - } +if (chip_enable_ble) { + pkg_config("capi-network-bluetooth") { + packages = [ "capi-network-bluetooth" ] } } source_set("tizen") { - public_configs = [ ":tizen_sdk_config" ] - - public_configs += [ + public_configs = [ ":dlog", ":glib", ":capi-appfw-preference", diff --git a/examples/build_overrides/tizen.gni b/examples/build_overrides/tizen.gni index 172e0a5a86209c..f03224fc9156f1 100644 --- a/examples/build_overrides/tizen.gni +++ b/examples/build_overrides/tizen.gni @@ -14,6 +14,6 @@ declare_args() { # Root directory for tizen. - tizen_root = "//config/tizen/chip-gn/platform" - tizen_home = "" + tizen_root = "//third_party/connectedhomeip/config/tizen/chip-gn/platform" + tizen_sdk = "" } diff --git a/scripts/build/builders/tizen.py b/scripts/build/builders/tizen.py index 33cdeac9161cad..dbeba204fc508c 100644 --- a/scripts/build/builders/tizen.py +++ b/scripts/build/builders/tizen.py @@ -77,7 +77,7 @@ def generate(self): gn_args = {} gn_args['target_os'] = 'tizen' gn_args['target_cpu'] = self.board.TargetCpuName() - gn_args['tizen_home'] = os.environ['TIZEN_HOME'] + gn_args['tizen_sdk'] = os.environ['TIZEN_HOME'] cmd += ' %s\' %s' % (' '.join([ '%s="%s"' % (key, value) diff --git a/scripts/build/expected_all_platform_commands.txt b/scripts/build/expected_all_platform_commands.txt index a5683dbeff347d..687bcf00dc8256 100644 --- a/scripts/build/expected_all_platform_commands.txt +++ b/scripts/build/expected_all_platform_commands.txt @@ -136,7 +136,7 @@ west build --cmake-only -d {out}/telink-tlsr9518adk80d-light -b tlsr9518adk80d { bash -c 'export PKG_CONFIG_SYSROOT_DIR=$TIZEN_HOME; export PKG_CONFIG_LIBDIR=$TIZEN_HOME/usr/lib/pkgconfig; export PKG_CONFIG_PATH=$TIZEN_HOME/usr/lib/pkgconfig; -gn gen --check --fail-on-unused-args --root={root}/examples/lighting-app/linux '"'"'--args= target_os="tizen" target_cpu="arm" tizen_home="TEST_TIZEN_HOME"'"'"' {out}/tizen-arm-light' +gn gen --check --fail-on-unused-args --root={root}/examples/lighting-app/linux '"'"'--args= target_os="tizen" target_cpu="arm" tizen_sdk="TEST_TIZEN_HOME"'"'"' {out}/tizen-arm-light' # Building {real_platform}-native-all_clusters ninja -C {out}/{real_platform}-native-all_clusters diff --git a/src/platform/Tizen/BUILD.gn b/src/platform/Tizen/BUILD.gn index 9a4caadaf3132d..29488bfc390787 100644 --- a/src/platform/Tizen/BUILD.gn +++ b/src/platform/Tizen/BUILD.gn @@ -53,8 +53,8 @@ static_library("Tizen") { deps = [ "${chip_root}/src/setup_payload" ] public_deps = [ - "${chip_root}/${tizen_root}:tizen", "${chip_root}/src/platform:platform_base", + "${tizen_root}:tizen", ] public_configs = [] From 6b0b8e08779fe02e1ceb6d180934ab5242a6f3e7 Mon Sep 17 00:00:00 2001 From: Wootak Jung Date: Fri, 3 Sep 2021 08:38:20 +0900 Subject: [PATCH 13/14] Modify lib/ files full path --- src/platform/Tizen/ConfigurationManagerImpl.cpp | 6 +++--- src/platform/Tizen/ConnectivityManagerImpl.cpp | 4 ++-- .../Tizen/DeviceNetworkProvisioningDelegateImpl.cpp | 4 ++-- src/platform/Tizen/Logging.cpp | 4 ++-- src/platform/Tizen/PosixConfig.cpp | 4 ++-- src/platform/Tizen/SystemTimeSupport.cpp | 4 ++-- 6 files changed, 13 insertions(+), 13 deletions(-) diff --git a/src/platform/Tizen/ConfigurationManagerImpl.cpp b/src/platform/Tizen/ConfigurationManagerImpl.cpp index d3be56fde6cfdc..7f41bb79b41d45 100644 --- a/src/platform/Tizen/ConfigurationManagerImpl.cpp +++ b/src/platform/Tizen/ConfigurationManagerImpl.cpp @@ -25,12 +25,12 @@ #include -#include +#include +#include +#include #include #include #include -#include -#include namespace chip { namespace DeviceLayer { diff --git a/src/platform/Tizen/ConnectivityManagerImpl.cpp b/src/platform/Tizen/ConnectivityManagerImpl.cpp index 5bb3e016532a89..dc8a721296a88b 100644 --- a/src/platform/Tizen/ConnectivityManagerImpl.cpp +++ b/src/platform/Tizen/ConnectivityManagerImpl.cpp @@ -24,8 +24,8 @@ #include -#include -#include +#include +#include #if CHIP_DEVICE_CONFIG_ENABLE_CHIPOBLE #include diff --git a/src/platform/Tizen/DeviceNetworkProvisioningDelegateImpl.cpp b/src/platform/Tizen/DeviceNetworkProvisioningDelegateImpl.cpp index 327f78f0865dbd..21f0c0fe3c9741 100644 --- a/src/platform/Tizen/DeviceNetworkProvisioningDelegateImpl.cpp +++ b/src/platform/Tizen/DeviceNetworkProvisioningDelegateImpl.cpp @@ -15,8 +15,8 @@ * limitations under the License. */ -#include -#include +#include +#include #include "DeviceNetworkProvisioningDelegateImpl.h" diff --git a/src/platform/Tizen/Logging.cpp b/src/platform/Tizen/Logging.cpp index 8a3826427d8b54..7c8865f1e09d73 100644 --- a/src/platform/Tizen/Logging.cpp +++ b/src/platform/Tizen/Logging.cpp @@ -17,8 +17,8 @@ #include -#include -#include +#include +#include #include #include diff --git a/src/platform/Tizen/PosixConfig.cpp b/src/platform/Tizen/PosixConfig.cpp index ebb5a8a1802b4e..146c0225a856a8 100644 --- a/src/platform/Tizen/PosixConfig.cpp +++ b/src/platform/Tizen/PosixConfig.cpp @@ -27,9 +27,9 @@ #include #include -#include +#include +#include #include -#include namespace chip { namespace DeviceLayer { diff --git a/src/platform/Tizen/SystemTimeSupport.cpp b/src/platform/Tizen/SystemTimeSupport.cpp index 9464485b1a7d55..70b473eb1a5cd4 100644 --- a/src/platform/Tizen/SystemTimeSupport.cpp +++ b/src/platform/Tizen/SystemTimeSupport.cpp @@ -25,8 +25,8 @@ #include -#include -#include +#include +#include namespace chip { namespace System { From 89f71e3b100162db9276a6d87f04c1546b575c43 Mon Sep 17 00:00:00 2001 From: Wootak Jung Date: Thu, 2 Sep 2021 13:49:05 +0900 Subject: [PATCH 14/14] Modify sysroot setting logic --- build/config/compiler/BUILD.gn | 5 ----- build/toolchain/tizen/tizen_toolchain.gni | 8 ++++---- examples/build_overrides/tizen.gni | 1 - scripts/build/builders/tizen.py | 5 +---- scripts/build/expected_all_platform_commands.txt | 5 +---- 5 files changed, 6 insertions(+), 18 deletions(-) diff --git a/build/config/compiler/BUILD.gn b/build/config/compiler/BUILD.gn index bca41543763883..9101fbb69746ae 100644 --- a/build/config/compiler/BUILD.gn +++ b/build/config/compiler/BUILD.gn @@ -120,11 +120,6 @@ config("abi_default") { } config("target_default") { - if (current_os == "tizen") { - import("//build_overrides/tizen.gni") - target_cflags += [ "--sysroot=$tizen_sdk" ] - target_ldflags += [ "--sysroot=$tizen_sdk" ] - } if (current_toolchain == default_toolchain) { defines = target_defines cflags = target_cflags diff --git a/build/toolchain/tizen/tizen_toolchain.gni b/build/toolchain/tizen/tizen_toolchain.gni index 130f6848c84174..9f88753925a4dc 100644 --- a/build/toolchain/tizen/tizen_toolchain.gni +++ b/build/toolchain/tizen/tizen_toolchain.gni @@ -13,8 +13,8 @@ # limitations under the License. import("//build_overrides/build.gni") -import("//build_overrides/tizen.gni") +import("${build_root}/config/sysroot.gni") import("${build_root}/toolchain/gcc_toolchain.gni") template("tizen_toolchain") { @@ -29,8 +29,8 @@ template("tizen_toolchain") { gcc_toolchain(target_name) { toolchain_args = _tizen_toolchain_args - ar = "$tizen_sdk/bin/arm-linux-gnueabi-ar" - cc = "$tizen_sdk/bin/arm-linux-gnueabi-gcc" - cxx = "$tizen_sdk/bin/arm-linux-gnueabi-g++" + ar = "$sysroot/bin/arm-linux-gnueabi-ar" + cc = "$sysroot/bin/arm-linux-gnueabi-gcc" + cxx = "$sysroot/bin/arm-linux-gnueabi-g++" } } diff --git a/examples/build_overrides/tizen.gni b/examples/build_overrides/tizen.gni index f03224fc9156f1..29a2771956f249 100644 --- a/examples/build_overrides/tizen.gni +++ b/examples/build_overrides/tizen.gni @@ -15,5 +15,4 @@ declare_args() { # Root directory for tizen. tizen_root = "//third_party/connectedhomeip/config/tizen/chip-gn/platform" - tizen_sdk = "" } diff --git a/scripts/build/builders/tizen.py b/scripts/build/builders/tizen.py index dbeba204fc508c..b8289f4bd5b6fe 100644 --- a/scripts/build/builders/tizen.py +++ b/scripts/build/builders/tizen.py @@ -69,15 +69,12 @@ def generate(self): "Environment TIZEN_HOME missing, cannot build tizen libraries") cmd = '''\ -export PKG_CONFIG_SYSROOT_DIR=$TIZEN_HOME; -export PKG_CONFIG_LIBDIR=$TIZEN_HOME/usr/lib/pkgconfig; -export PKG_CONFIG_PATH=$TIZEN_HOME/usr/lib/pkgconfig; gn gen --check --fail-on-unused-args --root=%s '--args=''' % self.root gn_args = {} gn_args['target_os'] = 'tizen' gn_args['target_cpu'] = self.board.TargetCpuName() - gn_args['tizen_sdk'] = os.environ['TIZEN_HOME'] + gn_args['sysroot'] = os.environ['TIZEN_HOME'] cmd += ' %s\' %s' % (' '.join([ '%s="%s"' % (key, value) diff --git a/scripts/build/expected_all_platform_commands.txt b/scripts/build/expected_all_platform_commands.txt index 687bcf00dc8256..3b3f5f78c71abf 100644 --- a/scripts/build/expected_all_platform_commands.txt +++ b/scripts/build/expected_all_platform_commands.txt @@ -133,10 +133,7 @@ source "$ZEPHYR_BASE/zephyr-env.sh"; west build --cmake-only -d {out}/telink-tlsr9518adk80d-light -b tlsr9518adk80d {root}/examples/lighting-app/telink' # Generating tizen-arm-light -bash -c 'export PKG_CONFIG_SYSROOT_DIR=$TIZEN_HOME; -export PKG_CONFIG_LIBDIR=$TIZEN_HOME/usr/lib/pkgconfig; -export PKG_CONFIG_PATH=$TIZEN_HOME/usr/lib/pkgconfig; -gn gen --check --fail-on-unused-args --root={root}/examples/lighting-app/linux '"'"'--args= target_os="tizen" target_cpu="arm" tizen_sdk="TEST_TIZEN_HOME"'"'"' {out}/tizen-arm-light' +bash -c 'gn gen --check --fail-on-unused-args --root={root}/examples/lighting-app/linux '"'"'--args= target_os="tizen" target_cpu="arm" sysroot="TEST_TIZEN_HOME"'"'"' {out}/tizen-arm-light' # Building {real_platform}-native-all_clusters ninja -C {out}/{real_platform}-native-all_clusters