Allow for resetting to USB bootsel via vendor-specific protocol

This commit is contained in:
shylie 2026-02-24 20:16:18 -05:00
parent 83e3b51b40
commit 868a0562be
2 changed files with 11 additions and 0 deletions

View File

@ -39,4 +39,8 @@ target_link_libraries(mtgcard PUBLIC
pico_unique_id pico_unique_id
) )
target_compile_definitions(mtgcard PRIVATE
PICO_ENTER_USB_BOOT_ON_EXIT=1
)
pico_add_extra_outputs(mtgcard) pico_add_extra_outputs(mtgcard)

View File

@ -6,6 +6,7 @@
#include <hardware/clocks.h> #include <hardware/clocks.h>
#include <pico/binary_info.h> #include <pico/binary_info.h>
#include <pico/bootrom.h>
#include <pico/stdlib.h> #include <pico/stdlib.h>
#include <tusb.h> #include <tusb.h>
@ -185,6 +186,12 @@ void tud_vendor_rx_cb(uint8_t itf, const uint8_t* buffer, uint16_t bufsize)
return; return;
} }
// special command to reset to bootsel
if (buffer[0] == 0x99)
{
rom_reset_usb_boot(0, 0);
}
rx.state = RX::GETTING_CMC; rx.state = RX::GETTING_CMC;
rx.card_index = CardSlot::get_unused(flash); rx.card_index = CardSlot::get_unused(flash);