Migrate from esptool, bossac or avrdude
nanoflash replaces the flashing tool of each family with one command and one manifest per project. This page maps the usual commands of esptool, bossac and avrdude to nanoflash.
From esptool
Write the offsets of the images in a board manifest once, or give each image a partition of a layout:
[[board]]
identifier = "my-board"
protocol = "espressif"
chip = "esp32-s3"
[[board.image]]
offset = 0x0
path = "build/bootloader/bootloader.bin"
[[board.image]]
offset = 0x8000
path = "build/partition_table/partition-table.bin"
[[board.image]]
offset = 0x10000
path = "build/hello_world.bin"
esptool 5 writes its commands with hyphens (write-flash), and esptool 4 with underscores
(write_flash).
| esptool | nanoflash |
|---|---|
write-flash <offset> <file> ... | nanoflash flash --board <manifest> |
erase-flash before a write | nanoflash flash --board <manifest> --erase-all |
chip-id, flash-id | nanoflash detect --port <port> |
merge-bin | nanoflash image build --board <manifest> --output <file> |
| An esp-web-tools manifest | Use it as it is: nanoflash flash --board manifest.json |
--baud | --baud-rate (USB-Serial-JTAG boards and the ESP32-C2 stay at 115200 baud, see Espressif) |
--port | --port, or nothing when only one port suits the board |
These esptool commands have no equivalent: read-flash, verify-flash, read-mac, image-info
and elf2image. nanoflash has no command that reads the flash. erase-region is an
[[board.erase]] entry of the manifest.
With a layout, nanoflash also generates the partition table, so the manifest does not list it. Do not list the image of the partition table with a layout whose partitions grow with the flash.
nanoflash does not patch the bootloader header (flash size, mode, frequency) and does not
initialise otadata. Build the bootloader with the right header, and list an image or an erase
entry for otadata when you need it reset.
From bossac (Nano 33 BLE, SAMD21)
| bossac | nanoflash |
|---|---|
bossac -d --port=<name> -U -i -e -w -v <bin> -R | nanoflash flash --board <manifest> --port <port> --json |
bossac -U -R (leave the bootloader) | nanoflash detect --port <bootloader port> --protocol samba |
-iprints the device information: the output offlashanddetectalready names the chip and the flash.-esendsXfrom the start of the application, which erases nothing on the bootloader of the Nano 33 BLE: the writes erase the pages.nanoflash flashdoes the same by default.--erase-allis the stricter equivalent: it clears the whole application area with0xFFpages (slower), for when stale bytes after the image must go.- The touch, the wait for the bootloader and the reset happen inside
flash. The port may be the port of the sketch or of the bootloader. - Exit code 2 replaces “No device found”, and exit code 3 a failed verification.
A manifest for a firmware with its own USB identity lists:
application-devices = [{ vendor = 0x1209, product = 0x0001 }](its pid.codes identity, for a firmware that enters the bootloader onbaud == 1200 && !dtr);bootloader-devices = [{ vendor = 0x2341, product = 0x005a }];- an image at
offset = 0x10000of the.binfile, or the ELF file itself.
nanoflash layout write --format linker or the constants of the build feature give the same
FLASH region as a hand-written memory.x.
A Cargo runner that calls objcopy and bossac
A firmware that Cargo flashes with a runner that calls objcopy and bossac can use
nanoflash run instead. The runner takes the ELF file, so the conversion is not needed.
-
Add a board manifest and a layout file (copy the ones of
examples/nano33ble/board), and name the manifest in[package.metadata.nanoflash]. -
List the USB identities of the board in
application-devicesandbootloader-devices. The touch at 1200 baud moves the board from the first to the second. An Arduino board with a 1200-baud touch shows the entries of the Nano 33 BLE. Add the identity of your firmware toapplication-deviceswhen it has its own. -
Replace the runner in
.cargo/config.tomlwithnanoflash run. When the serial port of the application speaks a binary protocol and not text, usenanoflash run --no-monitor, which only flashes.
From avrdude (Uno, Nano, Mega 2560, Leonardo)
avrdude -p<mcu> -c<protocol> -P<port> -b<speed> -D -Uflash:w:<file>.hex:i becomes:
$ nanoflash flash --board <manifest> --port <port> --json
-D(no chip erase) is the default behaviour: pages are erased as they are written.- The chip and the protocol come from the manifest.
-b<speed>is--baud-rate. Without it, nanoflash tries the usual rates of the bootloader (see Supported boards).-carduinoisprotocol = "stk500v1"(or"arduino"),-cwiringis"stk500v2"(or"wiring"), and-cavr109is"avr109". - The image is the same
.hexfile. - nanoflash reads back every page that it writes.