STM32L562 boot into FWU mode for USB via option byte programming
Using the information from the chip's datasheet and reference manual:

I have the following routine (using the HAL routines). My issue is that I have verified code execution and setting of the two OB values via JTAG, but when the system reset is issued I go right back into user code at 0x0800 0000 and not the DFU loader as expected (0x0BF9 0000).
This seems like it should be simple... what am I missing or doing wrong?
void EnterFirmwareUpdateMode(void)
{
HAL_StatusTypeDef status;
// See RM0438 STM32L562 Ref Manual - pg 193 sect 6.4.2 option bytes programming
// See boot configuration pg 98 table 6, line 4 - Set Flash OPTR nBoot0 to 0 and nSWBOOT0 to 0
status = HAL_FLASH_Unlock();
status = HAL_FLASH_OB_Unlock();
CLEAR_BIT(FLASH->OPTR, FLASH_OPTR_nSWBOOT0_Msk);
CLEAR_BIT(FLASH->OPTR, FLASH_OPTR_nBOOT0_Msk);
SET_BIT(FLASH->NSCR, FLASH_NSCR_OPTSTRT_Msk);
// Seems un-needed since Launch supposedly reboots processor
status = HAL_FLASH_OB_Lock();
status = HAL_FLASH_Lock();
// Reload option bytes before rebooting
HAL_FLASH_OB_Launch();
// Perform System Reset
NVIC_SystemReset();
// Question to self -- do I need to reverse the option bytes in my main entry code if loader ran?
while(1)
{
; // execution should not get here
}
}
