cancel
Showing results for 
Search instead for 
Did you mean: 

Conversion DFU-File to Hex-File

urban17
Associate

I try to convert a DFU-File to a Hex-File with the ST-Tool  "DfuFileMgr.exe" from the DfuSe_v3.0.6 Toolkit.
The reason for the conversion is, that we have an Update-Application in the field that works with USP-DFU update and the old DfuSe driver. Now we would like to change to a new Application with the CubeProgrammer-API. With the CubeProgrammer-API we can download a HEX-File over DFU-USB. For compatibility reason we would like to use the old DFU-Files, convert it to HEX and upload it over DFU-USB with the CubeProgrammer-API. 

I tested the convrersion it with a "round-trip":
1. Start with a given hex-File: test.hex (see attachment)
2. Convert hex-to-dfu with DfuFileMgr.exe => test.dfu (see attachment)
3. Convert back dfu-to-hex with DfuFileMgr.exe => test_00.hex (see attachment)

The generated hex-File test_00.hex has now data on Address 0x0800_0000. The original hex-File test.hex starts on Address 0x0800_C000!!! The converted Hex-File is unusable.

I verified the original and the generated hex file. The wrong code block in the gererated file from address 0x0800_0000 - 0x0800_01E0 (placed on line 516-530 in file test_00.hex) can be found in the original hex from address 0x0801_0000 - 0x0801_01E0 (placed on line 1027-1056 in the file test.hex).
The same is for each section changes 0x0801, 0x0802 and 0x0803. Always a block from 480 bytes from address 0x0000-0x01E0.

Somehow the DfuFileMgr seems to have a problem with the first code block from the original hex file from address 0x0800_C000 - 0x0800_C1D8. The next row starts on 0x0800_C1E0. The addresses from 0x0800_C1D9 - 0x0800_C1E0 are not defined in the original hex-file.
Exact the first code blocks from 480 Bytes are missplaced on the entries of the sections 0x0800, 0x0801, 0x0802.

My questions:

1. Can the DfuFileMgr.exe handle undifined code blocks in a HEX-file?

2. Is it "only" a problem for the convertion from dfu to hex or is the dfu file itselfe also wrong for hex files ith undefined code blocks?
 

1 ACCEPTED SOLUTION

Accepted Solutions
urban17
Associate

Many thanks for the fast reply. Good to know there is a bug for hex files with undifined adress blocks.

I also tried now the other converters. The conversion to "S19" and "multiple bin" are working without error with the same input dfu.

As a workaround, we take two steps. First we extract a s19 file from the dfu with the DfuFileMgr and then we generate a hex file from it with the tool SRecord.

View solution in original post

3 REPLIES 3

The tool generating the .HEX from the .DFU is broken. The segment line comes too late as the content wraps between 0x0800FFE0 into 0x08010000. I could build a tool that does this properly

...

:20FFC000074997F907305B09012000FA02F241F8232000BF0C37BD465DF8047B704700BFCC
:20FFE00000E100E080B483B000AF03463960FB7197F90730002B0ADB3B68DAB20C4997F9F1
:2000000007301201D2B20B4483F800230AE03B68DAB20849FB7903F00F03043B1201D2B26C
:200020000B441A7600BF0C37BD465DF8047B704700E100E000ED00E080B489B000AFF8604F
:20004000B9607A60FB6803F00703FB61FB69C3F10703042B28BF0423BB61FB690433062BAA
:2000600002D9FB69033B00E000237B614FF0FF32BB6902FA03F3DA43BB681A407B699A4046
:200080004FF0FF317B6901FA03F3D9437B680B40134318462437BD465DF8047B704780B500
:2000A00082B000AF78607868FFF74CFF00BF0837BD4680BD80B586B000AF0346B9607A60D2
:2000C000FB7300237B61FFF761FF78617A68B9687869FFF7B1FF024697F90F30114618462E
:2000E000FFF780FF00BF1837BD4680BD80B582B000AF0346FB7197F907301846FFF754FF04
:2001000000BF0837BD4680BD80B584B000AF78607B689B6DFB60FEF785FCB8607B6893F86F
:200120003530DBB2022B08D07B6880225A657B68002283F83420012352E07B681B681A6872
:200140007B681B6822F016021A607B681B685A697B681B6822F080025A617B681B6C002B22
:2001600003D17B689B6C002B07D07B681B681A687B681B6822F008021A607B681B681A68F3
:200180007B681B6822F001021A6013E0FEF74AFC0246BB68D31A052B0CD97B6820225A65EB
:2001A0007B68032283F835207B68002283F83420032315E07B681B681B6803F00103002B6D
:2001C000E4D17B68DB6D3F229A40FB689A607B68012283F835207B68002283F834200023DA
:020000040801F1
:2001E00018461037BD4680BD80B483B000AF78607B6893F83530DBB2022B04D07B68802246
:200200005A6501230CE07B68052283F835207B681B681A687B681B6822F001021A60002335

