Booting Problem in STM32L452

Uploaded firmware.bin file in .pioenvs/ folder using cubeProg, via stlinkv2 .Everything is fine for the first boot, once the power is removed I need to reprogram to the microcontroller. The same code works fine with the nucleo evaluation board. This is my build config, do i have to change something to upload it directly to a custom board.

platform = ststm32
board = nucleo_l452re
framework = arduino

Do you have the BOOT0 pin set to GND on the board?

boot0 pin is connected to gnd

What happens when you let the device powered and just press the Reset button? Does the firmware not execute after that, too?

Yes, its working fine when powered up.

And when you press the reset button the firmware just restarts without loosing the firmware right?

Exactly, for the first time it takes a second to get booted

Problem is with the external LSE crystal, custom board has no LSE, configuring the clock settings to use LSI fixed the issue :slight_smile: