From 1f51f6581662e635f9e1c54c2153a3662631a6b8 Mon Sep 17 00:00:00 2001
From: MaxineMuster <146550015+MaxineMuster@users.noreply.github.com>
Date: Mon, 30 Dec 2024 23:20:21 +0100
Subject: [PATCH] OTA for W800 + "Simple OTA" w/o httpd (#1471)
* OTA for W800
Removed unnecessary (and wasting resources) fetching of "index?status=1" on pages not using "state" div
Added simple "internal OTA" (just POST-ing a file)
Basic tests done - try avoiding other TCP connections to save memory
Somtimes there are memory related messages in log like "Thread create HTTP Client - errCOULD_NOT_ALLOCATE_REQUIRED_MEMORY".
OTA working in most cases, somtimes device crashes during update.
Device will immediatly reboot after OTA completion, even printfs after writing last bytes was not visible in console.
* Add some more warnings
Make file selector accepting images on extension for platform
For Beken: Check magic "RBL" and future Platform name in header
* Changed way to verify firmware files: must match OBK file structure for the platform
As suggested by @NonPIayerCharacter added "NO_PLATFORM_OTA" in obk_config.h
For platforms w/o OTA the page will be only showing a hint.
* Fix page for non OTA devices
* streamlined tests
moved platform dependent #define for OTA extension to obk_config.h
* Optimized JS code
Only show hint for ".rbl" file on Beken platforms
Added a #define OBK_OTA_NAME_EXTENSION, actually only for LN882H
(here UART and OTA file are identicaly except an "_OTA" in the file name).
Otherwise the UART file would also match the template
(this file would not be flashed because of additional checks, but if we can prevent this ...)
---
Makefile | 5 +-
src/httpserver/http_fns.c | 23 +++++-
src/httpserver/rest_interface.c | 139 +++++++++++++++++++++++++++++++-
src/obk_config.h | 9 ++-
4 files changed, 171 insertions(+), 5 deletions(-)
diff --git a/Makefile b/Makefile
index 53ea7dce3..eb7175433 100644
--- a/Makefile
+++ b/Makefile
@@ -193,7 +193,10 @@ sdk/OpenW600/tools/gcc-arm-none-eabi-4_9-2014q4/bin: submodules
.PHONY: OpenW800
OpenW800: sdk/OpenW800/tools/w800/csky/bin sdk/OpenW800/sharedAppContainer/sharedApp prebuild_OpenW800
- $(MAKE) -C sdk/OpenW800 EXTRA_CCFLAGS=-DPLATFORM_W800 CONFIG_W800_USE_LIB=n CONFIG_W800_TOOLCHAIN_PATH="$(shell realpath sdk/OpenW800/tools/w800/csky/bin)/"
+ # if building new version, make sure "new_http.o" is deleted (it contains build time and version, so build time is set to actual time)
+ rm -rf sdk/OpenW800/bin/build/w800/obj/sharedAppContainer/sharedApp/src/httpserver/new_http.o
+ # define APP_Version so it's not "W800_Test" every time
+ $(MAKE) -C sdk/OpenW800 EXTRA_CCFLAGS="-DPLATFORM_W800 -DUSER_SW_VER=\\\"${APP_VERSION}\\\"" CONFIG_W800_USE_LIB=n CONFIG_W800_TOOLCHAIN_PATH="$(shell realpath sdk/OpenW800/tools/w800/csky/bin)/"
mkdir -p output/$(APP_VERSION)
cp sdk/OpenW800/bin/w800/w800.fls output/$(APP_VERSION)/OpenW800_$(APP_VERSION).fls
cp sdk/OpenW800/bin/w800/w800_ota.img output/$(APP_VERSION)/OpenW800_$(APP_VERSION)_ota.img
diff --git a/src/httpserver/http_fns.c b/src/httpserver/http_fns.c
index a8889acac..12f918558 100644
--- a/src/httpserver/http_fns.c
+++ b/src/httpserver/http_fns.c
@@ -3011,11 +3011,30 @@ int http_fn_ota_exec(http_request_t* request) {
int http_fn_ota(http_request_t* request) {
http_setup(request, httpMimeTypeHTML);
http_html_start(request, "OTA system");
- poststr(request, "
For a more user-friendly experience, it is recommended to use the OTA option in the Web Application, where you can easily drag and drop files without needing to set up a server. On Beken platforms, the .rbl file is used for OTA updates. In the OTA section below, paste the link to the .rbl file (an HTTP server is required).
");
- add_label_text_field(request, "URL for new bin file", "host", "", "");
+
+ const char htmlOTA[] = "";
+
+ poststr(request, "
Expert feature: Upload firmware OTA file. If unsure, please use Web App!