Skip to content

Commit

Permalink
[Telink] Add TL3218X sceleton
Browse files Browse the repository at this point in the history
  • Loading branch information
s07641069 committed Sep 9, 2024
1 parent 48be002 commit 42d7194
Show file tree
Hide file tree
Showing 11 changed files with 196 additions and 14 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/chef.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -108,9 +108,9 @@ jobs:
uses: ./.github/actions/checkout-submodules-and-bootstrap
with:
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 ab81a585fca6a83b30e1f4e58a021113d6a3acb8"
- 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 322432f1d903337f9e5501835d7057a7a73168f6"
- name: CI Examples Telink
shell: bash
run: |
Expand Down
24 changes: 18 additions & 6 deletions .github/workflows/examples-telink.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,8 @@ jobs:
with:
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 ab81a585fca6a83b30e1f4e58a021113d6a3acb8"
- name: Update Zephyr to specific revision (for developers purpose)
run: scripts/run_in_build_env.sh "python3 scripts/tools/telink/update_zephyr.py 322432f1d903337f9e5501835d7057a7a73168f6"

- name: Build example Telink (B92 retention) Air Quality Sensor App
run: |
Expand Down Expand Up @@ -107,13 +107,13 @@ jobs:
- name: clean out build output
run: rm -rf ./out

- name: Build example Telink (B92 retention) Contact Sensor App
- name: Build example Telink (tl321x retention) Contact Sensor App
run: |
./scripts/run_in_build_env.sh \
"./scripts/build/build_examples.py --target 'telink-tlsr9528a_retention-contact-sensor' build"
"./scripts/build/build_examples.py --target 'telink-tl3218x_retention-contact-sensor' build"
.environment/pigweed-venv/bin/python3 scripts/tools/memory/gh_sizes.py \
telink tlsr9528a_retention contact-sensor-app \
out/telink-tlsr9528a_retention-contact-sensor/zephyr/zephyr.elf \
telink tl3218x_retention contact-sensor-app \
out/telink-tl3218x_retention-contact-sensor/zephyr/zephyr.elf \
/tmp/bloat_reports/
- name: clean out build output
Expand Down Expand Up @@ -153,6 +153,18 @@ jobs:
- name: clean out build output (keep tools)
run: rm -rf ./out/telink*

- name: Build example Telink (tl321x) Lighting App with OTA, Shell, Factory Data
run: |
./scripts/run_in_build_env.sh \
"./scripts/build/build_examples.py --target 'telink-tl3218x-light-ota-shell-factory-data' build"
.environment/pigweed-venv/bin/python3 scripts/tools/memory/gh_sizes.py \
telink tl3218x light-app-ota-shell-factory-data \
out/telink-tl3218x-light-ota-shell-factory-data/zephyr/zephyr.elf \
/tmp/bloat_reports/
- name: clean out build output (keep tools)
run: rm -rf ./out/telink*

- name: Build example Telink (B92) Light Switch App with OTA, Shell, Factory Data
run: |
./scripts/run_in_build_env.sh \
Expand Down
45 changes: 43 additions & 2 deletions config/telink/chip-module/Kconfig.defaults
Original file line number Diff line number Diff line change
Expand Up @@ -138,16 +138,20 @@ config BT_BUF_ACL_TX_SIZE

config BT_RX_STACK_SIZE
default 810 if BT_B9X
default 810 if BT_TLX
default 2048 if BT_W91

config BT_HCI_TX_STACK_SIZE
default 640 if BT_B9X
default 640 if BT_TLX
default 2048 if BT_W91

config BT_DEVICE_NAME_GATT_WRITABLE
bool
default n

if SOC_SERIES_RISCV_TELINK_B9X

config B9X_BLE_CTRL_THREAD_STACK_SIZE
default 576

Expand All @@ -165,7 +169,30 @@ choice B9X_BLE_CTRL_MAC_TYPE
default B9X_BLE_CTRL_MAC_TYPE_RANDOM_STATIC
endchoice

endif
endif # SOC_SERIES_RISCV_TELINK_B9X

if SOC_SERIES_RISCV_TELINK_TLX

# config TLX_BLE_CTRL_THREAD_STACK_SIZE
# default 576
#
# config TLX_BLE_CTRL_MASTER_MAX_NUM
# default 0
#
# config TLX_BLE_CTRL_SLAVE_MAX_NUM
# default 1
#
# config TLX_BLE_CTRL_RF_POWER
# default 3 if PM
# default 9
#
# choice TLX_BLE_CTRL_MAC_TYPE
# default TLX_BLE_CTRL_MAC_TYPE_RANDOM_STATIC
# endchoice

endif # TLX_BLE_CTRL_MASTER_MAX_NUM

endif # BT

