sdk

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 sdk makes and uses prebuilt ESP-IDF packs: everything an ESP32 firmware build needs from ESP-IDF (component archives, headers, linker scripts, bootloader, partition table, exact flags), harvested from one real ESP-IDF build of a reference project. A Volt build with a pack compiles only Volt's own files and links; no CMake, Ninja or ESP-IDF source.

Index

Constants

View Source
const SpecFile = "build.json"

SpecFile is the pack's build description, at the pack root.

Variables

View Source
var OptimizeFlags = map[string]string{"debug": "-Og", "size": "-Os", "speed": "-O2"}

OptimizeFlags maps volt.toml's optimize setting to GCC flags.

Functions

func Archive

func Archive(pack, out string) (string, error)

Archive writes pack dir as a reproducible tar.gz (sorted entries, fixed times and owners, top-level dir named after the pack) and returns its SHA-256.

func CompilerBin

func CompilerBin(buildDir string) (string, error)

CompilerBin returns the compiler bin dir an ESP-IDF build used.

func ConfigDefines

func ConfigDefines(path string) ([]string, error)

ConfigDefines returns an sdkconfig.h's #define lines, sorted, without CONFIG_IDF_INIT_VERSION: it records which ESP-IDF first wrote the sdkconfig, not a build setting.

func Find

func Find(chip string) (string, error)

Find returns the installed pack for chip; with several, the newest built.

func Install

func Install(archive string) (string, error)

Install unpacks a pack archive into Root, replacing an installed copy, and returns its dir. A <archive>.sha256 next to it, when present, must match.

func ProfileHash

func ProfileHash(pack string) (string, error)

ProfileHash identifies a pack's configuration: the defines of its sdkconfig.h (see ConfigDefines).

func Root

func Root() string

Root is where installed packs live (toolchain.SdkRoot): the toolchain installs them from the manifest, `volt sdk install` from a file.

Types

type App

type App struct {
	Name      string   // app name; output is <Out>/<Name>.{elf,bin,map}
	Version   string   // PROJECT_VER in the app descriptor ("1" if empty)
	Project   string   // generated project dir, mapped to "." in __FILE__
	Sources   []string // Volt's C files in ESP-IDF's libmain.a order: main.c, runtime, drivers
	Framework string   // Volt framework include dir
	Out       string
	Optimize  string   // replaces the pack's -O flag for Volt's sources ("" keeps it)
	Include   []string // headers force-included (-include) in Volt's sources, e.g. device libraries' header.h
}

App is one firmware to build with a pack.

type FlashPart

type FlashPart struct {
	Name   string `json:"name"` // bootloader, partition-table, app
	Offset string `json:"offset"`
	File   string `json:"file,omitempty"`
}

FlashPart is one image written at flash time. The app has no File: it is the project's own image.

type ImageDiff

type ImageDiff struct {
	Same, Loaded bool
	First        int // first differing offset outside those fields, or -1
}

ImageDiff compares two ESP app images. Same means byte-identical; Loaded means equal apart from the embedded ELF SHA-256 (at 0xb0) and the trailing checksum and digest, i.e. every byte the chip runs is the same.

func CompareImages

func CompareImages(a, b []byte) ImageDiff

type Provenance

type Provenance struct {
	Chip     string `json:"chip"`
	Compiler string `json:"compiler"` // first line of gcc --version
	BuiltAt  string `json:"built_at"`
}

Provenance is a pack's provenance.json.

type Result

type Result struct {
	ELF, Bin, Map        string
	Units, Compiled      int      // C files, and how many were out of date
	Linked               bool     // false: everything was up to date
	Warnings             []string // compiler output of successful compiles
	Compile, Link, Image time.Duration
}

Result is a finished pack build.

func Build

func Build(ctx context.Context, pack string, s *Spec, app App, t Tools) (*Result, error)

Build compiles app's sources with the pack's flags, links them against the pack and makes the app image. Work is incremental: an object is rebuilt only when its compiler, arguments, source or any header it included changed, and the ELF and image only when an object or the link line did.

type Source

type Source struct {
	BuildDir  string // <project>/build (holds build.ninja)
	IDF       string // IDF_PATH
	Framework string // Volt framework include dir (not packed: {framework})
	Profile   string // the sdkconfig the reference was built with
}

Source is a finished ESP-IDF build of the reference project.

type Spec

type Spec struct {
	Format     int    `json:"format"`
	Chip       string `json:"chip"`
	IDFVersion string `json:"idf_version"`
	ToolPrefix string `json:"tool_prefix"` // e.g. xtensa-esp32-elf-

	// Compiling Volt's files (generated main.c, runtime, drivers).
	CFlags   []string `json:"cflags"`
	Includes []string `json:"includes"` // in order, as -I

	// AppDesc is ESP-IDF's app descriptor: it embeds the project name and
	// build time, so it is compiled per project into its own archive.
	AppDesc struct {
		Src  string   `json:"src"`
		Args []string `json:"args"` // compiler args, without -c/-o
	} `json:"app_desc"`

	// Link is ESP-IDF's link line: <cxx> Flags LDFlags ElfSrc -o x.elf
	// LibPath Libs.
	Link struct {
		Flags   []string `json:"flags"`
		LDFlags []string `json:"ldflags"`
		ElfSrc  string   `json:"elf_src"`
		LibPath []string `json:"lib_path"`
		Libs    []string `json:"libs"`
	} `json:"link"`

	// Elf2Image are ESP-IDF's esptool arguments ("--chip c elf2image …"),
	// without -o and the ELF.
	Elf2Image []string `json:"elf2image"`

	FlashSettings map[string]string `json:"flash_settings"` // flash_mode, flash_freq, flash_size
	Flash         []FlashPart       `json:"flash"`
}

Spec is build.json. Paths and arguments may hold placeholders, expanded at build time: {pack} the pack dir, {project} the generated project dir (the prefix ESP-IDF maps to "." in __FILE__), {framework} Volt's framework include dir, {name}/{version} the app name and version, {map} the link map, {app} the archive of Volt's objects (ESP-IDF's libmain.a) and {app_desc} the per-project app descriptor archive.

func Harvest

func Harvest(src Source, out string) (*Spec, error)

Harvest writes a pack into out (which must not exist) from a reference build, returning its spec.

func LoadSpec

func LoadSpec(pack string) (*Spec, error)

LoadSpec reads a pack's build.json.

type Tools

type Tools struct {
	Bin string    // compiler bin dir (holds <tool_prefix>gcc)
	Log io.Writer // optional: every command and its output
}

Tools are the host programs a pack build runs.

Jump to

Keyboard shortcuts

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