From b5ba4c9285c9078d0cf775e86e19876325ed9a65 Mon Sep 17 00:00:00 2001 From: Enari Date: Wed, 9 Jun 2021 09:01:47 +0300 Subject: [PATCH 01/10] Changes to libota --- Makefile | 18 +++++++++++++++++- README.md | 18 ++++++++++++++++++ libota/README.md | 4 ++++ 3 files changed, 39 insertions(+), 1 deletion(-) create mode 100644 libota/README.md diff --git a/Makefile b/Makefile index 651ac25..d95a11d 100644 --- a/Makefile +++ b/Makefile @@ -26,6 +26,9 @@ INCLUDE_BOOTLOADER ?= 0 # Specify beatstack config, single-hop if not set LIBBEAT_CONFIG ?= "" + +LIBOTA_CONFIG = 0 + #app start #if bootloader is included APP_START value is retrived from .board file #with current bootloader APP_START should be 0x20000 @@ -56,7 +59,7 @@ RELEASE_BUILD ?= 1 CFLAGS += -DBASE_LOG_LEVEL=0xFFFF # Enable debug messages -VERBOSE ?= 0 +VERBOSE ?= 1 # Disable info messages #SILENT ?= 1 @@ -273,6 +276,19 @@ SOURCES += $(NODE_PLATFORM_DIR)/silabs/watchdog.c INCLUDES += -I$(ROOT_DIR)/libmist/ LDLIBS += $(ROOT_DIR)/libmist/$(MCU_FAMILY)/libmistmiddleware.a +#libota +ifneq ($(LIBOTA_CONFIG),"") + ifneq ("$(wildcard libota/updater.h)","") + $(info libota found and included) + INCLUDES += -I$(ROOT_DIR)/libota/ + LDLIBS += $(ROOT_DIR)/libota/$(MCU_FAMILY)/libota.a + else + ifneq ($(MAKECMDGOALS),clean) + $(error "ERROR: libota enabled but not found") + endif + endif +endif + #beatsack ifneq ($(LIBBEAT_CONFIG),"") ifneq ("$(wildcard libbeat/$(LIBBEAT_CONFIG)/beatstack.h)","") diff --git a/README.md b/README.md index 1c95342..8ea79c4 100644 --- a/README.md +++ b/README.md @@ -74,6 +74,24 @@ Makefile (or Makefile.private) or set on the command line: make INCLUDE_BEATSTACK=1 ``` +# Thinnect OTA (libota) + +The example application can be optionally built with the Thinnect mesh network +layer. The library needs to be obtained separately. The library bundle should +include a header `updater.h` and the static library `libota.a` for a given +architecture. These need to be stored as: +``` +$(WORKSPACE_ROOT)/libbeat/updater.h +$(WORKSPACE_ROOT)/libbeat/$(MCU_ARCH)/libota.a +``` + +Additionally LIBOTA_CONFIG needs to be set to 1. This can be done in the +Makefile (or Makefile.private) or set on the command line: + +``` +make LIBOTA_CONFIG=1 +``` + # Setup This repository relies on several dependencies that are all publically available diff --git a/libota/README.md b/libota/README.md new file mode 100644 index 0000000..5cbe244 --- /dev/null +++ b/libota/README.md @@ -0,0 +1,4 @@ +Store OTA library components in this folder. + +MCU_FAMILY/libota.a +updater.h \ No newline at end of file From 8b8a83c5ffbfad1759dedf94d7218c46faa3da06 Mon Sep 17 00:00:00 2001 From: Enari Date: Wed, 9 Jun 2021 09:02:43 +0300 Subject: [PATCH 02/10] Turned verbose off --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index d95a11d..dce7b2b 100644 --- a/Makefile +++ b/Makefile @@ -59,7 +59,7 @@ RELEASE_BUILD ?= 1 CFLAGS += -DBASE_LOG_LEVEL=0xFFFF # Enable debug messages -VERBOSE ?= 1 +VERBOSE ?= 0 # Disable info messages #SILENT ?= 1 From b37f39e93872941b2002681263b7e03c688cb9fe Mon Sep 17 00:00:00 2001 From: Enari Date: Wed, 9 Jun 2021 14:00:02 +0300 Subject: [PATCH 03/10] Added bootloader check for libota --- Makefile | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index dce7b2b..8ea1d93 100644 --- a/Makefile +++ b/Makefile @@ -280,8 +280,12 @@ LDLIBS += $(ROOT_DIR)/libmist/$(MCU_FAMILY)/libmistmiddleware.a ifneq ($(LIBOTA_CONFIG),"") ifneq ("$(wildcard libota/updater.h)","") $(info libota found and included) - INCLUDES += -I$(ROOT_DIR)/libota/ - LDLIBS += $(ROOT_DIR)/libota/$(MCU_FAMILY)/libota.a + ifeq ("$(INCLUDE_BOOTLOADER)", "1") + INCLUDES += -I$(ROOT_DIR)/libota/ + LDLIBS += $(ROOT_DIR)/libota/$(MCU_FAMILY)/libota.a + else + $(error "ERROR: ota enabled and included but bootloader missing") + endif else ifneq ($(MAKECMDGOALS),clean) $(error "ERROR: libota enabled but not found") From 41319eaae7489de209be749b4d39594b60566faa Mon Sep 17 00:00:00 2001 From: Enari Date: Wed, 9 Jun 2021 14:03:47 +0300 Subject: [PATCH 04/10] Modified bootloader check --- Makefile | 4 +++- libota/README.md | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index 8ea1d93..9622582 100644 --- a/Makefile +++ b/Makefile @@ -284,7 +284,9 @@ ifneq ($(LIBOTA_CONFIG),"") INCLUDES += -I$(ROOT_DIR)/libota/ LDLIBS += $(ROOT_DIR)/libota/$(MCU_FAMILY)/libota.a else - $(error "ERROR: ota enabled and included but bootloader missing") + ifneq ($(MAKECMDGOALS),clean) + $(error "ERROR: ota enabled and included but bootloader missing") + endif endif else ifneq ($(MAKECMDGOALS),clean) diff --git a/libota/README.md b/libota/README.md index 5cbe244..4da8285 100644 --- a/libota/README.md +++ b/libota/README.md @@ -1,4 +1,4 @@ Store OTA library components in this folder. MCU_FAMILY/libota.a -updater.h \ No newline at end of file +updater_lib.h \ No newline at end of file From 1108dc69a18798cad56ae1f9cb2617836144353d Mon Sep 17 00:00:00 2001 From: Enari Date: Wed, 9 Jun 2021 14:13:41 +0300 Subject: [PATCH 05/10] Added ui and updater init --- Makefile | 1 + main.c | 15 +++++++++++++++ 2 files changed, 16 insertions(+) diff --git a/Makefile b/Makefile index 9622582..8233ae7 100644 --- a/Makefile +++ b/Makefile @@ -283,6 +283,7 @@ ifneq ($(LIBOTA_CONFIG),"") ifeq ("$(INCLUDE_BOOTLOADER)", "1") INCLUDES += -I$(ROOT_DIR)/libota/ LDLIBS += $(ROOT_DIR)/libota/$(MCU_FAMILY)/libota.a + CFLAGS += -DINCLUDE_OTA else ifneq ($(MAKECMDGOALS),clean) $(error "ERROR: ota enabled and included but bootloader missing") diff --git a/main.c b/main.c index 896f2f6..771525c 100644 --- a/main.c +++ b/main.c @@ -57,6 +57,11 @@ #include "log.h" #include "sys_panic.h" + +#ifdef INCLUDE_OTA +#include "updater.h" +#endif + #define USER_FILE_SYS_NR 0 #define DEVICE_ANNOUNCEMENT_PERIOD_S 300 @@ -138,7 +143,12 @@ static comms_layer_t * radio_setup (am_addr_t node_addr, uint8_t eui[IEEE_EUI64_ debug1("radio rdy"); return radio; } +#ifdef INCLUDE_OTA +static void ota_active(bool status) +{ +} +#endif static void main_loop () { // Switch to a thread-safe logger @@ -183,6 +193,11 @@ static void main_loop () sys_panic("radio"); } + #ifdef INCLUDE_OTA + uint8_t uuid[16] = {0}; + sigGetBoardUUID(&uuid); + updater_init(radio, NULL, ota_active); + #endif // Start deviceannouncement application ------------------------------------ if (0 == announcement_app_init(radio, DEVICE_ANNOUNCEMENT_PERIOD_S)) { From d926051ced8d5cd83abba38c6fedb7a65c6c955b Mon Sep 17 00:00:00 2001 From: Enari Date: Wed, 16 Jun 2021 10:51:35 +0300 Subject: [PATCH 06/10] Changes to makefile and main.c --- Makefile | 10 ++++++---- main.c | 2 +- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/Makefile b/Makefile index 8233ae7..51c8940 100644 --- a/Makefile +++ b/Makefile @@ -14,7 +14,7 @@ CONFIG ?= normal $(info CONFIG=$(CONFIG)) include config/$(CONFIG).mk -DEFAULT_RADIO_CHANNEL ?= 13 +DEFAULT_RADIO_CHANNEL ?= 20 # Set device address at compile time, will override signature when != 0 NODE_AM_ADDR ?= 0 @@ -27,7 +27,7 @@ INCLUDE_BOOTLOADER ?= 0 LIBBEAT_CONFIG ?= "" -LIBOTA_CONFIG = 0 +LIBOTA_CONFIG = 1 #app start #if bootloader is included APP_START value is retrived from .board file @@ -272,6 +272,8 @@ SOURCES += $(NODE_PLATFORM_DIR)/silabs/retargetspi.c SOURCES += $(NODE_PLATFORM_DIR)/silabs/retargeti2c.c SOURCES += $(NODE_PLATFORM_DIR)/silabs/watchdog.c +SOURCES += panic_handler.c ### REMOVE THIS FOR SURE + # mist library INCLUDES += -I$(ROOT_DIR)/libmist/ LDLIBS += $(ROOT_DIR)/libmist/$(MCU_FAMILY)/libmistmiddleware.a @@ -379,9 +381,9 @@ $(BUILD_DIR)/$(PROJECT_NAME).bin: $(BUILD_DIR)/$(PROJECT_NAME).elf $(HIDE_CMD)$(TC_OBJCOPY) --strip-all -O binary "$<" "$@" $(HIDE_CMD)$(HEADEREDIT) -v size -v crc $@ -$(BUILD_DIR)/combo.bin: bootloader/wfs201-bootloader.bin $(BUILD_DIR)/$(PROJECT_NAME).bin +$(BUILD_DIR)/combo.bin: bootloader/tsb2-dev/bootloader.bin $(BUILD_DIR)/$(PROJECT_NAME).bin $(call pInfo,Building combo [$@]) - srec_cat bootloader/wfs201-bootloader.bin -binary -offset $(BOOTLOADER_START) \ + srec_cat bootloader/tsb2-dev/bootloader.bin -binary -offset $(BOOTLOADER_START) \ $(BUILD_DIR)/$(PROJECT_NAME).bin -binary -offset $(APP_START) \ -o $@ -binary chmod 755 "$@" diff --git a/main.c b/main.c index 771525c..88e8ef5 100644 --- a/main.c +++ b/main.c @@ -196,7 +196,7 @@ static void main_loop () #ifdef INCLUDE_OTA uint8_t uuid[16] = {0}; sigGetBoardUUID(&uuid); - updater_init(radio, NULL, ota_active); + updater_init(radio, uuid, ota_active); #endif // Start deviceannouncement application ------------------------------------ if (0 == announcement_app_init(radio, DEVICE_ANNOUNCEMENT_PERIOD_S)) From ee3614bde800116060cf27e4472778bc8687a238 Mon Sep 17 00:00:00 2001 From: EnariSaar Date: Thu, 17 Jun 2021 16:24:53 +0300 Subject: [PATCH 07/10] Added correct functions for ota widget --- Makefile | 9 +++++---- main.c | 19 ++++++++++--------- 2 files changed, 15 insertions(+), 13 deletions(-) diff --git a/Makefile b/Makefile index 51c8940..35f1568 100644 --- a/Makefile +++ b/Makefile @@ -14,11 +14,11 @@ CONFIG ?= normal $(info CONFIG=$(CONFIG)) include config/$(CONFIG).mk -DEFAULT_RADIO_CHANNEL ?= 20 +DEFAULT_RADIO_CHANNEL ?= 12 # Set device address at compile time, will override signature when != 0 NODE_AM_ADDR ?= 0 -DEFAULT_PAN_ID ?= 0x22 +DEFAULT_PAN_ID ?= 0xFF #include bootloader INCLUDE_BOOTLOADER ?= 0 @@ -27,7 +27,7 @@ INCLUDE_BOOTLOADER ?= 0 LIBBEAT_CONFIG ?= "" -LIBOTA_CONFIG = 1 +LIBOTA_CONFIG = 0 #app start #if bootloader is included APP_START value is retrived from .board file @@ -209,6 +209,7 @@ INCLUDES += -I$(NODE_PLATFORM_DIR)/widgets SOURCES += $(NODE_PLATFORM_DIR)/widgets/basic_rtos_filesystem_setup.c SOURCES += $(NODE_PLATFORM_DIR)/widgets/basic_rtos_logger_setup.c SOURCES += $(NODE_PLATFORM_DIR)/widgets/basic_rtos_threads_stats.c +SOURCES += $(NODE_PLATFORM_DIR)/widgets/basic_rtos_ota_setup.c # device signature INCLUDES += -I$(ZOO)/thinnect.device-signature/signature \ @@ -272,7 +273,7 @@ SOURCES += $(NODE_PLATFORM_DIR)/silabs/retargetspi.c SOURCES += $(NODE_PLATFORM_DIR)/silabs/retargeti2c.c SOURCES += $(NODE_PLATFORM_DIR)/silabs/watchdog.c -SOURCES += panic_handler.c ### REMOVE THIS FOR SURE +SOURCES += panic_handler.c # mist library INCLUDES += -I$(ROOT_DIR)/libmist/ diff --git a/main.c b/main.c index 88e8ef5..77c8dbb 100644 --- a/main.c +++ b/main.c @@ -59,7 +59,7 @@ #ifdef INCLUDE_OTA -#include "updater.h" +#include "basic_rtos_ota_setup.h" #endif #define USER_FILE_SYS_NR 0 @@ -78,6 +78,8 @@ static comms_layer_t * m_radio_comm = NULL; static comms_layer_t * m_beat_comm = NULL; #endif +static comms_receiver_t m_receiver_bc_data; + static void radio_start_done (comms_layer_t * comms, comms_status_t status, void * user) { debug("started %d", status); @@ -119,6 +121,7 @@ static comms_layer_t * radio_setup (am_addr_t node_addr, uint8_t eui[IEEE_EUI64_ { err1("!license_rcvr"); } + #else info1("Starting single-hop"); radio = m_radio_comm; @@ -143,12 +146,7 @@ static comms_layer_t * radio_setup (am_addr_t node_addr, uint8_t eui[IEEE_EUI64_ debug1("radio rdy"); return radio; } -#ifdef INCLUDE_OTA -static void ota_active(bool status) -{ -} -#endif static void main_loop () { // Switch to a thread-safe logger @@ -194,9 +192,12 @@ static void main_loop () } #ifdef INCLUDE_OTA - uint8_t uuid[16] = {0}; - sigGetBoardUUID(&uuid); - updater_init(radio, uuid, ota_active); + bool feed_watchdog = false; + #ifdef INCLUDE_BEATSTACK + basic_rtos_ota_setup(m_beat_comm, m_radio_comm, true, &feed_watchdog); + #else + basic_rtos_ota_setup(NULL, m_radio_comm, true, &feed_watchdog); + #endif #endif // Start deviceannouncement application ------------------------------------ if (0 == announcement_app_init(radio, DEVICE_ANNOUNCEMENT_PERIOD_S)) From 0e18fcdb44b9f3f03a5b0c43c9baeb73272616df Mon Sep 17 00:00:00 2001 From: EnariSaar Date: Mon, 21 Jun 2021 14:23:50 +0300 Subject: [PATCH 08/10] Added libota to gitignore --- .gitignore | 5 ++++- Makefile | 4 ++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/.gitignore b/.gitignore index 7045539..8d6ae49 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,6 @@ build Makefile.private -libbeat/beatstack.h \ No newline at end of file +libbeat/beatstack.h +libbeat/ +bootloader/ +libota/ diff --git a/Makefile b/Makefile index 35f1568..75fd780 100644 --- a/Makefile +++ b/Makefile @@ -6,7 +6,7 @@ PROJECT_NAME ?= mistexample VERSION_MAJOR ?= 1 VERSION_MINOR ?= 0 -VERSION_PATCH ?= 0 +VERSION_PATCH ?= 1 VERSION_DEVEL ?= "-dev" # Include some optional configuration when requested @@ -27,7 +27,7 @@ INCLUDE_BOOTLOADER ?= 0 LIBBEAT_CONFIG ?= "" -LIBOTA_CONFIG = 0 +LIBOTA_CONFIG = #app start #if bootloader is included APP_START value is retrived from .board file From d90845adbfcd0a1fbd270df74729c0e1cd2ce8a1 Mon Sep 17 00:00:00 2001 From: EnariSaar Date: Tue, 22 Jun 2021 15:57:58 +0300 Subject: [PATCH 09/10] Implemented suggested changes from pr --- Makefile | 20 +++++++++----------- README.md | 8 ++++++-- 2 files changed, 15 insertions(+), 13 deletions(-) diff --git a/Makefile b/Makefile index 75fd780..7a515b6 100644 --- a/Makefile +++ b/Makefile @@ -4,9 +4,9 @@ PROJECT_NAME ?= mistexample -VERSION_MAJOR ?= 1 +VERSION_MAJOR ?= 2 VERSION_MINOR ?= 0 -VERSION_PATCH ?= 1 +VERSION_PATCH ?= 0 VERSION_DEVEL ?= "-dev" # Include some optional configuration when requested @@ -18,7 +18,7 @@ DEFAULT_RADIO_CHANNEL ?= 12 # Set device address at compile time, will override signature when != 0 NODE_AM_ADDR ?= 0 -DEFAULT_PAN_ID ?= 0xFF +DEFAULT_PAN_ID ?= 0x22 #include bootloader INCLUDE_BOOTLOADER ?= 0 @@ -26,8 +26,7 @@ INCLUDE_BOOTLOADER ?= 0 # Specify beatstack config, single-hop if not set LIBBEAT_CONFIG ?= "" - -LIBOTA_CONFIG = +LIBOTA_CONFIG = 0 #app start #if bootloader is included APP_START value is retrived from .board file @@ -209,8 +208,9 @@ INCLUDES += -I$(NODE_PLATFORM_DIR)/widgets SOURCES += $(NODE_PLATFORM_DIR)/widgets/basic_rtos_filesystem_setup.c SOURCES += $(NODE_PLATFORM_DIR)/widgets/basic_rtos_logger_setup.c SOURCES += $(NODE_PLATFORM_DIR)/widgets/basic_rtos_threads_stats.c -SOURCES += $(NODE_PLATFORM_DIR)/widgets/basic_rtos_ota_setup.c - +ifneq ($(LIBOTA_CONFIG),"") + SOURCES += $(NODE_PLATFORM_DIR)/widgets/basic_rtos_ota_setup.c +endif # device signature INCLUDES += -I$(ZOO)/thinnect.device-signature/signature \ -I$(ZOO)/thinnect.device-signature/area @@ -273,8 +273,6 @@ SOURCES += $(NODE_PLATFORM_DIR)/silabs/retargetspi.c SOURCES += $(NODE_PLATFORM_DIR)/silabs/retargeti2c.c SOURCES += $(NODE_PLATFORM_DIR)/silabs/watchdog.c -SOURCES += panic_handler.c - # mist library INCLUDES += -I$(ROOT_DIR)/libmist/ LDLIBS += $(ROOT_DIR)/libmist/$(MCU_FAMILY)/libmistmiddleware.a @@ -382,9 +380,9 @@ $(BUILD_DIR)/$(PROJECT_NAME).bin: $(BUILD_DIR)/$(PROJECT_NAME).elf $(HIDE_CMD)$(TC_OBJCOPY) --strip-all -O binary "$<" "$@" $(HIDE_CMD)$(HEADEREDIT) -v size -v crc $@ -$(BUILD_DIR)/combo.bin: bootloader/tsb2-dev/bootloader.bin $(BUILD_DIR)/$(PROJECT_NAME).bin +$(BUILD_DIR)/combo.bin: bootloader/wfs201-bootloader.bin $(BUILD_DIR)/$(PROJECT_NAME).bin $(call pInfo,Building combo [$@]) - srec_cat bootloader/tsb2-dev/bootloader.bin -binary -offset $(BOOTLOADER_START) \ + srec_cat bootloader/wfs201-bootloader.bin -binary -offset $(BOOTLOADER_START) \ $(BUILD_DIR)/$(PROJECT_NAME).bin -binary -offset $(APP_START) \ -o $@ -binary chmod 755 "$@" diff --git a/README.md b/README.md index 8ea79c4..76fdade 100644 --- a/README.md +++ b/README.md @@ -81,8 +81,12 @@ layer. The library needs to be obtained separately. The library bundle should include a header `updater.h` and the static library `libota.a` for a given architecture. These need to be stored as: ``` -$(WORKSPACE_ROOT)/libbeat/updater.h -$(WORKSPACE_ROOT)/libbeat/$(MCU_ARCH)/libota.a +$(WORKSPACE_ROOT)/libota/updater.h +$(WORKSPACE_ROOT)/libota/updater_fs.h/ +$(WORKSPACE_ROOT)/libota/updater.h/ +$(WORKSPACE_ROOT)/libota/updater_header.h/ +$(WORKSPACE_ROOT)/libota/updater_lib.h +$(WORKSPACE_ROOT)/libota/$(MCU_ARCH)/libota.a ``` Additionally LIBOTA_CONFIG needs to be set to 1. This can be done in the From 344238b539d802da331c132c0f933d08482f03f0 Mon Sep 17 00:00:00 2001 From: EnariSaar Date: Tue, 22 Jun 2021 15:59:54 +0300 Subject: [PATCH 10/10] Implemented changes from pr --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 76fdade..446eaf8 100644 --- a/README.md +++ b/README.md @@ -76,7 +76,7 @@ make INCLUDE_BEATSTACK=1 # Thinnect OTA (libota) -The example application can be optionally built with the Thinnect mesh network +The example application can be optionally built with the Thinnect mesh update layer. The library needs to be obtained separately. The library bundle should include a header `updater.h` and the static library `libota.a` for a given architecture. These need to be stored as: