Read back hex to verify programming

⚠️
Hi there.. thanks for coming to the forums. Exciting news! we’re now in the process of moving to our new forum platform that will offer better functionality and is contained within the main Dialog website. All posts and accounts have been migrated. We’re now accepting traffic on the new forum only - please POST any new threads at//www.xmece.com/support. We’ll be fixing bugs / optimising the searching and tagging over the coming days.
10 posts / 0 new
Last post
hughesk
Offline
Last seen:2 years 6 months ago
Joined:2014-04-26 02:56
Read back hex to verify programming

Hello,
I would like to use the SmartSnippets.exe CLI tool to read the contents of flash after programming the DA14580, and automatically compare the result byte-wise with the original hex file.
Can you please point me to a tool to either convert from the Keil-output hex file TO the SmartSnippets formatted hex data, or vice versa?

Currently, the Keil output looks like this (is this Intel hex format?):
:020000042000DA
:1000000000980020B9040020C1040020D904002079
:1000100000000000000000000000000000000000E0

And the Smart Snippets CLI outputs a file that looks like:
Address Hex Text
0x00000 70 50 00 00 00 00 4A D0 pP J?
0x00008 00 98 00 20 B9 04 00 20 ? ?

One could programmatically convert the intel hex into the ASCII hex shown in the Smart Snippets file and cut out just the hex portion of that file, but if there is a simpler way to do this validation, that would be much appreciated!

Thanks,
Kevin

Device:
MT_dialog
Offline
Last seen:2 months 3 weeks ago
Staff
Joined:2015-06-08 11:34
Hi hughesk,

Hi hughesk,

The output of keil is a .hex intel format file and what is burned in the flash is the actual binary file, since the cli passes the .hex file through a hex2bin.exe in order to generate the .bin file. The cli command tool embedds a verify flag if that is what you are looking for. Please check the help document of the Smart Snippets (open the Smart Snippets Toolbox and check the help option, there you will find the Help document) it explains also the cli commands available for the 58x and the 68x families.

Thanks MT_dialog

hughesk
Offline
Last seen:2 years 6 months ago
Joined:2014-04-26 02:56
Hello,

Hello,
I am coming back to this issue after some time. I have two followup questions:
1.I do not see a CLI option for a verify flag related to flash memory. If Smartsnippets and the DA14580 binary file used during flashing already do a verification of the flash memory, I just need some way to demonstrate that before releasing to production. So, do you have either a verify flag that I missed, or any way to one-time demonstrate or test Smartsnippets/DA14580 flash memory verification?

2. If there is either not a verification flag or the verification process is not able to be demonstrated, then I can read the flash memory contents back onto disk. This is straightforward, and I can then convert that hex file to a binary file. I then want to compare two binary files:
a. The binary generated from the flash read back
b. The binary generated from the Keil-compiled hex file
However, I find that the two have some slight differences. Ignoring the first 8 bytes (added to make it bootable), it seems that there are a few strings of 0x00's in the readback from flash that are 0xFF's in the Keil-hex binary. Are these locations predictable? I cannot do a straight verification unless I can account for these (admittedly minor) differences, and I would not necessarily want to hard code them as exceptions.

Thanks in advance for your help!

MT_dialog
Offline
Last seen:2 months 3 weeks ago
Staff
Joined:2015-06-08 11:34
Hi hughesk,

Hi hughesk,

  1. 我不确定问题,CLI逗号nd that burns a file to the flash includes a verify option, if set the [-verify] flag tool will verify the burned binary on the flash. What exactly do you mean "one-time demo from flash verification" ? The tool if instructed to verify it will promt that verification has succeeded. Please check on the help options of the SSToolbox the help document of the tool.
  2. Regarding the second question what you download into the ARM in a binary file .bin file and not a the .hex file as generated from keil, you cannot directly compare those two files. Those areas in the binary with the FF's are the holes that keil produces due to the fact that the scatter file and the memory organization that the 580 has. The .hex file doesn't have those kind of holes since it includes addresses that are converted from the hex2bin utility. But the text file that will be generated from the read is directly comparable with the .bin file that you ve used to burn the fw (in different formats offcourse).

Thanks MT_dialog

hughesk
Offline
Last seen:2 years 6 months ago
Joined:2014-04-26 02:56
Hello,

Hello,
Thank you for the prompt reply.

Regarding the CLI options, 'SmartSnippets.exe -help' does not print out any -verify option in SmartSnippets v3.8. Is this a new feature?

hughesk
Offline
Last seen:2 years 6 months ago
Joined:2014-04-26 02:56
And regarding the binary

