Skip to main content
Visitor II
December 1, 2023
Solved

STM32H7 USB DFU firmware boodloader bug

  • December 1, 2023
  • 2 replies
  • 2084 views

Hi,

 

We are using STM32H7, and we found that the following instruction doesn't work:

 

/* Test if user code is programmed starting from address 0x08020000 */
if (((*(__IO uint32_t *) USBD_DFU_APP_DEFAULT_ADD) & 0x2FFC0000) == 0x20000000) <--- It is always FALSE. Despite there is user code!
{
 /* Jump to user application */
 JumpAddress = *(__IO uint32_t *) (USBD_DFU_APP_DEFAULT_ADD + 4);
 JumpToApplication = (pFunction) JumpAddress;
 
 /* Initialize user application's Stack Pointer */
 __set_MSP(*(__IO uint32_t *) USBD_DFU_APP_DEFAULT_ADD);
 JumpToApplication();
}

 We've tried with the mask: & 0x2FFC0000 and & 0x2FFE0000

What could be the issue? Another mask is needed for stm32H7?

Thank you

 

BR

    This topic has been closed for replies.
    Best answer by Tesla DeLorean

    The test is basically to check if the Initial SP points to RAM and isn't a) 0xFFFFFFFF and b) is ideally 32-bit aligned. It was originally conceived for a platform with 128KB at 0x20000000, but that was like a decade ago, and things have moved along, got a shed-load of STM32 some with RAMs at 0x10000000, 0x24000000, 0x38000000, or whatever.

    You can removed, fix or improve the test.

    Start by determining WHAT you're actually putting in there via startup.s and your linker script.

    2 replies

    Super User
    December 1, 2023
    Visitor II
    December 1, 2023

    So.. for now, what can we do? Any solution?? :frowning_face:

    Super User
    December 1, 2023

    Edit the file to correct it, presumably the value should be 0x24100000 but I didn't dig into it.

    Super User
    December 1, 2023
    /* Test if user code is programmed starting from address 0x08020000 */

     Example of why no comments is better than deceiving comments.