From a12f89d41217e0c53e5f059e9975ae0070af674c Mon Sep 17 00:00:00 2001 From: Kasper Lund Date: Wed, 7 Sep 2022 13:08:26 +0200 Subject: [PATCH] Use firmware.upgrade (#239) * Avoid direct use of esp32.deep_sleep * Pull in newer SDK * Address review feedback --- src/jaguar.toit | 17 +++++++++++------ third_party/toit | 2 +- 2 files changed, 12 insertions(+), 7 deletions(-) diff --git a/src/jaguar.toit b/src/jaguar.toit index b10067c2..ef9e0ba0 100644 --- a/src/jaguar.toit +++ b/src/jaguar.toit @@ -53,10 +53,15 @@ registry_ / ContainerRegistry ::= ContainerRegistry main arguments: try: catch --trace: registry_.start_installed - exception := catch --trace: serve arguments - logger.error "rebooting due to $(exception)" - finally: - esp32.deep_sleep (Duration --s=1) + serve arguments + finally: | is_exception exception | + // We shouldn't be able to get here without an exception having + // been thrown, but we play it defensively and force an exception + // if that should ever happen. + if not is_exception: unreachable + // Jaguar runs as a critical container, so an uncaught exception + // will cause the system to reboot. + logger.error "rebooting due to $exception.value" serve arguments: port := HTTP_PORT @@ -463,9 +468,9 @@ serve_incoming_requests socket/tcp.ServerSocket id/uuid.Uuid name/string address // TODO(kasper): Maybe we can share the way we try to close down // the HTTP server nicely with the corresponding code where we // handle /code requests? - writer.detach.close // Close connection nicely before rebooting. + writer.detach.close // Close connection nicely before upgrading. sleep --ms=500 - esp32.deep_sleep (Duration --ms=10) + firmware.upgrade // Validate SDK version before attempting to run code. else if sdk_version_header != vm_sdk_version: diff --git a/third_party/toit b/third_party/toit index 4d4d07c1..f6f0239b 160000 --- a/third_party/toit +++ b/third_party/toit @@ -1 +1 @@ -Subproject commit 4d4d07c12a7c42f79829357c0dd85738e2b0d3b1 +Subproject commit f6f0239b5278b31f2e2e04b0b6bf339c37d2dd9e