Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Telink] Fix DFU target build & add to CI #29754

Merged
merged 3 commits into from
Oct 17, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions .github/workflows/examples-telink.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -148,13 +148,13 @@ jobs:
- name: clean out build output
run: rm -rf ./out

- name: Build example Telink (B92) Lock App
- name: Build example Telink (B92) Lock App with DFU
run: |
./scripts/run_in_build_env.sh \
"./scripts/build/build_examples.py --target 'telink-tlsr9528a-lock' build"
"./scripts/build/build_examples.py --target 'telink-tlsr9528a-lock-dfu' build"
.environment/pigweed-venv/bin/python3 scripts/tools/memory/gh_sizes.py \
telink tlsr9528a lock-app \
out/telink-tlsr9528a-lock/zephyr/zephyr.elf \
telink tlsr9528a lock-app-dfu \
out/telink-tlsr9528a-lock-dfu/zephyr/zephyr.elf \
/tmp/bloat_reports/

- name: clean out build output
Expand Down
11 changes: 8 additions & 3 deletions config/telink/chip-module/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -173,28 +173,33 @@ dt_nodelabel(dts_partition_path NODELABEL "boot_partition")
dt_reg_size(mcuboot_size PATH ${dts_partition_path})
math(EXPR boot_blocks "${mcuboot_size} / ${BLOCK_SIZE}" OUTPUT_FORMAT DECIMAL)

if (CONFIG_CHIP_OTA_IMAGE_BUILD)
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};${USB_BOOT_DTC_OVERLAY_FILE}"
COMMAND
cp ${PROJECT_BINARY_DIR}/../modules/chip-module/build_mcuboot/zephyr/zephyr.bin ${PROJECT_BINARY_DIR}/zephyr.mcuboot.bin
)

add_custom_target(merge_mcuboot ALL
COMMAND
dd if=${PROJECT_BINARY_DIR}/../modules/chip-module/build_mcuboot/zephyr/zephyr.bin of=${PROJECT_BINARY_DIR}/zephyr.bin
dd if=${PROJECT_BINARY_DIR}/zephyr.mcuboot.bin of=${PROJECT_BINARY_DIR}/zephyr.bin
COMMAND
dd if=${PROJECT_BINARY_DIR}/zephyr.signed.bin of=${PROJECT_BINARY_DIR}/zephyr.bin bs=${BLOCK_SIZE} seek=${boot_blocks}
)

add_dependencies(merge_mcuboot ${ZEPHYR_FINAL_EXECUTABLE})

if (CONFIG_CHIP_OTA_IMAGE_BUILD)
chip_ota_image(chip-ota-image
INPUT_FILES ${PROJECT_BINARY_DIR}/zephyr.signed.bin
OUTPUT_FILE ${PROJECT_BINARY_DIR}/zephyr-ota.bin
)

add_dependencies(merge_mcuboot ${ZEPHYR_FINAL_EXECUTABLE})
add_dependencies(chip-ota-image ${ZEPHYR_FINAL_EXECUTABLE})
endif()
endif()

# get code-partition factory_partition address
dt_nodelabel(dts_partition_path NODELABEL "factory_partition")
Expand Down
1 change: 1 addition & 0 deletions scripts/build/build/targets.py
Original file line number Diff line number Diff line change
Expand Up @@ -720,6 +720,7 @@ def BuildTelinkTarget():
])

target.AppendModifier('ota', enable_ota=True)
target.AppendModifier('dfu', enable_dfu=True)
target.AppendModifier('shell', enable_shell=True)
target.AppendModifier('rpc', enable_rpcs=True)
target.AppendModifier('factory-data', enable_factory_data=True)
Expand Down
5 changes: 5 additions & 0 deletions scripts/build/builders/telink.py
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,7 @@ def __init__(self,
app: TelinkApp = TelinkApp,
board: TelinkBoard = TelinkBoard,
enable_ota: bool = False,
enable_dfu: bool = False,
enable_shell: bool = False,
enable_rpcs: bool = False,
enable_factory_data: bool = False,
Expand All @@ -145,6 +146,7 @@ def __init__(self,
self.app = app
self.board = board
self.enable_ota = enable_ota
self.enable_dfu = enable_dfu
self.enable_shell = enable_shell
self.enable_rpcs = enable_rpcs
self.enable_factory_data = enable_factory_data
Expand Down Expand Up @@ -172,6 +174,9 @@ def generate(self):
if self.enable_ota:
flags.append("-DCONFIG_CHIP_OTA_REQUESTOR=y")

if self.enable_dfu:
flags.append("-DCONFIG_BOOTLOADER_MCUBOOT=y")

if self.enable_shell:
flags.append("-DCONFIG_CHIP_LIB_SHELL=y")

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 @@ -22,5 +22,5 @@ nrf-native-posix-64-tests
qpg-qpg6105-{lock,light,shell,persistent-storage}
stm32-stm32wb5mm-dk-light
tizen-arm-{all-clusters,all-clusters-minimal,chip-tool,light,tests}[-no-ble][-no-thread][-no-wifi][-asan][-ubsan]
telink-{tlsr9518adk80d,tlsr9528a}-{air-quality-sensor,all-clusters,all-clusters-minimal,bridge,contact-sensor,light,light-switch,lock,ota-requestor,pump,pump-controller,resource-monitoring,shell,smoke-co-alarm,temperature-measurement,thermostat,window-covering}[-ota][-shell][-rpc][-factory-data][-4mb]
telink-{tlsr9518adk80d,tlsr9528a}-{air-quality-sensor,all-clusters,all-clusters-minimal,bridge,contact-sensor,light,light-switch,lock,ota-requestor,pump,pump-controller,resource-monitoring,shell,smoke-co-alarm,temperature-measurement,thermostat,window-covering}[-ota][-dfu][-shell][-rpc][-factory-data][-4mb]
openiotsdk-{shell,lock}[-mbedtls][-psa]
17 changes: 9 additions & 8 deletions src/platform/telink/OTAUtil.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,15 @@
#include <app/clusters/ota-requestor/DefaultOTARequestorDriver.h>
#include <app/clusters/ota-requestor/DefaultOTARequestorStorage.h>
#include <platform/telink/OTAImageProcessorImpl.h>

using namespace chip;
using namespace chip::DeviceLayer;
#endif

#if CONFIG_BOOTLOADER_MCUBOOT
#include <zephyr/dfu/mcuboot.h>
#endif
#include <zephyr/logging/log.h>

using namespace chip;
using namespace chip::DeviceLayer;
LOG_MODULE_DECLARE(app, CONFIG_CHIP_APP_LOG_LEVEL);

#ifdef CONFIG_CHIP_OTA_REQUESTOR

Expand Down Expand Up @@ -59,14 +60,14 @@ void OtaConfirmNewImage()
{
if (mcuboot_swap_type() == BOOT_SWAP_TYPE_REVERT)
{
CHIP_ERROR err = System::MapErrorZephyr(boot_write_img_confirmed());
if (CHIP_NO_ERROR == err)
int img_confirmation = boot_write_img_confirmed();
if (img_confirmation)
{
ChipLogProgress(SoftwareUpdate, "New firmware image confirmed");
LOG_ERR("Image not confirmed %d. Will be reverted!", img_confirmation);
}
else
{
ChipLogError(SoftwareUpdate, "Failed to confirm firmware image, it will be reverted on the next boot");
LOG_INF("Image confirmed");
}
}
}