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 ¶
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 ¶
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.
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 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.