From 42d71940440931fa562f0062bae822c1888fce23 Mon Sep 17 00:00:00 2001 From: Alex Tsitsiura Date: Fri, 30 Aug 2024 15:53:35 +0300 Subject: [PATCH] [Telink] Add TL3218X sceleton --- .github/workflows/chef.yaml | 6 +- .github/workflows/examples-telink.yaml | 24 ++++++-- config/telink/chip-module/Kconfig.defaults | 45 +++++++++++++- examples/platform/telink/common.cmake | 2 +- scripts/build/build/targets.py | 2 + scripts/build/builders/telink.py | 6 ++ .../build/testdata/all_targets_linux_x64.txt | 2 +- src/platform/telink/telink-mbedtls-config.h | 2 +- src/platform/telink/tl3218x.overlay | 61 +++++++++++++++++++ src/platform/telink/tl3218x_2m_flash.overlay | 36 +++++++++++ src/platform/telink/tl3218x_retention.overlay | 24 ++++++++ 11 files changed, 196 insertions(+), 14 deletions(-) create mode 100644 src/platform/telink/tl3218x.overlay create mode 100644 src/platform/telink/tl3218x_2m_flash.overlay create mode 100644 src/platform/telink/tl3218x_retention.overlay diff --git a/.github/workflows/chef.yaml b/.github/workflows/chef.yaml index da12476696bce9..2604e6773a89a7 100644 --- a/.github/workflows/chef.yaml +++ b/.github/workflows/chef.yaml @@ -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: | diff --git a/.github/workflows/examples-telink.yaml b/.github/workflows/examples-telink.yaml index 22007fb77a3085..49fd1c11c87502 100644 --- a/.github/workflows/examples-telink.yaml +++ b/.github/workflows/examples-telink.yaml @@ -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: | @@ -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 @@ -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 \ diff --git a/config/telink/chip-module/Kconfig.defaults b/config/telink/chip-module/Kconfig.defaults index ea5a6822b74cb5..d240f927b02fac 100644 --- a/config/telink/chip-module/Kconfig.defaults +++ b/config/telink/chip-module/Kconfig.defaults @@ -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 @@ -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 @@ -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 diff --git a/examples/platform/telink/common.cmake b/examples/platform/telink/common.cmake index 9b8149c7d02d6a..fe99da59d94baa 100644 --- a/examples/platform/telink/common.cmake +++ b/examples/platform/telink/common.cmake @@ -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") diff --git a/scripts/build/build/targets.py b/scripts/build/build/targets.py index 2c5f84ca30ad37..817f1eabfdaaed 100755 --- a/scripts/build/build/targets.py +++ b/scripts/build/build/targets.py @@ -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([ diff --git a/scripts/build/builders/telink.py b/scripts/build/builders/telink.py index b9cd709ba6b44c..fe51197df1bf28 100644 --- a/scripts/build/builders/telink.py +++ b/scripts/build/builders/telink.py @@ -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: @@ -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) diff --git a/scripts/build/testdata/all_targets_linux_x64.txt b/scripts/build/testdata/all_targets_linux_x64.txt index d391093a153fcf..2debdf8fd69683 100644 --- a/scripts/build/testdata/all_targets_linux_x64.txt +++ b/scripts/build/testdata/all_targets_linux_x64.txt @@ -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] diff --git a/src/platform/telink/telink-mbedtls-config.h b/src/platform/telink/telink-mbedtls-config.h index 921255d9425289..3675b2cab22c79 100644 --- a/src/platform/telink/telink-mbedtls-config.h +++ b/src/platform/telink/telink-mbedtls-config.h @@ -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 diff --git a/src/platform/telink/tl3218x.overlay b/src/platform/telink/tl3218x.overlay new file mode 100644 index 00000000000000..4c74bb14ea216c --- /dev/null +++ b/src/platform/telink/tl3218x.overlay @@ -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 = ; + }; + pwm_ch1_pb2_default: pwm_ch1_pb2_default { + pinmux = ; + }; + pwm_ch2_pb0_default: pwm_ch2_pb0_default { + pinmux = ; + }; +}; diff --git a/src/platform/telink/tl3218x_2m_flash.overlay b/src/platform/telink/tl3218x_2m_flash.overlay new file mode 100644 index 00000000000000..a87ebba57e874b --- /dev/null +++ b/src/platform/telink/tl3218x_2m_flash.overlay @@ -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>; + }; + }; +}; diff --git a/src/platform/telink/tl3218x_retention.overlay b/src/platform/telink/tl3218x_retention.overlay new file mode 100644 index 00000000000000..0890951e787f96 --- /dev/null +++ b/src/platform/telink/tl3218x_retention.overlay @@ -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"; +};