cancel
Showing results for 
Search instead for 
Did you mean: 

STM32H723 DFU mode sometimes not entering

adakPal
Visitor

I am using STM32H723VG and I want to implement bootloader for firmware update. I want to enter STM32 bootloader to flash data through USB DFU inside firmware:

 
#define BOOTLOADER_ADDRESS_START 0x1FF09800
void Bootloader_JumpToBootloader()
{
    __disable_irq();
 
    USBD_DeInit(&hUsbDeviceFS);
    HAL_RCC_DeInit();
    HAL_DeInit();

    HAL_Delay(100);

    SysTick->CTRL = 0;

    uint8_t cnt = (sizeof(NVIC->ICER) / sizeof(*NVIC->ICER));
    for (int i = 0; i < cnt; i++)
    {
        NVIC->ICER[i] = 0xFFFFFFFF;
        NVIC->ICPR[i] = 0xFFFFFFFF;
    }

    SCB_InvalidateICache();
    SCB_DisableICache();
    SCB_CleanDCache();
    SCB_DisableDCache();

    __set_MSP(*((uint32_t *)BOOTLOADER_ADDRESS_START));

    SCB->VTOR = BOOTLOADER_ADDRESS_START;
   
    void (*SysMemBootJump)(void);
    SysMemBootJump = (void (*)(void))(*((uint32_t *)(BOOTLOADER_ADDRESS_START + 4U)));
    SysMemBootJump();
}

The issue I'm encountering is that the USB DFU interface only initializes sporadically after executing this function. Sometimes the DFU mode starts correctly, and I'm able to flash new firmware without any problems. Other times, the DFU mode doesn't initialize at all, and the device isn't recognized over USB.

I've tried disabling all peripherals before jumping to the bootloader, but this hasn't resolved the issue. It seems to be random whether the DFU mode starts correctly or not.

 

Any insights, suggestions, or guidance would be greatly appreciated!

Thank you!

1 REPLY 1
TDK
Guru

> __disable_irq();

The USB DFU bootloader requires interrupts to be enabled. Your code disables them globally.

TDK_0-1727698461908.png

 

Put __enable_irq() somewhere prior to jumping to the bootloader.

If you feel a post has answered your question, please click "Accept as Solution".