Copyright © https://mongoose-os.com

Mongoose OS Forum

frame

OTA update from dash.mongoose-os.com reboots if same build id is sent to device

nliviunliviu Romania
edited March 19 in Mongoose OS
  1. Goal - avoid updating and rebooting when trying to OTA update to the same firmware build id
  2. What I did - use mgos_upd_set_event_cb(updateCB, NULL) with 2 scenarios:
    Code (the significant part is static bool updateCB(enum mgos_upd_event ev, const void *ev_data, void *cb_arg)):
    2.1. use ctx->ignore_same_version = true;
    2.2 compare the remote and local build_id and set ctx->result = 1; and ctx->status_msg = "Same build id!"; if they match

  3. Expect to cancel/finish the update in both cases, without rebooting.

  4. Observed behaviour.
    4.1. use ota-hhtp-server - both cases are working as expected:
[Mar 11 16:57:10.090] mgos_http_ev         0x3ffca750 HTTP connection from 192.168.1.10:52217
[Mar 11 16:57:10.099] updater_context_crea starting, timeout 300
[Mar 11 16:57:10.108] updateCB             Update - (1) INIT
[Mar 11 16:57:11.114] parse_manifest       FW: ota esp32 1.0.0_1 20180311-145548/??? -> 1.0.0_1 20180311-145548/???
[Mar 11 16:57:11.125] updater_finish       Finished: 1 Version is the same as current
[Mar 11 16:57:11.138] updateCB             Update - (4) END, ctx->update_state=9, ctx->status_msg=Version is the same as current
[Mar 11 16:57:11.180] mongoose_poll        New heap free LWM: 203664
[Mar 11 16:57:11.296] mongoose_poll        New heap free LWM: 201252
[Mar 11 16:57:14.964] isUpdateInProgress   Update in progress, ctx->ignore_same_version=true
[Mar 11 16:57:24.963] mainTimerCB          minFreeHeap=201252, freeHeap=224452
[Mar 11 17:30:00.630] mgos_http_ev         0x3ffcbbe8 HTTP connection from 192.168.1.10:52399
[Mar 11 17:30:00.639] updater_context_crea starting, timeout 300
[Mar 11 17:30:00.647] updateCB             Update - (1) INIT
[Mar 11 17:30:01.331] isUpdateInProgress   Update in progress, ctx->ignore_same_version=false
[Mar 11 17:30:01.654] parse_manifest       FW: ota esp32 1.0.0_1 20180311-150128/??? -> 1.0.0_1 20180311-150128/???
[Mar 11 17:30:01.669] mgos_upd_begin       App: ota.bin -> app_0, FS: fs.img -> fs_0
[Mar 11 17:30:01.678] updater_process_int  App: ota FW: 1.0.0_1 Build ID: 20180311-150128/???
[Mar 11 17:30:01.692] updateCB             Update - (2) BEGIN, remote=20180311-150128/???, local=20180311-150128/??? (isSame=1)
[Mar 11 17:30:01.699] updater_finish       Finished: 1 Same build id!
[Mar 11 17:30:01.711] updateCB             Update - (4) END, ctx->update_state=9, ctx->status_msg=Same build id!
[Mar 11 17:30:01.788] mongoose_poll        New heap free LWM: 205392

4.2. - use dash.mongoose - both cases are rebooting the device (and the update context is living too long)

[Mar 11 16:59:00.434] updateCB             Update - (1) INIT
[Mar 11 16:59:00.449] state_cb             Starting OTA with URL [https://dash.mongoose-os.com/api/v1/ota/<user_name>/fw-init.zip]
[Mar 11 16:59:01.979] parse_manifest       FW: ota esp32 1.0.0_1 20180311-145548/??? -> 1.0.0_1 20180311-145548/???
[Mar 11 16:59:01.991] updater_finish       Finished: 1 Version is the same as current
[Mar 11 16:59:02.006] updateCB             Update - (4) END, ctx->update_state=9, ctx->status_msg=Version is the same as current
[Mar 11 16:59:04.964] isUpdateInProgress   Update in progress, ctx->ignore_same_version=true
...
[Mar 11 17:00:34.964] isUpdateInProgress   Update in progress, ctx->ignore_same_version=true
[Mar 11 17:00:36.086] request_next_chunk   OTA finished, rebooting device
[Mar 11 17:00:36.096] mgos_system_restart_ Rebooting in 500 ms
[Mar 11 17:00:36.606] mgos_vfs_umount_all  Unmounting filesystems
[Mar 11 17:03:29.819] updateCB             Update - (1) INIT
[Mar 11 17:03:29.833] state_cb             Starting OTA with URL [https://dash.mongoose-os.com/api/v1/ota/<user_name>/fw-begin.zip]
[Mar 11 17:03:31.351] parse_manifest       FW: ota esp32 1.0.0_1 20180311-150128/??? -> 1.0.0_1 20180311-150128/???
[Mar 11 17:03:31.366] mgos_upd_begin       App: ota.bin -> app_0, FS: fs.img -> fs_0
[Mar 11 17:03:31.377] updater_process_int  App: ota FW: 1.0.0_1 Build ID: 20180311-150128/???
[Mar 11 17:03:31.390] updateCB             Update - (2) BEGIN, remote=20180311-150128/???, local=20180311-150128/??? (isSame=1)
[Mar 11 17:03:31.397] updater_finish       Finished: 1 Same build id!
[Mar 11 17:03:31.412] updateCB             Update - (4) END, ctx->update_state=9, ctx->status_msg=Same build id!
[Mar 11 17:03:36.809] isUpdateInProgress   Update in progress, ctx->ignore_same_version=false
...
[Mar 11 17:05:16.821] isUpdateInProgress   Update in progress, ctx->ignore_same_version=false
[Mar 11 17:05:17.859] request_next_chunk   OTA finished, rebooting device
[Mar 11 17:05:17.867] mgos_system_restart_ Rebooting in 500 ms
[Mar 11 17:05:18.374] mgos_vfs_umount_all  Unmounting filesystems

fw-begin is the firmware where the following lines are commented out

            //struct update_context* ctx = updater_context_get_current();
            //ctx->ignore_same_version = true;

LE. As far as I remember, back on 1.18, when ota-http-client was open source, the flag ctx->ignore_same_version was set to true by default.

Sign In or Register to comment.