Trying to make minimal fw that supports OTA via mDash

Hey all,

I find myself in a position where I need a bare minimum firmware that I can use to fix a device that is soft-bricked in the field.

I’m having an issue where my device firmware is quite large (1.4mb) and it takes approximately 10 minutes for an OTA to flash, but my in-field device is rebooting every 5 minutes.

I’m trying to create a bare minimum firmware but am having trouble:

  1. Creating a FW that is approx 700-800kb (I tested with a stopwatch, so smaller the better)
  2. FW that gets applied after upload (struggling with this for some reason)
  3. Can still be OTA’d once updated

Would appreciate any suggestions on library-efficient ways to get my FW small as possible, or knowledge on what libs are MUST.

So far I’ve got:

  - origin: https://github.com/mongoose-os-libs/dash
  - origin: https://github.com/mongoose-os-libs/ca-bundle
  - origin: https://github.com/mongoose-os-libs/http-server
  - origin: https://github.com/mongoose-os-libs/ota-shadow
  - origin: https://github.com/mongoose-os-libs/ota-http-client
  - origin: https://github.com/mongoose-os-libs/ota-http-server
  - origin: https://github.com/mongoose-os-libs/rpc-common
  - origin: https://github.com/mongoose-os-libs/rpc-loopback
  - origin: https://github.com/mongoose-os-libs/rpc-service-config
    version: latest
  - origin: https://github.com/mongoose-os-libs/rpc-service-fs
  - origin: https://github.com/mongoose-os-libs/rpc-service-ota
  - origin: https://github.com/mongoose-os-libs/rpc-service-wifi
  - origin: https://github.com/mongoose-os-libs/rpc-ws
#include "mg_rpc_channel_loopback.h"
#include "mgos.h"
#include "mgos_rpc.h"

enum mgos_app_init_result mgos_app_init(void) {
  struct mg_rpc_call_opts opts = {.dst = mg_mk_str(MGOS_RPC_LOOPBACK_ADDR)};
  mg_rpc_callf(mgos_rpc_get_global(), mg_mk_str("OTA.Commit"), NULL, NULL,
               &opts, NULL);

  return MGOS_APP_INIT_SUCCESS;
}

The above compiles but is not being applied on reboot for some reason.

Thanks.

There seem to be a lot more libraries required to get mDash working with OTA, a lot more than I expected. I’ve edited the above that is working with OTA.

Would appreciate any ideas about what can be cut, the feedback loop is slow since I can’t curl with my cutdown FW.

Looking through the includes from each of the libs I’ve noticed that only one of the libs was including the wifi library, which is probably why it wasn’t working without it.

Even with JUST the wifi lib my base fw grows to 1.2MB, so I think a “900kb FW” is out of the question.

Are there any other options to speed up OTA or am I going to have to give this one up?