STM32 G431RB wont boot! But works on Arduino IDE

Look at those program counter (pc) values.

They’re in 0x1fff4818. That’s not flash memory where your firmware was burned into. It’s the “System memory” in accordance to the reference manual’s memory map:

https://www.st.com/resource/en/reference_manual/rm0440-stm32g4-series-advanced-armbased-32bit-mcus-stmicroelectronics.pdf

page 83.

0x1FFFF 0000 up to 0x1FFF 7000 is “System memory”, and 0x1fff4818 is right in there.

“System memory” means bootloader. It should only go there if you have the bootloader pins BOOT0 connected to +3.3V instead of GND. How is that pin connected on your board?

Try connecting that pin to GND, or changing the option bytes as said per First line of reset handler throws exception on STM32G4 - #2 by gfriend