Initial Release
This commit is contained in:
13
system/double_tap_usb_boot/CMakeLists.txt
Normal file
13
system/double_tap_usb_boot/CMakeLists.txt
Normal file
@@ -0,0 +1,13 @@
|
||||
add_library(double_tap_usb_boot INTERFACE)
|
||||
|
||||
# inclusion of this library will allow you to double tap reset within 100ms to launch into bootrom USB bootloader
|
||||
if (PICO_ON_DEVICE)
|
||||
target_sources(double_tap_usb_boot INTERFACE
|
||||
${CMAKE_CURRENT_LIST_DIR}/double_tap_usb_boot.c
|
||||
)
|
||||
|
||||
target_link_libraries(double_tap_usb_boot INTERFACE
|
||||
pico_bootrom
|
||||
pico_time
|
||||
)
|
||||
endif ()
|
||||
36
system/double_tap_usb_boot/double_tap_usb_boot.c
Normal file
36
system/double_tap_usb_boot/double_tap_usb_boot.c
Normal file
@@ -0,0 +1,36 @@
|
||||
#include "pico.h"
|
||||
#include "pico/time.h"
|
||||
#include "pico/bootrom.h"
|
||||
|
||||
// Allow user override of the LED mask
|
||||
#ifndef USB_BOOT_LED_ACTIVITY_MASK
|
||||
#define USB_BOOT_LED_ACTIVITY_MASK 0
|
||||
#endif
|
||||
|
||||
// Doesn't make any sense for a RAM only binary
|
||||
#if !PICO_NO_FLASH
|
||||
static const uint32_t magic_token[] = {
|
||||
0xf01681de, 0xbd729b29, 0xd359be7a,
|
||||
};
|
||||
|
||||
static uint32_t __uninitialized_ram(magic_location)[count_of(magic_token)];
|
||||
|
||||
// run at initialization time
|
||||
static void __attribute__((constructor)) boot_double_tap_check() {
|
||||
for (uint i = 0; i < count_of(magic_token); i++) {
|
||||
if (magic_location[i] != magic_token[i]) {
|
||||
// Arm for 100 ms then disarm and continue booting
|
||||
for (i = 0; i < count_of(magic_token); i++) {
|
||||
magic_location[i] = magic_token[i];
|
||||
}
|
||||
busy_wait_us(100000);
|
||||
magic_location[0] = 0;
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
magic_location[0] = 0;
|
||||
reset_usb_boot(USB_BOOT_LED_ACTIVITY_MASK, 0);
|
||||
}
|
||||
|
||||
#endif
|
||||
Reference in New Issue
Block a user