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 651ac25..7a515b6 100644 --- a/Makefile +++ b/Makefile @@ -4,7 +4,7 @@ PROJECT_NAME ?= mistexample -VERSION_MAJOR ?= 1 +VERSION_MAJOR ?= 2 VERSION_MINOR ?= 0 VERSION_PATCH ?= 0 VERSION_DEVEL ?= "-dev" @@ -14,7 +14,7 @@ CONFIG ?= normal $(info CONFIG=$(CONFIG)) include config/$(CONFIG).mk -DEFAULT_RADIO_CHANNEL ?= 13 +DEFAULT_RADIO_CHANNEL ?= 12 # Set device address at compile time, will override signature when != 0 NODE_AM_ADDR ?= 0 @@ -26,6 +26,8 @@ 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 @@ -206,7 +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 - +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,6 +277,26 @@ 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) + 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") + endif + endif + 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..446eaf8 100644 --- a/README.md +++ b/README.md @@ -74,6 +74,28 @@ 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 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: +``` +$(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 +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..4da8285 --- /dev/null +++ b/libota/README.md @@ -0,0 +1,4 @@ +Store OTA library components in this folder. + +MCU_FAMILY/libota.a +updater_lib.h \ No newline at end of file diff --git a/main.c b/main.c index 896f2f6..77c8dbb 100644 --- a/main.c +++ b/main.c @@ -57,6 +57,11 @@ #include "log.h" #include "sys_panic.h" + +#ifdef INCLUDE_OTA +#include "basic_rtos_ota_setup.h" +#endif + #define USER_FILE_SYS_NR 0 #define DEVICE_ANNOUNCEMENT_PERIOD_S 300 @@ -73,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); @@ -114,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; @@ -183,6 +191,14 @@ static void main_loop () sys_panic("radio"); } + #ifdef INCLUDE_OTA + 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)) {