Skip to content

Commit 816489e

Browse files
matheusmbarjhedberg
authored andcommitted
mgmt: hawkbit: Add options to not confirm or erase at init
Current implementation forces confirmation of current boot image and second slot erase at hawkbit_init() and it is impossible to communicate with hawkBit server without running it. This makes impossible to notify update failures to server (#71750) Add option HAWKBIT_CONFIRM_IMG_ON_INIT to allow disabling the auto image confirmation and HAWKBIT_ERASE_SECOND_SLOT_ON_CONFIRM to select if the second partition slot shall be erased or not. Disable those to handle of these behaviors on application code. Signed-off-by: Matheus Marques <[email protected]>
1 parent bca62b6 commit 816489e

File tree

3 files changed

+26
-5
lines changed

3 files changed

+26
-5
lines changed

doc/releases/release-notes-4.3.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -217,6 +217,8 @@ New APIs and options
217217
* hawkBit
218218

219219
* :kconfig:option:`CONFIG_HAWKBIT_REBOOT_NONE`
220+
* :kconfig:option:`CONFIG_HAWKBIT_CONFIRM_IMG_ON_INIT`
221+
* :kconfig:option:`CONFIG_HAWKBIT_ERASE_SECOND_SLOT_ON_CONFIRM`
220222

221223
* Modem
222224

subsys/mgmt/hawkbit/Kconfig

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -258,6 +258,21 @@ config HAWKBIT_SAVE_PROGRESS_INTERVAL
258258
Set the interval (in percent) that the hawkBit update download progress will be saved.
259259
0 means that the progress will be saved every time a new chunk is downloaded.
260260

261+
config HAWKBIT_CONFIRM_IMG_ON_INIT
262+
bool "Confirm boot image at hawkBit init"
263+
default y
264+
help
265+
Automatically confirm current boot image at hawkBit initialization.
266+
Application shall handle image confirmation when set to false.
267+
268+
config HAWKBIT_ERASE_SECOND_SLOT_ON_CONFIRM
269+
bool "Erase second slot after confirming boot image"
270+
default y
271+
depends on HAWKBIT_CONFIRM_IMG_ON_INIT
272+
help
273+
Erase the second image slot partition contents after confirming current boot image
274+
at hawkBit init.
275+
261276
module = HAWKBIT
262277
module-str = Log Level for hawkbit
263278
module-help = Enables logging for hawkBit code.

subsys/mgmt/hawkbit/hawkbit.c

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -910,18 +910,22 @@ int hawkbit_init(void)
910910

911911
image_ok = boot_is_img_confirmed();
912912
LOG_INF("Current image is%s confirmed", image_ok ? "" : " not");
913-
if (!image_ok) {
913+
914+
if (IS_ENABLED(CONFIG_HAWKBIT_CONFIRM_IMG_ON_INIT) && !image_ok) {
914915
ret = boot_write_img_confirmed();
915916
if (ret < 0) {
916917
LOG_ERR("Failed to confirm current image: %d", ret);
917918
return ret;
918919
}
919920

920921
LOG_DBG("Marked current image as OK");
921-
ret = boot_erase_img_bank(flash_img_get_upload_slot());
922-
if (ret < 0) {
923-
LOG_ERR("Failed to erase second slot: %d", ret);
924-
return ret;
922+
923+
if (IS_ENABLED(CONFIG_HAWKBIT_ERASE_SECOND_SLOT_ON_CONFIRM)) {
924+
ret = boot_erase_img_bank(flash_img_get_upload_slot());
925+
if (ret < 0) {
926+
LOG_ERR("Failed to erase second slot: %d", ret);
927+
return ret;
928+
}
925929
}
926930

927931
hawkbit_event_raise(HAWKBIT_EVENT_CONFIRMED_CURRENT_IMAGE);

0 commit comments

Comments
 (0)