Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/Duet3D/RepRapFirmware.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Crocker <dcrocker@eschertech.com>2021-07-30 10:17:45 +0300
committerDavid Crocker <dcrocker@eschertech.com>2021-07-30 10:17:45 +0300
commit7c5ef6000bdeebfa8d51c0ead656ea554f1eb882 (patch)
tree170bd0a4bc3f8282d6a97f16498b356a64b2f925 /src/Hardware/ExceptionHandlers.cpp
parent7b0dde7831f35450b6c5c077b00821b118eb9570 (diff)
parentd7fd1866ffbfbb87229fa89ae2c7add48307cd8a (diff)
Merge branch 'v3-chrishamm' into 3.4-input-shaping
Diffstat (limited to 'src/Hardware/ExceptionHandlers.cpp')
-rw-r--r--src/Hardware/ExceptionHandlers.cpp9
1 files changed, 8 insertions, 1 deletions
diff --git a/src/Hardware/ExceptionHandlers.cpp b/src/Hardware/ExceptionHandlers.cpp
index 640c0a41..1413108d 100644
--- a/src/Hardware/ExceptionHandlers.cpp
+++ b/src/Hardware/ExceptionHandlers.cpp
@@ -15,6 +15,12 @@
# include <Reset.h>
#endif
+#if SAME5x
+// Magic address and value to launch the uf2 bootloader on failure, see inc/uf2.h in uf2-samdx1 repository
+# define DBL_TAP_PTR ((volatile uint32_t *)(HSRAM_ADDR + HSRAM_SIZE - 4))
+# define DBL_TAP_MAGIC 0xf01669ef // Randomly selected, adjusted to have first and last bit set
+#endif
+
// Perform a software reset. 'stk' points to the exception stack (r0 r1 r2 r3 r12 lr pc xPSR) if the cause is an exception, otherwise it is nullptr.
[[noreturn]] void SoftwareReset(SoftwareResetReason initialReason, const uint32_t *stk) noexcept
{
@@ -31,7 +37,8 @@
if (initialReason == SoftwareResetReason::erase)
{
#if SAME5x
- //TODO invalidate flash so the USB bootloader runs
+ // Start from uf2 bootloader next time. This pretends the reset button has been pressed twice in short succession
+ *DBL_TAP_PTR = DBL_TAP_MAGIC;
#else
EraseAndReset();
#endif