I overwrote by mistake ST-Link programming pins PA13 and PA14. Now I cannot reprogram my chip.
How could I fix the problem?
To 'unbrick' STM32F4, connect BOOT0 pin to 3V pin and then you can erase or flash it.
I also ran into this problem but due to my circuit, was not able to use the bootloader to recover it.
At first I thought I was hosed, but eventually learned that you can connect via JTAG while the chip is being held in reset. When held in reset, the pins go to their default states and thus the chip can be reprogrammed even if your application remaps them for other uses when it runs.
The OpenOCD command to enable this is:
reset_config srst_only srst_nogate connect_assert_srst
I have heard that ST-Link supports connect-under-reset as well, but I am not familiar with it.
edit: Did a quick search, and it is indeed supported by ST-Link. See UM0892 for details (search for "connect under reset").