From 18f4914f37cff45b13a01fdc7df280ee292add51 Mon Sep 17 00:00:00 2001 From: rbaron Date: Sun, 12 May 2024 14:50:51 +0200 Subject: [PATCH] FOTA configs for safer firmware matching --- code/nrf-connect/samples/zigbee/prj_fota.conf | 22 ++++++++++++++++--- code/nrf-connect/samples/zigbee/src/main.c | 4 +++- 2 files changed, 22 insertions(+), 4 deletions(-) diff --git a/code/nrf-connect/samples/zigbee/prj_fota.conf b/code/nrf-connect/samples/zigbee/prj_fota.conf index e9d769a..7c16e20 100644 --- a/code/nrf-connect/samples/zigbee/prj_fota.conf +++ b/code/nrf-connect/samples/zigbee/prj_fota.conf @@ -76,13 +76,29 @@ CONFIG_ASSERT=y ## # Software build version in the basic_attrs cluster. -CONFIG_PRST_ZB_SOFTWARE_VERSION="test-sw-1" +CONFIG_PRST_ZB_SOFTWARE_VERSION="dev" # Enable Zigbee FOTA library CONFIG_ZIGBEE_FOTA=y -CONFIG_ZIGBEE_FOTA_HW_VERSION=52 + CONFIG_ZIGBEE_FOTA_ENDPOINT=5 -CONFIG_MCUBOOT_IMGTOOL_SIGN_VERSION="1.0.0" +CONFIG_ZIGBEE_FOTA_LOG_LEVEL_DBG=y + +# DIY Zigbee FOTA manufacturer ID. +CONFIG_ZIGBEE_FOTA_MANUFACTURER_ID=0xDB15 + +# This must be BOARD_REVISION_CODE. +# TODO: move this to Kconfig. +CONFIG_ZIGBEE_FOTA_HW_VERSION=4 + +# Set for which hardware versions this FOTA image is valid. +CONFIG_ENABLE_ZIGBEE_FOTA_MIN_HW_VERSION=y +CONFIG_ZIGBEE_FOTA_MIN_HW_VERSION=0x00 +CONFIG_ENABLE_ZIGBEE_FOTA_MAX_HW_VERSION=y +CONFIG_ZIGBEE_FOTA_MAX_HW_VERSION=0xff + +# 0.0.0 is a safe default for development. +CONFIG_MCUBOOT_IMGTOOL_SIGN_VERSION="0.0.0" CONFIG_ZIGBEE_FOTA_COMMENT="b-parasite" # Ensure an MCUboot-compatible binary is generated. diff --git a/code/nrf-connect/samples/zigbee/src/main.c b/code/nrf-connect/samples/zigbee/src/main.c index 0efad06..2d794e3 100644 --- a/code/nrf-connect/samples/zigbee/src/main.c +++ b/code/nrf-connect/samples/zigbee/src/main.c @@ -149,7 +149,7 @@ static void confirm_image(void) { static void ota_evt_handler(const struct zigbee_fota_evt *evt) { switch (evt->id) { case ZIGBEE_FOTA_EVT_PROGRESS: - prst_led_flash(1); + LOG_INF("OTA progress: %d%%", evt->dl.progress); break; case ZIGBEE_FOTA_EVT_FINISHED: LOG_INF("Reboot application."); @@ -386,6 +386,8 @@ int main(void) { power_down_unused_ram(); #ifdef CONFIG_ZIGBEE_FOTA + LOG_INF("Firmware version: %s", CONFIG_MCUBOOT_IMGTOOL_SIGN_VERSION); + /* Initialize Zigbee FOTA download service. */ zigbee_fota_init(ota_evt_handler);