From 917f88e5f90d35ebaef23668b4f0b75e09875c53 Mon Sep 17 00:00:00 2001 From: Serhii Salamakha Date: Wed, 25 Oct 2023 10:26:38 +0300 Subject: [PATCH] [Telink] Add DFU via USB for Mars board --- config/telink/chip-module/CMakeLists.txt | 12 +++++++- src/platform/telink/tlsr9518adk80d_mars.conf | 5 +++- .../telink/tlsr9518adk80d_mars.overlay | 12 +++----- .../telink/tlsr9518adk80d_mars_boot.overlay | 28 +++++++++++++++++++ 4 files changed, 47 insertions(+), 10 deletions(-) create mode 100644 src/platform/telink/tlsr9518adk80d_mars_boot.overlay diff --git a/config/telink/chip-module/CMakeLists.txt b/config/telink/chip-module/CMakeLists.txt index e9d506e538f131..235784dae7a6d8 100644 --- a/config/telink/chip-module/CMakeLists.txt +++ b/config/telink/chip-module/CMakeLists.txt @@ -154,6 +154,16 @@ else() unset(USB_BOOT_DTC_OVERLAY_FILE) endif() +if(${TLNK_MARS_BOARD} MATCHES y) + if(EXISTS "${CHIP_ROOT}/src/platform/telink/${BOARD}_mars_boot.overlay") + set(MARS_BOOT_DTC_OVERLAY_FILE "${CHIP_ROOT}/src/platform/telink/${BOARD}_mars_boot.overlay") + else() + unset(MARS_BOOT_DTC_OVERLAY_FILE) + endif() +else() + unset(MARS_CONF_OVERLAY_FILE) +endif() + if(EXISTS "${CHIP_ROOT}/src/platform/telink/${BOARD}.overlay") set(GLOBAL_DTC_OVERLAY_FILE "${CHIP_ROOT}/src/platform/telink/${BOARD}.overlay") else() @@ -185,7 +195,7 @@ if (CONFIG_BOOTLOADER_MCUBOOT) add_custom_target(build_mcuboot ALL COMMAND west build -b ${BOARD} -d build_mcuboot ${ZEPHYR_BASE}/../bootloader/mcuboot/boot/zephyr - -- -DOVERLAY_CONFIG=${GLOBAL_BOOTLOADER_CONF_OVERLAY_FILE} -DDTC_OVERLAY_FILE="${GLOBAL_DTC_OVERLAY_FILE};${FLASH_DTC_OVERLAY_FILE};${USB_BOOT_DTC_OVERLAY_FILE}" + -- -DOVERLAY_CONFIG=${GLOBAL_BOOTLOADER_CONF_OVERLAY_FILE} -DDTC_OVERLAY_FILE="${GLOBAL_DTC_OVERLAY_FILE};${FLASH_DTC_OVERLAY_FILE};${USB_BOOT_DTC_OVERLAY_FILE};${MARS_BOOT_DTC_OVERLAY_FILE}" COMMAND cp ${PROJECT_BINARY_DIR}/../modules/chip-module/build_mcuboot/zephyr/zephyr.bin ${PROJECT_BINARY_DIR}/zephyr.mcuboot.bin ) diff --git a/src/platform/telink/tlsr9518adk80d_mars.conf b/src/platform/telink/tlsr9518adk80d_mars.conf index 1c076febc2f4bd..fe619104c86578 100644 --- a/src/platform/telink/tlsr9518adk80d_mars.conf +++ b/src/platform/telink/tlsr9518adk80d_mars.conf @@ -1,4 +1,7 @@ CONFIG_CHIP_USE_MARS_SENSOR=y CONFIG_CHIP_BUTTON_MANAGER_IRQ_MODE=y CONFIG_I2C=y -CONFIG_SENSOR=y \ No newline at end of file +CONFIG_SENSOR=y +CONFIG_USB_DEVICE_STACK=y +CONFIG_USB_DEVICE_INITIALIZE_AT_BOOT=n +CONFIG_USB_CDC_ACM_LOG_LEVEL_OFF=y \ No newline at end of file diff --git a/src/platform/telink/tlsr9518adk80d_mars.overlay b/src/platform/telink/tlsr9518adk80d_mars.overlay index 87a2f67ae50d56..2b93d82d507626 100644 --- a/src/platform/telink/tlsr9518adk80d_mars.overlay +++ b/src/platform/telink/tlsr9518adk80d_mars.overlay @@ -1,24 +1,20 @@ / { leds { + /delete-node/ led_3; + led_red: led_3 { - gpios = <&gpiob 6 GPIO_ACTIVE_HIGH>; label = "LED Red"; + gpios = <&gpiob 6 GPIO_ACTIVE_HIGH>; }; }; keys { /delete-node/ button_1; - /delete-node/ button_3; + /delete-node/ button_4; compatible = "gpio-keys"; key_1: button_1 { - gpios = <&gpiod 2 (GPIO_PULL_UP | GPIO_ACTIVE_LOW)>; - }; - key_2: button_2 { gpios = <&gpiod 1 (GPIO_PULL_UP | GPIO_ACTIVE_LOW)>; }; - key_3: button_3 { - gpios = <&gpioc 1 (GPIO_PULL_UP | GPIO_ACTIVE_LOW)>; - }; key_4: button_4 { gpios = <&gpiod 3 (GPIO_PULL_UP | GPIO_ACTIVE_LOW)>; }; diff --git a/src/platform/telink/tlsr9518adk80d_mars_boot.overlay b/src/platform/telink/tlsr9518adk80d_mars_boot.overlay new file mode 100644 index 00000000000000..64a998bb306178 --- /dev/null +++ b/src/platform/telink/tlsr9518adk80d_mars_boot.overlay @@ -0,0 +1,28 @@ +/ { + leds { + /delete-node/ led_0; + + led_blue: led_0 { + label = "LED Blue"; + gpios = <&gpiob 6 GPIO_ACTIVE_HIGH>; + }; + }; + + keys { + /delete-node/ button_dfu; + + key_dfu: button_dfu { + label = "USB DFU"; + gpios = <&gpiod 2 (GPIO_PULL_UP | GPIO_ACTIVE_LOW)>; + }; + }; +}; + +&gpioc { + interrupts = <38 1>; +}; + +&gpiod { + interrupts = <37 1>; + status = "okay"; +};