Other Parts Discussed in Thread: UNIFLASH,
I have a couple of questions regarding the updates to the OTA process in the 1.50.0.6 SDK release.
- The new tar bundle cmd file has removed the maxsize field and added a SHA256 digest field?
- Will the UniFlash tool be updated with this change when creating an OTA bundle? I'm currently using UniFlash version 4.2.0.1490, when I check for updates the program says I'm up to date and the OTA bundle does not include the digest field.
I've manually added the digest field to the tar cmd file and I am attempting an OTA using the standalone OtaArchive files. I continually have errors with parsing the JSON within the cmd file. I have minified the JSON within the command file to reduce file size however, below is the beutified version:
[
{
"signature_base64": "PFK8nL9HkPkuKlJyIPuKjPdMTl3j7J9gGjuyKcq+iccI9VYCzT6kR/xo/Y0prGKdNguadwHtk99R2WMQol/g5HtqpybXoFgbMXWi92pasi5FcydMcwVhiNoQ1N6iaC38xxRW+ENyi7IZ4TJWawKmU+m/Hkaj2JgOKQYL6Q2G6aSJNqeeHiR2/j2lGp14uYuVHiAjqR7K5Bn1lOwGPceLt9vzqwCab09BxXbKd1FL/+I6Ors6/yzz/aPL0U/2v0GY+b0UlPSNTGZvUJZr602AccrjYPwgAYdm2oaozjdNm7jeWB0FlML3HxrUTlHkRtHlQN/gfzSLZeI9QKSPt1j4Sg==",
"secured": 1,
"bundle": 1,
"certificate": "codecert",
"filename": "/sys/mcuimg.bin",
"digest": "36eb915d01360116d456fee5d81dffae26466e254c78b0ad54a3620ab8f1ae8b"
},
{
"signature_base64": "RwR0tNkidq2EQduuNtEBly1a1yBeAqayJWpceocSxdQQs1t1Dcelgxa8Iwa6sQ62uCzwdiaYMFVJwMOwRMJRlA9Tol0ZiRGc8FrRSVdI1JQCRiawkHgl0RNw2h4tnTovVXDBeouHdEbtkZpQBPA7dw+aHwq1vm0NIL5Sn0ZkoXV8Knq/TLIGeindiI/xpNHkr1JvISiv6XoO8DdlEbM5/FN1Blr9N99DGkZVpbqqyu8FPzQos76wyJVlG9vl4XSRZV4EkawBE+Rd5YfJ2bRYBtdOtEUZiJ5ZIXdQ7KBrAUESL61LH6RH+keW546pru4aSYQa2551zi/gr1GO0s8e8w==",
"secured": 1,
"bundle": 1,
"certificate": "",
"filename": "/sys/servicepack.ucf",
"digest": "51c316ebc565876ef093eae24fe14c0617ba90295b91f665a2c42898337e59ee"
}
]
I've found that this section of the Json_parse function within json.c rearranges the array structure:
if (jsonText[0] == '[')
{
/* 6 extra characters - {"#": [jsonText in array format] } */
jsonTextLen+=ARRAY_TO_OBJ_EXTRA_CHARS_NUM;
ArrayToObj = (char * )(malloc(jsonTextLen));
if (ArrayToObj != NULL)
{
memset(ArrayToObj, 0, jsonTextLen);
/* convert the Json array to be a value of an object name "#" */
sprintf(ArrayToObj, "{\"#\":%s}",jsonText);
jsonText = ArrayToObj;
}
else
{
return JSON_RC__MEMORY_ALLOCATION_ERROR;
}
}
However, the ParseCommon function expects to see a ']' or ',' character at the end of the JSON object. As the sprintf above only adds a '}' character to the end of the JSON object it fails at the end of parsing.
- I'm curious as to why the JSON object that the OtaArchive "finds" passes the '[' character to the JSON parser? Since the format of the OTA cmd file is specified, wouldn't to be advantageous to just ignore the character?