# Board retention config
if BOARD_TLSR9528A_RETENTION || BOARD_TLSR9258A_RETENTION || BOARD_TLSR9518ADK80D_RETENTION
Expand All @@ -177,10 +204,24 @@ config TELINK_B9X_MATTER_RETENTION_LAYOUT

config PWM
default n

endif

if BOARD_TL3218X_RETENTION

config SOC_SERIES_RISCV_TELINK_TLX_NON_RETENTION_RAM_CODE
default y if PM

config TELINK_TLX_MATTER_RETENTION_LAYOUT
default y if PM

config PWM
default n

endif

# Board non-retention config
if BOARD_TLSR9118BDK40D || BOARD_TLSR9528A || BOARD_TLSR9258A || BOARD_TLSR9518ADK80D
if BOARD_TLSR9118BDK40D || BOARD_TLSR9528A || BOARD_TLSR9258A || BOARD_TLSR9518ADK80D || BOARD_TL3218X
config PWM
default y
endif
Expand Down
2 changes: 1 addition & 1 deletion examples/platform/telink/common.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ if(NOT EXISTS "${BOOT_CONF_OVERLAY_FILE}")
message(FATAL_ERROR "${BOOT_CONF_OVERLAY_FILE} doesn't exist")
endif()

if(${CONFIG_USB_TELINK_B9X} MATCHES y)
if((${CONFIG_USB_TELINK_B9X} MATCHES y) OR (${CONFIG_USB_TELINK_TLX} MATCHES y))
set(BOOT_USB_CONF_OVERLAY_FILE "${CHIP_ROOT}/config/telink/app/bootloader_usb.conf")
if(NOT EXISTS "${BOOT_USB_CONF_OVERLAY_FILE}")
message(FATAL_ERROR "${BOOT_USB_CONF_OVERLAY_FILE} doesn't exist")
Expand Down
2 changes: 2 additions & 0 deletions scripts/build/build/targets.py
Original file line number Diff line number Diff line change
Expand Up @@ -755,6 +755,8 @@ def BuildTelinkTarget():
TargetPart('tlsr9528a_retention', board=TelinkBoard.TLSR9528A_RETENTION),
TargetPart('tlsr9258a', board=TelinkBoard.TLSR9258A),
TargetPart('tlsr9258a_retention', board=TelinkBoard.TLSR9258A_RETENTION),
TargetPart('tl3218x', board=TelinkBoard.TL3218X),
TargetPart('tl3218x_retention', board=TelinkBoard.TL3218X_RETENTION),
])

