esptool

package
v0.2.4 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 1, 2026 License: AGPL-3.0 Imports: 23 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package esptool does in Go what Volt used Espressif's esptool (Python) for: making an app image from an ELF (elf2image) and writing images to a board. Output matches esptool 4.12 byte for byte.

Index

Constants

This section is empty.

Variables

View Source
var ErrConnect = errors.New("failed to connect")

ErrConnect is returned when the chip does not answer in download mode.

Functions

func Elf2Image

func Elf2Image(elfData []byte, o ImageOptions) ([]byte, error)

Elf2Image makes an app image from an ELF, as esptool elf2image does.

func Probe

func Probe(ctx context.Context, port string) bool

Probe reports whether an ESP32 in download mode answers on port, without resetting it (esptool --before no_reset chip_id): a live chip, rather than a bare USB-serial bridge or a board running firmware.

func WriteFlash

func WriteFlash(ctx context.Context, o FlashOptions) error

WriteFlash writes parts to the chip on o.Port as esptool write_flash does with the default options (default_reset, stub, compressed, verified, then hard_reset).

Types

type Chip

type Chip struct {
	Name        string
	ImageChipID uint16
	IROM, DROM  [2]uint32 // flash-mapped [start, end)
	IROMAlign   int       // MMU page size
	MemoryMap   []memRange
	FlashSizes  map[string]byte
	FlashFreqs  map[string]byte
}

Chip holds what image making needs to know about a chip.

func ChipByName

func ChipByName(name string) (*Chip, error)

ChipByName returns a supported chip.

type FlashOptions

type FlashOptions struct {
	Chip                            *Chip
	Port                            string
	Baud                            int // after the stub runs (ROM talks 115200)
	FlashMode, FlashFreq, FlashSize string
	Parts                           []FlashPart
	// Progress reports done/total bytes written, over all parts.
	Progress func(msg string, done, total int)
	// Full writes every part even when flash already holds it.
	Full bool
	// Skipped, if set, is told about each part left alone because flash
	// already held it.
	Skipped func(FlashPart)
	Log     io.Writer // optional protocol log
}

FlashOptions are write_flash's settings.

type FlashPart

type FlashPart struct {
	Offset uint32
	Data   []byte
	Name   string // for messages
}

FlashPart is one image written at an offset.

type ImageOptions

type ImageOptions struct {
	Chip                            *Chip
	FlashMode, FlashFreq, FlashSize string
	ELFSHA256Offset                 int // 0: none
	MinRev                          uint8
	MinRevFull, MaxRevFull          uint16
}

ImageOptions are elf2image's settings.

func ParseElf2ImageArgs

func ParseElf2ImageArgs(args []string) (ImageOptions, error)

ParseElf2ImageArgs reads esptool's "--chip c elf2image …" arguments, as a pack's build.json records them. Any other argument is an error, so a pack asking for something this port does not do fails instead of differing.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL