2.14.0 custom url OTA failure

1. My goal is:

Allow OTA update via S3 url on 2.14.0

2. My actions are:

mos.yml file:

...
libs:
  - origin: https://github.com/mongoose-os-libs/aws
  - origin: https://github.com/mongoose-os-libs/ca-bundle
  - origin: https://github.com/mongoose-os-libs/http-server
  - origin: git@github.com:cesanta/mos-libs.git/ota-common
  - origin: git@github.com:cesanta/mos-libs.git/ota-http-client
  - origin: https://github.com/mongoose-os-libs/wifi
  - origin: https://github.com/mongoose-os-libs/rpc-mqtt
  - origin: https://github.com/mongoose-os-libs/rpc-service-config
  - origin: https://github.com/mongoose-os-libs/rpc-service-fs
  - origin: https://github.com/mongoose-os-libs/rpc-uart
  - origin: https://github.com/mongoose-os-libs/sntp
...

build command:

mos build --clean --local --verbose --gh-token <token>

note: the GitHub token is verified, it can clone the private mos-libs repo

3. The result I see is:

Calling mgos_ota_http_start(url, NULL) in code results in the following crash report:

note: file url is redacted but is a verified build.

...
mgos_ota_http_clien:270 Update URL: http://custom-url.com/fw.zip
[Jul 26 15:50:44.031] Guru Meditation Error: Core  0 panic'ed (LoadProhibited). Exception was unhandled.
[Jul 26 15:50:44.031] Core 0 register dump:
[Jul 26 15:50:44.032] PC      : 0x40182fb2  PS      : 0x00060b30  A0      : 0x801831e4  A1      : 0x3ffb5ed0  
[Jul 26 15:50:44.032] A2      : 0x3ffc3960  A3      : 0x00000000  A4      : 0x00000001  A5      : 0x0000ff00  
[Jul 26 15:50:44.032] A6      : 0x00ff0000  A7      : 0xff000000  A8      : 0x80182fb2  A9      : 0x3ffb5eb0  
[Jul 26 15:50:44.032] A10     : 0x3ffcb230  A11     : 0x00000030  A12     : 0x40081ea8  A13     : 0x3ffb8f2c  
[Jul 26 15:50:44.032] A14     : 0x00000001  A15     : 0x00000002  SAR     : 0x0000001f  EXCCAUSE: 0x0000001c  
[Jul 26 15:50:44.032] EXCVADDR: 0x00000000  LBEG    : 0x4000c46c  LEND    : 0x4000c477  LCOUNT  : 0x00000000  
[Jul 26 15:50:44.032] 
[Jul 26 15:50:44.032] Backtrace: 0x40182fb2 0x401831e1 0x400edadf 0x400e6cf3 0x400e3be6 0x4017ba1e 0x4017cec6 0x4017fc00 0x401906fd 0x40177a5d 0x4008398a 0x40083b51
[Jul 26 15:50:44.032] 
[Jul 26 15:50:44.032] --- BEGIN CORE DUMP ---
[Jul 26 15:50:44.032] mos: catching core dump
[Jul 26 15:50:44.032] ..............
[Jul 26 15:51:20.147] ---- END CORE DUMP ----
[Jul 26 15:51:20.152] mos: wrote to project-dir/source/esp/core-esp-esp32-20190726-155120.065100614 (460223 bytes)
[Jul 26 15:51:20.154] mos: analyzing core dump
Core dump by esp/esp32 0.7.3 20190726-212906/v1.1-rc1.2-18-g63637ba-bugfix/190724-fix-wifi-connect-dirty
Using ELF file at: project-dir/source/esp/build/objs/esp.elf
Using Docker image: docker.io/mgos/esp32-build:3.2-r6
Running docker run --rm -v project-dir/source/esp/build/objs/esp.elf:/fw.elf -v project-dir/source/esp/core-esp-esp32-20190726-155120.065100614:/core -v project-dir/source/esp:project-dir/source/esp docker.io/mgos/esp32-build:3.2-r6 bash -c /usr/local/bin/serve_core.py --rom=/opt/Espressif/rom/rom.bin --rom_addr=0x40000000 --xtensa_addr_fixup=true /fw.elf /core & $MGOS_TARGET_GDB /fw.elf -ex 'target remote 127.0.0.1:1234' -ex 'set confirm off' -ex bt -ex quit
GNU gdb (crosstool-NG crosstool-ng-1.22.0-80-g6c4433a) 7.10
Copyright (C) 2015 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.  Type "show copying"
and "show warranty" for details.
This GDB was configured as "--host=x86_64-build_pc-linux-gnu --target=xtensa-esp32-elf".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>.
Find the GDB manual and other documentation resources online at:
<http://www.gnu.org/software/gdb/documentation/>.
For help, type "help".
Type "apropos word" to search for commands related to "word"...
Reading symbols from /fw.elf...done.
314	/data/tmp/mos_prebuild/tmp/mos_libs/ota-http-client/src/mgos_ota_http_client.c: No such file or directory.
Remote debugging using 127.0.0.1:1234
mgos_ota_http_start_internal (
    url=0x3ffc38dc "http://custom-url.com/fw.zip", opts=0x0, restrict_url=true)
    at /data/tmp/mos_prebuild/tmp/mos_libs/ota-http-client/src/mgos_ota_http_client.c:314
