Build and run for embeded

This commit is contained in:
Li Jie
2025-09-05 17:47:34 +08:00
parent df8f67db5a
commit 5e5d5c2a83
9 changed files with 828 additions and 288 deletions

View File

@@ -20,6 +20,18 @@ func MakeFirmwareImage(infile, outfile, format, fmtDetail string) error {
return fmt.Errorf("unsupported firmware format: %s", format)
}
// ExtractFileFormatFromEmulator extracts file format from emulator command template
// Returns the format if found (e.g. "bin", "hex", "zip", "img"), empty string if not found
func ExtractFileFormatFromEmulator(emulatorCmd string) string {
formats := []string{"bin", "hex", "zip", "img", "uf2"}
for _, format := range formats {
if strings.Contains(emulatorCmd, "{"+format+"}") {
return format
}
}
return ""
}
// GetFileExtFromFormat converts file format to file extension
func GetFileExtFromFormat(format string) string {
switch format {
@@ -33,6 +45,8 @@ func GetFileExtFromFormat(format string) string {
return ".uf2"
case "zip":
return ".zip"
case "img":
return ".img"
default:
return ""
}
@@ -47,7 +61,7 @@ func ConvertOutput(infile, outfile, binaryFormat, fileFormat string) error {
return nil
}
// Only support conversion to hex format
// Only support conversion to hex and format
if fileFormat == "hex" {
return convertToHex(infile, outfile)
}