Skip to content

Commit

Permalink
[Telink] ieee802154 optimization for power consumption
Browse files Browse the repository at this point in the history
- reduce malloc size.
- add configs
 - OPENTHREAD_CSMABACKOFF_OPTIMIZATION,
 - ZEPHYR_NETBUFFER_OPTIMIZATION,
 - IEEE802154_TLX_OPTIMIZATION.
- reduce RAM usage for tl3218x.
- update zephyr revision.

Signed-off-by: Damien Ji <[email protected]>
  • Loading branch information
damien0x0023 committed Dec 30, 2024
1 parent 3e36bd0 commit 06cc432
Show file tree
Hide file tree
Showing 5 changed files with 48 additions and 8 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/chef.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ jobs:
platform: telink
- name: Update Zephyr to specific revision (for developers purpose)
shell: bash
run: scripts/run_in_build_env.sh "python3 scripts/tools/telink/update_zephyr.py 3108dced67ee46d7b00a0abb3d7155e32c2b7c6f"
run: scripts/run_in_build_env.sh "python3 scripts/tools/telink/update_zephyr.py origin/develop_tlx802154_optimization"
- name: CI Examples Telink
shell: bash
run: |
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/examples-telink.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ jobs:
gh-context: ${{ toJson(github) }}

- name: Update Zephyr to specific revision (for developers purpose)
run: scripts/run_in_build_env.sh "python3 scripts/tools/telink/update_zephyr.py 3108dced67ee46d7b00a0abb3d7155e32c2b7c6f"
run: scripts/run_in_build_env.sh "python3 scripts/tools/telink/update_zephyr.py origin/develop_tlx802154_optimization"

- name: Build example Telink (B92 retention) Air Quality Sensor App
# Run test for master and s07641069 PRs
Expand Down
24 changes: 19 additions & 5 deletions config/telink/chip-module/Kconfig.defaults
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ config HEAP_MEM_POOL_SIZE

# need to enlarge to 21000 , to pass TC_RR_1.1
config COMMON_LIBC_MALLOC_ARENA_SIZE
default 21000 if SOC_RISCV_TELINK_TL321X || SOC_SERIES_RISCV_TELINK_B9X_RETENTION
default 14336 if SOC_SERIES_RISCV_TELINK_TLX_RETENTION || SOC_SERIES_RISCV_TELINK_B9X_RETENTION
default 12288

config NET_IPV6_MLD
Expand Down Expand Up @@ -324,10 +324,24 @@ config CHIP_ENABLE_ICD_SUPPORT


config OPENTHREAD_CSMABACKOFF_OPTIMIZATION
bool "Skip the first backoff during sending data request"
depends on CHIP_ENABLE_ICD_SUPPORT
default n if SOC_SERIES_RISCV_TELINK_TLX_RETENTION || SOC_SERIES_RISCV_TELINK_B9X_RETENTION
default n
bool "Skip the first backoff during sending data request"
depends on CHIP_ENABLE_ICD_SUPPORT
default y if SOC_SERIES_RISCV_TELINK_TLX_RETENTION || SOC_SERIES_RISCV_TELINK_B9X_RETENTION
default n

config ZEPHYR_NETBUFFER_OPTIMIZATION
bool "Move the net buffer from iram to dram"
default y if SOC_SERIES_RISCV_TELINK_TLX_RETENTION || SOC_SERIES_RISCV_TELINK_B9X_RETENTION
default n
help
This option enables the net buffer from iram to dram.

config IEEE802154_TLX_OPTIMIZATION
bool "optimize the rf performance for tlx"
default y if SOC_SERIES_RISCV_TELINK_TLX_RETENTION
default n
help
optimize the rf performance for tlx.

config OPENTHREAD_THREAD_STACK_SIZE
default 2400 if PM || SOC_RISCV_TELINK_TL321X
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,10 @@ extern "C" void otSysProcessDrivers(otInstance * aInstance);
extern "C" void otAppCliInit(otInstance * aInstance);
#endif

