Parser for ESP32-family application images.
An image is an 8-byte header, a 16-byte extended header, the segments, padding and a checksum byte closing a 16-byte boundary, then an optional SHA256 digest. ESP8266 images have no extended header and are not supported.
Summary
Functions
Rewrites the flash mode, size and frequency bytes of a bootloader image.
Types
@type t() :: %Esp32.Image{ checksum: byte(), checksum_ok?: boolean(), chip: Esp32.Chip.name() | {:unknown, non_neg_integer()}, data_length: pos_integer(), entry_point: non_neg_integer(), flash_freq: 0..15, flash_mode: 0..3, flash_size: 0..15, hash_appended?: boolean(), segments: [%{offset: non_neg_integer(), data: binary()}] }
Functions
@spec patch_header(binary(), Esp32.Chip.name(), keyword()) :: {:ok, binary()} | {:error, term()}
Rewrites the flash mode, size and frequency bytes of a bootloader image.
Options :flash_mode (:qio | :qout | :dio | :dout), :flash_freq ("40m" …) and
:flash_size ("4MB" …) default to :keep. Binaries that are not images are
returned unchanged; an appended SHA256 digest is recomputed.