cancel
Showing results for 
Search instead for 
Did you mean: 

STM32H7 USB DFU firmware boodloader bug

JosepM Ribera
Associate III

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

1 ACCEPTED SOLUTION

Accepted Solutions

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
Up vote any posts that you find helpful, it shows what's working..

View solution in original post

7 REPLIES 7
TDK
Guru

Known issue as of two years ago.

https://community.st.com/t5/stm32cubemx-mcus/usb-dfu-example-bug-stm32h7/td-p/182234

 

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

So.. for now, what can we do? Any solution?? ☹️

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".

It still doesn't work..

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
Up vote any posts that you find helpful, it shows what's working..

Check there's actually a viable vector table there.

Dump the ELF, HEX or binary to see what's in the memory location.

Check the .MAP and startup.s

Consider adding some ability to output diagnostics or telemetry via a serial port so you can print out memory content, progress, or pass / fail status. This doesn't have to be in a final product, but needs to be there for debugging and board bring-up if you need to retain your sanity, or can't have the debugger single-step every situation due to real-time constraints.

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
Pavel A.
Evangelist III
/* Test if user code is programmed starting from address 0x08020000 */

 Example of why no comments is better than deceiving comments.