AnsweredAssumed Answered

Jump to user application in the USB_Device/DFU_Standalone Example

Question asked by penev.dimitar on Sep 27, 2016
Latest reply on Sep 27, 2016 by Clive One
Hello,


I am using STM32Cube_FW_L4_V1.5.1 library and I am trying to test the 
STM32Cube_FW_L4_V1.5.0\Projects\STM32L476G_EVAL\Applications\USB_Device\DFU_Standalone application. 

I have STM32L476RG-Nucleo + NUCLEO-CCA02M1 (for the USB support). 
I had to modify few small items in the DFU_Standalone application (as it is intended for STM32L476G_EVAL).
What I have achieved so far:
1. The DFU_Standalone builds and loads properly on my target
2. My Windows PC with DfuSe Demo recognize the connected target  as DFU device
3. I have build a small LED blinking application and tested it works OK if loaded using ST-link/v2
4. I have converted the blink.bin ->blink.dfu using DfuFileMgr.exe. I have set loading address to 0x0800C000 so it matches the USBD_DFU_APP_DEFAULT_ADD in DFU_Standalon
5. I am able to load blink.dfu using DfuSe Demo and I see the blinking code at offset 0x0800C000 exactly as I have in my bin file
6. If I set using the debugger the PC to 0x0800C000 and start the execution I see my blinking working fine.
7. If I reset the CPU the DFU_Standalon properly find application at 0x0800C000 and tries to jump to it and now my question. Jumping to my application (in DFU_Standalon) is done like this and it doesn't work but hit HardFault_Handler.

 JumpAddress = *(__IO uint32_t*) (USBD_DFU_APP_DEFAULT_ADD + 4);
 JumpToApplication = (pFunction) JumpAddress;
      
 __set_MSP(*(__IO uint32_t*) USBD_DFU_APP_DEFAULT_ADD);
 JumpToApplication();     

Should my application code starts with stack pointer and then a jump to the actual code? It seems it is not true in my case. 

Or more general is there somewhere a description about the way user application needs to be written and linked to bin, so after loading it (as dfu) using  DFU_Standalone will start properly. 

Thank you!
Dimitar

Outcomes