When trying to load firmware with gdb it started throwing an error "PC register is not available"...
I'm trying to get usb working with Zig on the stm32 and somehow flashing stopped working... This is the output from gdb:
Reading symbols from firmware.elf...
Remote debugging using localhost:3333
PC register is not available
(gdb) load
You can't do that when your target is `exec'
The solution? Erase the flash and try again!
$ pyocd erase --target stm32g474retx --chip
0001545 I Erasing chip... [eraser]
0001749 I Done [eraser]
Now restart openocd/pyocd and load again
Reading symbols from firmware.elf...
Remote debugging using localhost:3333
0xfffffffe in ?? ()
(gdb) monitor reset halt
Resetting target with halt
Successfully halted device on reset
(gdb) load
Loading section .text, size 0xe968 lma 0x8000000
Loading section .ARM.exidx, size 0x880 lma 0x800e968
Loading section .data, size 0x18 lma 0x800f1e8
Start address 0x080008fa, load size 61952
Transfer rate: 17 KB/sec, 1877 bytes/write.
Erasing lets you re-flash and debug what is happening... so what was the actual cause of all the hang causing the debugger to fail?
Turns out I was attempting to enable the USB peripheral without setting the USB clock source first! So if you see something similar, check your clock setup!
Hope this helps someone, cheers!