STM32 DFU not working through UART and USB

What behavior should be absolutely impossible. It’s like it’s jumping to random addresses. When you add

debug_init_break = 

in the platformio.ini and debug again, does it halt correctly in the Reset_Handler assembly? If you set a breakpoint in main() in the GDB (debug console) with b main and then use continue, does it hit main()?

1.5 pF for C1, C2 semes indeed a bit low for a 12.5pF crystal, but the LSE (32.768 kHz) crystal shouldn’t even be in use right now. The 24 MHz crystal is important to get USB running, as the USB clock needs to be a clean 48MHz. If your 25MHz crystal doesn’t swing due to too much or not enough load capacitance, then USB definitely won’t work correctly.

Using the C1, C2 = 2*CL – 2*Cstray formula referencing the other design

it was using a 6pF 32.768 kHz crystal with 1.5pF loading caps, and 8pF loading caps for a 9pF 25MHz crystal. That is approxiamely estimating Cstray to be 5pF.

What exact 24MHz crytal are you using?

I’ve seem to be using a 12pF YXC Crystal, using the formula and a Cstray of 5, i should be using a 14pF, yet…

I am using a 10p

I mean it should be close enough right? that means my Cstray needs to be 7pF. It feels like I am in the clear? (I am not sure)

Anyways, i have added debug_init_break =, for the first few times it worked great, just like you said, it halts at Reset_Handler assembly, b main + continue in GDB and it stops at main() (which i assume is what you meant when you say “hit main()”). I was able to press “step into” a couple of times too! Then i decided to reupload a couple of times, it does halt at Reset_Handler, and b main as usual, but then when i continue…

it stopped stopping at main()! Even weirder, i cant pause it now! i can only stop it! This is weird :frowning:

I tried not b main+continue -ing and i just started letting it run after it halts at Reset Handler, then after some time i paused it, it came to this place shown above, stopping at “afnum”, i pressed “step into” a couple of times, and also pause/continuing it, it doesn’t move or proceed, after a reupload, i did the same thing and it stopped at line 157 (if (pin==(PinName)NC) and still doesn’t proceed or move anywhere just like last time, then after another reupload, it stopped at line 561 on a curly bracket and still doesn’t move anywhere else

what?

My interpretation is that it just decided to be stuck somewhere for whatever reason, and never enters main, and probably has something to do with getting the pin info

Are you 100% sure you’re using the right debug configuration that’s just “PIO Debug (project name)” and not the “(without uploading)” or other configuration? The call stack and crash is inexplicable to me. It looks like it’s running a totally different firmware than what was built.