...

test.dfu
0003034D

CRC32:6825DCD4 (Computed)

CRC32:00000000 (Computed Whole File)

0000 : 44 66 75 53 65 01 3D 03-03 00 01                DfuSe.=....

0003033D 1
0000 : 54 61 72 67 65 74 00 01-00 00 00 53 54 2E 2E 2E Target.....ST...
0010 : 00 3A 5C 00 65 6D 70 5C-68 65 78 5C 74 65 73 74 .:\.emp\hex\test
0020 : 2E 64 66 75 00 00 00 00-00 00 00 00 00 00 00 00 .dfu............
0030 : 00 00 00 00 00 00 00 00-00 00 00 00 00 00 00 00 ................
0040 : 00 00 00 00 00 00 00 00-00 00 00 00 00 00 00 00 ................
0050 : 00 00 00 00 00 00 00 00-00 00 00 00 00 00 00 00 ................
0060 : 00 00 00 00 00 00 00 00-00 00 00 00 00 00 00 00 ................
0070 : 00 00 00 00 00 00 00 00-00 00 00 00 00 00 00 00 ................
0080 : 00 00 00 00 00 00 00 00-00 00 00 00 00 00 00 00 ................
0090 : 00 00 00 00 00 00 00 00-00 00 00 00 00 00 00 00 ................
00A0 : 00 00 00 00 00 00 00 00-00 00 00 00 00 00 00 00 ................
00B0 : 00 00 00 00 00 00 00 00-00 00 00 00 00 00 00 00 ................
00C0 : 00 00 00 00 00 00 00 00-00 00 00 00 00 00 00 00 ................
00D0 : 00 00 00 00 00 00 00 00-00 00 00 00 00 00 00 00 ................
00E0 : 00 00 00 00 00 00 00 00-00 00 00 00 00 00 00 00 ................
00F0 : 00 00 00 00 00 00 00 00-00 00 00 00 00 00 00 00 ................
0100 : 00 00 00 00 00 00 00 00-00 00 20 02 03 00 02 00 .......... .....
0110 : 00 00                                           ..

00030220
0000 : 00 C0 00 08 D8 01 00 00-                        ........

0800C000 000001D8 (Basis / Length)

0000 : E0 C1 00 08 38 00 03 00-                        ....8...

0800C1E0 00030038

--------
00030220

0000 : 00 00 00 00 83 04 1A 01-55 46 44 10 D4 DC 25 68 ........UFD...%h

CRC32:6825DCD4 (Header)

.  

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

@Christian N please open a ticket on the DfuFileMgr tool failure, or indicate if further work / maintenance is going to be be done on such tools.

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

Many thanks for the fast reply. Good to know there is a bug for hex files with undifined adress blocks.

I also tried now the other converters. The conversion to "S19" and "multiple bin" are working without error with the same input dfu.

As a workaround, we take two steps. First we extract a s19 file from the dfu with the DfuFileMgr and then we generate a hex file from it with the tool SRecord.