Watchdog timer, boot reason tracking, net_poll frame limit, reboot/picoboot CLI commands

This commit is contained in:
Ian Gulliver
2026-04-12 08:27:21 +09:00
parent 6c3e0757f9
commit 21c7900444
7 changed files with 25 additions and 9 deletions

View File

@@ -9,16 +9,25 @@
static constexpr uint32_t XIP_BASE_ADDR = 0x10000000;
static constexpr uint32_t FLASH_SIZE = 2 * 1024 * 1024;
static constexpr uint32_t REBOOT_MAGIC = 0x504D5242;
static boot_reason detected_boot_reason;
static void poke_watchdog() {
watchdog_update();
dispatch_schedule_ms(500, poke_watchdog);
}
void handlers_init() {
if (watchdog_hw->scratch[0] == REBOOT_MAGIC)
detected_boot_reason = boot_reason::request_reboot;
auto val = static_cast<boot_reason>(watchdog_hw->scratch[0]);
if (val == boot_reason::request_reboot || val == boot_reason::watchdog)
detected_boot_reason = val;
else
detected_boot_reason = boot_reason::cold_boot;
watchdog_hw->scratch[0] = 0;
watchdog_hw->scratch[0] = static_cast<uint32_t>(boot_reason::watchdog);
watchdog_enable(1000, true);
}
void handlers_start() {
poke_watchdog();
}
std::optional<ResponsePICOBOOT> handle_picoboot(const responder&, const RequestPICOBOOT&) {
@@ -80,7 +89,7 @@ std::optional<ResponseFlashWrite> handle_flash_write(const responder&, const Req
std::optional<ResponseReboot> handle_reboot(const responder&, const RequestReboot&) {
dispatch_schedule_ms(100, []{
watchdog_hw->scratch[0] = REBOOT_MAGIC;
watchdog_hw->scratch[0] = static_cast<uint32_t>(boot_reason::request_reboot);
watchdog_reboot(0, 0, 0);
});
return ResponseReboot{};