And regarding the binary comparison, I took the following specific steps:
1.Compile to hex in Keil. Call this KeilOutput.hex
2. Run 'hex2bin.exe -l 8000' on the hex file to produce a 32KB KeilOutput.bin
3. Program KeilOutput.hex to the DA14580 SPI-connected Flash using SmartSnippets v3.8 via a JTAG probe, selecting "Yes" to make it bootable.
4. Read back Flash contents and save as FlashContents.hex.
5. Run 'hex2bin.exe -l 8000' on FlashContents.hex to create FlashContents.bin
6. Compare KeilOutput.bin to FlashContents.bin.

Ignoring the first 8 bytes of FlashContents.bin (due to the bootable option), the files almost entirely match, except for three sections of memory, which in FlashContents.bin are sets of '00' and in KeilOutput.bin are sets of 'FF'. The three sections in this particular set of files are near the beginning of memory and are 192, 28, and 92 bytes long. I'd be happy to share a snippet by email if you feel that would help.

Thanks,
Kevin

MT_dialog
Offline
Last seen:2 months 3 weeks ago
Staff
Joined:2015-06-08 11:34
Hi hughesk,

Hi hughesk,

Well, the Smart Snippets version that you are using is quite old, the Smart Snippets Toolbox Suite has replaced the Smart Snippets, but i think that even this version has the verify option, the -help command wont show this option, but if you try to use the write command mistakenly the tool will prompt you with the proper options. You can also check the Smart Snippets help option and the pdf that is available in that option.

Regarding the comparison between the burned and the read file, i ve done the same but the read back was done in .bin file instead of hex, the files were identical (except the bootable header and that the original file had an FF padding).

Thanks MT_dialog

hughesk
Offline
Last seen:2 years 6 months ago
Joined:2014-04-26 02:56
Hello,

Hello,
Thanks for the SmartSnippets version suggestion - I did not realize that SmartSnippets itself was updated in the Toolbox (I thought just an IDE...). Regardless, the newer version DOES have a -verify in the write flash CLI options. Now my question is just one of verification:

1.你有任何建议的方式展示吗that the 'verify' option actually performs a verification? Some means of either interrupting it and altering the readback so that it fails SPI flash verification once or something along those lines? This is needed for validation of the programming script before release into production.

2. OR, if there is not an easy way to demonstrate the verification process, then going back to the .bin, I do see that specifying a read back filename ending in '.bin' causes a binary file to be written (it was not clear that the file extension is actually used in determining the output from Smartsnippets). However, I still have exactly the same problem as when I read back and converted using hex2bin. That is, there are three strings at the beginning of memory that are 00's in the readback and FF's in the KeilOutput.bin (converted from KeilOutput.hex using hex2bin). Any idea why these are different?

Thanks,
Kevin

hughesk
Offline
Last seen:2 years 6 months ago
Joined:2014-04-26 02:56
Following up on the binary

Following up on the binary comparison:

如果我使用新的SmartSnippets燃烧十六进制file, I note that (in my particular hex file) address A8 is the start of a section that appears in the SmartSnippets window as '--', which I suppose means unspecified. If I burn to SPI Flash and then read back, the area starting at A8 is filled with '00'.
Opening a .bin file created with hex2bin, I see that the '--' area is instead replaced with FF. Therefore, the read-back flash binary does not match the hex2bin created binary.

EDIT:
Looks like this can be resolved by specifying the padding byte:
hex2bin.exe -p 0 [file.hex]
Results in 'file.bin' that matches the contents of read-back Flash memory.

I'm still interested to know if there is a method to test or demonstrate the SmartSnippets '-verify' option, but if there is not, I am satisfied with the read-back comparison against a correctly-created binary file.

MT_dialog
Offline
Last seen:2 months 3 weeks ago
Staff
Joined:2015-06-08 11:34
Hi hughesk,

Hi hughesk,

Regarding the CLI, and the verify option, pasting the command as from the Smart Snippets Toolbox manual : Executable -type spi -chip chip_version [-clk clk] [-cs cs] [-miso miso] [-mosi mosi] [-jtagjtag_serialNumber | -com_port portNumber] [-baudrate rate] [-gpio pinId] [-uart TxId][firmware firmware_file] -cmd write -file filename [-offset ofst] [-max size][-verify][-bootable] [-y] [-nomessages messageFilter]. What the command does is to write to the flash and then perform a read back in order to verify, but this behaviour is transparent to the user, the tool will just prompt you that its reading the flash in order to verify and then it will either promt you that the verification has succeded or not. In case you are looking for a seperate command on this that will show the entire procedure, no such thing is not available. Please find attached the screenshot from the procedure described above.

Thanks MT_dialog