Skip to main content
JosepM Ribera
Associate II
December 1, 2023
Solved

STM32H7 USB DFU firmware boodloader bug

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.
Tesla DeLorean
Tesla DeLoreanBest answer
Guru
December 1, 2023

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.

Tips, Buy me a coffee, or three.. PayPal Venmo (See Profile) Up vote any posts that you find helpful, it shows what's working..

7 replies

TDK
December 1, 2023
"If you feel a post has answered your question, please click ""Accept as Solution""."
JosepM Ribera
Associate II
December 1, 2023

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

TDK
December 1, 2023

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

"If you feel a post has answered your question, please click ""Accept as Solution""."
Pavel A.
December 1, 2023
/* Test if user code is programmed starting from address 0x08020000 */

 Example of why no comments is better than deceiving comments.