From 3ecee8e20811fc8cad664d40db9ad39dcafd09b8 Mon Sep 17 00:00:00 2001 From: Al Cutter Date: Fri, 15 Mar 2024 14:25:29 +0000 Subject: [PATCH] Fix rebooting --- trusted_os/rpc.go | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/trusted_os/rpc.go b/trusted_os/rpc.go index 23094c2..691969e 100644 --- a/trusted_os/rpc.go +++ b/trusted_os/rpc.go @@ -282,7 +282,12 @@ func (r *RPC) InstallApplet(b *rpc.FirmwareUpdate, _ *bool) error { return err } r.Ctx.Stop() - <-r.Ctx.Done() + // This must be done in a go-routine because the ExecCtx.Stop() above can only be + // actioned once the RPC has returned. + go func() { + <-r.Ctx.Done() + r.Reboot(nil, nil) + }() return r.Reboot(nil, nil) } @@ -292,8 +297,6 @@ var appletFirmwareBuffer []byte // Reboot resets the system. func (r *RPC) Reboot(_ *any, _ *bool) error { log.Printf("SM rebooting") - // Reduce Watchdog timeout for a faster reboot: - imx6ul.WDOG2.Service(500) usbarmory.Reset() return nil