aboutsummaryrefslogtreecommitdiffstats
path: root/src/atsamd/main.c
diff options
context:
space:
mode:
authorKevin O'Connor <kevin@koconnor.net>2022-09-30 17:36:42 -0400
committerKevin O'Connor <kevin@koconnor.net>2022-10-13 11:27:14 -0400
commit0a9becc39110c397b5cf2adfe69f369f70cb8925 (patch)
treea01e160184173dd2c20279697c6b888e730fdc5a /src/atsamd/main.c
parentbdf79caac422b019f6e61e2787005c2359165499 (diff)
downloadkutter-0a9becc39110c397b5cf2adfe69f369f70cb8925.tar.gz
kutter-0a9becc39110c397b5cf2adfe69f369f70cb8925.tar.xz
kutter-0a9becc39110c397b5cf2adfe69f369f70cb8925.zip
atsamd: Move bootloader_request() from usbserial.c to main.c
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
Diffstat (limited to 'src/atsamd/main.c')
-rw-r--r--src/atsamd/main.c18
1 files changed, 18 insertions, 0 deletions
diff --git a/src/atsamd/main.c b/src/atsamd/main.c
index d3943e6a..37b6cc8b 100644
--- a/src/atsamd/main.c
+++ b/src/atsamd/main.c
@@ -5,9 +5,27 @@
// This file may be distributed under the terms of the GNU GPLv3 license.
#include "board/armcm_boot.h" // armcm_main
+#include "board/misc.h" // bootloader_request
+#include "board/io.h" // writel
+#include "board/irq.h" // irq_disable
#include "internal.h" // SystemInit
#include "sched.h" // sched_main
+void
+bootloader_request(void)
+{
+ if (!CONFIG_FLASH_START)
+ return;
+ // Bootloader hack
+ irq_disable();
+#if CONFIG_MACH_SAMD21
+ writel((void*)0x20007FFC, 0x07738135);
+#elif CONFIG_MACH_SAMX5
+ writel((void*)(HSRAM_ADDR + HSRAM_SIZE - 4), 0xf01669ef);
+#endif
+ NVIC_SystemReset();
+}
+
// Main entry point - called from armcm_boot.c:ResetHandler()
void
armcm_main(void)