uOTA - OTA updater for MicroPython

Related tags

Hardware uota
Overview

uOTA - OTA updater for MicroPython

Overview

Update your device firmware written in MicroPython over the air. Suitable for private and/or larger projects with many files.

Requires MicroPython 1.17 or newer.

How it's different from other OTA Updaters

Other OTA updaters, notably rdehuyss/micropython-ota-updater, smysnk/micropython-ota-updater and RangerDigital/senko, update code from a particular branch on GitHub. This OTA is different in the following aspects:

  • update from any HTTP(S) server with no hardcoded endpoints, allowing you to keep control of your hosting without dependencies
  • no need for GitHub account
  • no need to make your code public or pay for private repos
  • replaces files in-place without storing uncompressed new firmware in flash
  • replaces files in the root of the filesystem
  • downloads new firmware as a single compressed .tar.gz file which is more efficient for a larger number of files
  • compares SHA256 hash of the new firmware file but not of individual files (optional)
  • checks if there is sufficient available free space in the file system (optional)
  • compares firmware version: the content of version file from MicroPython device file system and the version published on your server stored in latest file, see details below

Usage

Drop the following files into the root of your project:

  1. uota.py
  2. uota.cfg
    • must be a valid Python dictionary with the following keys:
      • url
        • base HTTP or HTTPS URL where to look for new firmware
        • ends with a trailing slash
      • tmp_filename
        • the new firmware will be stored in a file of this name
        • this file is deleted automatically after
      • excluded_files
        • files or directories with matching names will be skipped and not overwritten with new versions. Keep local device configuration such as wifi credentials or certificates from being overwritten.
      • delete
        • items are file/directory names as strings, these will be deleted after new firmware is installed
        • this configuration option is loaded after the new firmware is installed to perform any cleanup that may be needed
  3. version
    • the current version of the firmware
    • version check can be disabled by passing version_check=False argument to uota.check_for_updates()

Publish new firmware on your HTTP(S) server as two files:

  • firmware file of any name
    • a TAR file compressed with gzip, the content will be downloaded and unpacked directly into the root of the filesystem of your MicroPython device
    • can be created with tar -czf firmware.tar.gz * shell command on any Linux/UNIX/MacOS system
  • latest
    • a text file with the following fields separated by a semicolon:
      • version
      • new firmware filename available on the server
      • required amount of additional free space in flash, measured in kB (optional)
      • SHA256 hash of the new firmware file (optional, but makes the previous item mandatory)
    • valid examples:
      • 2.0.1;firmware.tar.gz
      • 2.0.1;firmware.tar.gz;2
      • 2.0.1;firmware.tar.gz;0;8870f8b3bd8b54437f0a7f721cd3f3fe208e60638dcf36a9f4efe31dab58c548
    • invalid examples:
      • firmware.tar.gz
      • 2.0.1;firmware.tar.gz;8870f8b3bd8b54437f0a7f721cd3f3fe208e60638dcf36a9f4efe31dab58c548

And then use uota in your project as follows. You must connect to wifi yourself as uota expects a working wifi connection to function.

import uota
import machine
...
from connect_wifi import connect_wifi
connect_wifi()
...
if do_ota_update and uota.check_for_updates():
      uota.install_new_firmware()
      machine.reset()

SSL security considerations

MicroPython's built-in SSL package does not support checking server certificate or authenticating the client with the server using certificates. uOTA can perform certificate pinning by checking the hash of server-side private key, if ucertpin is installed.

Certificate pinning

Certificate pinning is disabled by default. To enable it make ucertpin available for import and pass pubkey_hash=b'---your-SHA256-hash-value---' argument to uota.check_for_updates:

>>> import uota
>>> uota.check_for_updates()     # no certificate pinning
new version 0.3 is available
True
>>> uota.check_for_updates(pubkey_hash=b'abc')    # certificate pinning with incorrect hash
Certificate pinning failed, the hash of server public key does not match. Aborting the update.
False
You might also like...
For use with an 8-bit parallel TFT touchscreen using micropython
For use with an 8-bit parallel TFT touchscreen using micropython

ILI9341-parallel-TFT-driver-for-micropython For use with an 8-bit parallel TFT touchscreen using micropython. Many thanks to prenticedavid and his MCU

