Automatic self-update

  • Hi,
    There are lot of topics about "manual" OTA of Pycom modules but i can't find answer if it is possible to make an application which will automatically check for updated firmware at FTP or HTTP server (over WiFi), download it and then re-program itself? There seems to be room for previous firmware (because the long button press restores it) in onboard Flash so i assume it should be possible to write the firmware check/download code which should place the binary to the memory and then it should somehow trigger the bootloader to do the programming. But how exactly it is done or can be done at all? Can the previous/new binaries be accessed via Python I/O library? Basically i am thinking about building an application with LoPy which every week or so checks for firmware upgrades at my server.

    For extra clarity: It is a product with display and buttons. User can set up wifi and then the device should do the rest - let know about new updates, ask for update confirmation, etc. No cable connections and SW installation in user PC should be done - ideally :)

  • If you want to customise how the current process works have a look at the folder, especially updater.c.

  • Accessing devices on the field with FTP from outside could be impossible if user has firewall or device is behind router :(

    But still - i'm trying to undestand if this is possible or impossible. Xtensa and MicroPython or quite new to me but if there's just few functions or tweaks to do here and there then that's fine. Before i jump too deep to code then maybe someone could explain where and how the factory and previous images are stored? Are they in MCU or external Flash? As raw images in dedicated segments or as files in filesystem?
    And secondly how is the bootloader notified about new firmware image when using FTP upload? Are there some special flags in RAM or bootloader just checks for new image at every start-up?

  • @mkl
    At least for the moment you need to FTP into the Pycom board (so the Pycom board is the FTP server) for OTA upgrades.

    I guess you could have a simple script signalling a remote server to FTP PUT the update onto the board. Once getting a "complete" signal the board would then reset itself.

    Be aware that OTA updates are very new so there are a few limitations (you need to build a custom firmware, can't just pull an official image from Pycom) and while it works I don't think it's considered a stable production system yet.

Pycom on Twitter