#0  mgos_ota_http_start_internal (
    url=0x3ffc38dc "http://custom-url.com/fw.zip", opts=0x0, restrict_url=true)
    at /data/tmp/mos_prebuild/tmp/mos_libs/ota-http-client/src/mgos_ota_http_client.c:314
#1  0x401831e4 in mgos_ota_http_start (
    url=0x3ffc38dc "http://custom-url.com/fw.zip", opts=0x0)
    at /data/tmp/mos_prebuild/tmp/mos_libs/ota-http-client/src/mgos_ota_http_client.c:212
#2  0x400edae2 in OTA_task_1s ()
    at project-dir/source/esp/src/module/ota.c:98
#3  0x400e6cf6 in APP_task_1s (arg=<optimized out>)
    at project-dir/source/esp/src/app.c:134
#4  0x400e3be9 in mgos_timer_ev (nc=<optimized out>, ev=<optimized out>, 
    ev_data=<optimized out>, user_data=0x3ffc21dc)
    at project-dir/source/esp/lib/mos/mongoose-os/src/mgos_timers.c:92
#5  0x4017ba21 in mg_call (nc=0x3ffc21ec, 
    ev_handler=0x400e3b2c <mgos_timer_ev>, user_data=0x3ffc21dc, ev=6, 
    ev_data=0x3ffb5fc0 <mgos_task_stack+7864>) at mongoose/src/mg_net.c:96
#6  0x4017cec9 in mg_timer (now=1564176628.8634419, c=0x3ffc21ec)
    at mongoose/src/mg_net.c:118
#7  mg_if_poll (nc=0x3ffc21ec, now=1564176628.8634419)
    at mongoose/src/mg_net.c:157
#8  0x4017fc03 in mg_lwip_if_poll (iface=<optimized out>, 
    timeout_ms=<optimized out>) at common/platforms/lwip/mg_lwip_ev_mgr.c:136
#9  0x40190700 in mg_mgr_poll (m=0x3ffbb954 <s_mgr>, timeout_ms=0)
    at mongoose/src/mg_net.c:301
#10 0x40177a60 in mongoose_poll (ms=0)
    at /data/tmp/mos_prebuild/tmp/cesanta/mos-libs/mongoose/src/mgos_mongoose.c:61
#11 0x4008398d in mgos_mg_poll_cb (arg=<optimized out>)
    at project-dir/source/esp/deps/freertos/src/mgos_freertos.c:101
#12 0x40083b54 in mgos_task (arg=<optimized out>)
    at project-dir/source/esp/deps/freertos/src/mgos_freertos.c:220
...

4. My expectation & question is:

My latest builds with 2.14.0, upgraded from 2.5.1 crashes when attempting OTA updates with custom urls. Yes, we are licensed, but perhaps I’m building and applying the libs incorrectly…? The red flag for me is:

mgos_ota_http_start_internal (
    url=0x3ffc38dc "http://custom-url.com/fw.zip", opts=0x0, restrict_url=true)
    at /data/tmp/mos_prebuild/tmp/mos_libs/ota-http-client/src/mgos_ota_http_client.c:314

specifically restrict_url=true. I am guessing this is implying I cannot use my own file url, which I am able to do with older builds.

Am I missing a step to ensure I am using the licensed libraries to perform a custom url OTA update?

1 Like

Fixed by declaring the needed mgos_ota_opts like so:

// prepare ota request
struct mgos_ota_opts otaOpts = {
  .timeout = WIFI_OTA_DOWNLOAD_TIME_SEC,
  .commit_timeout = 300, // seconds
  .ignore_same_version = false,
};

mgos_ota_http_start( otaUrl, &otaOpts );