Fork me on GitHub

Architecture overview

Mongoose OS is a framework for building apps (firmwares) for low-power microcontrollers (uC), and consists of the following main components:

  1. mos tool. Provides device management and firmware building capabilities
  2. A build toolchain. This is a docker image which contains hardware vendor's SDK together with mongoose-os sources. A mos build command builds a firmware (we call it an "app") by taking mos.yml file in the current directory and invoking a build docker image either remotely (mos build) or locally (mos build --local).
  3. A collection of ready-to-use apps and libraries

Since Mongoose OS is based on the vendor's SDK, it extends the capabilities of the native SDK. For example, on ESP32 uC, Mongoose OS uses an ESP-IDF SDK, therefore it provides all capabilities that ESP-IDF provides, plus extra that come with Mongoose OS. If user code uses crossplatform API only, it can be built on all supported hardware platforms with no code changes:


Source code structure

mongoose-os/               - repository root
            common/        - various utility functions
            docs/          - documentaion you are reading now
            frozen/        - JSON parser/emitter
            fw/            - main source tree
               src/        - cross-platform sources
               platforms/  - platform-specific sources
            mongoose/      - networking core

Boot process

The boot process is driven by a cross-platform mgos_init.c. In short, the subsystems are initialised in the following order:

  • Native SDK init
  • GPIO
  • Configuration
  • WiFi
  • Platform-specific init
  • MDNS
  • SNTP
  • Libraries, which can define their order
  • User code is called, mgos_app_init()
  • All registered MGOS_HOOK_INIT_DONE hooks are invoked

If any of those init functions returns false, that means error. In this case, the firmware reboots immediately. This is done intentionally, in order to revert back to the previous firmware in case of failed OTA update.