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
- Variables
- func Archive(pack, out string) (string, error)
- func CompilerBin(buildDir string) (string, error)
- func ConfigDefines(path string) ([]string, error)
- func Find(chip string) (string, error)
- func Install(archive string) (string, error)
- func ProfileHash(pack string) (string, error)
- func Root() string
- type App
- type FlashPart
- type ImageDiff
- type Provenance
- type Result
- type Source
- type Spec
- type Tools
Constants ¶
const SpecFile = "build.json"
SpecFile is the pack's build description, at the pack root.
Variables ¶
var OptimizeFlags = map[string]string{"debug": "-Og", "size": "-Os", "speed": "-O2"}
OptimizeFlags maps volt.toml's optimize setting to GCC flags.
Functions ¶
func Archive ¶
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 ¶
CompilerBin returns the compiler bin dir an ESP-IDF build used.
func ConfigDefines ¶
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 Install ¶
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 ¶
ProfileHash identifies a pack's configuration: the defines of its sdkconfig.h (see ConfigDefines).
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 ¶
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 ¶
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.