Encoding version in OTA binary image

Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

cross mob
legic_1490776
Level 5
Level 5
25 likes received 10 likes received First like received

In my application in SDK 1.x, I implemented a 'version stamp' in the OTA image that I could check for to verify the version of the image.

I implemented this by declaring a constant structure in the code that contained a version number set from #define constants in the code.

This way, I was able to search the binary image for a particular string pattern and then pull the version out.

However, when I switched over to SDK 2.x, I found that this method no longer works.

It appears that string data in SDK 2.x, when it appears in the OTA image, has other bytes interspersed

For example, in the code, there is a line like this:

  ble_trace0("===SELF TEST REPORT===");

This shows up in the OTA binary, but not in a completely obvious way:

00004020  fb f1 53 45 4c 46 20 ff  54 45 53 54 20 52 45 50  |..SELF .TEST REP|

00004030  e7 4f 52 54 fd f1 ee f0  53 49 4f ff 4e 3a 25 73  |.ORT....SIO.N:%s|

I am not sure what is going on here, but it seems clear that it won't be easy to necessarily spot a string in the OTA binary.

Is there any better way to do this?  Is there some way I can force a particular string into the OTA binary from within the SDK build environment?  I feel more comfortable having the source code automatically produce an identifying mark in this way.

0 Likes
1 Solution

I do not think it is a good idea to search for a string in a binary image.  You rely on the compiler and make process behavior which is not documented and can change any time.  If you really want a string to be a part of your image you can modify the build process to concatenate string with your binary file, store in addition or instead of the the .ota image and use that file for download.  (see top level makefile for details).  If you look through the WICED-Secure-Over-the-Air-Firmware-Upgrade.pdf in the Doc directory, you will notice that the object which is used for upgrade includes the Product ID, Major version, Minor version combined with the binary image and the signature.  Current process validates IDs and signature on the device before image is stored or made active.  But you can modify process to verify this information before performing download as well.  All source code is included, so hopefully changing it will not cause much trouble.

View solution in original post

5 Replies