I'm trying to implement firmware update using the ROM API but having problems with it.
I have read section 7.3.6 from UM11126 and the attached ROM_API.pdf and as far as I can tell everything should work fine but it does not.
In the attached code below, I'm receiving the image.sb in small pieces and executing them just like in the example in ROM_API.pdf. However, I get kStatusRomLdrSignature (0x2775) error. This sounds like the image is not valid but I have built it with MCUXpresso Secure Provisioning tool and if I use the following blhost command when in ISP mode, the image is flashed just fine and boots:
blhost -t 240000 -p /dev/ttyACM0,57600 -- receive-sb-file /home/henrik/secure_provisioning/bootable_images/image.sb
Thus, I don't think the image can be the problem.
Image update code on LPC55S69:
status_t status;
kb_session_ref_t *session = NULL;
uint32_t kKbootApiVersion = 1u;
uint8_t certBuffer[(4096+432)*2] = { 0 };
kb_options_t options = {
.version = kKbootApiVersion,
.buffer = certBuffer, //array defined by user
.bufferLength = (4096+432)*2, // defined by user
.op = kRomLoadImage, //used for IAP feature
{
.loadSB = {
.profile = 0, // Also tried kKbootMinRSA4096
.minBuildNumber = 1, // Tried 0 too
.overrideSBBootSectionID = 1, // And here 0 too
.userSBKEK = NULL, //Set Null then IFR SBKEK will be used
.regionCount = 0,
.regions = NULL, // If regions is NULL, all memory is accessible by the SB file
},
}
};
status = kb_init(&session, &options);
if (status == kStatus_Success) {
uint8_t imageBuffer[1024];
while(1) {
// Receive 1024 byte pieces of image.sb file to imageBuffer
...
// Execute chunk
status = kb_execute(session, imageBuffer, 1024);
// Check return
if (status == kStatus_RomApiNeedMoreData) {
// Ask host for more data
...
continue;
} else if(status == kStatus_RomApiExecuteCompleted) {
// Signal end to host
...
break;
} else {
// Report error to host
...
break;
}
};
}
status_t statusdeinit = kb_deinit(session);
return status | statusdeinit;
The part I'm the most unsure about is kb_options_t. I have tried couple different options without any success and these are from ROM_API.pdf example so I assume they should work.
I have verified that the image pieces that I send are received correctly so that's not the problem.
This is the C API I'm using https://github.com/zephyrproject-rtos/hal_nxp.