Skip to content

Commit

Permalink
[Telink] Zephyr v3.7 update changes
Browse files Browse the repository at this point in the history
Adopted changes for Telink B9x board series for
upcoming update of Zephyr version.

Fixed err output from InitChipStack in mainCommon.
Tested advertisement tested manually.
  • Loading branch information
interfer authored and s07641069 committed Dec 2, 2024
1 parent 4c69001 commit 3663762
Show file tree
Hide file tree
Showing 8 changed files with 45 additions and 8 deletions.
20 changes: 19 additions & 1 deletion config/telink/chip-module/Kconfig.defaults
Original file line number Diff line number Diff line change
Expand Up @@ -80,12 +80,30 @@ config SYSTEM_WORKQUEUE_STACK_SIZE
default 616 if PM

config HEAP_MEM_POOL_SIZE
default 256
default 1280

config COMMON_LIBC_MALLOC_ARENA_SIZE
default 20716 if SOC_RISCV_TELINK_TL321X || SOC_SERIES_RISCV_TELINK_B9X_RETENTION
default 12288

choice LIBC_IMPLEMENTATION
default NEWLIB_LIBC
endchoice

config MBEDTLS_ENTROPY_ENABLED
bool
default y

config MBEDTLS_ZEPHYR_ENTROPY
bool
default y

config MBEDTLS_CTR_DRBG_ENABLED
default y

config MBEDTLS_CIPHER_AES_ENABLED
default y

config NET_IPV6_MLD
default n if PM
default y
Expand Down
2 changes: 1 addition & 1 deletion examples/platform/telink/common/src/mainCommon.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,6 @@ int main(void)
err = GetAppTask().StartApp();

exit:
LOG_ERR("Exit err %" CHIP_ERROR_FORMAT, err.Format());
LOG_ERR("Exit err %d" , err.Format());
return (err == CHIP_NO_ERROR) ? EXIT_SUCCESS : EXIT_FAILURE;
}
3 changes: 2 additions & 1 deletion examples/platform/telink/zephyr_ext/zephyr_key_matrix.c
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,8 @@ static void key_matrix_poll(struct key_matrix_data * key_matrix, bool init)
/* Key matrix scan worker */
static void key_matrix_scan_work(struct k_work * item)
{
struct key_matrix_data * key_matrix = CONTAINER_OF(item, struct key_matrix_data, work);
struct key_matrix_data * key_matrix =
CONTAINER_OF(k_work_delayable_from_work(item), struct key_matrix_data, work);

(void) k_work_schedule(&key_matrix->work, K_MSEC(KEY_MATRIX_SCAN_PERIOD_MS));
key_matrix_poll(key_matrix, false);
Expand Down
3 changes: 2 additions & 1 deletion examples/platform/telink/zephyr_ext/zephyr_key_pool.c
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,8 @@ static void key_pool_poll(struct key_pool_data * key_pool, bool init)
/* Key pool scan worker */
static void key_pool_event_work(struct k_work * item)
{
struct key_pool_data * key_pool = CONTAINER_OF(item, struct key_pool_data, work);
struct key_pool_data * key_pool =
CONTAINER_OF(k_work_delayable_from_work(item), struct key_pool_data, work);

key_pool_poll(key_pool, false);
}
Expand Down
3 changes: 2 additions & 1 deletion examples/platform/telink/zephyr_ext/zephyr_led_pool.c
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,8 @@ static void led_pool_aux_update(const struct led_pool_data * led_pool)
/* Led pool worker */
static void led_pool_event_work(struct k_work * item)
{
struct led_pool_data * led_pool = CONTAINER_OF(item, struct led_pool_data, work);
struct led_pool_data * led_pool =
CONTAINER_OF(k_work_delayable_from_work(item), struct led_pool_data, work);

led_pool_aux_update(led_pool);
(void) k_work_reschedule(&led_pool->work, led_pool_aux_timeout(led_pool));
Expand Down
3 changes: 2 additions & 1 deletion examples/platform/telink/zephyr_ext/zephyr_pwm_pool.c
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,8 @@ static void pwm_pool_aux_update(const struct pwm_pool_data * pwm_pool)
/* Pwm pool worker */
static void pwm_pool_event_work(struct k_work * item)
{
struct pwm_pool_data * pwm_pool = CONTAINER_OF(item, struct pwm_pool_data, work);
struct pwm_pool_data * pwm_pool =
CONTAINER_OF(k_work_delayable_from_work(item), struct pwm_pool_data, work);

pwm_pool_aux_update(pwm_pool);
(void) k_work_reschedule(&pwm_pool->work, pwm_pool_aux_timeout(pwm_pool));
Expand Down
16 changes: 14 additions & 2 deletions src/platform/telink/BLEManagerImpl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,13 +40,25 @@
#include <zephyr/bluetooth/addr.h>
#include <zephyr/bluetooth/gatt.h>
#include <zephyr/drivers/flash.h>
#include <zephyr/random/rand32.h>
#include <zephyr/random/random.h>
#include <zephyr/storage/flash_map.h>
#include <zephyr/sys/byteorder.h>
#include <zephyr/sys/util.h>

extern "C" {
extern __attribute__((noinline)) void telink_bt_blc_mac_init(uint8_t * bt_mac);

#ifdef CONFIG_BT_B9X

extern __attribute__((noinline)) int b9x_bt_blc_mac_init(uint8_t *bt_mac);
/**
* @brief bt mac initialization
*/
__attribute__((noinline)) void telink_bt_blc_mac_init(uint8_t *bt_mac)
{
b9x_bt_blc_mac_init(bt_mac);
}
#endif

}

#if defined(CONFIG_PM) && !defined(CONFIG_CHIP_ENABLE_PM_DURING_BLE)
Expand Down
3 changes: 3 additions & 0 deletions src/platform/telink/SystemPlatformConfig.h
Original file line number Diff line number Diff line change
Expand Up @@ -62,3 +62,6 @@ struct ChipDeviceEvent;
#endif

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

// Disable Zephyr Socket extensions module, as the Zephyr RTOS now implements recvmsg()
#define CHIP_SYSTEM_CONFIG_USE_ZEPHYR_SOCKET_EXTENSIONS 0

0 comments on commit 3663762

Please sign in to comment.