How to make a Release configuration?
Is your custom board powerd through ST-Link ?
If yes, are you using the latest ST-Link FW (could be V2J26M15, V2J26S4 or V2J26S0 // since i don’t know which ST-Link HW you are using)?
If not, this could be related to various causes (BOOT pins, you are executing from RAM .... )