STM32 G431RB wont boot! But works on Arduino IDE

Another possible problem is that the OpenOCD version that PlatformIO uses has a bug with STM32G4, that requires you to use the STM32CubeProgrammer to set the option byte in a way that disabled the “DBANK” (dual bank):

Or, try with the opposite value that you have. (After taking care of the first issue).

See also https://github.com/platformio/platform-ststm32/issues/848 and Compliation failed for STM32G0B1RCT6 MCU with STM32cube framework - #8 by maxgerhardt