target.AppendFixedTargets([
Expand Down
6 changes: 6 additions & 0 deletions scripts/build/builders/telink.py
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,8 @@ class TelinkBoard(Enum):
TLSR9528A_RETENTION = auto()
TLSR9258A = auto()
TLSR9258A_RETENTION = auto()
TL3218X = auto()
TL3218X_RETENTION = auto()

def GnArgName(self):
if self == TelinkBoard.TLRS9118BDK40D:
Expand All @@ -134,6 +136,10 @@ def GnArgName(self):
return 'tlsr9258a'
elif self == TelinkBoard.TLSR9258A_RETENTION:
return 'tlsr9258a_retention'
elif self == TelinkBoard.TL3218X:
return 'tl3218x'
elif self == TelinkBoard.TL3218X_RETENTION:
return 'tl3218x_retention'
else:
raise Exception('Unknown board type: %r' % self)

Expand Down
2 changes: 1 addition & 1 deletion scripts/build/testdata/all_targets_linux_x64.txt
Original file line number Diff line number Diff line change
Expand Up @@ -23,5 +23,5 @@ nuttx-x64-light
qpg-qpg6105-{lock,light,shell,persistent-storage,light-switch,thermostat}[-updateimage]
stm32-stm32wb5mm-dk-light
tizen-arm-{all-clusters,all-clusters-minimal,chip-tool,light,tests}[-no-ble][-no-thread][-no-wifi][-asan][-ubsan][-with-ui]
telink-{tlsr9118bdk40d,tlsr9518adk80d,tlsr9528a,tlsr9528a_retention,tlsr9258a,tlsr9258a_retention}-{air-quality-sensor,all-clusters,all-clusters-minimal,bridge,contact-sensor,light,light-switch,lock,ota-requestor,pump,pump-controller,shell,smoke-co-alarm,temperature-measurement,thermostat,window-covering}[-ota][-dfu][-shell][-rpc][-factory-data][-4mb][-mars][-usb]
telink-{tlsr9118bdk40d,tlsr9518adk80d,tlsr9528a,tlsr9528a_retention,tlsr9258a,tlsr9258a_retention,tl3218x,tl3218x_retention}-{air-quality-sensor,all-clusters,all-clusters-minimal,bridge,contact-sensor,light,light-switch,lock,ota-requestor,pump,pump-controller,shell,smoke-co-alarm,temperature-measurement,thermostat,window-covering}[-ota][-dfu][-shell][-rpc][-factory-data][-4mb][-mars][-usb]
openiotsdk-{shell,lock}[-mbedtls][-psa]
2 changes: 1 addition & 1 deletion src/platform/telink/telink-mbedtls-config.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
#define MBEDTLS_X509_CREATE_C
#define MBEDTLS_X509_CSR_WRITE_C

#ifdef CONFIG_TELINK_B9X_MBEDTLS_HW_ACCELERATION
#if defined CONFIG_TELINK_B9X_MBEDTLS_HW_ACCELERATION || CONFIG_TELINK_TLX_MBEDTLS_HW_ACCELERATION
#define MBEDTLS_AES_ALT
#define MBEDTLS_ECP_ALT
#endif
Expand Down
61 changes: 61 additions & 0 deletions src/platform/telink/tl3218x.overlay
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
/ {
/* Short TL_Key3 (J6 pin 21) to ground */
key_pool {
compatible = "gpio-keys";

inp {
gpios = <&gpiob 3 (GPIO_ACTIVE_LOW | GPIO_PULL_UP)>,
<&gpiob 5 (GPIO_ACTIVE_LOW | GPIO_PULL_UP)>;
};
};

key_matrix {
compatible = "gpio-keys";

col {
gpios = <&gpiob 6 GPIO_ACTIVE_HIGH>,
<&gpiob 7 GPIO_ACTIVE_HIGH>;
};

row {
gpios = <&gpiob 3 (GPIO_PULL_DOWN | GPIO_ACTIVE_HIGH)>,
<&gpiob 5 (GPIO_PULL_DOWN | GPIO_ACTIVE_HIGH)>;
};
};

led_pool {
compatible = "gpio-leds";

out {
gpios = <&gpiod 0 GPIO_ACTIVE_HIGH>;
};
};

pwm_pool {
compatible = "pwm-leds";
out {
pwms = <&pwm0 2 PWM_MSEC(20) PWM_POLARITY_NORMAL>,
<&pwm0 0 PWM_MSEC(20) PWM_POLARITY_NORMAL>,
<&pwm0 1 PWM_MSEC(20) PWM_POLARITY_NORMAL>;
};
};
};

&pwm0 {
/* On board RGB LEDs */
pinctrl-ch0 = <&pwm_ch0_pb1_default>;
pinctrl-ch2 = <&pwm_ch1_pb2_default>;
pinctrl-ch1 = <&pwm_ch2_pb0_default>;
};

&pinctrl {
pwm_ch0_pb1_default: pwm_ch0_pb1_default {
pinmux = <TLX_PINMUX_SET(TLX_PORT_B, TLX_PIN_1, TL321X_FUNC_PWM0)>;
};
pwm_ch1_pb2_default: pwm_ch1_pb2_default {
pinmux = <TLX_PINMUX_SET(TLX_PORT_B, TLX_PIN_2, TL321X_FUNC_PWM1)>;
};
pwm_ch2_pb0_default: pwm_ch2_pb0_default {
pinmux = <TLX_PINMUX_SET(TLX_PORT_B, TLX_PIN_0, TL321X_FUNC_PWM2)>;
};
};
36 changes: 36 additions & 0 deletions src/platform/telink/tl3218x_2m_flash.overlay
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
&flash {
reg = <0x20000000 0x200000>;

partitions {
/delete-node/ partition@0;
/delete-node/ partition@20000;
/delete-node/ partition@88000;
/delete-node/ partition@f0000;
/delete-node/ partition@f4000;
/delete-node/ partition@fe000;
boot_partition: partition@0 {
label = "mcuboot";
reg = <0x00000000 0x13000>;
};
slot0_partition: partition@13000 {
label = "image-0";
reg = <0x13000 0xef000>;
};
factory_partition: partition@102000 {
label = "factory-data";
reg = <0x102000 0x1000>;
};
storage_partition: partition@103000 {
label = "storage";
reg = <0x103000 0xc000>;
};
slot1_partition: partition@10f000 {
label = "image-1";
reg = <0x10f000 0xef000>;
};
vendor_partition: partition@1fe000 {
label = "vendor-data";
reg = <0x1fe000 0x2000>;
};
};
};
24 changes: 24 additions & 0 deletions src/platform/telink/tl3218x_retention.overlay
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
/ {
/*
* There is no way to keep GPIOs
* during deep-sleep mode so output GPIOs
* and PWM's are useless.
*/

aliases {
/delete-property/ led0;
/delete-property/ led1;
/delete-property/ led2;
/delete-property/ led3;
/delete-property/ mcuboot-led0;
/delete-property/ pwm-led0;
/delete-property/ pwm-0;
};

/delete-node/ leds;
/delete-node/ pwm_leds;
};

&pwm0 {
status = "disabled";
};

0 comments on commit 42d7194

Please sign in to comment.