From 868a0562be3ed398bed21643866f288e4ef09a4a Mon Sep 17 00:00:00 2001 From: shylie Date: Tue, 24 Feb 2026 20:16:18 -0500 Subject: [PATCH] Allow for resetting to USB bootsel via vendor-specific protocol --- CMakeLists.txt | 4 ++++ src/main.cpp | 7 +++++++ 2 files changed, 11 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index 395b907..f633e01 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -39,4 +39,8 @@ target_link_libraries(mtgcard PUBLIC pico_unique_id ) +target_compile_definitions(mtgcard PRIVATE + PICO_ENTER_USB_BOOT_ON_EXIT=1 +) + pico_add_extra_outputs(mtgcard) diff --git a/src/main.cpp b/src/main.cpp index 733ec79..7f1e192 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -6,6 +6,7 @@ #include #include +#include #include #include @@ -185,6 +186,12 @@ void tud_vendor_rx_cb(uint8_t itf, const uint8_t* buffer, uint16_t bufsize) return; } + // special command to reset to bootsel + if (buffer[0] == 0x99) + { + rom_reset_usb_boot(0, 0); + } + rx.state = RX::GETTING_CMC; rx.card_index = CardSlot::get_unused(flash);