#if defined CONFIG_IEEE802154_TLX_OPTIMIZATION && CONFIG_IEEE802154_TLX_OPTIMIZATION
bool isThreadCommissioned = false;
#endif /* CONFIG_IEEE802154_TLX_OPTIMIZATION */

namespace chip {
namespace DeviceLayer {
namespace Internal {
Expand Down Expand Up @@ -372,6 +376,14 @@ bool GenericThreadStackManagerImpl_OpenThread<ImplClass>::_IsThreadAttached()
curRole = otThreadGetDeviceRole(mOTInst);
Impl()->UnlockThreadStack();

#if defined CONFIG_IEEE802154_TLX_OPTIMIZATION && CONFIG_IEEE802154_TLX_OPTIMIZATION
if ((curRole != OT_DEVICE_ROLE_DISABLED && curRole != OT_DEVICE_ROLE_DETACHED))
{
if (isThreadCommissioned == false)
isThreadCommissioned = true;
}
#endif /* CONFIG_IEEE802154_TLX_OPTIMIZATION */

return (curRole != OT_DEVICE_ROLE_DISABLED && curRole != OT_DEVICE_ROLE_DETACHED);
}

Expand Down
16 changes: 15 additions & 1 deletion src/platform/telink/SystemPlatformConfig.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,10 +44,20 @@ struct ChipDeviceEvent;
#define CHIP_SYSTEM_CONFIG_PLATFORM_PROVIDES_TIME 1
#endif // CHIP_SYSTEM_CONFIG_USE_POSIX_TIME_FUNCTS

#if defined(CONFIG_SOC_RISCV_TELINK_TL321X) || defined(CONFIG_SOC_SERIES_RISCV_TELINK_B9X_RETENTION)
#if defined CONFIG_SOC_RISCV_TELINK_TL321X || defined CONFIG_SOC_SERIES_RISCV_TELINK_B9X_RETENTION
#if defined CONFIG_IEEE802154_TLX_OPTIMIZATION && CONFIG_IEEE802154_TLX_OPTIMIZATION
#define CHIP_SYSTEM_PACKETBUFFER_FROM_CHIP_HEAP 0
#define CHIP_SYSTEM_PACKETBUFFER_FROM_CHIP_POOL 1
#else /* !CONFIG_IEEE802154_TLX_OPTIMIZATION */
#define CHIP_SYSTEM_PACKETBUFFER_FROM_CHIP_HEAP 1
#define CHIP_SYSTEM_PACKETBUFFER_FROM_CHIP_POOL 0
#endif /* CONFIG_IEEE802154_TLX_OPTIMIZATION */
#define CHIP_SYSTEM_CONFIG_POOL_USE_HEAP 1
#endif

#if defined CONFIG_SOC_RISCV_TELINK_TL321X
#define CHIP_SYSTEM_CONFIG_PACKETBUFFER_CAPACITY_MAX 1100
#elif defined CONFIG_SOC_SERIES_RISCV_TELINK_B9X_RETENTION
#define CHIP_SYSTEM_CONFIG_PACKETBUFFER_CAPACITY_MAX 1280
#endif

Expand All @@ -56,7 +66,11 @@ struct ChipDeviceEvent;

// Reduce packet buffer pool size (default 15) to reduce ram consumption
#if defined CONFIG_PM || defined CONFIG_SOC_RISCV_TELINK_TL321X
#if defined CONFIG_IEEE802154_TLX_OPTIMIZATION && CONFIG_IEEE802154_TLX_OPTIMIZATION
#define CHIP_SYSTEM_CONFIG_PACKETBUFFER_POOL_SIZE 6
#else /* !CONFIG_IEEE802154_TLX_OPTIMIZATION */
#define CHIP_SYSTEM_CONFIG_PACKETBUFFER_POOL_SIZE 0
#endif /* CONFIG_IEEE802154_TLX_OPTIMIZATION */
#else
#define CHIP_SYSTEM_CONFIG_PACKETBUFFER_POOL_SIZE 8
#endif
Expand Down

0 comments on commit 06cc432

Please sign in to comment.