Skip to content

Commit

Permalink
TE5 fixes (#9449)
Browse files Browse the repository at this point in the history
As described in #9261
several SRAM optimizations were needed:
* decrease the number of Fabrics to 4 (from 16);
* use OT MTD lib for the E-Lock App (which is an SED);
* disable LWIP TCP/RAW/Debug/packet buffers.

Also, fix a bug in KVS where the deletion of some keys was not done properly.

Signed-off-by: Doru Gucea <[email protected]>
  • Loading branch information
doru91 authored and pull[bot] committed Sep 13, 2021
1 parent adf3372 commit 1509840
Show file tree
Hide file tree
Showing 11 changed files with 70 additions and 32 deletions.
4 changes: 2 additions & 2 deletions examples/lighting-app/k32w/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,8 @@ k32w_executable("light_app") {
"${chip_root}/src/lib",
"${chip_root}/third_party/mbedtls:mbedtls",
"${k32w_platform_dir}/app/support:freertos_mbedtls_utils",
"${openthread_root}:libopenthread-cli-mtd",
"${openthread_root}:libopenthread-mtd",
"${openthread_root}:libopenthread-cli-ftd",
"${openthread_root}:libopenthread-ftd",
]

cflags = [ "-Wconversion" ]
Expand Down
16 changes: 15 additions & 1 deletion examples/lighting-app/k32w/include/CHIPProjectConfig.h
Original file line number Diff line number Diff line change
Expand Up @@ -176,10 +176,24 @@
*/
#define CHIP_DEVICE_CONFIG_BLE_ADVERTISING_TIMEOUT (15 * 60 * 1000)

/**
* CONFIG_CHIP_NFC_COMMISSIONING, CHIP_DEVICE_CONFIG_ENABLE_NFC
*
* Set these defines to 1 if NFC Commissioning is needed
*/
#define CONFIG_CHIP_NFC_COMMISSIONING 1

#define CHIP_DEVICE_CONFIG_ENABLE_NFC 1

/**
* @def CHIP_CONFIG_MAX_DEVICE_ADMINS
*
* @brief
* Maximum number of administrators that can provision the device. Each admin
* can provision the device with their unique operational credentials and manage
* their access control lists.
*/
#define CHIP_CONFIG_MAX_DEVICE_ADMINS 4 // 3 fabrics + 1 for rotation slack

/**
* CHIP_CONFIG_EVENT_LOGGING_DEFAULT_IMPORTANCE
*
Expand Down
4 changes: 2 additions & 2 deletions examples/lighting-app/k32w/main/AppTask.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ CHIP_ERROR AppTask::Init()

K32W_LOG("Current Firmware Version: %s", currentFirmwareRev);

#ifdef CONFIG_CHIP_NFC_COMMISSIONING
#if CONFIG_CHIP_NFC_COMMISSIONING
PlatformMgr().AddEventHandler(ThreadProvisioningHandler, 0);
#endif

Expand Down Expand Up @@ -500,7 +500,7 @@ void AppTask::BleHandler(AppEvent * aEvent)
}
}

#ifdef CONFIG_CHIP_NFC_COMMISSIONING
#if CONFIG_CHIP_NFC_COMMISSIONING
void AppTask::ThreadProvisioningHandler(const ChipDeviceEvent * event, intptr_t)
{
if (event->Type == DeviceEventType::kCHIPoBLEAdvertisingChange && event->CHIPoBLEAdvertisingChange.Result == kActivity_Stopped)
Expand Down
4 changes: 2 additions & 2 deletions examples/lock-app/k32w/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,8 @@ k32w_executable("lock_app") {
"${chip_root}/third_party/mbedtls:mbedtls",
"${chip_root}/third_party/simw-top-mini:se05x",
"${k32w_platform_dir}/app/support:freertos_mbedtls_utils",
"${openthread_root}:libopenthread-cli-ftd",
"${openthread_root}:libopenthread-ftd",
"${openthread_root}:libopenthread-cli-mtd",
"${openthread_root}:libopenthread-mtd",
]

cflags = [ "-Wconversion" ]
Expand Down
23 changes: 22 additions & 1 deletion examples/lock-app/k32w/include/CHIPProjectConfig.h
Original file line number Diff line number Diff line change
Expand Up @@ -176,10 +176,31 @@
*/
#define CHIP_DEVICE_CONFIG_BLE_ADVERTISING_TIMEOUT (15 * 60 * 1000)

/**
* CONFIG_CHIP_NFC_COMMISSIONING, CHIP_DEVICE_CONFIG_ENABLE_NFC
*
* Set these defines to 1 if NFC Commissioning is needed
*/
#define CONFIG_CHIP_NFC_COMMISSIONING 1

#define CHIP_DEVICE_CONFIG_ENABLE_NFC 1

/**
* CHIP_DEVICE_CONFIG_THREAD_FTD
*
* E-Lock Demo Application is a Thread SED (Sleepy End Device)
*/
#define CHIP_DEVICE_CONFIG_THREAD_FTD 0

/**
* @def CHIP_CONFIG_MAX_DEVICE_ADMINS
*
* @brief
* Maximum number of administrators that can provision the device. Each admin
* can provision the device with their unique operational credentials and manage
* their access control lists.
*/
#define CHIP_CONFIG_MAX_DEVICE_ADMINS 4 // 3 fabrics + 1 for rotation slack

/**
* CHIP_CONFIG_EVENT_LOGGING_DEFAULT_IMPORTANCE
*
Expand Down
5 changes: 5 additions & 0 deletions examples/platform/k32w/app/project_include/OpenThreadConfig.h
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,11 @@
#define OPENTHREAD_CONFIG_BORDER_ROUTER_ENABLE 0
#define OPENTHREAD_CONFIG_DHCP6_CLIENT_ENABLE 0
#define OPENTHREAD_CONFIG_DHCP6_SERVER_ENABLE 0
#define OPENTHREAD_CONFIG_TCP_ENABLE 0

#define OPENTHREAD_CONFIG_NUM_MESSAGE_BUFFERS 44

//#define OPENTHREAD_CONFIG_LOG_LEVEL OT_LOG_LEVEL_DEBG

// Use the NXP-supplied default platform configuration for remainder
// of OpenThread config options.
Expand Down
14 changes: 12 additions & 2 deletions src/lwip/k32w/lwipopts.h
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,19 @@

#define LWIP_SOCKET 0

// TODO: seems like this is unnecessary on Thread-only platforms
#if INET_CONFIG_ENABLE_RAW_ENDPOINT
#define LWIP_RAW 1
#define MEMP_NUM_RAW_PCB (5)
#else
#define LWIP_RAW 0
#define MEMP_NUM_RAW_PCB 0
#endif // INET_CONFIG_ENABLE_RAW_ENDPOINT
#if INET_CONFIG_ENABLE_TCP_ENDPOINT
#define LWIP_TCP 1
#else
#define LWIP_TCP 0
#define MEMP_NUM_TCP_PCB 0
#endif // INET_CONFIG_ENABLE_TCP_ENDPOINT

// TODO: verify count
#define MEMP_NUM_UDP_PCB (7)
Expand Down Expand Up @@ -126,7 +136,7 @@

// TODO: make LWIP_DEBUG conditional on build type

#define LWIP_DEBUG 1
#define LWIP_DEBUG 0
#define MEMP_OVERFLOW_CHECK (0)
#define MEMP_SANITY_CHECK (0)
#define MEM_DEBUG (LWIP_DBG_OFF)
Expand Down
2 changes: 0 additions & 2 deletions src/platform/K32W/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,6 @@ static_library("K32W") {
public_deps = [ "${chip_root}/src/platform:platform_base" ]

if (chip_enable_openthread) {
public_deps += [ "${openthread_root}:libopenthread-ftd" ]

sources += [
"../OpenThread/OpenThreadUtils.cpp",
"ThreadStackManagerImpl.cpp",
Expand Down
15 changes: 7 additions & 8 deletions src/platform/K32W/K32WConfig.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -381,16 +381,15 @@ CHIP_ERROR K32WConfig::FactoryResetConfigInternal(Key firstKey, Key lastKey)
CHIP_ERROR err;

// Iterate over all the CHIP Config PDM ID records and delete each one
err = ForEachRecord(kMinConfigKey_ChipConfig, kMaxConfigKey_ChipConfig, false,
[](const Key & pdmKey, const size_t & length) -> CHIP_ERROR {
CHIP_ERROR err2;
err = ForEachRecord(firstKey, lastKey, false, [](const Key & pdmKey, const size_t & length) -> CHIP_ERROR {
CHIP_ERROR err2;

err2 = ClearConfigValue(pdmKey);
SuccessOrExit(err2);
err2 = ClearConfigValue(pdmKey);
SuccessOrExit(err2);

exit:
return err2;
});
exit:
return err2;
});

// Return success at end of iterations.
if (err == CHIP_END_OF_INPUT)
Expand Down
12 changes: 0 additions & 12 deletions src/platform/K32W/ThreadStackManagerImpl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -81,18 +81,6 @@ extern "C" void otTaskletsSignalPending(otInstance * p_instance)
ThreadStackMgrImpl().SignalThreadActivityPending();
}

#if (!defined(cPWR_UsePowerDownMode) || (cPWR_UsePowerDownMode == 0))
/**
* Glue function called directly by the OpenThread stack when system event processing work
* is pending.
*/
extern "C" void otSysEventSignalPending(void)
{
BaseType_t yieldRequired = ThreadStackMgrImpl().SignalThreadActivityPendingFromISR();
portYIELD_FROM_ISR(yieldRequired);
}
#endif

extern "C" void * pvPortCallocRtos(size_t num, size_t size)
{
size_t totalAllocSize = (size_t)(num * size);
Expand Down
3 changes: 3 additions & 0 deletions src/platform/K32W/args.gni
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@ lwip_platform = "k32w"
chip_inet_config_enable_ipv4 = false
chip_inet_config_enable_dns_resolver = false

chip_inet_config_enable_tcp_endpoint = false
chip_inet_config_enable_raw_endpoint = false

chip_build_tests = false

chip_mdns = "platform"
Expand Down

0 comments on commit 1509840

Please sign in to comment.