STM32 gotchas
112. After setting GPIOA things stop to work (due to overwriting SWD pins settings)

STM32 are debugged and programmed predominantly through the SWD interface, which consists primarily of two signals, clock SWCLK and data SWDAT. Probably in all STM32 these two signals are mapped to pins PA14 and PA13, and represent one of the possible alternate functions of those pins. This means, that those two pins after reset are not set as Digital or Analog Input, as most of other GPIO pins, rather, they are set as Alternate Function in GPIOA_MODER (and AF0 is selected for them in GPIOA_AFR[1], but that is also the reset value of GPIOx_AFR registers). They also have non-default settings in GPIOA_OSPEEDR and GPIOA_PUPDR registers.

If user rewrites the GPIO_MODER register (usually at the beginning of program) without taking into account settings of PA13 and PA14, they cease to function as SWD. This has the logical, but often surprising consequence, that once such program is run, the debugging interface almost immediately stops working. The chip also cannot be reprogrammed "on the fly", which is also may be surprising for those who are not aware of this issue. It has to be reprogrammed under reset - either by instructing the debugger/programmer to program under hardware reset, while making sure the programmer is connected to target's NRST, or by manually holding the NRST pin of the chip low.

Overwriting settings for PA13 and PA14 in GPIOA_AFR[1] would have the same consequence, but it is less likely to happen, as users would overwrite it most probably to the same value (0). Overwriting the high-slew-rate setting for PA13=SWDAT in GPIOA_OSPEEDR may result not only in not-working SWD, but also in surprisingly unreliable SWD, depending on exact details of connection and debugger's function.

Overwriting the pullups/pulldowns settings is on the other hand unlikely to have any noticeable effect with connected debugger, it mostly prevents inadvertent effects when the debugger is not connected.