In stm32l4xx_hal.c, there is a bug with HAL_SYSCFG_EnableMemorySwappingBank().
The code is identical to the Disable version. The enable swapping is currently this:
void HAL_SYSCFG_EnableMemorySwappingBank(void)
{
*(__IO uint32_t *)FB_MODE_BB = 0x00000000UL;
}
and instead of = 0, it should be the equivalent of 0x100.
Also, the lower 3-bits should be maintained since they are MEM_MODE bits. As it turns out, %000 is Main Flash memory, which is probably good for most, but it's still a bad implementation.
