cancel
Showing results for 
Search instead for 
Did you mean: 

Extend bytes for application fw version in the image header

Zoey
Associate III

For our application, we require more than 2 bytes to identify the fw version. However, the current SBSFU has only 2 bytes fw version in the header. What is the easiest way to add a few more bytes for fw version? Thanks!

4 REPLIES 4
Arno1
Senior

Hello,

This is a somewhat old question but I'll add my take on it anyway.

From what I was able to find you can change the format of the struct packing in the python script prepareimage.py.

    header = pack('<'+str(len(magic))+'sHHIII'+str(len(tag))+'s'+str(len(pfwtag))+'s'+str(len(nonce))+'s'+str(args.reserved)+'s',
                    magic, protocol, version, size, pfwoffset, pfwsize, tag, pfwtag, nonce, reserved)

Here you see sHHIII. The second H indicates a 2-byte integer. You can change this according to the list in https://docs.python.org/2/library/struct.html#format-characters. For example i for 4-byte integer or q for an 8 byte integer.

Regards,

Arno

Zoey
Associate III

Thanks for your suggestion. I guess, then there are also changes need to be made in SBSFU (for processing header, like SE_FwRawHeaderTypeDef).

I found that there is a field "reserved". Would it be easier just to use "reserved" instead of the real "version" field?

Hello Zoey,

Besides SE_FwRawHeaderTypeDef I also found SE_APP_ActiveFwInfo_t as part of the secure engine middelware.

Both would need to be changed but what I'm most concerned about is how it changes the size of the header so I think you are left with 2 choices:

either you change the FwVersion field and decrease the number of Reserved bytes or you use the Reserved bytes instead like you suggested.

In the second case you also have to change the function SE_APPLI_GetActiveFwInfo to take your version number and put it in p_FwInfo->ActiveFwSize. (you would still need to change SE_APP_ActiveFwInfo_t though to use a larger int type).

How using the reserved bytes would change the python script like in my previous answer I don't know but you might not need to change anything there at all as long as you software is consistent in using the reserved bytes.

BR, Arno

Zoey
Associate III

Thanks Arno. :D You are right that there are other things that might need to be changed even if using the "reserved" field. I will try "reserved" field first and then see.