From f05834b4a513f5b7fcb879f74119afcc05e10f77 Mon Sep 17 00:00:00 2001 From: doru91 Date: Thu, 2 Jun 2022 21:09:09 +0300 Subject: [PATCH] [K32W0] TE9 fixes (#18952) * [K32W0] TE9 fixes * patch BLE and PDM libraries * remove LWIP from K32W0 * add locking mechanism in UDPEndpointImplOpenThread * re-enable detail logging * enable BLE 2M bitrate * updated max number of KVS keys * undefine OPENTHREAD_CONFIG_PLATFORM_CSL_UNCERT as is not needed anymore * use the correct OT configuration * increase the number of packet buffers * add API "bool _IsAdvertising(void)" implementation on our k32w platform * fix OTA compilation issue * fix signing script * fix compilation error (missing idle task function) * fix lock-app LEDs states Signed-off-by: Doru Gucea * Fixes * increase the maximum number of KVS keys * remove unused file. Signed-off-by: Doru Gucea * Fix section name Signed-off-by: Doru Gucea * Fix section matching for buffer pool Signed-off-by: Doru Gucea --- .../nxp/k32w/k32w0/main/AppTask.cpp | 31 +++++++++--- .../nxp/k32w/k32w0/main/include/app_config.h | 4 +- .../lock-app/nxp/k32w/k32w0/main/AppTask.cpp | 19 +++++++ .../nxp/k32w/k32w0/main/include/app_config.h | 4 +- .../app/ldscripts/chip-k32w061-linker.ld | 4 +- .../app/project_include/OpenThreadConfig.h | 49 +++++++++++++++++-- .../k32w/k32w0/app/support/FreeRtosHooks.c | 6 ++- examples/platform/nxp/k32w/k32w0/args.gni | 3 ++ .../shell/nxp/k32w/k32w0/main/AppTask.cpp | 19 +++++++ examples/shell/nxp/k32w/k32w0/main/main.cpp | 2 +- .../nxp/k32w/k32w0/BLEManagerImpl.cpp | 13 ++++- .../k32w/k32w0/ConnectivityManagerImpl.cpp | 2 + .../k32w/k32w0/DiagnosticDataProviderImpl.cpp | 2 + .../k32w/k32w0/KeyValueStoreManagerImpl.cpp | 2 +- src/platform/nxp/k32w/k32w0/Logging.cpp | 2 + .../nxp/k32w/k32w0/PlatformManagerImpl.cpp | 4 ++ .../nxp/k32w/k32w0/SystemPlatformConfig.h | 1 + .../nxp/k32w/k32w0/ThreadStackManagerImpl.cpp | 4 +- .../nxp/k32w/k32w0/ThreadStackManagerImpl.h | 6 +-- .../nxp/k32w/k32w0/WarmPlatformConfig.h | 40 --------------- src/platform/nxp/k32w/k32w0/args.gni | 5 +- src/system/BUILD.gn | 3 ++ third_party/nxp/k32w0_sdk/k32w0_sdk.gni | 6 ++- .../nxp/k32w0_sdk/sdk_fixes/patch_k32w_sdk.sh | 16 ++++++ .../platforms/nxp/k32w/k32w0/BUILD.gn | 2 +- 25 files changed, 177 insertions(+), 72 deletions(-) delete mode 100644 src/platform/nxp/k32w/k32w0/WarmPlatformConfig.h diff --git a/examples/lighting-app/nxp/k32w/k32w0/main/AppTask.cpp b/examples/lighting-app/nxp/k32w/k32w0/main/AppTask.cpp index 4e8d5c5fb6cec4..f5b14b9eb2a7e3 100644 --- a/examples/lighting-app/nxp/k32w/k32w0/main/AppTask.cpp +++ b/examples/lighting-app/nxp/k32w/k32w0/main/AppTask.cpp @@ -28,6 +28,8 @@ #include #include +#include + #include #include #include @@ -184,12 +186,27 @@ CHIP_ERROR AppTask::Init() return err; } +void LockOpenThreadTask(void) +{ + chip::DeviceLayer::ThreadStackMgr().LockThreadStack(); +} + +void UnlockOpenThreadTask(void) +{ + chip::DeviceLayer::ThreadStackMgr().UnlockThreadStack(); +} + void AppTask::InitServer(intptr_t arg) { static chip::CommonCaseDeviceServerInitParams initParams; (void) initParams.InitializeStaticResourcesBeforeServerInit(); // Init ZCL Data Model and start server + chip::Inet::EndPointStateOpenThread::OpenThreadEndpointInitParam nativeParams; + nativeParams.lockCb = LockOpenThreadTask; + nativeParams.unlockCb = UnlockOpenThreadTask; + nativeParams.openThreadInstancePtr = chip::DeviceLayer::ThreadStackMgrImpl().OTInstance(); + initParams.endpointNativeParams = static_cast(&nativeParams); VerifyOrDie((chip::Server::GetInstance().Init(initParams)) == CHIP_NO_ERROR); } @@ -690,13 +707,6 @@ void AppTask::OTAResumeEventHandler(AppEvent * aEvent) } } -extern "C" void vApplicationIdleHook(void) -{ -#if CHIP_DEVICE_CONFIG_ENABLE_OTA_REQUESTOR - OTA_TransactionResume(); -#endif -} - void AppTask::PostEvent(const AppEvent * aEvent) { if (sAppEventQueue != NULL) @@ -753,3 +763,10 @@ void AppTask::UpdateDeviceStateInternal(intptr_t arg) /* set the device state */ sLightLED.Set(onoffAttrValue); } + +extern "C" void OTAIdleActivities(void) +{ +#if CHIP_DEVICE_CONFIG_ENABLE_OTA_REQUESTOR + OTA_TransactionResume(); +#endif +} diff --git a/examples/lighting-app/nxp/k32w/k32w0/main/include/app_config.h b/examples/lighting-app/nxp/k32w/k32w0/main/include/app_config.h index b12d3284b2be3a..eaf82926e65b8f 100644 --- a/examples/lighting-app/nxp/k32w/k32w0/main/include/app_config.h +++ b/examples/lighting-app/nxp/k32w/k32w0/main/include/app_config.h @@ -34,8 +34,8 @@ #define APP_BUTTON_PUSH 1 -#define SYSTEM_STATE_LED LED1 -#define LIGHT_STATE_LED LED2 +#define SYSTEM_STATE_LED LED2 +#define LIGHT_STATE_LED LED1 // Time it takes for the light to switch on/off #define ACTUATOR_MOVEMENT_PERIOS_MS 50 diff --git a/examples/lock-app/nxp/k32w/k32w0/main/AppTask.cpp b/examples/lock-app/nxp/k32w/k32w0/main/AppTask.cpp index 2572cdd35a2698..015784f6d6e8dd 100644 --- a/examples/lock-app/nxp/k32w/k32w0/main/AppTask.cpp +++ b/examples/lock-app/nxp/k32w/k32w0/main/AppTask.cpp @@ -28,6 +28,8 @@ #include #include +#include + #include #include #include @@ -162,12 +164,27 @@ CHIP_ERROR AppTask::Init() return err; } +void LockOpenThreadTask(void) +{ + chip::DeviceLayer::ThreadStackMgr().LockThreadStack(); +} + +void UnlockOpenThreadTask(void) +{ + chip::DeviceLayer::ThreadStackMgr().UnlockThreadStack(); +} + void AppTask::InitServer(intptr_t arg) { static chip::CommonCaseDeviceServerInitParams initParams; (void) initParams.InitializeStaticResourcesBeforeServerInit(); // Init ZCL Data Model and start server + chip::Inet::EndPointStateOpenThread::OpenThreadEndpointInitParam nativeParams; + nativeParams.lockCb = LockOpenThreadTask; + nativeParams.unlockCb = UnlockOpenThreadTask; + nativeParams.openThreadInstancePtr = chip::DeviceLayer::ThreadStackMgrImpl().OTInstance(); + initParams.endpointNativeParams = static_cast(&nativeParams); VerifyOrDie((chip::Server::GetInstance().Init(initParams)) == CHIP_NO_ERROR); } @@ -739,3 +756,5 @@ void AppTask::UpdateClusterStateInternal(intptr_t arg) ChipLogError(NotSpecified, "ERR: updating on/off %x", status); } } + +extern "C" void OTAIdleActivities(void) {} diff --git a/examples/lock-app/nxp/k32w/k32w0/main/include/app_config.h b/examples/lock-app/nxp/k32w/k32w0/main/include/app_config.h index 1d0ff5a16b17d2..cfed43e850c4bc 100644 --- a/examples/lock-app/nxp/k32w/k32w0/main/include/app_config.h +++ b/examples/lock-app/nxp/k32w/k32w0/main/include/app_config.h @@ -34,8 +34,8 @@ #define APP_BUTTON_PUSH 1 -#define LOCK_STATE_LED LED1 -#define SYSTEM_STATE_LED LED2 +#define LOCK_STATE_LED LED2 +#define SYSTEM_STATE_LED LED1 // Time it takes in ms for the simulated actuator to move from one // state to another. diff --git a/examples/platform/nxp/k32w/k32w0/app/ldscripts/chip-k32w061-linker.ld b/examples/platform/nxp/k32w/k32w0/app/ldscripts/chip-k32w061-linker.ld index 3bb149e142b48c..3bb028d183d9dd 100644 --- a/examples/platform/nxp/k32w/k32w0/app/ldscripts/chip-k32w061-linker.ld +++ b/examples/platform/nxp/k32w/k32w0/app/ldscripts/chip-k32w061-linker.ld @@ -211,9 +211,9 @@ SECTIONS _etext = .; - .heap_controller (COPY): + .heap_packet_buffer (COPY): { - *(.ll_exchange_mem) + *(.bss._ZN4chip6System12PacketBuffer11sBufferPoolE) __HeapBase = .; _heap = .; KEEP(*(.heap*)) diff --git a/examples/platform/nxp/k32w/k32w0/app/project_include/OpenThreadConfig.h b/examples/platform/nxp/k32w/k32w0/app/project_include/OpenThreadConfig.h index f59258a294be03..667574786bb91e 100644 --- a/examples/platform/nxp/k32w/k32w0/app/project_include/OpenThreadConfig.h +++ b/examples/platform/nxp/k32w/k32w0/app/project_include/OpenThreadConfig.h @@ -22,40 +22,80 @@ * */ +#include "openthread-core-k32w061-config.h" + #pragma once // Disable the Nxp-supplied OpenThread logging facilities // and use the facilities provided by the Device Layer // (see src/platform/K32W/Logging.cpp). +#undef OPENTHREAD_CONFIG_LOG_OUTPUT #define OPENTHREAD_CONFIG_LOG_OUTPUT OPENTHREAD_CONFIG_LOG_OUTPUT_APP // When operating in a less than ideal RF environment, having a more forgiving configuration // of OpenThread makes thread a great deal more reliable. -#define OPENTHREAD_CONFIG_TMF_ADDRESS_QUERY_MAX_RETRY_DELAY 120 // default is 28800 +#undef OPENTHREAD_CONFIG_TMF_ADDRESS_QUERY_MAX_RETRY_DELAY +#define OPENTHREAD_CONFIG_TMF_ADDRESS_QUERY_MAX_RETRY_DELAY 120 // default is 28800 + +#undef OPENTHREAD_CONFIG_MAC__DEFAULT_MAX_FRAME_RETRIES_DIRECT #define OPENTHREAD_CONFIG_MAC__DEFAULT_MAX_FRAME_RETRIES_DIRECT 15 // default is 3 + +#undef OPENTHREAD_CONFIG_MAC_DEFAULT_MAX_FRAME_RETRIES_INDIRECT #define OPENTHREAD_CONFIG_MAC_DEFAULT_MAX_FRAME_RETRIES_INDIRECT 1 // default is 0 -#define OPENTHREAD_CONFIG_MAC_MAX_TX_ATTEMPTS_INDIRECT_POLLS 16 // default is 4 + +#undef OPENTHREAD_CONFIG_MAC_MAX_TX_ATTEMPTS_INDIRECT_POLLS +#define OPENTHREAD_CONFIG_MAC_MAX_TX_ATTEMPTS_INDIRECT_POLLS 16 // default is 4 // Enable periodic parent search to speed up finding a better parent. -#define OPENTHREAD_CONFIG_PARENT_SEARCH_ENABLE 1 // default is 0 -#define OPENTHREAD_CONFIG_PARENT_SEARCH_RSS_THRESHOLD -45 // default is -65 +#undef OPENTHREAD_CONFIG_PARENT_SEARCH_ENABLE +#define OPENTHREAD_CONFIG_PARENT_SEARCH_ENABLE 1 // default is 0 + +#undef OPENTHREAD_CONFIG_PARENT_SEARCH_RSS_THRESHOLD +#define OPENTHREAD_CONFIG_PARENT_SEARCH_RSS_THRESHOLD -45 // default is -65 + +#undef OPENTHREAD_CONFIG_MLE_INFORM_PREVIOUS_PARENT_ON_REATTACH #define OPENTHREAD_CONFIG_MLE_INFORM_PREVIOUS_PARENT_ON_REATTACH 1 // default is 0 // Use smaller maximum interval to speed up reattaching. +#undef OPENTHREAD_CONFIG_MLE_ATTACH_BACKOFF_MAXIMUM_INTERVAL #define OPENTHREAD_CONFIG_MLE_ATTACH_BACKOFF_MAXIMUM_INTERVAL (60 * 10 * 1000) // default 1200000 ms // disable unused features +#undef OPENTHREAD_CONFIG_COAP_API_ENABLE #define OPENTHREAD_CONFIG_COAP_API_ENABLE 0 + +#undef OPENTHREAD_CONFIG_JOINER_ENABLE #define OPENTHREAD_CONFIG_JOINER_ENABLE 0 + +#undef OPENTHREAD_CONFIG_COMMISSIONER_ENABLE #define OPENTHREAD_CONFIG_COMMISSIONER_ENABLE 0 + +#undef OPENTHREAD_CONFIG_UDP_FORWARD_ENABLE #define OPENTHREAD_CONFIG_UDP_FORWARD_ENABLE 0 + +#undef OPENTHREAD_CONFIG_BORDER_ROUTER_ENABLE #define OPENTHREAD_CONFIG_BORDER_ROUTER_ENABLE 0 + +#undef OPENTHREAD_CONFIG_DHCP6_CLIENT_ENABLE #define OPENTHREAD_CONFIG_DHCP6_CLIENT_ENABLE 0 + +#undef OPENTHREAD_CONFIG_DHCP6_SERVER_ENABLE #define OPENTHREAD_CONFIG_DHCP6_SERVER_ENABLE 0 + +#undef OPENTHREAD_CONFIG_TCP_ENABLE #define OPENTHREAD_CONFIG_TCP_ENABLE 0 +#undef OPENTHREAD_CONFIG_MLE_LINK_METRICS_SUBJECT_ENABLE +#define OPENTHREAD_CONFIG_MLE_LINK_METRICS_SUBJECT_ENABLE 0 + +#undef OPENTHREAD_CONFIG_MLE_LINK_METRICS_INITIATOR_ENABLE +#define OPENTHREAD_CONFIG_MLE_LINK_METRICS_INITIATOR_ENABLE 0 + +#undef OPENTHREAD_CONFIG_NUM_MESSAGE_BUFFERS #define OPENTHREAD_CONFIG_NUM_MESSAGE_BUFFERS 44 +#undef OPENTHREAD_CONFIG_PLATFORM_CSL_UNCERT + //#define OPENTHREAD_CONFIG_LOG_LEVEL OT_LOG_LEVEL_DEBG // Use the NXP-supplied default platform configuration for remainder @@ -64,4 +104,3 @@ // NB: This file gets included during the build of OpenThread. Hence // it cannot use "openthread" in the path to the included file. // -#include "openthread-core-k32w061-config.h" diff --git a/examples/platform/nxp/k32w/k32w0/app/support/FreeRtosHooks.c b/examples/platform/nxp/k32w/k32w0/app/support/FreeRtosHooks.c index 0884a8f261f226..8b94397ae7a39d 100644 --- a/examples/platform/nxp/k32w/k32w0/app/support/FreeRtosHooks.c +++ b/examples/platform/nxp/k32w/k32w0/app/support/FreeRtosHooks.c @@ -217,6 +217,7 @@ void vPortSuppressTicksAndSleep(TickType_t xExpectedIdleTime) OSA_InterruptEnable(); } +#endif /* (cPWR_UsePowerDownMode) && (configUSE_TICKLESS_IDLE != 0) */ static void BOARD_ActionOnIdle(void) { @@ -228,9 +229,10 @@ static void BOARD_ActionOnIdle(void) #endif } +extern void OTAIdleActivities(); + void vApplicationIdleHook(void) { + OTAIdleActivities(); BOARD_ActionOnIdle(); } - -#endif /* (cPWR_UsePowerDownMode) && (configUSE_TICKLESS_IDLE != 0) */ diff --git a/examples/platform/nxp/k32w/k32w0/args.gni b/examples/platform/nxp/k32w/k32w0/args.gni index 747d22ba2ad90e..954fad9a2faee2 100644 --- a/examples/platform/nxp/k32w/k32w0/args.gni +++ b/examples/platform/nxp/k32w/k32w0/args.gni @@ -32,3 +32,6 @@ chip_system_project_config_include = "" chip_system_config_provide_statistics = false chip_with_nlfaultinjection = true + +chip_system_config_use_open_thread_inet_endpoints = true +chip_with_lwip = false diff --git a/examples/shell/nxp/k32w/k32w0/main/AppTask.cpp b/examples/shell/nxp/k32w/k32w0/main/AppTask.cpp index 89b0e14eb59717..efb0ccdadeaaf5 100644 --- a/examples/shell/nxp/k32w/k32w0/main/AppTask.cpp +++ b/examples/shell/nxp/k32w/k32w0/main/AppTask.cpp @@ -28,6 +28,8 @@ #include #include +#include + #include "Keyboard.h" #include "LED.h" #include "LEDWidget.h" @@ -69,6 +71,16 @@ CHIP_ERROR AppTask::StartAppTask() return err; } +void LockOpenThreadTask(void) +{ + chip::DeviceLayer::ThreadStackMgr().LockThreadStack(); +} + +void UnlockOpenThreadTask(void) +{ + chip::DeviceLayer::ThreadStackMgr().UnlockThreadStack(); +} + CHIP_ERROR AppTask::Init() { CHIP_ERROR err = CHIP_NO_ERROR; @@ -76,6 +88,11 @@ CHIP_ERROR AppTask::Init() // Init ZCL Data Model and start server static chip::CommonCaseDeviceServerInitParams initParams; (void) initParams.InitializeStaticResourcesBeforeServerInit(); + chip::Inet::EndPointStateOpenThread::OpenThreadEndpointInitParam nativeParams; + nativeParams.lockCb = LockOpenThreadTask; + nativeParams.unlockCb = UnlockOpenThreadTask; + nativeParams.openThreadInstancePtr = chip::DeviceLayer::ThreadStackMgrImpl().OTInstance(); + initParams.endpointNativeParams = static_cast(&nativeParams); chip::Server::GetInstance().Init(initParams); // Initialize device attestation config @@ -434,3 +451,5 @@ void AppTask::DispatchEvent(AppEvent * aEvent) K32W_LOG("Event received with no handler. Dropping event."); } } + +extern "C" void OTAIdleActivities(void) {} diff --git a/examples/shell/nxp/k32w/k32w0/main/main.cpp b/examples/shell/nxp/k32w/k32w0/main/main.cpp index 196623359aaffd..2cb58a3b34f660 100644 --- a/examples/shell/nxp/k32w/k32w0/main/main.cpp +++ b/examples/shell/nxp/k32w/k32w0/main/main.cpp @@ -50,7 +50,7 @@ extern InitFunc __init_array_start; extern InitFunc __init_array_end; /* needed for FreeRtos Heap 4 */ -uint8_t __attribute__((section(".heap"))) ucHeap[0xF000]; +uint8_t __attribute__((section(".heap"))) ucHeap[HEAP_SIZE]; extern "C" unsigned int sleep(unsigned int seconds) { diff --git a/src/platform/nxp/k32w/k32w0/BLEManagerImpl.cpp b/src/platform/nxp/k32w/k32w0/BLEManagerImpl.cpp index 288cfbffbec3ea..cc46ea6602a4b8 100644 --- a/src/platform/nxp/k32w/k32w0/BLEManagerImpl.cpp +++ b/src/platform/nxp/k32w/k32w0/BLEManagerImpl.cpp @@ -184,7 +184,6 @@ CHIP_ERROR BLEManagerImpl::_Init() VerifyOrExit(bleAppCreated == pdPASS, err = CHIP_ERROR_INCORRECT_STATE); /* BLE Radio Init */ - XCVR_TemperatureUpdate(BOARD_GetTemperature()); VerifyOrExit(XCVR_Init(BLE_MODE, DR_2MBPS) == gXcvrSuccess_c, err = CHIP_ERROR_INCORRECT_STATE); /* Create BLE Controller Task */ @@ -245,6 +244,11 @@ bool BLEManagerImpl::_IsAdvertisingEnabled(void) return mFlags.Has(Flags::kAdvertisingEnabled); } +bool BLEManagerImpl::_IsAdvertising(void) +{ + return mFlags.Has(Flags::kAdvertising); +} + bool BLEManagerImpl::RemoveConnection(uint8_t connectionHandle) { CHIPoBLEConState * bleConnState = GetConnectionState(connectionHandle, true); @@ -1010,7 +1014,7 @@ void BLEManagerImpl::bleAppTask(void * p_arg) if (msg->type == BLE_KW_MSG_ERROR) { - ChipLogProgress(DeviceLayer, "BLE Fatal Error: %d.\n", msg->data.u8); + ChipLogProgress(DeviceLayer, "BLE Error: %d.\n", msg->data.u8); } else if (msg->type == BLE_KW_MSG_CONNECTED) { @@ -1276,6 +1280,11 @@ void BLEManagerImpl::blekw_gap_connection_cb(deviceId_t deviceId, gapConnectionE if (pConnectionEvent->eventType == gConnEvtConnected_c) { + ChipLogProgress(DeviceLayer, "BLE K32W: Trying to set the PHY to 2M"); + + (void) Gap_LeSetPhy(FALSE, deviceId, 0, gConnPhyUpdateReqTxPhySettings_c, gConnPhyUpdateReqRxPhySettings_c, + (uint16_t) gConnPhyUpdateReqPhyOptions_c); + /* Notify App Task that the BLE is connected now */ (void) blekw_msg_add_u8(BLE_KW_MSG_CONNECTED, (uint8_t) deviceId); #if defined(cPWR_UsePowerDownMode) && (cPWR_UsePowerDownMode) diff --git a/src/platform/nxp/k32w/k32w0/ConnectivityManagerImpl.cpp b/src/platform/nxp/k32w/k32w0/ConnectivityManagerImpl.cpp index 9fc2bacaf5d8a2..51227fa1019c63 100644 --- a/src/platform/nxp/k32w/k32w0/ConnectivityManagerImpl.cpp +++ b/src/platform/nxp/k32w/k32w0/ConnectivityManagerImpl.cpp @@ -24,10 +24,12 @@ #include #include +#if CHIP_SYSTEM_CONFIG_USE_LWIP #include #include #include #include +#endif #if CHIP_DEVICE_CONFIG_ENABLE_CHIPOBLE #include diff --git a/src/platform/nxp/k32w/k32w0/DiagnosticDataProviderImpl.cpp b/src/platform/nxp/k32w/k32w0/DiagnosticDataProviderImpl.cpp index 14e4126a066166..6df2cfb5b1785b 100644 --- a/src/platform/nxp/k32w/k32w0/DiagnosticDataProviderImpl.cpp +++ b/src/platform/nxp/k32w/k32w0/DiagnosticDataProviderImpl.cpp @@ -27,7 +27,9 @@ #include #include +#if CHIP_SYSTEM_CONFIG_USE_LWIP #include +#endif #include diff --git a/src/platform/nxp/k32w/k32w0/KeyValueStoreManagerImpl.cpp b/src/platform/nxp/k32w/k32w0/KeyValueStoreManagerImpl.cpp index 09fe21772150b4..cf30ee9a4c6eb1 100644 --- a/src/platform/nxp/k32w/k32w0/KeyValueStoreManagerImpl.cpp +++ b/src/platform/nxp/k32w/k32w0/KeyValueStoreManagerImpl.cpp @@ -38,7 +38,7 @@ namespace DeviceLayer { namespace PersistedStorage { /* TODO: adjust these values */ -constexpr size_t kMaxNumberOfKeys = 30; +constexpr size_t kMaxNumberOfKeys = 125; constexpr size_t kMaxKeyValueBytes = 255; KeyValueStoreManagerImpl KeyValueStoreManagerImpl::sInstance; diff --git a/src/platform/nxp/k32w/k32w0/Logging.cpp b/src/platform/nxp/k32w/k32w0/Logging.cpp index 4d3a5ce2f8c9c5..eca2baf51216c1 100644 --- a/src/platform/nxp/k32w/k32w0/Logging.cpp +++ b/src/platform/nxp/k32w/k32w0/Logging.cpp @@ -157,6 +157,7 @@ void ENFORCE_FORMAT(3, 0) LogV(const char * module, uint8_t category, const char #undef K32W_LOG_MODULE_NAME #define K32W_LOG_MODULE_NAME lwip +#if CHIP_SYSTEM_CONFIG_USE_LWIP /** * LwIP log output function. */ @@ -169,6 +170,7 @@ extern "C" void ENFORCE_FORMAT(1, 2) LwIPLog(const char * msg, ...) GenericLog(msg, v, module, chip::Logging::kLogCategory_None); va_end(v); } +#endif // CHIP_SYSTEM_CONFIG_USE_LWIP #if CHIP_DEVICE_CONFIG_ENABLE_THREAD diff --git a/src/platform/nxp/k32w/k32w0/PlatformManagerImpl.cpp b/src/platform/nxp/k32w/k32w0/PlatformManagerImpl.cpp index ef6c5c3556d1dd..95303b4e922666 100644 --- a/src/platform/nxp/k32w/k32w0/PlatformManagerImpl.cpp +++ b/src/platform/nxp/k32w/k32w0/PlatformManagerImpl.cpp @@ -31,7 +31,9 @@ #include #include +#if CHIP_SYSTEM_CONFIG_USE_LWIP #include +#endif #include @@ -114,8 +116,10 @@ CHIP_ERROR PlatformManagerImpl::_InitChipStack(void) mStartTime = System::SystemClock().GetMonotonicTimestamp(); +#if CHIP_SYSTEM_CONFIG_USE_LWIP // Initialize LwIP. tcpip_init(NULL, NULL); +#endif err = chip::Crypto::add_entropy_source(app_entropy_source, NULL, 16); SuccessOrExit(err); diff --git a/src/platform/nxp/k32w/k32w0/SystemPlatformConfig.h b/src/platform/nxp/k32w/k32w0/SystemPlatformConfig.h index d1b09b1f70c58f..a589a86223d16d 100644 --- a/src/platform/nxp/k32w/k32w0/SystemPlatformConfig.h +++ b/src/platform/nxp/k32w/k32w0/SystemPlatformConfig.h @@ -37,6 +37,7 @@ struct ChipDeviceEvent; // ==================== Platform Adaptations ==================== #define CHIP_SYSTEM_CONFIG_PLATFORM_PROVIDES_TIME 1 #define CHIP_SYSTEM_CONFIG_EVENT_OBJECT_TYPE const struct ::chip::DeviceLayer::ChipDeviceEvent * +#define CHIP_SYSTEM_CONFIG_PACKETBUFFER_POOL_SIZE 11 // ========== Platform-specific Configuration Overrides ========= diff --git a/src/platform/nxp/k32w/k32w0/ThreadStackManagerImpl.cpp b/src/platform/nxp/k32w/k32w0/ThreadStackManagerImpl.cpp index 3c11ed202c29f7..7f5d4961ba41e4 100644 --- a/src/platform/nxp/k32w/k32w0/ThreadStackManagerImpl.cpp +++ b/src/platform/nxp/k32w/k32w0/ThreadStackManagerImpl.cpp @@ -32,7 +32,7 @@ #include #include -#include +#include #include @@ -55,7 +55,7 @@ CHIP_ERROR ThreadStackManagerImpl::InitThreadStack(otInstance * otInst) // Initialize the generic implementation base classes. err = GenericThreadStackManagerImpl_FreeRTOS::DoInit(); SuccessOrExit(err); - err = GenericThreadStackManagerImpl_OpenThread_LwIP::DoInit(otInst); + err = GenericThreadStackManagerImpl_OpenThread::DoInit(otInst); SuccessOrExit(err); exit: diff --git a/src/platform/nxp/k32w/k32w0/ThreadStackManagerImpl.h b/src/platform/nxp/k32w/k32w0/ThreadStackManagerImpl.h index 5f0ee2917240ab..5e68b31524d81b 100644 --- a/src/platform/nxp/k32w/k32w0/ThreadStackManagerImpl.h +++ b/src/platform/nxp/k32w/k32w0/ThreadStackManagerImpl.h @@ -28,7 +28,7 @@ #include #include #include -#include +#include extern "C" void otSysEventSignalPending(void); @@ -46,7 +46,7 @@ extern int GetEntropy_K32W(uint8_t * buf, size_t bufSize); * using the NXP SDK and the OpenThread stack. */ class ThreadStackManagerImpl final : public ThreadStackManager, - public Internal::GenericThreadStackManagerImpl_OpenThread_LwIP, + public Internal::GenericThreadStackManagerImpl_OpenThread, public Internal::GenericThreadStackManagerImpl_FreeRTOS { // Allow the ThreadStackManager interface class to delegate method calls to @@ -57,7 +57,7 @@ class ThreadStackManagerImpl final : public ThreadStackManager, // this class. #ifndef DOXYGEN_SHOULD_SKIP_THIS friend Internal::GenericThreadStackManagerImpl_OpenThread; - friend Internal::GenericThreadStackManagerImpl_OpenThread_LwIP; + friend Internal::GenericThreadStackManagerImpl_OpenThread; friend Internal::GenericThreadStackManagerImpl_FreeRTOS; #endif diff --git a/src/platform/nxp/k32w/k32w0/WarmPlatformConfig.h b/src/platform/nxp/k32w/k32w0/WarmPlatformConfig.h deleted file mode 100644 index b249c23837f10a..00000000000000 --- a/src/platform/nxp/k32w/k32w0/WarmPlatformConfig.h +++ /dev/null @@ -1,40 +0,0 @@ -/* - * - * Copyright (c) 2020 Project CHIP Authors - * Copyright (c) 2020 Google LLC. - * All rights reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/** - * @file - * Platform-specific configuration overrides for the Chip - * Addressing and Routing Module (WARM) on K32W platforms - * using the NXP SDK. - * - */ - -#pragma once - -// ==================== Platform Adaptations ==================== - -#define WARM_CONFIG_SUPPORT_THREAD 1 -#define WARM_CONFIG_SUPPORT_THREAD_ROUTING 0 -#define WARM_CONFIG_SUPPORT_LEGACY6LOWPAN_NETWORK 0 -#define WARM_CONFIG_SUPPORT_WIFI 0 -#define WARM_CONFIG_SUPPORT_CELLULAR 0 - -// ========== Platform-specific Configuration Overrides ========= - -/* none so far */ diff --git a/src/platform/nxp/k32w/k32w0/args.gni b/src/platform/nxp/k32w/k32w0/args.gni index d6ccbd8bb86e29..1d72bfc74b1f2c 100644 --- a/src/platform/nxp/k32w/k32w0/args.gni +++ b/src/platform/nxp/k32w/k32w0/args.gni @@ -29,9 +29,12 @@ chip_build_tests = false chip_mdns = "platform" # Trying to fit into the available flash by disabling optional logging for now -chip_detail_logging = false +chip_detail_logging = true chip_progress_logging = true +chip_system_config_use_open_thread_inet_endpoints = true +chip_with_lwip = false + mbedtls_target = "${chip_root}/third_party/nxp/k32w0_sdk:mbedtls" openthread_external_mbedtls = mbedtls_target diff --git a/src/system/BUILD.gn b/src/system/BUILD.gn index 4dc27781e2ba0c..c05b19a2b62a06 100644 --- a/src/system/BUILD.gn +++ b/src/system/BUILD.gn @@ -145,6 +145,9 @@ source_set("system_config_header") { if (chip_device_platform == "qpg") { public_deps += [ "${qpg_sdk_build_root}:qpg_sdk" ] } + if (chip_device_platform == "k32w0") { + public_deps += [ "${k32w0_sdk_build_root}:k32w0_sdk" ] + } # Add platform here as needed. } diff --git a/third_party/nxp/k32w0_sdk/k32w0_sdk.gni b/third_party/nxp/k32w0_sdk/k32w0_sdk.gni index b9a9889e1f4a40..8b844cadaf03ae 100644 --- a/third_party/nxp/k32w0_sdk/k32w0_sdk.gni +++ b/third_party/nxp/k32w0_sdk/k32w0_sdk.gni @@ -158,7 +158,7 @@ template("k32w0_sdk") { "USE_SDK_OSA=0", "gSerialManagerMaxInterfaces_c=2", "FSL_RTOS_FREE_RTOS=1", - "gTotalHeapSize_c=0xDC00", + "gTotalHeapSize_c=0xB000", "gUartDebugConsole_d=1", "DEBUG_SERIAL_INTERFACE_INSTANCE=0", "APP_SERIAL_INTERFACE_INSTANCE=1", @@ -187,6 +187,9 @@ template("k32w0_sdk") { "gSupportBle=1", "SUPPORT_FOR_BLE=1", "gEnableBleInactivityTimeNotify=1", + "gConnPhyUpdateReqTxPhySettings_c=(gLePhy2MFlag_c)", + "gConnPhyUpdateReqRxPhySettings_c=(gLePhy2MFlag_c)", + "gConnPhyUpdateReqPhyOptions_c=(gLeCodingNoPreference_c)", "DUAL_MODE_APP=1", "gMainThreadStackSize_c=5096", "HEAP_SIZE=gTotalHeapSize_c", @@ -272,6 +275,7 @@ template("k32w0_sdk") { "-Wno-sign-compare", "-Wno-clobbered", "-Wno-implicit-fallthrough", + "-Wno-shadow", "-mthumb", "-MMD", "-MP", diff --git a/third_party/nxp/k32w0_sdk/sdk_fixes/patch_k32w_sdk.sh b/third_party/nxp/k32w0_sdk/sdk_fixes/patch_k32w_sdk.sh index 49a18592d4a5a2..324199c6db7f5a 100755 --- a/third_party/nxp/k32w0_sdk/sdk_fixes/patch_k32w_sdk.sh +++ b/third_party/nxp/k32w0_sdk/sdk_fixes/patch_k32w_sdk.sh @@ -45,5 +45,21 @@ convert_to_dos "$SIGN_FILE_PATH" patch -N --binary -d "$NXP_K32W061_SDK_ROOT"/tools/imagetool/ -p1 <"$SOURCE_DIR/sign_images_sh.patch" sed -i 's/\r$//' "$SIGN_FILE_PATH" +echo "Downloading PDM and BLE libraries from NXP server..." + +rm -rf patch_for_K32W061_SDK_2_6_4.zip patch_for_K32W061_SDK_2_6_4 +wget https://www.nxp.com/downloads/en/libraries/patch_for_K32W061_SDK_2_6_4.zip +exitCode=$? +if [ "$exitCode" -ne 0 ]; then + echo "Download error" + exit +fi + +unzip patch_for_K32W061_SDK_2_6_4.zip +cp patch_for_K32W061_SDK_2_6_4/controller_config.c "$NXP_K32W061_SDK_ROOT"/middleware/wireless/ble_controller/config/ +cp patch_for_K32W061_SDK_2_6_4/controller_interface.h "$NXP_K32W061_SDK_ROOT"/middleware/wireless/ble_controller/interface/ +cp patch_for_K32W061_SDK_2_6_4/lib_ble_controller.a "$NXP_K32W061_SDK_ROOT"/middleware/wireless/ble_controller/lib/ +cp patch_for_K32W061_SDK_2_6_4/libPDM_extFlash.a "$NXP_K32W061_SDK_ROOT"/middleware/wireless/framework/PDM/Library/ + echo "K32W SDK MR3 QP1 was patched!" exit 0 diff --git a/third_party/openthread/platforms/nxp/k32w/k32w0/BUILD.gn b/third_party/openthread/platforms/nxp/k32w/k32w0/BUILD.gn index 913daa683c61ec..b942608b82ac9b 100644 --- a/third_party/openthread/platforms/nxp/k32w/k32w0/BUILD.gn +++ b/third_party/openthread/platforms/nxp/k32w/k32w0/BUILD.gn @@ -38,8 +38,8 @@ config("openthread_k32w0_config") { source_set("openthread_core_config_k32w0") { sources = [ + "${chip_root}/examples/platform/nxp/k32w/k32w0/app/project_include/OpenThreadConfig.h", "${openthread_nxp_root}/src/k32w0/k32w061/openthread-core-k32w061-config-check.h", - "${openthread_nxp_root}/src/k32w0/k32w061/openthread-core-k32w061-config.h", ] public_configs = [ ":openthread_k32w0_config" ]