aboutsummaryrefslogtreecommitdiffstats
path: root/src/rp2040
diff options
context:
space:
mode:
authorKevin O'Connor <kevin@koconnor.net>2022-11-17 18:42:14 -0500
committerKevin O'Connor <kevin@koconnor.net>2022-11-19 10:13:50 -0500
commit8977c4e764688917689f1c2ac427d4cddcbe0515 (patch)
treef5bd595650285f09c238042efd17c8d853890dbe /src/rp2040
parentb9a378c1ca630ba72d19640e7dee2ec4aec971ea (diff)
downloadkutter-8977c4e764688917689f1c2ac427d4cddcbe0515.tar.gz
kutter-8977c4e764688917689f1c2ac427d4cddcbe0515.tar.xz
kutter-8977c4e764688917689f1c2ac427d4cddcbe0515.zip
rp2040: Fix watchdog enable
The rp2040 watchdog does not actually reset anything by default. The psm_hw->wdsel field must be programmed to actually get a reset on a watchdog failure. Program that field so the watchdog is usable. Also, disable the watchdog before attempting a reboot into the bootloader. Otherwise the machine may just reboot a second time due to a missed watchdog event in the bootloader. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
Diffstat (limited to 'src/rp2040')
-rw-r--r--src/rp2040/main.c3
1 files changed, 3 insertions, 0 deletions
diff --git a/src/rp2040/main.c b/src/rp2040/main.c
index eac3a0b9..c14e2759 100644
--- a/src/rp2040/main.c
+++ b/src/rp2040/main.c
@@ -9,6 +9,7 @@
#include "generic/armcm_reset.h" // try_request_canboot
#include "hardware/structs/clocks.h" // clock_hw_t
#include "hardware/structs/pll.h" // pll_hw_t
+#include "hardware/structs/psm.h" // psm_hw
#include "hardware/structs/resets.h" // sio_hw
#include "hardware/structs/watchdog.h" // watchdog_hw
#include "hardware/structs/xosc.h" // xosc_hw
@@ -30,6 +31,7 @@ DECL_TASK(watchdog_reset);
void
watchdog_init(void)
{
+ psm_hw->wdsel = PSM_WDSEL_BITS & ~(PSM_WDSEL_ROSC_BITS|PSM_WDSEL_XOSC_BITS);
watchdog_reset();
watchdog_hw->ctrl = (WATCHDOG_CTRL_PAUSE_DBG0_BITS
| WATCHDOG_CTRL_PAUSE_DBG1_BITS
@@ -46,6 +48,7 @@ DECL_INIT(watchdog_init);
void
bootloader_request(void)
{
+ watchdog_hw->ctrl = 0;
try_request_canboot();
// Use the bootrom-provided code to reset into BOOTSEL mode
reset_to_usb_boot(0, 0);