From 81b5955a5c5c5b04eb334daafe1ec29821427c9e Mon Sep 17 00:00:00 2001 From: R Date: Mon, 6 Jul 2026 17:45:40 +0100 Subject: [PATCH] Perturb USB de-config to better match vendor behavior This was one of many changes along the path of discovering that `wfi` seems to just break USBD. This change is probably not necessary, but it feels more elegant. --- bootloader.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/bootloader.c b/bootloader.c index 659243c..36c0c42 100644 --- a/bootloader.c +++ b/bootloader.c @@ -995,8 +995,10 @@ __attribute__((naked)) int main(void) { while (!(STK_SR & 1)) {} STK_CTLR = 0; STK_SR = 0; - R16_USBD_CNTR = 0b11; R32_EXTEN_CTR &= ~(1 << 1); + R16_USBD_CNTR = 1; + R16_USBD_ISTR = 0; + R16_USBD_CNTR = 0b11; if (ADDRESS_HI >> 8 == 0x20) { // ram boot, go back to original clock settings R32_RCC_CFGR0 = (R32_RCC_CFGR0 & ~0b11) | 0b00;