Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

[Telink] Enable -Wundef by default on Zephyr platform #29613

Merged
merged 24 commits into from
Oct 9, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion build/config/compiler/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -258,7 +258,6 @@ config("strict_warnings") {
# to be more fine-grained than current_os, but it's not clear that
# we can access that here.
if (current_os != "freertos" && current_os != "mbed" &&
current_os != "zephyr" &&
# cmsis-rtos is OpenIOT
current_os != "cmsis-rtos" &&
# cyw30739 is one of the Infineon builds
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ CHIP_ERROR GenericPlatformManagerImpl_Zephyr<ImplClass>::_StopEventLoopTask(void
template <class ImplClass>
void GenericPlatformManagerImpl_Zephyr<ImplClass>::_Shutdown(void)
{
#if CONFIG_REBOOT
#ifdef CONFIG_REBOOT
sys_reboot(SYS_REBOOT_WARM);
#else
// NB: When this is implemented, |mInitialized| can be removed.
Expand Down
16 changes: 8 additions & 8 deletions src/platform/Zephyr/PlatformManagerImpl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@
* for Zephyr platforms.
*/

#if !CONFIG_NORDIC_SECURITY_BACKEND
#if !defined(CONFIG_NORDIC_SECURITY_BACKEND)
Damian-Nordic marked this conversation as resolved.
Show resolved Hide resolved
#include <crypto/CHIPCryptoPAL.h> // nogncheck
#endif // !CONFIG_NORDIC_SECURITY_BACKEND
#endif // !defined(CONFIG_NORDIC_SECURITY_BACKEND)

#include <platform/internal/CHIPDeviceLayerInternal.h>

Expand All @@ -45,7 +45,7 @@ PlatformManagerImpl PlatformManagerImpl::sInstance{ sChipThreadStack };

static k_timer sOperationalHoursSavingTimer;

#if !CONFIG_NORDIC_SECURITY_BACKEND && !defined(CONFIG_MBEDTLS_ZEPHYR_ENTROPY)
#if !defined(CONFIG_NORDIC_SECURITY_BACKEND) && !defined(CONFIG_MBEDTLS_ZEPHYR_ENTROPY)
static int app_entropy_source(void * data, unsigned char * output, size_t len, size_t * olen)
{
const struct device * entropy = DEVICE_DT_GET(DT_CHOSEN(zephyr_entropy));
Expand All @@ -71,7 +71,7 @@ static int app_entropy_source(void * data, unsigned char * output, size_t len, s

return ret;
}
#endif // !CONFIG_NORDIC_SECURITY_BACKEND && !defined(CONFIG_MBEDTLS_ZEPHYR_ENTROPY)
#endif // !defined(CONFIG_NORDIC_SECURITY_BACKEND) && !defined(CONFIG_MBEDTLS_ZEPHYR_ENTROPY)

void PlatformManagerImpl::OperationalHoursSavingTimerEventHandler(k_timer * timer)
{
Expand Down Expand Up @@ -108,20 +108,20 @@ CHIP_ERROR PlatformManagerImpl::_InitChipStack(void)
{
CHIP_ERROR err;

#if !CONFIG_NORDIC_SECURITY_BACKEND && !defined(CONFIG_MBEDTLS_ZEPHYR_ENTROPY)
#if !defined(CONFIG_NORDIC_SECURITY_BACKEND) && !defined(CONFIG_MBEDTLS_ZEPHYR_ENTROPY)
// Minimum required from source before entropy is released ( with mbedtls_entropy_func() ) (in bytes)
const size_t kThreshold = 16;
#endif // !CONFIG_NORDIC_SECURITY_BACKEND && !defined(CONFIG_MBEDTLS_ZEPHYR_ENTROPY)
#endif // !defined(CONFIG_NORDIC_SECURITY_BACKEND) && !defined(CONFIG_MBEDTLS_ZEPHYR_ENTROPY)

// Initialize the configuration system.
err = Internal::ZephyrConfig::Init();
SuccessOrExit(err);

#if !CONFIG_NORDIC_SECURITY_BACKEND && !defined(CONFIG_MBEDTLS_ZEPHYR_ENTROPY)
#if !defined(CONFIG_NORDIC_SECURITY_BACKEND) && !defined(CONFIG_MBEDTLS_ZEPHYR_ENTROPY)
// Add entropy source based on Zephyr entropy driver
err = chip::Crypto::add_entropy_source(app_entropy_source, NULL, kThreshold);
SuccessOrExit(err);
#endif // !CONFIG_NORDIC_SECURITY_BACKEND && !defined(CONFIG_MBEDTLS_ZEPHYR_ENTROPY)
#endif // !defined(CONFIG_NORDIC_SECURITY_BACKEND) && !defined(CONFIG_MBEDTLS_ZEPHYR_ENTROPY)

// Call _InitChipStack() on the generic implementation base class to finish the initialization process.
err = Internal::GenericPlatformManagerImpl_Zephyr<PlatformManagerImpl>::_InitChipStack();
Expand Down
4 changes: 2 additions & 2 deletions src/platform/Zephyr/ThreadStackManagerImpl.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,9 @@
#include <zephyr/net/openthread.h>

#include <openthread/thread.h>
#if !CONFIG_SOC_SERIES_RISCV_TELINK_B9X
#if !defined(CONFIG_SOC_SERIES_RISCV_TELINK_B9X)
bzbarsky-apple marked this conversation as resolved.
Show resolved Hide resolved
#include <platform/Zephyr/BLEManagerImpl.h>
#endif // !CONFIG_SOC_SERIES_RISCV_TELINK_B9X
#endif // !defined(CONFIG_SOC_SERIES_RISCV_TELINK_B9X)

#include <lib/support/logging/CHIPLogging.h>

Expand Down
22 changes: 17 additions & 5 deletions src/platform/nrfconnect/CHIPDevicePlatformConfig.h
Original file line number Diff line number Diff line change
Expand Up @@ -87,19 +87,27 @@
#define CHIP_DEVICE_CONFIG_DEVICE_SOFTWARE_VERSION_STRING CONFIG_CHIP_DEVICE_SOFTWARE_VERSION_STRING
#endif

#ifdef CONFIG_NET_L2_OPENTHREAD
#define CHIP_DEVICE_CONFIG_ENABLE_THREAD CONFIG_NET_L2_OPENTHREAD
#else
#define CHIP_DEVICE_CONFIG_ENABLE_THREAD 0
#endif

#ifdef CONFIG_WIFI_NRF700X
#define CHIP_DEVICE_CONFIG_ENABLE_WIFI CONFIG_WIFI_NRF700X

#if CHIP_DEVICE_CONFIG_ENABLE_WIFI
#define CHIP_DEVICE_CONFIG_ENABLE_WIFI_STATION 1
#define CHIP_DEVICE_CONFIG_ENABLE_WIFI_AP 0
#else
#define CHIP_DEVICE_CONFIG_ENABLE_WIFI 0
#define CHIP_DEVICE_CONFIG_ENABLE_WIFI_STATION 0
#define CHIP_DEVICE_CONFIG_ENABLE_WIFI_AP 0
#endif

#ifdef CONFIG_BT
bzbarsky-apple marked this conversation as resolved.
Show resolved Hide resolved
#define CHIP_DEVICE_CONFIG_ENABLE_CHIPOBLE CONFIG_BT
#else
#define CHIP_DEVICE_CONFIG_ENABLE_CHIPOBLE 0
#endif

// ========== Platform-specific Configuration =========

Expand All @@ -126,6 +134,8 @@
#if !defined(CONFIG_CHIP_MALLOC_SYS_HEAP) && defined(CONFIG_NEWLIB_LIBC)
/// Use mallinfo() to obtain the heap usage statistics exposed by SoftwareDiagnostics cluster attributes.
#define CHIP_DEVICE_CONFIG_HEAP_STATISTICS_MALLINFO 1
#else
#define CHIP_DEVICE_CONFIG_HEAP_STATISTICS_MALLINFO 0
#endif // !defined(CONFIG_CHIP_MALLOC_SYS_HEAP) && defined(CONFIG_NEWLIB_LIBC)
#endif // CHIP_DEVICE_CONFIG_HEAP_STATISTICS_MALLINFO

Expand Down Expand Up @@ -217,9 +227,11 @@
#endif // CONFIG_CHIP_ENABLE_DNS_CLIENT
#endif // CONFIG_CHIP_ENABLE_DNSSD_SRP

#ifdef CONFIG_CHIP_ENABLE_ICD_SUPPORT
#if defined(CONFIG_CHIP_ENABLE_ICD_SUPPORT) && defined(CONFIG_CHIP_THREAD_SSED)
#define CHIP_DEVICE_CONFIG_THREAD_SSED CONFIG_CHIP_THREAD_SSED
#endif // CONFIG_CHIP_ENABLE_ICD_SUPPORT
#else
#define CHIP_DEVICE_CONFIG_THREAD_SSED 0
#endif // defined(CONFIG_CHIP_ENABLE_ICD_SUPPORT) && defined(CONFIG_CHIP_THREAD_SSED)

#ifndef CHIP_DEVICE_CONFIG_ICD_SLOW_POLL_INTERVAL
#ifdef CONFIG_CHIP_ICD_SLOW_POLL_INTERVAL
Expand All @@ -246,7 +258,7 @@
#endif // CONFIG_CHIP_EXTENDED_DISCOVERY

#ifndef CHIP_DEVICE_CONFIG_ROTATING_DEVICE_ID_UNIQUE_ID_LENGTH
#if CONFIG_CHIP_FACTORY_DATA
#ifdef CONFIG_CHIP_FACTORY_DATA
// UID will be copied from the externally programmed factory data, so we don't know the actual length and we need to assume some max
// boundary.
#define CHIP_DEVICE_CONFIG_ROTATING_DEVICE_ID_UNIQUE_ID_LENGTH CONFIG_CHIP_FACTORY_DATA_ROTATING_DEVICE_UID_MAX_LEN
Expand Down
2 changes: 1 addition & 1 deletion src/platform/nrfconnect/CHIPPlatformConfig.h
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@
#define CHIP_CONFIG_MAX_FABRICS 5
#endif

#if CONFIG_CHIP_LOG_SIZE_OPTIMIZATION
#ifdef CONFIG_CHIP_LOG_SIZE_OPTIMIZATION
// Disable some of the too detailed log modules to save flash
#define CHIP_CONFIG_LOG_MODULE_ExchangeManager_DETAIL 0
#define CHIP_CONFIG_LOG_MODULE_Crypto_DETAIL 0
Expand Down
2 changes: 1 addition & 1 deletion src/platform/nrfconnect/ExternalFlashManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ class ExternalFlashManager

virtual void DoAction(Action aAction)
{
#if CONFIG_PM_DEVICE && CONFIG_NORDIC_QSPI_NOR
#if defined(CONFIG_PM_DEVICE) && defined(CONFIG_NORDIC_QSPI_NOR)
bzbarsky-apple marked this conversation as resolved.
Show resolved Hide resolved
// utilize the QSPI driver sleep power mode
const auto * qspi_dev = DEVICE_DT_GET(DT_INST(0, nordic_qspi_nor));
if (device_is_ready(qspi_dev))
Expand Down
4 changes: 2 additions & 2 deletions src/platform/nrfconnect/FactoryDataProvider.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
#include "CHIPDevicePlatformConfig.h"
#include <crypto/CHIPCryptoPAL.h>

#if CONFIG_CHIP_CERTIFICATION_DECLARATION_STORAGE
#ifdef CONFIG_CHIP_CERTIFICATION_DECLARATION_STORAGE
#include <credentials/CertificationDeclaration.h>
#include <platform/Zephyr/ZephyrConfig.h>
#endif
Expand Down Expand Up @@ -101,7 +101,7 @@ CHIP_ERROR FactoryDataProvider<FlashFactoryData>::Init()
template <class FlashFactoryData>
CHIP_ERROR FactoryDataProvider<FlashFactoryData>::GetCertificationDeclaration(MutableByteSpan & outBuffer)
{
#if CONFIG_CHIP_CERTIFICATION_DECLARATION_STORAGE
#ifdef CONFIG_CHIP_CERTIFICATION_DECLARATION_STORAGE
size_t cdLen = 0;

if (Internal::ZephyrConfig::ReadConfigValueBin(Internal::ZephyrConfig::kConfigKey_CertificationDeclaration,
Expand Down
6 changes: 3 additions & 3 deletions src/platform/nrfconnect/OTAImageProcessorImpl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
#include <platform/CHIPDeviceLayer.h>
#include <system/SystemError.h>

#if CONFIG_CHIP_CERTIFICATION_DECLARATION_STORAGE
#ifdef CONFIG_CHIP_CERTIFICATION_DECLARATION_STORAGE
#include <credentials/CertificationDeclaration.h>
#include <platform/Zephyr/ZephyrConfig.h>
#include <zephyr/settings/settings.h>
Expand All @@ -40,7 +40,7 @@

namespace chip {
namespace {
#if CONFIG_CHIP_CERTIFICATION_DECLARATION_STORAGE
#ifdef CONFIG_CHIP_CERTIFICATION_DECLARATION_STORAGE
// Cd globals are needed to be accessed from dfu image writer lambdas
uint8_t sCdBuf[chip::Credentials::kMaxCMSSignedCDMessage] = { 0 };
size_t sCdSavedBytes = 0;
Expand Down Expand Up @@ -89,7 +89,7 @@ CHIP_ERROR OTAImageProcessorImpl::PrepareDownloadImpl()
ReturnErrorOnFailure(System::MapErrorZephyr(dfu_multi_image_register_writer(&writer)));
};

#if CONFIG_CHIP_CERTIFICATION_DECLARATION_STORAGE
#ifdef CONFIG_CHIP_CERTIFICATION_DECLARATION_STORAGE
dfu_image_writer cdWriter;
cdWriter.image_id = CONFIG_CHIP_CERTIFiCATION_DECLARATION_OTA_IMAGE_ID;
cdWriter.open = [](int id, size_t size) { return size <= sizeof(sCdBuf) ? 0 : -EFBIG; };
Expand Down
5 changes: 0 additions & 5 deletions src/platform/nrfconnect/wifi/WiFiManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -178,11 +178,6 @@ class WiFiManager
static_assert(kConnectionRecoveryMinIntervalMs < kConnectionRecoveryMaxIntervalMs);
static_assert(kConnectionRecoveryJitterMs <= kConnectionRecoveryMaxIntervalMs);

#if CHIP_DEVICE_CONFIG_ENABLE_SED
static constexpr uint8_t kDefaultDTIMInterval = 3;
static constexpr uint8_t kBeaconIntervalMs = 100;
#endif

CHIP_ERROR Init();
CHIP_ERROR Scan(const ByteSpan & ssid, ScanResultCallback resultCallback, ScanDoneCallback doneCallback,
bool internalScan = false);
Expand Down
19 changes: 16 additions & 3 deletions src/platform/telink/CHIPDevicePlatformConfig.h
Original file line number Diff line number Diff line change
Expand Up @@ -87,10 +87,19 @@
#define CHIP_DEVICE_CONFIG_DEVICE_SOFTWARE_VERSION_STRING CONFIG_CHIP_DEVICE_SOFTWARE_VERSION_STRING
#endif

#define CHIP_DEVICE_CONFIG_ENABLE_THREAD CONFIG_NET_L2_OPENTHREAD

#ifndef CHIP_DEVICE_CONFIG_ENABLE_WIFI
#define CHIP_DEVICE_CONFIG_ENABLE_WIFI 0
#endif

#if CHIP_DEVICE_CONFIG_ENABLE_WIFI
#define CHIP_DEVICE_CONFIG_ENABLE_WIFI_STATION 1
#define CHIP_DEVICE_CONFIG_ENABLE_WIFI_AP 0
#else
#define CHIP_DEVICE_CONFIG_ENABLE_WIFI_STATION 0
#define CHIP_DEVICE_CONFIG_ENABLE_WIFI_AP 0

#define CHIP_DEVICE_CONFIG_ENABLE_THREAD CONFIG_NET_L2_OPENTHREAD
#endif

#define CHIP_DEVICE_CONFIG_ENABLE_CHIPOBLE CONFIG_BT

Expand Down Expand Up @@ -187,7 +196,7 @@
#endif // CHIP_DEVICE_CONFIG_CHIP_TASK_PRIORITY

#ifndef CHIP_DEVICE_CONFIG_CHIP_TASK_STACK_SIZE
#if CONFIG_PM
#ifdef CONFIG_PM
#define CHIP_DEVICE_CONFIG_CHIP_TASK_STACK_SIZE 4864
#else
#define CHIP_DEVICE_CONFIG_CHIP_TASK_STACK_SIZE 8192
Expand Down Expand Up @@ -237,3 +246,7 @@
#define CHIP_DEVICE_CONFIG_ICD_FAST_POLL_INTERVAL chip::System::Clock::Milliseconds32(CONFIG_CHIP_ICD_FAST_POLLING_INTERVAL)
#endif // CONFIG_CHIP_ICD_FAST_POLLING_INTERVAL
#endif // CHIP_DEVICE_CONFIG_ICD_FAST_POLL_INTERVAL

#ifndef CONFIG_CHIP_CERTIFICATION_DECLARATION_STORAGE
#define CONFIG_CHIP_CERTIFICATION_DECLARATION_STORAGE 0
#endif // CONFIG_CHIP_CERTIFICATION_DECLARATION_STORAGE
6 changes: 5 additions & 1 deletion src/platform/telink/CHIPPlatformConfig.h
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@
#define CHIP_CONFIG_BDX_MAX_NUM_TRANSFERS 1
#endif // CHIP_CONFIG_BDX_MAX_NUM_TRANSFERS

#if CONFIG_PM
#ifdef CONFIG_PM

#ifndef CHIP_CONFIG_ENABLE_SERVER_IM_EVENT
#define CHIP_CONFIG_ENABLE_SERVER_IM_EVENT 0
Expand Down Expand Up @@ -106,6 +106,10 @@
#define CHIP_CONFIG_MAX_FABRICS 5
#endif

#ifndef CONFIG_CHIP_LOG_SIZE_OPTIMIZATION
#define CONFIG_CHIP_LOG_SIZE_OPTIMIZATION 0
#endif

#if CONFIG_CHIP_LOG_SIZE_OPTIMIZATION
// Disable some of the too detailed log modules to save flash
#define CHIP_CONFIG_LOG_MODULE_ExchangeManager_DETAIL 0
Expand Down
2 changes: 1 addition & 1 deletion src/platform/telink/SystemPlatformConfig.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ struct ChipDeviceEvent;
#define CHIP_SYSTEM_CONFIG_USE_SOCKETS 1

// Reduce packet buffer pool size (default 15) to reduce ram consumption
#if CONFIG_PM
#ifdef CONFIG_PM
#define CHIP_SYSTEM_CONFIG_PACKETBUFFER_POOL_SIZE 0
#else
#define CHIP_SYSTEM_CONFIG_PACKETBUFFER_POOL_SIZE 8
Expand Down
4 changes: 2 additions & 2 deletions src/system/SystemConfig.h
Original file line number Diff line number Diff line change
Expand Up @@ -733,7 +733,7 @@ struct LwIPEvent;
* Defaults to enabled on Zephyr platforms that do not enable Zephyr POSIX layer.
*/
#ifndef CHIP_SYSTEM_CONFIG_USE_ZEPHYR_SOCKETS
#if CHIP_SYSTEM_CONFIG_USE_SOCKETS && defined(__ZEPHYR__) && CONFIG_NET_SOCKETS_POSIX_NAMES
#if CHIP_SYSTEM_CONFIG_USE_SOCKETS && defined(__ZEPHYR__) && defined(CONFIG_NET_SOCKETS_POSIX_NAMES)
bzbarsky-apple marked this conversation as resolved.
Show resolved Hide resolved
#define CHIP_SYSTEM_CONFIG_USE_ZEPHYR_SOCKETS 1
#else
#define CHIP_SYSTEM_CONFIG_USE_ZEPHYR_SOCKETS 0
Expand Down Expand Up @@ -765,7 +765,7 @@ struct LwIPEvent;
* Defaults to enabled on Zephyr platforms that enable CONFIG_EVENTFD.
*/
#ifndef CHIP_SYSTEM_CONFIG_USE_ZEPHYR_EVENTFD
#if defined(__ZEPHYR__) && CONFIG_EVENTFD
#if defined(__ZEPHYR__) && defined(CONFIG_EVENTFD)
bzbarsky-apple marked this conversation as resolved.
Show resolved Hide resolved
#define CHIP_SYSTEM_CONFIG_USE_ZEPHYR_EVENTFD 1
#else
#define CHIP_SYSTEM_CONFIG_USE_ZEPHYR_EVENTFD 0
Expand Down
Loading