Skip to main content
Visitor II
February 13, 2017
Solved

How to load application using USB DFU loader

  • February 13, 2017
  • 3 replies
  • 1933 views
Posted on February 13, 2017 at 14:03

Short description: I can load .dfu file from DFU_Standalone code sample, but cannot load my own .dfu file.

Details:

I am trying to work with DFU_Standalone code sample. It works with STM32469I_EVAL_SysTick_0x08008000.dfu file provided in Binary directory.

So, I open STM32469I-EVAL_USBD-FS project (full path STM32Cube_FW_F4_V1.14.0\Projects\STM32469I_EVAL\Applications\USB_Device\DFU_Standalone\SW4STM32\STM32469I-EVAL_USBD-FS) in the System Workbench for STM32, build and execute it. Then I run DfuSeDemo application and see 'STM Device in DFU mode'. After this I click 'Choose' button in 'Upgrade' box, select STM32469I_EVAL_SysTick_0x08008000.dfu file, click 'Upgrade'. Finally, I execute 'Leave DFU mode'. STM32469I_EVAL_SysTick_0x08008000 is activated, I see 4 LEDs animation on the board.

Now I want to load another application, instead of STM32469I_EVAL_SysTick_0x08008000. So, I open GPIO_IOToggle code sample in the System Workbench (full path is STM32Cube_FW_F4_V1.14.0\Projects\STM32469I_EVAL\Examples\GPIO\GPIO_IOToggle\SW4STM32) and build it. Result is STM32469I_EVAL.bin file. Then I execute DfuFileMgr.exe, and generate STM32469I_EVAL.dfu file from STM32469I_EVAL.bin. In Multi Bin injection I fill Address value with 08008000. Finally, I run DfuSeDemo, upgrade STM32469I_EVAL.dfu file and click 'Leave DFU mode'. Application is not loaded, DFU_Standalone program remains active. No LED animation, and DfuSe Demo stlll shows 'STM Device in DFU mode'.

So, how can I make .dfu file from my own project, which is loadable by DFU_Standalone bootloader? In the file DFU_Standalone\Binary\readme.txt I see: The offset address of this binary is 0x08008000 which matches the definition in DFU application 'USBD_DFU_APP_DEFAULT_ADD'.

How can I set this offset in GPIO_IOToggle project? What changes exactly should I make in any project, to make a binary loadable by DFU_Standalone and DfuSeDemo programs?

Environment:

OS: Windows 10 x64

Board: STM32469I-EVAL

STM32Cube_FW_F4_V1.14.0

STM32 Workbench v.1.8

DfuSe_Demo_V3.0.5_Setup

#dfu #linker #offset #firmware-upgrade
    This topic has been closed for replies.
    Best answer by Tesla DeLorean
    Posted on February 13, 2017 at 14:56

    You'd have to physically build the file for the 0x08008000 address. The linker would need to create the output at this address (typically via linker script or settings), and any code setting the vector table address (SystemInit) would also need to be configured to this address also.

    Simply loading a .BIN at the specified address isn't sufficient. A .HEX would contain the address as output by the linker. You could review the .MAP to confirm the address the linker is building the image at.

    3 replies

    Technical Moderator
    February 13, 2017
    Posted on February 13, 2017 at 14:25

    Hello

    Farber.Alex

    ,

    What's the state of BOOT0 pin?

    Make sure you have BOOT0 pulled low

    on your board to execute your code.

    Regards

    Imen

    Visitor II
    February 13, 2017
    Posted on February 13, 2017 at 14:58

    Hello Imen,

    SW1 and SW2 are in the left position, PIN0 is low. My guess is that pins are OK, something is wring in the file I want to load. .dfu file from code sample is OK, and my own file is not working.

    Graduate II
    February 13, 2017
    Posted on February 13, 2017 at 14:56

    You'd have to physically build the file for the 0x08008000 address. The linker would need to create the output at this address (typically via linker script or settings), and any code setting the vector table address (SystemInit) would also need to be configured to this address also.

    Simply loading a .BIN at the specified address isn't sufficient. A .HEX would contain the address as output by the linker. You could review the .MAP to confirm the address the linker is building the image at.

    Visitor II
    February 13, 2017
    Posted on February 13, 2017 at 15:08

    Hello Clive,

    I am trying to do this. In the project .ld file I found the line:

    FLASH (rx)     : ORIGIN = 0x8000000, LENGTH = 2048K

    Tried to replace 0x8000000 with 0x08008000, still doesn't work. Probably I need to do something else, but I don't know exactly what to change.

    Visitor II
    February 14, 2017
    Posted on February 14, 2017 at 13:25

    Got it working when changed the program in 3 places:

    1.DFU program reads int value from 0x8008000 address and tests it for some condition. This is always false when I burn my own application, so I just excluded this check for now.

    2. Application project, .ld file:

    FLASH (rx)     : ORIGIN = 0x8000000, LENGTH = 2048K

    replace with

    FLASH (rx)     : ORIGIN = 0x08008000, LENGTH = 2048K

    3. Application project, SystemInit function:

    SCP->VTOR = FLASH_BASE | VECT_TAB_OFFSET;

    replace with

    SCP->VTOR = 0x08008000 | VECT_TAB_OFFSET;

    Now I can build the application project, convert .bin to .dfu and burn it to device. It is activated successfully.

    It is also a good idea to generate .hex file, as described here:

    http://www.openstm32.org/forumthread925

     

    .hex file is more convenient to convert to .dfu.

    Graduate II
    February 16, 2017
    Posted on February 16, 2017 at 17:07

    In Keil you can also run command line tools, and get it to auto-generate a .DFU file

    https://community.st.com/0D50X00009XkeovSAB