binary-format supports uf2, nrf-dfu

This commit is contained in:
Li Jie
2025-08-23 10:24:18 +08:00
parent 508b23a584
commit e40bdc196b
12 changed files with 437 additions and 10 deletions

View File

@@ -5,10 +5,15 @@ import (
"strings"
)
func MakeFirmwareImage(infile, outfile, format string) error {
fmt.Printf("Creating firmware image from %s to %s with format %s\n", infile, outfile, format)
// MakeFirmwareImage creates a firmware image from the given input file.
func MakeFirmwareImage(infile, outfile, format, fmtDetail string) error {
if strings.HasPrefix(format, "esp") {
return makeESPFirmareImage(infile, outfile, format)
} else if format == "uf2" {
uf2Family := fmtDetail
return convertELFFileToUF2File(infile, outfile, uf2Family)
} else if format == "nrf-dfu" {
return makeDFUFirmwareImage(infile, outfile)
}
return fmt.Errorf("unsupported firmware format: %s", format)
}