Build epoch in info, flash-status command, cmake version embedding

This commit is contained in:
Ian Gulliver
2026-04-12 09:02:31 +09:00
parent 21c7900444
commit a41ee70a3c
9 changed files with 85 additions and 5 deletions

View File

@@ -113,7 +113,7 @@ func closeTargets(targets []target) {
func main() {
if len(os.Args) < 2 {
fmt.Fprintf(os.Stderr, "usage: picomap <command> [args...]\n\ncommands:\n info\n load\n log\n reboot\n picoboot\n test\n")
fmt.Fprintf(os.Stderr, "usage: picomap <command> [args...]\n\ncommands:\n info\n flash-status\n load\n log\n reboot\n picoboot\n test\n")
os.Exit(1)
}
cmd := os.Args[1]
@@ -123,6 +123,8 @@ func main() {
switch cmd {
case "info":
err = cmdInfo(args)
case "flash-status":
err = cmdFlashStatus(args)
case "load":
err = cmdLoad(args)
case "log":
@@ -134,7 +136,7 @@ func main() {
case "test":
err = cmdTestGroup(args)
default:
fmt.Fprintf(os.Stderr, "usage: picomap <command> [args...]\n\ncommands:\n info\n load\n log\n reboot\n picoboot\n test\n")
fmt.Fprintf(os.Stderr, "usage: picomap <command> [args...]\n\ncommands:\n info\n flash-status\n load\n log\n reboot\n picoboot\n test\n")
os.Exit(1)
}
if err != nil {
@@ -150,7 +152,8 @@ func printInfo(via string, info *client.ResponseInfo) {
"mac", net.HardwareAddr(info.MAC[:]).String(),
"ip", net.IP(info.IP[:]).String(),
"firmware", info.FirmwareName,
"boot", info.Boot.String())
"boot", info.Boot.String(),
"build_epoch", info.BuildEpoch)
}
func cmdInfo(args []string) error {
@@ -204,6 +207,31 @@ func cmdLog(args []string) error {
return nil
}
func cmdFlashStatus(args []string) error {
fs := flag.NewFlagSet("flash-status", flag.ExitOnError)
tf := addTargetFlags(fs)
fs.Parse(args)
targets, err := tf.connect(500 * time.Millisecond)
if err != nil {
return err
}
defer closeTargets(targets)
for _, t := range targets {
status, err := t.client.FlashStatus()
if err != nil {
slog.Error("flash-status error", "via", t.name, "err", err)
continue
}
slog.Info("flash-status",
"via", t.name,
"boot_partition", status.BootPartition,
"boot_type", status.BootType)
}
return nil
}
func cmdReboot(args []string) error {
fs := flag.NewFlagSet("reboot", flag.ExitOnError)
tf := addTargetFlags(fs)