From f0668801d961157a61f20c9698164fb451a5d680 Mon Sep 17 00:00:00 2001 From: xengineering Date: Sun, 30 Mar 2025 18:41:02 +0200 Subject: fw: app: update: Finish first HTTP PUT /update This adds marking the application firmware image in the secondary slot for a permanent update and rebooting the device. It is a known bug that the corresponding HTTP request is never properly closed since the device reboots while handling the request. Nevertheless the current state works and enables remote updates. --- fw/app/src/update.c | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/fw/app/src/update.c b/fw/app/src/update.c index ff4ce6a..5e119eb 100644 --- a/fw/app/src/update.c +++ b/fw/app/src/update.c @@ -8,11 +8,14 @@ #include #include +#include #include +#include #include #include #include #include +#include LOG_MODULE_REGISTER(update); @@ -74,8 +77,21 @@ static int update_handler( LOG_ERR("Processed %zd octets but wrote %zd", processed, written); return ret; } - LOG_INF("Handled update request receiving %zd octets.", processed); + LOG_DBG("Received %zd octets.", processed); processed = 0; + + const bool permanent = true; + ret = boot_request_upgrade((int)permanent); + if (ret < 0) { + LOG_ERR("Failed to mark uploaded image for update (%d)", ret); + return ret; + } + + LOG_INF("New application firmware uploaded and marked for update"); + + LOG_INF("Rebooting to complete remote update"); + log_flush(); + sys_reboot(SYS_REBOOT_COLD); } return 0; -- cgit v1.2.3-70-g09d2