Skip to content

Commit

Permalink
[Telink] Adopt to latest telink zephyr & Update Telink image to 0.6.0…
Browse files Browse the repository at this point in the history
…2 (Cherry-pick project-chip#22971) (project-chip#23380)

* [Telink] Adopt to latest telink zephyr & Update Telink image to 0.6.02 (project-chip#22971)

* [Telink] use zephyr in include path
* [Telink] use telink zephyr crypto
* [Telink] rename IEEE802154 functions and isr table offset fix
* [Telink] restyle
* [Telink]: Update Telink image to 0.6.02

* [Telink] Add CHIP license attribution
  • Loading branch information
s07641069 authored Nov 3, 2022
1 parent 7f2b0a5 commit a17c005
Show file tree
Hide file tree
Showing 57 changed files with 90 additions and 13,971 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/examples-telink.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ jobs:
if: github.actor != 'restyled-io[bot]'

container:
image: connectedhomeip/chip-build-telink:0.5.99
image: connectedhomeip/chip-build-telink:0.6.02
volumes:
- "/tmp/bloat_reports:/tmp/bloat_reports"

Expand Down
5 changes: 3 additions & 2 deletions config/telink/app/zephyr.conf
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ CONFIG_OPENTHREAD_DEBUG=y
CONFIG_OPENTHREAD_L2_DEBUG=y
CONFIG_OPENTHREAD_L2_LOG_LEVEL_INF=y

CONFIG_NET_CONFIG_IEEE802154_DEV_NAME="IEEE802154"
CONFIG_NET_CONFIG_IEEE802154_DEV_NAME="IEEE802154_b91"
CONFIG_NET_CONFIG_MY_IPV6_ADDR="fdde:ad00:beef::1"
CONFIG_NET_CONFIG_PEER_IPV6_ADDR="fdde:ad00:beef::2"

Expand All @@ -87,7 +87,8 @@ CONFIG_OPENTHREAD_DUA=y
CONFIG_OPENTHREAD_MLR=y

# mbedTLS tweaks
CONFIG_MBEDTLS_DEBUG=y
CONFIG_MBEDTLS_TEST=y
CONFIG_MBEDTLS_PKCS5_C=y
CONFIG_MBEDTLS_USER_CONFIG_ENABLE=y
CONFIG_MBEDTLS_USER_CONFIG_FILE="telink-mbedtls-config.h"

Expand Down
9 changes: 0 additions & 9 deletions config/telink/chip-module/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -108,16 +108,7 @@ if (CONFIG_POSIX_API)
)
endif()

# Add MbedTLS config file
list(APPEND CHIP_CFLAGS -DMBEDTLS_CONFIG_FILE=CONFIG_MBEDTLS_CFG_FILE)

# Add hardware cryptography dependencies
zephyr_include_directories(${ZEPHYR_BASE}/../modules/crypto/mbedtls/include)
zephyr_include_directories(${ZEPHYR_BASE}/modules/mbedtls/configs)
zephyr_include_directories(${CHIP_ROOT}/src/platform/telink/)
zephyr_include_directories(${CHIP_ROOT}/src/platform/telink/crypto/)
zephyr_sources(${ZEPHYR_BASE}/../modules/hal/telink/tlsr9/drivers/B91/aes.c)
zephyr_sources(${ZEPHYR_BASE}/../modules/hal/telink/tlsr9/drivers/B91/pke.c)

zephyr_get_compile_flags(CHIP_CFLAGS_C C)
zephyr_get_compile_flags(CHIP_CFLAGS_CC CXX)
Expand Down
2 changes: 1 addition & 1 deletion examples/light-switch-app/telink/include/AppTask.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@

#include "AppEvent.h"

#include <drivers/gpio.h>
#include <zephyr/drivers/gpio.h>

#include <platform/CHIPDeviceLayer.h>

Expand Down
2 changes: 1 addition & 1 deletion examples/light-switch-app/telink/prj.conf
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ CONFIG_OPENTHREAD_PANID=4660
CONFIG_OPENTHREAD_CHANNEL=15
CONFIG_OPENTHREAD_NETWORK_NAME="OpenThreadDemo"
CONFIG_OPENTHREAD_XPANID="11:11:11:11:22:22:22:22"
CONFIG_NET_CONFIG_IEEE802154_DEV_NAME="IEEE802154"
CONFIG_NET_CONFIG_IEEE802154_DEV_NAME="IEEE802154_b91"

# Disable Matter OTA DFU
CONFIG_CHIP_OTA_REQUESTOR=n
Expand Down
4 changes: 2 additions & 2 deletions examples/light-switch-app/telink/src/AppTask.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,8 @@
#include "OTAUtil.h"
#endif

#include <logging/log.h>
#include <zephyr.h>
#include <zephyr/logging/log.h>
#include <zephyr/zephyr.h>

#include <algorithm>

Expand Down
2 changes: 1 addition & 1 deletion examples/light-switch-app/telink/src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
#include <lib/support/CHIPMem.h>
#include <platform/CHIPDeviceLayer.h>

#include <kernel.h>
#include <zephyr/kernel.h>

LOG_MODULE_REGISTER(app);

Expand Down
2 changes: 1 addition & 1 deletion examples/lighting-app/telink/include/LightingManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
#include <system/SystemError.h>

#include <cstdint>
#include <drivers/gpio.h>
#include <zephyr/drivers/gpio.h>

class LightingManager
{
Expand Down
2 changes: 1 addition & 1 deletion examples/lighting-app/telink/prj.conf
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ CONFIG_OPENTHREAD_PANID=4660
CONFIG_OPENTHREAD_CHANNEL=15
CONFIG_OPENTHREAD_NETWORK_NAME="OpenThreadDemo"
CONFIG_OPENTHREAD_XPANID="11:11:11:11:22:22:22:22"
CONFIG_NET_CONFIG_IEEE802154_DEV_NAME="IEEE802154"
CONFIG_NET_CONFIG_IEEE802154_DEV_NAME="IEEE802154_b91"

# Disable Matter OTA DFU
CONFIG_CHIP_OTA_REQUESTOR=n
Expand Down
4 changes: 2 additions & 2 deletions examples/lighting-app/telink/src/AppTask.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,8 @@
#include "OTAUtil.h"
#endif

#include <logging/log.h>
#include <zephyr.h>
#include <zephyr/logging/log.h>
#include <zephyr/zephyr.h>

#include <algorithm>

Expand Down
6 changes: 3 additions & 3 deletions examples/lighting-app/telink/src/LightingManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@

#include <lib/support/CodeUtils.h>

#include <drivers/pwm.h>
#include <logging/log.h>
#include <zephyr.h>
#include <zephyr/drivers/pwm.h>
#include <zephyr/logging/log.h>
#include <zephyr/zephyr.h>

LOG_MODULE_DECLARE(app);

Expand Down
2 changes: 1 addition & 1 deletion examples/lighting-app/telink/src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
#include <lib/support/CHIPMem.h>
#include <platform/CHIPDeviceLayer.h>

#include <kernel.h>
#include <zephyr/kernel.h>

LOG_MODULE_REGISTER(app);

Expand Down
2 changes: 1 addition & 1 deletion examples/ota-requestor-app/telink/include/AppTask.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@

#include "AppEvent.h"

#include <drivers/gpio.h>
#include <zephyr/drivers/gpio.h>

#include <platform/CHIPDeviceLayer.h>

Expand Down
2 changes: 1 addition & 1 deletion examples/ota-requestor-app/telink/prj.conf
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ CONFIG_OPENTHREAD_PANID=4660
CONFIG_OPENTHREAD_CHANNEL=15
CONFIG_OPENTHREAD_NETWORK_NAME="OpenThreadDemo"
CONFIG_OPENTHREAD_XPANID="11:11:11:11:22:22:22:22"
CONFIG_NET_CONFIG_IEEE802154_DEV_NAME="IEEE802154"
CONFIG_NET_CONFIG_IEEE802154_DEV_NAME="IEEE802154_b91"

# Disable Matter OTA DFU
CONFIG_CHIP_OTA_REQUESTOR=y
Expand Down
4 changes: 2 additions & 2 deletions examples/ota-requestor-app/telink/src/AppTask.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,8 @@
#include "OTAUtil.h"
#endif

#include <logging/log.h>
#include <zephyr.h>
#include <zephyr/logging/log.h>
#include <zephyr/zephyr.h>

#include <algorithm>

Expand Down
2 changes: 1 addition & 1 deletion examples/ota-requestor-app/telink/src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
#include <lib/support/CHIPMem.h>
#include <platform/CHIPDeviceLayer.h>

#include <kernel.h>
#include <zephyr/kernel.h>

LOG_MODULE_REGISTER(app);

Expand Down
2 changes: 1 addition & 1 deletion examples/platform/telink/util/include/ButtonManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@

#pragma once

#include <device.h>
#include <vector>
#include <zephyr/device.h>

#define STATE_HIGH 1
#define STATE_LOW 0
Expand Down
2 changes: 1 addition & 1 deletion examples/platform/telink/util/include/LEDWidget.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
#pragma once

#include <cstdint>
#include <drivers/gpio.h>
#include <zephyr/drivers/gpio.h>

class LEDWidget
{
Expand Down
10 changes: 5 additions & 5 deletions examples/platform/telink/util/src/ButtonManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,11 @@
*/

#include <assert.h>
#include <device.h>
#include <drivers/gpio.h>
#include <kernel.h>
#include <logging/log.h>
#include <zephyr.h>
#include <zephyr/device.h>
#include <zephyr/drivers/gpio.h>
#include <zephyr/kernel.h>
#include <zephyr/logging/log.h>
#include <zephyr/zephyr.h>

LOG_MODULE_REGISTER(ButtonManager);

Expand Down
2 changes: 1 addition & 1 deletion examples/platform/telink/util/src/LEDWidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@

#include "LEDWidget.h"

#include <zephyr.h>
#include <zephyr/zephyr.h>

const struct device * LEDWidget::mPort = NULL;

Expand Down
2 changes: 1 addition & 1 deletion examples/platform/telink/util/src/ThreadUtil.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
#include <app/server/Dnssd.h>
#include <lib/support/ThreadOperationalDataset.h>

#include <zephyr.h>
#include <zephyr/zephyr.h>

#include <cstring>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
#include <platform/internal/GenericPlatformManagerImpl.h>

#include <sys/select.h>
#include <zephyr.h>
#include <zephyr/zephyr.h>

namespace chip {
namespace DeviceLayer {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
#include <system/SystemError.h>
#include <system/SystemLayer.h>

#include <sys/reboot.h>
#include <zephyr/sys/reboot.h>

#define DEFAULT_MIN_SLEEP_PERIOD (60 * 60 * 24 * 30) // Month [sec]

Expand Down
2 changes: 1 addition & 1 deletion src/inet/InetInterface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@
#endif // CHIP_SYSTEM_CONFIG_USE_SOCKETS && CHIP_SYSTEM_CONFIG_USE_BSD_IFADDRS

#if CHIP_SYSTEM_CONFIG_USE_ZEPHYR_NET_IF
#include <net/net_if.h>
#include <zephyr/net/net_if.h>
#endif // CHIP_SYSTEM_CONFIG_USE_ZEPHYR_NET_IF

#if CHIP_SYSTEM_CONFIG_USE_OPEN_THREAD_ENDPOINT
Expand Down
2 changes: 1 addition & 1 deletion src/inet/InetInterface.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ struct ifaddrs;
#endif // CHIP_SYSTEM_CONFIG_USE_BSD_IFADDRS

#if CHIP_SYSTEM_CONFIG_USE_ZEPHYR_NET_IF
#include <device.h>
#include <zephyr/device.h>

struct net_if;
struct net_if_ipv4;
Expand Down
6 changes: 3 additions & 3 deletions src/platform/Zephyr/DiagnosticDataProviderImpl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,13 @@
#include <platform/Zephyr/DiagnosticDataProviderImpl.h>
#include <platform/Zephyr/SysHeapMalloc.h>

#include <drivers/hwinfo.h>
#include <sys/util.h>
#include <zephyr/drivers/hwinfo.h>
#include <zephyr/sys/util.h>

#if CHIP_DEVICE_LAYER_TARGET_NRFCONNECT
#include <platform/nrfconnect/Reboot.h>
#elif defined(CONFIG_MCUBOOT_IMG_MANAGER)
#include <dfu/mcuboot.h>
#include <zephyr/dfu/mcuboot.h>
#endif

#include <malloc.h>
Expand Down
2 changes: 1 addition & 1 deletion src/platform/Zephyr/KeyValueStoreManagerImpl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
#include <lib/support/logging/CHIPLogging.h>
#include <system/SystemError.h>

#include <settings/settings.h>
#include <zephyr/settings/settings.h>

namespace chip {
namespace DeviceLayer {
Expand Down
2 changes: 1 addition & 1 deletion src/platform/Zephyr/KeyValueStoreManagerImpl.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@

#pragma once

#include <zephyr.h>
#include <zephyr/zephyr.h>

namespace chip {
namespace DeviceLayer {
Expand Down
6 changes: 3 additions & 3 deletions src/platform/Zephyr/Logging.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@
#include <lib/support/EnforceFormat.h>
#include <lib/support/logging/Constants.h>

#include <kernel.h>
#include <logging/log.h>
#include <sys/cbprintf.h>
#include <zephyr/kernel.h>
#include <zephyr/logging/log.h>
#include <zephyr/sys/cbprintf.h>

// If CONFIG_LOG_MODE_MINIMAL the timestamp is NOT added automatically by the Zephyr logger
#ifdef CONFIG_LOG_MODE_MINIMAL
Expand Down
2 changes: 1 addition & 1 deletion src/platform/Zephyr/PlatformManagerImpl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@
#include <platform/Zephyr/DiagnosticDataProviderImpl.h>
#include <platform/internal/GenericPlatformManagerImpl_Zephyr.ipp>

#include <drivers/entropy.h>
#include <malloc.h>
#include <zephyr/drivers/entropy.h>

namespace chip {
namespace DeviceLayer {
Expand Down
2 changes: 1 addition & 1 deletion src/platform/Zephyr/SystemTimeSupport.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@

#include <system/SystemError.h>

#include <zephyr.h>
#include <zephyr/zephyr.h>

#if !CHIP_SYSTEM_CONFIG_USE_POSIX_TIME_FUNCTS

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 @@ -25,8 +25,8 @@

#include <platform/OpenThread/GenericThreadStackManagerImpl_OpenThread.h>

#include <net/openthread.h>
#include <zephyr.h>
#include <zephyr/net/openthread.h>
#include <zephyr/zephyr.h>

#include <openthread/thread.h>
#if !CONFIG_SOC_SERIES_RISCV_TELINK_B91
Expand Down
2 changes: 1 addition & 1 deletion src/platform/Zephyr/ZephyrConfig.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
#include <lib/support/logging/CHIPLogging.h>
#include <platform/internal/testing/ConfigUnitTest.h>

#include <settings/settings.h>
#include <zephyr/settings/settings.h>

namespace chip {
namespace DeviceLayer {
Expand Down
10 changes: 5 additions & 5 deletions src/platform/telink/BLEManagerImpl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
/*Includes for ieee802154 switchings */
#define DT_DRV_COMPAT telink_b91_zb
#include <drivers/ieee802154/b91.h>
#include <net/ieee802154_radio.h>
#include <zephyr/net/ieee802154_radio.h>

/* Telink headers */
#include "drivers.h"
Expand Down Expand Up @@ -319,11 +319,11 @@ CHIP_ERROR BLEManagerImpl::_InitStack(void)
SuccessOrExit(err);

/* Resetup stimer interrupt to handle BLE stack */
ret = irq_connect_dynamic(STIMER_IRQ_NUM, 2, stimer_irq_handler, NULL, 0);
ret = irq_connect_dynamic(STIMER_IRQ_NUM + CONFIG_2ND_LVL_ISR_TBL_OFFSET, 2, stimer_irq_handler, NULL, 0);
ChipLogDetail(DeviceLayer, "Stimer IRQ assigned vector %d", ret);

/* Resetup rf interrupt to handle BLE stack */
ret = irq_connect_dynamic(RF_IRQ_NUM, 2, rf_irq_handler, NULL, 0);
ret = irq_connect_dynamic(RF_IRQ_NUM + CONFIG_2ND_LVL_ISR_TBL_OFFSET, 2, rf_irq_handler, NULL, 0);
ChipLogDetail(DeviceLayer, "RF IRQ assigned vector %d", ret);

exit:
Expand Down Expand Up @@ -577,7 +577,7 @@ CHIP_ERROR BLEManagerImpl::StartAdvertising(void)
/* @todo: move to RadioSwitch module*/
const struct device * radio_dev = device_get_binding(CONFIG_NET_CONFIG_IEEE802154_DEV_NAME);
__ASSERT(radio_dev != NULL, "Fail to get radio device");
b91_ieee802154_deinit(radio_dev);
b91_deinit(radio_dev);

/* It is time to init BLE stack */
err = _InitStack();
Expand Down Expand Up @@ -837,7 +837,7 @@ void BLEManagerImpl::SwitchToIeee802154(void)
__ASSERT(radio_dev != NULL, "Fail to get radio device");

/* Init IEEE802154 */
result = b91_ieee802154_init(radio_dev);
result = b91_init(radio_dev);
__ASSERT(result == 0, "Fail to init IEEE802154 radio. Error: %d", result);
}

Expand Down
Loading

0 comments on commit a17c005

Please sign in to comment.