Keyboard shortcuts

Press ← or → to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Supported boards and protocols

nanoflash flashes these chips natively and in the browser. Each protocol is one backend and, in the browser, one WebAssembly module (the three AVR protocols share the avr module).

Summary

Protocol (protocol =)Chips (chip =)BoardsVerifyImages
espressifesp32, esp32-s2, esp32-s3, esp32-c2, esp32-c3, esp32-c5, esp32-c6, esp32-h2, esp32-p4Any board with an Espressif chip, through its ROM loaderMD5Binary, Intel HEX, ELF (application image)
sambanrf52840Arduino Nano 33 BLECRC-16 (Z)Binary, Intel HEX, ELF
sambasamd21g18a, samd21j18a, samd21e18aArduino SAMD21 boards, such as the MKR WiFi 1010CRC-16 (Z)Binary, Intel HEX, ELF
stk500v1 (alias arduino)atmega328pArduino Uno, Nano, Pro Mini (Optiboot, ATmegaBOOT)Read-backBinary, Intel HEX, ELF
stk500v2 (alias wiring)atmega2560Arduino Mega 2560 (the wiring bootloader)Read-backBinary, Intel HEX, ELF
avr109atmega32u4Arduino Leonardo, Micro, Pro Micro (Caterina)Read-backBinary, Intel HEX, ELF

The browser package reads binary and Intel HEX images only: its WebAssembly modules do not have the elf feature. The ESP8266 is not supported. USB DFU, UF2, CMSIS-DAP (in the command only) and Nordic serial DFU are planned.

Espressif

  • The board resets into its ROM loader through DTR and RTS (espressif-classic, through a UART bridge) or through the USB-Serial-JTAG peripheral (espressif-usb-serial-jtag, USB identity 303a:1001).
  • The default baud rate is 460800 through a UART bridge. USB-Serial-JTAG and the ESP32-C2 stay at 115200 baud. When the caller asks for another rate on one of them, the flash goes on at 115200 baud and nanoflash reports a note with the reason. The USB-Serial-JTAG peripheral has no baud rate. The ESP32-C2 ROM loader computes its rates for a 40 MHz crystal, which many boards replace with a 26 MHz one. A request for 115200 baud gives no note.
  • Writes are compressed, except on the ESP32. No flasher stub is used: the ROM supports compressed writes and MD5.
  • In secure download mode, the ROM refuses SPI_FLASH_MD5, so what was written is not read back (not-verified-in-secure-download-mode).
  • An ELF image goes to a firmware or update partition at a multiple of 0x10000. The command turns it into an application image with espflash 4.7. The library and the browser package refuse ELF images on Espressif.
  • With a detect layout, build the bootloader for the flash size or with flash size detection.

SAM-BA (Arduino Nano 33 BLE, SAMD21)

  • A 1200-baud touch on the port of the sketch starts the bootloader, which appears as another USB device. The Nano 33 BLE goes from 2341:805a to 2341:005a. nanoflash waits up to 15 s for it.
  • nanoflash writes and checks the images with CRC-16, then resets into the application.
  • The bootloader at the start of flash is never written. writable_from is 0x10000 on the Nano 33 BLE and 0x2000 on the SAMD21 boards.
  • The SAMD21 bootloader erases more than it writes. What flash erases describes it.
  • --baud-rate is ignored.

AVR (Arduino Uno, Nano, Mega 2560, Leonardo)

  • Arduino’s AVR boards take the .hex file that the Arduino IDE builds.
  • STK500v1 (Uno, Nano, Pro Mini): a pulse on DTR resets the board into Optiboot or the older ATmegaBOOT. nanoflash tries 115200 baud, then 57600 (the old Nano bootloader).
  • STK500v2 (Mega 2560): the same pulse resets the board into the wiring bootloader, at 115200 baud only. It never erases above 0x3BFFF, so the application ends at 0x3C000, and its erase order limits the order of the images (What flash erases).
  • AVR109 (Leonardo, Micro, Pro Micro): a 1200-baud touch starts Caterina, which shows up on its own port (2341:8036 becomes 2341:0036 on a Leonardo). Caterina goes back to the sketch 8 s after the touch, so nanoflash waits 7 s for it natively and 5 s in the browser. --baud-rate is ignored.
  • Pages are written whole and read back to check them. The bootloader at the top of the flash is never written: writable_to is 0x7E00 on an Uno with Optiboot.
  • The bootloaders have no usable chip erase, so “erased” means “programmed with 0xFF”.

USB identities that detect knows

Without --protocol, detect picks the protocol from the USB identity of the port:

USB identityProtocol
Uno: 2341:0043, 2341:0001, 2a03:0043, 2341:0243, 2341:006a and kinstk500v1
Mega 2560: 2341:0010, 2341:0042 and their 2a03 and 02xx variantsstk500v2
Leonardo, Micro and other ATmega32U4 boards: 2341:8036, 2341:0036 and kin, with Adafruit’s and SparkFun’savr109
Any other product of vendor 0x2341samba
Vendor 0x303aespressif

A Nano or a Pro Mini behind a serial bridge (FTDI, CH340) has no known identity: pass --protocol, or a board manifest whose board lists no devices.