Prior art and licences
What already exists for flashing and partitioning microcontrollers, natively and in the browser, and what nanoflash reuses, contributes to or writes itself. Surveyed on 2026-11-22; versions and licences come from crates.io, npm and the projects’ repositories on that date.
Summary
- No Rust or WebAssembly project unifies several bootloader protocols behind one API, and none unifies partition layouts across vendors. The closest, probe-rs, only drives debug probes.
- Every web flasher covers one vendor or one protocol (esptool-js, esp-web-tools, webdfu, DAPjs).
- The building blocks exist and are permissively licensed:
espflash(without its serial port layer),dfu-core,nusb(now with a WebUSB backend),mbrman,gpt_disk_types,esp-idf-part,uf2_block. - Some protocols have no reusable Rust implementation: the Espressif ROM loader over an
asynchronous transport, SAM-BA, and the STK500v1, STK500v2 and AVR109 bootloaders of Arduino’s
AVR boards. nanoflash writes those, using
espflash, BOSSA and avrdude as references. See Design decisions for the choices that follow from this survey.
Multi-protocol flashers
| Project | Scope | Licence | Notes |
|---|---|---|---|
| probe-rs 0.32.0 | Debug probes: CMSIS-DAP, ST-Link, J-Link, ESP USB-JTAG, WCH-Link | MIT OR Apache-2.0 | No ROM serial loaders, SAM-BA, DFU or UF2. Synchronous. Its WebAssembly build is several MB, far above the limit of 256000 bytes of a nanoflash module, and the proposed changes for asynchronous probes (pull request #2958) were not taken upstream. The CMSIS-DAP layer is not a separate crate. |
| esptool-js 0.7.1 | Espressif ROM loader over Web Serial (and WebUSB for CH34x bridges) | Apache-2.0 | Espressif only. |
| esp-web-tools 10.5.2 | Install button and manifest on top of esptool-js | Apache-2.0 | Espressif only. Its manifest format is accepted by nanoflash. |
| Adafruit WebSerial ESPTool | Espressif over Web Serial | MIT | Espressif only. |
| webdfu | USB DFU over WebUSB | ISC | Unmaintained since 2021. |
| DAPjs | CMSIS-DAP over WebUSB | MIT | JavaScript. |
| Arduino Cloud Agent | Native helper that runs bossac, avrdude… for the browser | AGPL-3.0 | Not a web flasher; not reused. |
| espflash-wasm | Experiment running espflash in the browser | MIT OR Apache-2.0 | Last change in 2023. |
| ESP32 Bit Pirate web tools | esptool-js, STM32 AN3155, avrdude in WebAssembly | various | Several separate tools on one page, not one API. |
Per protocol
Espressif ROM serial bootloader
- espflash 4.7.0, MIT OR Apache-2.0 (relicensed in
#224). Supports ESP32, C2, C3, C5, C6, C61, H2,
H21, H4, P4, S2, S3 and S31.
- Its
ConnectionandFlasherare synchronous and bound to the concreteserialporttypes; they only exist behind theserialportfeature. There is no custom transport and Web Serial is asynchronous only, so they cannot run in the browser. - Without that feature the crate still provides the
commandmodule (encoding of every loader command),target::Chip(chip detection values, register addresses, write sizes, eFuse fields) and the flasher stubs. We built it forwasm32-unknown-unknownwithdefault-features = false: it compiles. Its dependencies (regex,deku,object,esp-idf-part) weigh on the WebAssembly bundle; this is measured before committing to it. - Issue #1091 asks for user-supplied serial
ports; the maintainer put it on hold but would consider a contribution for a future major
version. PR #834 (no_std with
embedded-io) is open and inactive since 2025-07.
- Its
- esptool 5.6.0 (Python) is GPL-2.0-or-later: nanoflash does not port from it.
- esp-flasher-stub is Apache-2.0 OR MIT; the stubs can be redistributed.
- The protocol is documented by Espressif: serial protocol.
Decision: write our own asynchronous loader over nanoflash’s transport trait: SLIP framing,
commands, reset sequences, orchestration, written from Espressif’s protocol documentation with
espflash and esptool-js as references. Copy the few chip constants we need (detection values,
about 40 lines) from espflash with attribution (MIT OR Apache-2.0) rather than depending on it:
its dependency tree would dominate the WebAssembly bundle for those few lines. Use the ROM loader
without a flasher stub at first (the ROM supports compressed writes and MD5); the stub is a later
speed-up. Offer the transport design upstream on #1091 once it has proven itself.
The nanoflash command uses one more part of espflash 4.7: image_format, to turn an ELF file
into an ESP-IDF application image. That code is large and changes with each chip, and it needs no
transport, so it is reused natively and not rewritten. The library and the browser package do not
use it.
SAM-BA and the bossac dialect
- BOSSA 1.9.1 and the active
arduino/BOSSA fork (1.9.1-arduino6): BSD-3-Clause.
The reference implementation is
Samba.cpp: ASCII commandsN#,V#,O/o/W/w/S/R/G, plus the Arduino extensions advertised as[Arduino:XYZ...]in the version string:X(erase),Y(write buffer to flash),Z(CRC),I(identify chip),K(reset). arduino/BOSSA ships a SAM-BA emulator in its tests. - The SAMD bootloader of ArduinoCore-samd is LGPL-2.1 (device side; not vendored).
- Arduino Nano 33 BLE (ArduinoCore-mbed boards.txt):
upload.tool=bossac,use_1200bps_touch=true,wait_for_upload_port=true, VID0x2341, PIDs0x005a,0x805a,0x015a,0x025a; upload commandbossac -U -i -e -w file.bin -R. arduino/BOSSA identifiesnRF52840-QIAAthroughI. The bootloader itself is distributed as a binary only (issue #90). - Rust: only
bossa, C++ bindings throughcxx, native only, last changed in 2023.
Decision: write our own SAM-BA implementation in Rust from the protocol (the command set with the Arduino extensions, the nRF52 and SAMD families of Arduino’s bootloaders, and the 1200-baud touch), with BOSSA as a behaviour reference only: no code is ported, so the crate stays MIT OR Apache-2.0. A binding to BOSSA works natively only: its serial I/O is blocking C++ with exceptions, so running it in the browser would need a separate C++ to WebAssembly build and Chromium’s JSPI to suspend on Web Serial. That would mean a second toolchain and module to replace about 700 lines of Rust.
STK500 and AVR109 (Arduino’s AVR boards)
Surveyed on 2026-11-23. Arduino’s boards.txt (ArduinoCore-avr) uploads every AVR board with
avrdude: upload.protocol=arduino (STK500v1: Optiboot on the Uno, ATmegaBOOT on the old Nano and
Pro Mini), wiring (STK500v2: the Mega 2560’s bootloader) or avr109 (Caterina on the
Leonardo, Micro and other ATmega32U4 boards, after a 1200-baud touch).
- The protocols are documented by Atmel: application notes AVR061 (STK500 communication protocol), AVR068 (STK500v2) and AVR109 (self-programming).
- avrdude: GPL-2.0-or-later, C, the reference uploader. nanoflash does not port from it.
- Rust crates: none fits. ravedude 0.3.0 (MIT OR
Apache-2.0, avr-hal) runs the avrdude binary; avrisp 0.3.1
(BSD-2-Clause,
no_std) holds the SPI instructions of in-system programming, not the bootloaders’ serial protocols; avr-boot 0.3.2 (MIT) is for firmware that programs its own flash. Nothing speaks STK500v1, STK500v2 or AVR109 over an asynchronous transport, natively or in the browser. - The bootloaders run on the board and are behaviour references only: Optiboot (GPL-2.0),
ATmegaBOOT and the wiring bootloader of the Mega 2560 (GPL-2.0-or-later,
stk500boot.cin ArduinoCore-avr), and Caterina, derived from LUFA’s CDC bootloader. The wiring bootloader erases one page per page programmed, in order from 0x0, and never from 0x3C000 (itsAPP_END): nanoflash follows that order. - simavr: GPL-3.0, an AVR simulator; it runs the
bootloaders from ArduinoCore-avr in
mise run test-simavr, as a test tool installed or downloaded at test time, never committed or distributed with nanoflash. - Intel HEX, the format of Arduino’s images: ihex 3.0.0 (MIT
OR Apache-2.0) needs
std; nanoflash decodes it itself (no_std, fallible allocation) and usesihexin its tests.
Decision: write the three protocols in Rust from Atmel’s application notes and from
observing the bootloaders (and avrdude) on simavr and on boards, sharing the 1200-baud touch
with SAM-BA: no code is ported from avrdude, Optiboot, ATmegaBOOT, the wiring bootloader,
Caterina or simavr, and each file of src/avr/ says so in its first comment.
USB DFU
- dfu-core 0.11.1: MIT OR Apache-2.0,
#![no_std], sans-I/O (DfuIotrait), synchronous andasyncmodes, DfuSe memory layouts. - dfu-nusb 0.2.0 (async, on nusb 0.2) and dfu-libusb 0.6.2: same licence.
- webdfu: ISC, JavaScript, unmaintained.
Decision: reuse dfu-core over nanoflash’s USB transport (nusb natively and in the
browser).
UF2
- Specification: microsoft/uf2 (MIT); family identifiers in
uf2families.json. RP20400xe48bff56, absolute0xe48bff57, data0xe48bff58, RP2350 Arm secure0xe48bff59, RP2350 RISC-V0xe48bff5a, RP2350 Arm non-secure0xe48bff5b; they match pico-sdkboot/uf2.h. - Crates: uf2_block 0.1.0 (MIT OR Apache-2.0), uf2-decode 0.2.0 (MIT), uftwo 0.3.0 (MPL-2.0, not used).
- picotool 2.3.1: BSD-3-Clause.
Decision: encode blocks ourselves (a 32-byte header and a 476-byte payload; about 50 lines); native writes copy the file onto the mounted drive, the browser writes through the File System Access API (a directory picker on the board’s drive).
CMSIS-DAP and Nordic serial DFU (later)
- The
probe-rscrate, in the command only. There is no CMSIS-DAP route in the browser: on 2026-11-30 the browser route through probe-rs was judged a dead end, because its WebAssembly build is several MB, over the limit of 256000 bytes of a module, and upstream did not take the proposed changes. DAPjs (MIT, JavaScript) would be a second engine, which is an anti-goal. - Nordic serial DFU: no Rust implementation surveyed in depth; to be revisited when the backend is scheduled.
Partition tables and file system images
| Need | Crate | Licence | no_std |
|---|---|---|---|
| Espressif partition table | esp-idf-part 0.6.0 | MIT OR Apache-2.0 | no (CSV, regex, deku) |
| MBR | mbrman 0.7.0 | MIT OR Apache-2.0 | yes (new in 0.7) |
| GPT | gpt_disk_types 0.16.1 | MIT OR Apache-2.0 | yes |
| GPT (reading, tests) | gpt 4.1.0 | MIT | no |
| FAT image | fatfs 0.3.6 | MIT | 0.4 (unreleased) |
| LittleFS image | littlefs2 0.8.1 | MIT OR Apache-2.0 | yes, but wraps C (littlefs2-sys) |
esp-idf-part needs std, and both the Espressif table (32-byte entries plus an MD5 row) and
the MBR (four 16-byte entries) are small fixed formats, so nanoflash writes them itself, no_std,
and uses esp-idf-part, mbrman, ESP-IDF’s gen_esp32part.py and sfdisk in tests to read its
output back. LittleFS image building stays native only (C toolchain); the browser accepts an
image built elsewhere.
Transports
| Need | Native | Browser |
|---|---|---|
| Serial | serialport 4.10.1 (MPL-2.0, used as a dependency, never copied) | web-sys Web Serial (behind web_sys_unstable_apis); no maintained wrapper crate, so nanoflash writes a thin one. serialport’s Web Serial work (#165, PR #224 closed) did not land. |
| USB | nusb 0.2.9 (Apache-2.0 OR MIT) | nusb’s WebUSB backend (#199, since 0.2.6, async API only, --cfg=web_sys_unstable_apis) |
| Mass storage (UF2) | std::fs | File System Access API |
Web Serial and WebUSB are implemented by Chromium-based browsers only; the command line is the fallback everywhere else.
esp-web-tools manifest
Documented at esphome.github.io/esp-web-tools, types
in src/const.ts:
- top level:
name,version,home_assistant_domain?,funding_url?,new_install_prompt_erase?,new_install_skip_erase?(deprecated),new_install_improv_wait_time?,builds[]; - build:
chipFamily(ESP32,ESP32-C2,ESP32-C3,ESP32-C5,ESP32-C6,ESP32-C61,ESP32-H2,ESP32-P4,ESP32-S2,ESP32-S3,ESP8266),parts[]withpath(relative to the manifest, or a URL) andoffset, andserialType?(cdcoruart, in the code only).
Licences of reference implementations
| Reference | Licence | How nanoflash uses it |
|---|---|---|
| espflash | MIT OR Apache-2.0 | reference for the loader; chip constants copied with attribution |
| esptool-js | Apache-2.0 | reference for reset sequences in the browser |
| esptool (Python) | GPL-2.0-or-later | not used |
| esp-flasher-stub | Apache-2.0 OR MIT | stubs, later |
| BOSSA, arduino/BOSSA | BSD-3-Clause | behaviour reference, no code ported |
| ArduinoCore-samd bootloader | LGPL-2.1 | protocol reference only, not vendored |
| avrdude | GPL-2.0-or-later | behaviour reference only, no code ported |
| Optiboot | GPL-2.0 | behaviour reference only (on the board), no code ported |
| ATmegaBOOT, the wiring bootloader (ArduinoCore-avr) | GPL-2.0-or-later | behaviour reference only (on the board), no code ported |
| Caterina (ArduinoCore-avr) | derived from LUFA | behaviour reference only (on the board), no code ported |
| simavr | GPL-3.0 | test tool only, installed or downloaded at test time, never distributed |
| ihex | MIT OR Apache-2.0 | test-only dependency |
| dfu-core | MIT OR Apache-2.0 | dependency |
| microsoft/uf2 | MIT | specification and family identifiers |
| pico-sdk | BSD-3-Clause | family identifiers (cross-check) |
| probe-rs | MIT OR Apache-2.0 | dependency (later) |
| DAPjs | MIT | not used |
| serialport | MPL-2.0 | dependency only |
| Arduino Cloud Agent | AGPL-3.0 | not used |
nanoflash itself is licensed MIT OR Apache-2.0.
What could go upstream
- espflash: an asynchronous transport trait (issue #1091), once nanoflash’s loop has run on hardware. This would let espflash itself run in the browser.
- probe-rs: nothing. The route through asynchronous probes for WebUSB (#2958) is closed.
- esp-idf-part:
no_stdsupport, so the Espressif writer can move next to the others.