cancel
Showing results for 
Search instead for 
Did you mean: 

Runtime DFU application in STM32L4 series

Lakshmi Lavanya
Associate II
Posted on December 08, 2016 at 14:07

Hello Everyone,

I need DFU application which can load the new firmware at run time.

I want to implement DFU in stm32l476G-Eval board, tried with DFU bootloader method (Connecting Boot0 to VCC) it is working fine.

Compiled the DFU standalone example application and ran it but it is not showing as a DFU device when i connected the eval board to PC.

Can any body explain or point me to the links which can explain how to implement the DFU standalone method. How the run time DFU will work? how much space it will take for the DFU code?

#stm32l4 #usb #stm32l476g-eval #stm32l4-dfu-runtime #dfu

Note: this post was migrated and contained many threaded conversations, some content may be missing.
37 REPLIES 37
Posted on August 23, 2017 at 08:10

How can i write DFU file ? (means own Boot loader at 0x08000000) , I have new image but i have no idea about how to write own DFU file so pls guide me

Posted on August 23, 2017 at 11:43

Hi ,

When my program start it enter into internal bootloader and i can able to flash using USB communication . Now my problem is , I want to enter into application program (0x08004000) after flash get complete.

My plan is when STM32 reset ,my STM32F207ZG controller goes to DFU mode and flash the firmware into application memory and After finish flashing, it jump into application memory.

Posted on August 23, 2017 at 15:10

I think you're going to need to manage that in your boot loader, because the processor resets into 0x08000000, you should determine if the image at 0x08004000 is valid, and transfer control.

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
Posted on August 23, 2017 at 15:25

Yes my bootloader in 0x08000000 and image file in 0x08004000 , but my doubt is how to write bootloader to change the device into DFU mode . If i use internal bootloader means then how i can able to jump into application image .

Posted on August 23, 2017 at 15:30

Transfer control means?

 setting main stack pointer or something else

---------------------------------------------------------------------------

If i Jump into DFU mode then how can i come out from that

Thanks

Manikandan

Posted on August 23, 2017 at 16:53

To exit wouldn't you click 'Leave DFU Mode' in DFuSe Demo? I would expect it to reset the part, there's no 'jump to this code' option.

Think about how the processor works, when you transfer control to the application code from your boot loader code what conditions/state does the entry point of the application expect? If it is a Reset_Handler in the Vector Table, then assume, at a minimum, that there are expectations about SP and PC registers, and that interrupts aren't masked, etc.

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
Posted on August 23, 2017 at 18:10

SysMemBootJump = (void (*)(void)) (*((uint32_t *) 0x1fff0004));

    

        HAL_RCC_DeInit();

        SysTick->CTRL = 0;

        SysTick->LOAD = 0;

        SysTick->VAL = 0;

        __set_MSP(0x20004000);

        SysMemBootJump();

        while (1)

            ;

This is my bootloader main code, my doubt is instead of setting MSP as 0x20004000( 

__set_MSP(0x20004000);)  to 0x080004000 right or wrong ?, Means i set MSP to my application code and in command I give leave dfu this also I dono right or wrong . If anything wrong pls give me some example code because I get confusing more 

Posted on August 23, 2017 at 19:38

You want the stack in RAM, so pointing it at 0x08004000 in FLASH will be a disaster.

The 32-bit data value at 0x08004000 is the value the processor wants for the stack, ie

SP = *((uint32_t *)0x08004000); // The content of the address, not the address itself

// Your Loader Code transferring control to Application Code

AppJump = (void (*)(void)) (*((uint32_t *)0x08004004)); // Initial PC [+4]

__set_MSP(*((uint32_t *)0x08004000)); // Initial SP [+0]

AppJump();

The micro-controller has a very simple view of the world, understand how it executes code and starts and you'll be far less confused.

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