MPY tool - manage files on devices running MicroPython

mpytool MPY tool - manage files on devices running MicroPython It is an alternative to ampy Target of this project is to make more clean code, faster,

Controlling fireworks with micropython
Controlling fireworks with micropython

Controlling-fireworks-with-micropython How the code works line 1-4 from machine

Pylorawan is a Micropython wrapper for lorawan devices from RAK Wireless.
Pylorawan is a Micropython wrapper for lorawan devices from RAK Wireless.

pylorawan Pylorawan is a Micropython wrapper for lorawan devices from RAK Wireless. Tested on a Raspberry PI Pico with a RAK4200(H) Evaluation Board (

OTA APK Extractor - A script utilises payload dumper and image extractor tools to extract the apps from the system.img of an android OTA file
MODSKIN-LOLPRO-updater: The mod is fkn 10y old and has'nt a self-updater

The mod is fkn 10y old and has'nt a self-updater. To use it just run the exec, wait some seconds, and it will run the new modsk

Modi2-firmware-updater - MODI+ Firmware Updater With Python

MODI+ Firmware Updater 실행 준비 python3(파이썬3.9 혹은 그 이상의 버전)를 컴퓨터에 설치 python3 -m pip

Micropython-wifimanager-esp8266 - Simple Wifi Manager for ESP8266 using MicroPython

micropython-wifimanager-esp8266 Simple Wifi Manager for ESP8266 using MicroPytho

Official implementation of our CVPR2021 paper
Official implementation of our CVPR2021 paper "OTA: Optimal Transport Assignment for Object Detection" in Pytorch.

OTA: Optimal Transport Assignment for Object Detection This project provides an implementation for our CVPR2021 paper "OTA: Optimal Transport Assignme

A script for performing OTA update over BLE on ESP32

A script for performing OTA update over BLE on ESP32

Alternative firmware for ESP8266 with easy configuration using webUI, OTA updates, automation using timers or rules, expandability and entirely local control over MQTT, HTTP, Serial or KNX. Full documentation at

Alternative firmware for ESP8266/ESP32 based devices with easy configuration using webUI, OTA updates, automation using timers or rules, expandability

Simple script to download OTA packages from Realme's endpoint.

Realme OTA Downloader CLI tool (based on this C# program) to create requests to the Realme's endpoint. Requirements Python 3.9. pycryptodome. Installa

GitHub Actions Version Updater Updates All GitHub Action Versions in a Repository and Creates a Pull Request with the Changes.
GitHub Actions Version Updater Updates All GitHub Action Versions in a Repository and Creates a Pull Request with the Changes.

GitHub Actions Version Updater GitHub Actions Version Updater is GitHub Action that is used to update other GitHub Actions in a Repository and create

Application Updater using an download link

Application-Updater This tool will update your app using an storage link

Auto-updater for the Northstar Titanfall 2 client

northstar-updater Auto-updater for the Northstar Titanfall 2 client Usage Put the exe into your Titanfall 2 directory next to Titanfall2.exe Then, whe

Python project setup, updater, and launcher

Launcher Python project setup, updater, and launcher Purpose: Increase project productivity and provide features easily. Once installed as a git submo

Python project setup, updater, and launcher

pyLaunch Python project setup, updater, and launcher Purpose: Increase project productivity and provide features easily. Once installed as a git submo

MicroPython - a lean and efficient Python implementation for microcontrollers and constrained systems
MicroPython - a lean and efficient Python implementation for microcontrollers and constrained systems

The MicroPython project This is the MicroPython project, which aims to put an implementation of Python 3.x on microcontrollers and small embedded syst

Simple GUI menu for micropython using a rotary encoder and basic display.

Micropython encoder based menu This is a simple menu system written in micropython. It uses a switch, a rotary encoder and an OLED display.

Comments
  • Add support for logging module

    Add support for logging module

    Hi,

    Great project!

    Would you consider a PR to support the logging module? Logging is important when devices are deployed remotely.

    The attached PR will import the logging module and if it isn't available log entries will be printed.

    Patrick

    opened by ThinkTransit 11
  • Possible bug on uota.py line 183.

    Possible bug on uota.py line 183.

    Hi, thanks for the great project!

    I found a problem in line 183: not quiet and log.debug(f'creating directory {file_name} ... ', end='')

    If I change that line to this below works: not quiet and log.debug(f'creating directory {file_name} ... ')

    Complete log error:

    >>> import uota
    WARNING: ucertpin package not found, certificate pinning is disabled
    >>> uota.check_for_updates()
    WARNING: local version information missing, ignoring it
    INFO: new version 2.0.1 is available
    True
    >>> uota.install_new_firmware()
    Traceback (most recent call last):
      File "<stdin>", line 1, in <module>
      File "uota.py", line 183, in install_new_firmware
    TypeError: unexpected keyword argument 'end'
    >>> 
    

    Is that a really bug or am I doing something wrong?

    Thank you.

    opened by beyonlo 0
  • two OTA partition how to?

    two OTA partition how to?

    I compiled a ESP32 firmware , and now , boot partition is ota_0. uota could download and unzip firmware I put in a LAN web server. It's good.

    My problem is how to copy this firmware downloaded in ota_0 and copy it to ota_1?

    Since copied to ota_1. I could set boot partition by esp32.Partition.set_boot()

    opened by kenjican 1
  • clarification for files/locations needed

    clarification for files/locations needed

    am I correct that my project folder will need to contain:

    • a copy of your uota.py module from this lib section
    • an adjusted version of your uota.cfg.example as uota.cfg
    • a copy of my micropython .bin file
    • all my .py files used in my project and I will create a .gz file with all the contents of this folder into a new folder (e.g. .../esp32upload? In addition add the adjusted text file "latest" into this folder

    then uota.cfg url could be "http://localhost/.../esp32upload/"

    and where is the module connect_wifi coming from and how do I provide credentials for the connection?

    opened by juergmaier 4
Owner
Martin Komon
Martin Komon
Micropython-wifimanager-esp8266 - Simple Wifi Manager for ESP8266 using MicroPython

micropython-wifimanager-esp8266 Simple Wifi Manager for ESP8266 using MicroPytho

Abhinuv Nitin Pitale 1 Jan 4, 2022
A script for performing OTA update over BLE on ESP32

A script for performing OTA update over BLE on ESP32

Felix Biego 18 Dec 15, 2022
Alternative firmware for ESP8266 with easy configuration using webUI, OTA updates, automation using timers or rules, expandability and entirely local control over MQTT, HTTP, Serial or KNX. Full documentation at

Alternative firmware for ESP8266/ESP32 based devices with easy configuration using webUI, OTA updates, automation using timers or rules, expandability

Theo Arends 59 Dec 26, 2022
MicroPython driver for 74HC595 shift registers

MicroPython 74HC595 A MicroPython library for 74HC595 8-bit shift registers. There's both an SPI version and a bit-bang version, each with a slightly

Mike Causer 17 Nov 29, 2022
A Raspberry Pi Pico plant sensor hub coded in Micropython

plantsensor A Raspberry Pi Pico plant sensor hub coded in Micropython I used: 1x Raspberry Pi Pico - microcontroller 1x Waveshare Pico OLED 1.3 - scre

null 78 Sep 20, 2022
An open source operating system designed primarily for the Raspberry Pi Pico, written entirely in MicroPython

PycOS An open source operating system designed primarily for the Raspberry Pi Pico, written entirely in MicroPython. "PycOS" is an combination of the

null 8 Oct 6, 2022
ESP32 micropython implementation of Art-Net client

E_uArtnet ESP32 micropython implementation of Art-Net client Instalation Use thonny Open the root folder in thonny and upload the Empire folder like i

null 2 Dec 7, 2021
Micropython automatic watering

micropython-automatic-watering micropython automatic watering his code was developed to be used with nodemcu esp8266, but can be modified to work with

null 1 Nov 24, 2021
Testing out some (stolen) DMA code for RP2040 Micropython

RP2040_micropython_dma testing out some (stolen) DMA code for RP2040 Micropython. Heavy inspiration and some code from https://iosoft.blog/2021/10/26/

null 2 Dec 29, 2022
ENC28J60 Ethernet chip driver for MicroPython (RP2)

micropy-ENC28J60 ENC28J60 Ethernet chip driver for MicroPython v1.17 (RP2) Rationale ENC28J60 is a popular and cheap module for DIY projects. At the m

null 11 Nov 16, 2022