diff --git a/.github/workflows/examples-telink.yaml b/.github/workflows/examples-telink.yaml index 4efd43881b46b8..5dfb22a3bc3749 100644 --- a/.github/workflows/examples-telink.yaml +++ b/.github/workflows/examples-telink.yaml @@ -316,6 +316,20 @@ jobs: - name: clean out build output run: rm -rf ./out + - name: Build example Telink (tl7218x ml7g) Lighting App + # Run test for master and s07641069 PRs + if: github.event.pull_request.number == null || github.event.pull_request.head.repo.full_name == 's07641069/connectedhomeip' + run: | + ./scripts/run_in_build_env.sh \ + "./scripts/build/build_examples.py --target 'telink-tl7218x-ml7g' build" + .environment/pigweed-venv/bin/python3 scripts/tools/memory/gh_sizes.py \ + telink tl7218x_ml7g lighting-app \ + out/telink-tl7218x_ml7g-lighting-app/zephyr/zephyr.elf \ + /tmp/bloat_reports/ + + - name: clean out build output + run: rm -rf ./out + - name: Build example Telink (B91) Thermostat App # Run test for master and s07641069 PRs if: github.event.pull_request.number == null || github.event.pull_request.head.repo.full_name == 's07641069/connectedhomeip' diff --git a/examples/platform/telink/common.cmake b/examples/platform/telink/common.cmake index 8db743b533f696..8f748ad92c1818 100644 --- a/examples/platform/telink/common.cmake +++ b/examples/platform/telink/common.cmake @@ -65,6 +65,38 @@ else() unset(MARS_CONF_OVERLAY_FILE) endif() +if(${TLNK_7218X_ML7G_BOARD} MATCHES y) + set(ML_DTC_OVERLAY_FILE "${CHIP_ROOT}/src/platform/telink/${BOARD}_ml7g.overlay") + if(NOT EXISTS "${ML_DTC_OVERLAY_FILE}") + message(FATAL_ERROR "${ML_DTC_OVERLAY_FILE} doesn't exist") + endif() + set(ML_CONF_OVERLAY_FILE "${CHIP_ROOT}/src/platform/telink/${BOARD}_ml7g.conf") + if(NOT EXISTS "${ML_CONF_OVERLAY_FILE}") + message(FATAL_ERROR "${ML_CONF_OVERLAY_FILE} doesn't exist") + endif() +elseif(${TLNK_7218X_ML7M_BOARD} MATCHES y) + set(ML_DTC_OVERLAY_FILE "${CHIP_ROOT}/src/platform/telink/${BOARD}_ml7m.overlay") + if(NOT EXISTS "${ML_DTC_OVERLAY_FILE}") + message(FATAL_ERROR "${ML_DTC_OVERLAY_FILE} doesn't exist") + endif() + set(ML_CONF_OVERLAY_FILE "${CHIP_ROOT}/src/platform/telink/${BOARD}_ml7m.conf") + if(NOT EXISTS "${ML_CONF_OVERLAY_FILE}") + message(FATAL_ERROR "${ML_CONF_OVERLAY_FILE} doesn't exist") + endif() +elseif(${TLNK_3218X_ML3M_BOARD} MATCHES y) + set(ML_DTC_OVERLAY_FILE "${CHIP_ROOT}/src/platform/telink/${BOARD}_ml3m.overlay") + if(NOT EXISTS "${ML_DTC_OVERLAY_FILE}") + message(FATAL_ERROR "${ML_DTC_OVERLAY_FILE} doesn't exist") + endif() + set(ML_CONF_OVERLAY_FILE "${CHIP_ROOT}/src/platform/telink/${BOARD}_ml3m.conf") + if(NOT EXISTS "${ML_CONF_OVERLAY_FILE}") + message(FATAL_ERROR "${ML_CONF_OVERLAY_FILE} doesn't exist") + endif() +else() + unset(ML_DTC_OVERLAY_FILE) + unset(ML_CONF_OVERLAY_FILE) +endif() + if(${TLNK_USB_DONGLE} MATCHES y) set(USB_BOOT_DTC_OVERLAY_FILE "${CHIP_ROOT}/src/platform/telink/${BASE_BOARD}_usb_boot.overlay") if(NOT EXISTS "${USB_BOOT_DTC_OVERLAY_FILE}") @@ -130,15 +162,15 @@ endif() if(DTC_OVERLAY_FILE) set(DTC_OVERLAY_FILE - "${DTC_OVERLAY_FILE} ${GLOBAL_DTC_OVERLAY_FILE} ${USB_DTC_OVERLAY_FILE} ${MARS_DTC_OVERLAY_FILE} ${FLASH_DTC_OVERLAY_FILE} ${LOCAL_DTC_OVERLAY_FILE}" + "${DTC_OVERLAY_FILE} ${GLOBAL_DTC_OVERLAY_FILE} ${USB_DTC_OVERLAY_FILE} ${MARS_DTC_OVERLAY_FILE} ${FLASH_DTC_OVERLAY_FILE} ${LOCAL_DTC_OVERLAY_FILE} ${ML_DTC_OVERLAY_FILE}" CACHE STRING "" FORCE ) else() - set(DTC_OVERLAY_FILE ${GLOBAL_DTC_OVERLAY_FILE} ${USB_DTC_OVERLAY_FILE} ${MARS_DTC_OVERLAY_FILE} ${FLASH_DTC_OVERLAY_FILE} ${LOCAL_DTC_OVERLAY_FILE}) + set(DTC_OVERLAY_FILE ${GLOBAL_DTC_OVERLAY_FILE} ${USB_DTC_OVERLAY_FILE} ${MARS_DTC_OVERLAY_FILE} ${FLASH_DTC_OVERLAY_FILE} ${LOCAL_DTC_OVERLAY_FILE} ${ML_DTC_OVERLAY_FILE}) endif() if(NOT CONF_FILE) - set(CONF_FILE ${USB_CONF_OVERLAY_FILE} ${MARS_CONF_OVERLAY_FILE} ${ZEPHYR_VERSION_OVERLAY_FILE} prj.conf) + set(CONF_FILE ${USB_CONF_OVERLAY_FILE} ${MARS_CONF_OVERLAY_FILE} prj.conf ${ML_CONF_OVERLAY_FILE}) endif() # Load NCS/Zephyr build system diff --git a/scripts/build/build/targets.py b/scripts/build/build/targets.py index a84f5b96e77676..23db950edc7fc5 100755 --- a/scripts/build/build/targets.py +++ b/scripts/build/build/targets.py @@ -818,6 +818,7 @@ def BuildTelinkTarget(): target.AppendModifier('factory-data', enable_factory_data=True) target.AppendModifier('4mb', enable_4mb_flash=True) target.AppendModifier('mars', mars_board_config=True) + target.AppendModifier('tl7218x_ml7g', tl7218x_ml7g_board_config=True) target.AppendModifier('usb', usb_board_config=True) target.AppendModifier('compress-lzma', compress_lzma_config=True) target.AppendModifier('thread-analyzer', thread_analyzer_config=True) diff --git a/scripts/build/builders/telink.py b/scripts/build/builders/telink.py index d48453bf08f099..072cccff11d561 100644 --- a/scripts/build/builders/telink.py +++ b/scripts/build/builders/telink.py @@ -159,6 +159,7 @@ def __init__(self, enable_factory_data: bool = False, enable_4mb_flash: bool = False, mars_board_config: bool = False, + tl7218x_ml7g_board_config: bool = False, usb_board_config: bool = False, compress_lzma_config: bool = False, thread_analyzer_config: bool = False, @@ -174,6 +175,7 @@ def __init__(self, self.enable_factory_data = enable_factory_data self.enable_4mb_flash = enable_4mb_flash self.mars_board_config = mars_board_config + self.tl7218x_ml7g_board_config = tl7218x_ml7g_board_config self.usb_board_config = usb_board_config self.compress_lzma_config = compress_lzma_config self.thread_analyzer_config = thread_analyzer_config @@ -219,6 +221,9 @@ def generate(self): if self.mars_board_config: flags.append("-DTLNK_MARS_BOARD=y") + if self.tl7218x_ml7g_board_config: + flags.append("-DTLNK_7218X_ML7G_BOARD=y") + if self.usb_board_config: flags.append("-DTLNK_USB_DONGLE=y") diff --git a/scripts/build/testdata/all_targets_linux_x64.txt b/scripts/build/testdata/all_targets_linux_x64.txt index 304fa82d00e35c..b2603874ef9004 100644 --- a/scripts/build/testdata/all_targets_linux_x64.txt +++ b/scripts/build/testdata/all_targets_linux_x64.txt @@ -23,5 +23,5 @@ qpg-qpg6105-{light,light-switch,lock,persistent-storage,shell,thermostat}[-updat realtek-rtl8777g-{all-clusters,light-switch,lighting,lock,ota-requestor,thermostat,window} stm32-stm32wb5mm-dk-light tizen-{arm,arm64}-{all-clusters,chip-tool,light,tests}[-asan][-coverage][-no-ble][-no-thread][-no-wifi][-ubsan][-with-ui] -telink-{tl3218x,tl3218x_retention,tl7218x,tl7218x_retention,tlsr9118bdk40d,tlsr9518adk80d,tlsr9528a,tlsr9528a_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}[-4mb][-compress-lzma][-dfu][-factory-data][-mars][-ota][-precompiled-ot][-rpc][-shell][-thread-analyzer][-usb] +telink-{tl3218x,tl3218x_retention,tl7218x,tl7218x_retention,tl7218x_ml7g,tlsr9118bdk40d,tlsr9518adk80d,tlsr9528a,tlsr9528a_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}[-4mb][-compress-lzma][-dfu][-factory-data][-mars][-ota][-precompiled-ot][-rpc][-shell][-thread-analyzer][-usb][-tl7218x_ml7g] openiotsdk-{lock,shell}[-mbedtls][-psa] diff --git a/src/platform/telink/tl3218x_ml3m.conf b/src/platform/telink/tl3218x_ml3m.conf new file mode 100644 index 00000000000000..81d3e4f7355d4d --- /dev/null +++ b/src/platform/telink/tl3218x_ml3m.conf @@ -0,0 +1,6 @@ +CONFIG_CHIP_BUTTON_MANAGER_IRQ_MODE=y + +# USB configuration (Disable it if need full logging) +CONFIG_USB_DEVICE_STACK=y +CONFIG_USB_DEVICE_INITIALIZE_AT_BOOT=n +CONFIG_USB_CDC_ACM_LOG_LEVEL_OFF=y diff --git a/src/platform/telink/tl3218x_ml3m.overlay b/src/platform/telink/tl3218x_ml3m.overlay new file mode 100644 index 00000000000000..9ff4e9aa2b34cc --- /dev/null +++ b/src/platform/telink/tl3218x_ml3m.overlay @@ -0,0 +1,140 @@ + +/ { + model = "telink,tl321x"; + compatible = "telink,tl3218x"; + + chosen { + zephyr,console = &cdc_acm_uart0; + zephyr,shell-uart = &cdc_acm_uart0; + }; + + aliases { + /delete-property/ mcuboot-button0; + pwm-led0 = &pwm_led_white; + pwm-0 = &pwm0; + }; + + leds { + compatible = "gpio-leds"; + + led_white: led_0 { + gpios = <&gpioe 5 GPIO_ACTIVE_HIGH>; + label = "LED White"; + }; + + led_green: led_1 { + gpios = <&gpioe 4 GPIO_ACTIVE_HIGH>; + label = "LED Green"; + }; + + }; + + /delete-node/ pwm_leds; + + pwm_leds { + compatible = "pwm-leds"; + + pwm_led_white: pwm_led_0 { + pwms = <&pwm0 0 PWM_MSEC(20) PWM_POLARITY_NORMAL>; + label = "PWM LED White"; + }; + }; + + keys { + compatible = "gpio-keys"; + + key_1: button_1 { + label = "User KEY1"; + gpios = <&gpioe 2 (GPIO_ACTIVE_LOW | GPIO_PULL_UP)>; + }; + + key_2: button_2 { + label = "User KEY2"; + gpios = <&gpioe 6 (GPIO_ACTIVE_LOW | GPIO_PULL_UP)>; + }; + + key_3: button_3 { + label = "User KEY3"; + gpios = <&gpioa 4 (GPIO_ACTIVE_LOW | GPIO_PULL_UP)>; + }; + + key_4: button_4 { + label = "User KEY4"; + gpios = <&gpioa 7 (GPIO_ACTIVE_LOW | GPIO_PULL_UP)>; + }; + + }; + + /* Short TL_Key3 (J6 pin 31) to ground */ + key_pool { + compatible = "gpio-keys"; + + inp { + gpios = <&gpioe 2 (GPIO_ACTIVE_LOW | GPIO_PULL_UP)>, + <&gpioe 6 (GPIO_ACTIVE_LOW | GPIO_PULL_UP)>; + }; + }; + + led_pool { + compatible = "gpio-leds"; + + out { + gpios = <&gpioe 4 GPIO_ACTIVE_HIGH>, + <&gpioe 5 GPIO_ACTIVE_HIGH>; + }; + }; + + pwm_pool { + compatible = "pwm-leds"; + out { + pwms = <&pwm0 0 PWM_MSEC(20) PWM_POLARITY_NORMAL>, + <&pwm0 1 PWM_MSEC(20) PWM_POLARITY_NORMAL>, + <&pwm0 2 PWM_MSEC(20) PWM_POLARITY_NORMAL>, + <&pwm0 3 PWM_MSEC(20) PWM_POLARITY_NORMAL>; + }; + }; +}; + +&uart0 { + status = "okay"; + current-speed = <115200>; + pinctrl-0 = <&uart0_tx_pb6_default &uart0_rx_pb7_default>; + pinctrl-names = "default"; +}; + +&pwm0 { + status = "okay"; + clock-frequency = <300000>; + pinctrl-ch3 = <&pwm_ch3_pe5_default>; +}; + +&pinctrl { + /* Set pad-mul-sel register value. + * Note: Pins functions below (pinmux = <...>) depend on this value. + */ + pad-mul-sel = <1>; + + /* UART0: TX(PB6), RX(PB7) */ + + uart0_tx_pb6_default: uart0_tx_pb6_default { + pinmux = ; + }; + uart0_rx_pb7_default: uart0_rx_pb7_default { + pinmux = ; + }; + + /* PWM Channel 3 (PE5) */ + pwm_ch3_pe5_default: pwm_ch3_pe5_default { + pinmux = ; + }; + +}; + +/* USB configuration (Disable it if need full logging) */ +&zephyr_udc0 { + cdc_acm_uart0: cdc_acm_uart0 { + compatible = "zephyr,cdc-acm-uart"; + }; +}; diff --git a/src/platform/telink/tl7218x_ml7g.conf b/src/platform/telink/tl7218x_ml7g.conf new file mode 100644 index 00000000000000..8fd4b0dff8b732 --- /dev/null +++ b/src/platform/telink/tl7218x_ml7g.conf @@ -0,0 +1,9 @@ +CONFIG_CHIP_BUTTON_MANAGER_IRQ_MODE=y + +# Disable PWM because PE1~5 are used for PWM +CONFIG_PWM=n + +# USB configuration (Disable it if need full logging) +CONFIG_USB_DEVICE_STACK=y +CONFIG_USB_DEVICE_INITIALIZE_AT_BOOT=n +CONFIG_USB_CDC_ACM_LOG_LEVEL_OFF=y diff --git a/src/platform/telink/tl7218x_ml7g.overlay b/src/platform/telink/tl7218x_ml7g.overlay new file mode 100644 index 00000000000000..d7c857f8fa2845 --- /dev/null +++ b/src/platform/telink/tl7218x_ml7g.overlay @@ -0,0 +1,119 @@ + +/ { + model = "telink,tl721x"; + compatible = "telink,tl7218x"; + + chosen { + zephyr,console = &cdc_acm_uart0; + zephyr,shell-uart = &cdc_acm_uart0; + }; + + aliases { + /delete-property/ mcuboot-button0; + }; + + leds { + compatible = "gpio-leds"; + + led_green: led_1 { + gpios = <&gpioe 2 GPIO_ACTIVE_HIGH>; + label = "LED Green"; + }; + + led_white: led_2 { + gpios = <&gpioe 1 GPIO_ACTIVE_HIGH>; + label = "LED White"; + }; + }; + + keys { + compatible = "gpio-keys"; + + key_1: button_1 { + label = "User KEY1"; + gpios = <&gpioe 3 (GPIO_ACTIVE_LOW | GPIO_PULL_UP)>; + }; + + key_2: button_2 { + label = "User KEY2"; + gpios = <&gpioe 5 (GPIO_ACTIVE_LOW | GPIO_PULL_UP)>; + }; + + key_3: button_3 { + label = "User KEY3"; + gpios = <&gpiof 4 (GPIO_ACTIVE_LOW | GPIO_PULL_UP)>; + }; + + key_4: button_4 { + label = "User KEY4"; + gpios = <&gpioa 7 (GPIO_ACTIVE_LOW | GPIO_PULL_UP)>; + }; + + }; + + /* Short TL_Key3 (J6 pin 31) to ground */ + key_pool { + compatible = "gpio-keys"; + + inp { + gpios = <&gpioe 3 (GPIO_ACTIVE_LOW | GPIO_PULL_UP)>, + <&gpioe 5 (GPIO_ACTIVE_LOW | GPIO_PULL_UP)>; + }; + }; + + led_pool { + compatible = "gpio-leds"; + + out { + gpios = <&gpioe 2 GPIO_ACTIVE_HIGH>, + <&gpioe 1 GPIO_ACTIVE_HIGH>; + }; + }; + + /delete-node/ pwm_pool; + +}; + + +&gpioe { + interrupts = <39 1>; + status = "okay"; +}; + +&uart0 { + status = "okay"; + current-speed = <115200>; + pinctrl-0 = <&uart0_tx_pf1_default &uart0_rx_pf2_default>; + pinctrl-names = "default"; +}; + +/* Disable LSPI in overlay */ +&lspi { + status = "disabled"; +}; + +&pinctrl { + /* Set pad-mul-sel register value. + * Note: Pins functions below (pinmux = <...>) depend on this value. + */ + pad-mul-sel = <1>; + + /* UART0: TX(PF1), RX(PF2), RTS(PB4), CTS(PB6) */ + + uart0_tx_pf1_default: uart0_tx_pf1_default { + pinmux = ; + }; + uart0_rx_pf2_default: uart0_rx_pf2_default { + pinmux = ; + }; + +}; + +/* USB configuration (Disable it if need full logging) */ +&zephyr_udc0 { + cdc_acm_uart0: cdc_acm_uart0 { + compatible = "zephyr,cdc-acm-uart"; + }; +}; diff --git a/src/platform/telink/tl7218x_ml7m.conf b/src/platform/telink/tl7218x_ml7m.conf new file mode 100644 index 00000000000000..8fd4b0dff8b732 --- /dev/null +++ b/src/platform/telink/tl7218x_ml7m.conf @@ -0,0 +1,9 @@ +CONFIG_CHIP_BUTTON_MANAGER_IRQ_MODE=y + +# Disable PWM because PE1~5 are used for PWM +CONFIG_PWM=n + +# USB configuration (Disable it if need full logging) +CONFIG_USB_DEVICE_STACK=y +CONFIG_USB_DEVICE_INITIALIZE_AT_BOOT=n +CONFIG_USB_CDC_ACM_LOG_LEVEL_OFF=y diff --git a/src/platform/telink/tl7218x_ml7m.overlay b/src/platform/telink/tl7218x_ml7m.overlay new file mode 100644 index 00000000000000..66e81ed3de7365 --- /dev/null +++ b/src/platform/telink/tl7218x_ml7m.overlay @@ -0,0 +1,107 @@ + +/ { + model = "telink,tl721x"; + compatible = "telink,tl7218x"; + + chosen { + zephyr,console = &cdc_acm_uart0; + zephyr,shell-uart = &cdc_acm_uart0; + }; + + aliases { + /delete-property/ mcuboot-button0; + }; + + leds { + compatible = "gpio-leds"; + + led_green: led_1 { + gpios = <&gpioe 2 GPIO_ACTIVE_HIGH>; + label = "LED Green"; + }; + + led_white: led_2 { + gpios = <&gpioe 1 GPIO_ACTIVE_HIGH>; + label = "LED White"; + }; + }; + + keys { + compatible = "gpio-keys"; + + key_1: button_1 { + label = "User KEY1"; + gpios = <&gpioe 3 (GPIO_ACTIVE_LOW | GPIO_PULL_UP)>; + }; + + key_2: button_2 { + label = "User KEY2"; + gpios = <&gpioe 5 (GPIO_ACTIVE_LOW | GPIO_PULL_UP)>; + }; + }; + + key_pool { + compatible = "gpio-keys"; + + inp { + gpios = <&gpioe 3 (GPIO_ACTIVE_LOW | GPIO_PULL_UP)>, + <&gpioe 5 (GPIO_ACTIVE_LOW | GPIO_PULL_UP)>; + }; + }; + + led_pool { + compatible = "gpio-leds"; + + out { + gpios = <&gpioe 2 GPIO_ACTIVE_HIGH>, + <&gpioe 1 GPIO_ACTIVE_HIGH>; + }; + }; + + /delete-node/ pwm_pool; + +}; + + +&gpioe { + interrupts = <39 1>; + status = "okay"; +}; + +&uart0 { + status = "okay"; + current-speed = <115200>; + pinctrl-0 = <&uart0_tx_pb6_default &uart0_rx_pb7_default>; + pinctrl-names = "default"; +}; + +/* Disable LSPI in overlay */ +&lspi { + status = "disabled"; +}; + +&pinctrl { + /* Set pad-mul-sel register value. + * Note: Pins functions below (pinmux = <...>) depend on this value. + */ + pad-mul-sel = <1>; + + /* UART0: TX(PB6), RX(PB7) */ + + uart0_tx_pb6_default: uart0_tx_pb6_default { + pinmux = ; + }; + uart0_rx_pb7_default: uart0_rx_pb7_default { + pinmux = ; + }; + +}; + +/* USB configuration (Disable it if need full logging) */ +&zephyr_udc0 { + cdc_acm_uart0: cdc_acm_uart0 { + compatible = "zephyr,cdc-acm-uart"; + }; +};