cancel
Showing results for 
Search instead for 
Did you mean: 

How to use DFU leave functionality from STM32CubeProgrammer CLI MCU

kareled
Associate II

Hello,

I'm using CLI version of Cube Programmer for accessing/erasing/writing FLASH of STM32F412 MCU. The problem which I have is that I'm not able to reset board after series of action performed over DFU (using ST micro bootloader) while connected over USB. I do not see any way how to perform DFU leave operation which is described in AN3156 and this way how to restart customer board back to the customer firmware and this all by using CLI version of the cube programmer.

Am I missing anything? Is there any way how to perform reset over DFU/USB on F4? Any hint is highly appreciated here!

Thanks,

Karel

 

1 ACCEPTED SOLUTION

Accepted Solutions
MM..1
Chief III

Have you try -g switch?

View solution in original post

5 REPLIES 5
MM..1
Chief III

Have you try -g switch?

Thanks a lot for the suggestion. Indeed -g switch helps here, but it's not that simple.

-g,     --go           : Run the code at the specified partition ID.
     [<partitionID>]    : Partition ID
                          If not specified, last loaded partition
                          will be started

     [<startAdress>]    : Start address
                          If not specified, last loaded segment address
     [<noack>]          : No acknowledgment required
                          If not specified, acknowledgment will be required

 since I needed to specify start address, from the description above I'm also forced to specify partitionID. Honestly I tried:

-g partitionID=1 startAddress=0x8008001

-g 1 0x8008001

-g 0 0x8008001

-g 0x0 0x8008001

and such but nothing works. So I've given up and tried to use just start address.

-g 0x8008001

and this does not work either. But the output of such command is very convincing:

USB speed   : Full Speed (12MBit/s)
Manuf. ID   : STMicroelectronics
Product ID  : STM32  BOOTLOADER
SN          : 383939593231
DFU protocol: 1.1
Board       : --
Device ID   : 0x0441
Device name : STM32F412
Flash size  : 1 MBytes (default)
Device type : MCU
Revision ID : --
Device CPU  : Cortex-M4

RUNNING Program ...
  Address:      : 0x8008001
Start operation achieved successfully

I don't know why this does not work, but it does not work only when done for the *FIRST* time. Once you try for the *SECOND* time, it miraculously works! And btw, the output is still the same.

So I've tested around 5 times and *always* after second invocation I'm back in the customer application.

Great! And thanks a lot for your help!
Karel

0x8008001

cant be start...


@MM..1 wrote:
0x8008001

cant be start...


It is, by design and it's intentional. Linking script looks:

 

MEMORY
{
[...]
}
/* 16k for vector table and 1x 16k sector config FLASH */
_stext = ORIGIN(FLASH) + 0x8000;

And elf looks:

ELF Header:
  Magic:   7f 45 4c 46 01 01 01 00 00 00 00 00 00 00 00 00
  Class:                             ELF32
  Data:                              2's complement, little endian
  Version:                           1 (current)
  OS/ABI:                            UNIX - System V
  ABI Version:                       0
  Type:                              EXEC (Executable file)
  Machine:                           ARM
  Version:                           0x1
  Entry point address:               0x8008001
  Start of program headers:          52 (bytes into file)
  Start of section headers:          18814232 (bytes into file)
  Flags:                             0x5000400
  Size of this header:               52 (bytes)
  Size of program headers:           32 (bytes)
  Number of program headers:         6
  Size of section headers:           40 (bytes)
  Number of section headers:         24
  Section header string table index: 22

 

And elf header looks:

ELF Header:
Magic: 7f 45 4c 46 01 01 01 00 00 00 00 00 00 00 00 00
Class: ELF32
Data: 2's complement, little endian
Version: 1 (current)
OS/ABI: UNIX - System V
ABI Version: 0
Type: EXEC (Executable file)
Machine: ARM
Version: 0x1
Entry point address: 0x8008001
Start of program headers: 52 (bytes into file)
Start of section headers: 18814232 (bytes into file)
Flags: 0x5000400
Size of this header: 52 (bytes)
Size of program headers: 32 (bytes)
Number of program headers: 6
Size of section headers: 40 (bytes)
Number of section headers: 24
Section header string table index: 22