Page 1 of 1

XUEF216-512-TQ128-C20 Field update

Posted: Tue Aug 28, 2018 11:08 am
by asihvo
Hi,
I trying to update XUEF216-512-TQ128-C20 over serial port and have encountered some problems
flash_persist_init(ports); // Connects the SPI
fl_getFactoryImage(b0);
if ( fl_getNextBootImage(b1)) {
while(fl_startImageAdd(b0,kBF_MAX_IMAGE_SIZE,0));
}
else {
fl_startImageReplace(b1,kBF_MAX_IMAGE_SIZE,0);
}
// repeat this block until all is written
// data = 256 bytes from RS-232
if( (value =fl_writeImagePage(data) ) )
{
break;
}


xflash --erase-all --verbose --target XUEF216-512-TQ128-C20
xflash --factory bin/factory.xe --upgrade 1 bin/bf_prec_bridge_final-0.2.4.xe
time xflash --factory bin/factory.xe --upgrade 2 bin/bf_prec_bridge_final.xe -o xmos-update.bin
The images are identical except their version number differes.

Usually I can connect and load one page from xmos-update.bin and decode it but writing the data fails every single time. I have ran out of ideas what I am doing wrong.

regards
AP Sihvonen

Re: XUEF216-512-TQ128-C20 Field update

Posted: Wed Aug 29, 2018 12:57 pm
by mon2
Hi. No direct experience with this but believe you are not passing a valid parm to fl_writeImagePage.

The parm is to be a char array that defines your page to be saved. Take the contents from your RS232 read and stuff it into an array -> pass that array to this routine to test again. Guessing the call was being rejected.

Please post your results.

Reference (the same API call is being used in this posted code):

https://github.com/xcore/sc_flash/blob/ ... rc/main.xc

Re: XUEF216-512-TQ128-C20 Field update

Posted: Fri Aug 31, 2018 4:49 am
by asihvo
I managed to pinpoint the problem to fl_startImageReplace, If I use fl_startImageAdd (without the while loop) everything works perfectly.

Re: XUEF216-512-TQ128-C20 Field update

Posted: Tue Sep 04, 2018 8:48 am
by asihvo
Any Ideas, I also tried to to delete a image and then add mae after the previuous image. It writes a few image and then fails to write any more images. I am some what puzeled with the behaviour.

Re: XUEF216-512-TQ128-C20 Field update

Posted: Tue Sep 04, 2018 3:59 pm
by mon2
Hi. Can you post exactly what you are doing and also the results that you see after your process?

Re: XUEF216-512-TQ128-C20 Field update

Posted: Wed Sep 05, 2018 4:53 am
by asihvo
Following code works. But if I try to replace the image or delete it and
then add image, the write fails. Sometimes the first write fails sometimes
the 17:th. The while loop around ImageReplace hangs the device, I cannot get
any response after that, Without while it fails on write. Summa summarum:
I can add updates at the end but I cannot replace a image, which is quite annoying.


case flash_if[int i].start_firmware_update() -> int value:
flash_persist_init(ports);
fl_getFactoryImage(b0);
int add_after=0;
value = 0; // no error
while (! fl_getNextBootImage(b1))
{
add_after++;
memcpy(&b2,&b1,sizeof(b1));
}
if ( ! add_after ) {
fl_startImageAdd(b0,kBF_MAX_IMAGE_SIZE,0);
}
else {
fl_startImageAdd(b2,kBF_MAX_IMAGE_SIZE,0);
//while(fl_startImageReplace(b2,kBF_MAX_IMAGE_SIZE));
}

break;
case flash_if[int i].load_firmware_update_chunk(char data[kBF_FIRMWARE_IMAGE_CHUNK_SIZE], int nr) -> int value:
memcpy(latest_chunk_data, data, kBF_FIRMWARE_IMAGE_CHUNK_SIZE);
latest_chunk_nr = nr;
base64_decode(latest_chunk_data,kBF_FIRMWARE_IMAGE_CHUNK_SIZE,decoded);
value = 0; // no error
break;
case flash_if[int i].write_firmware_update_chunk(int nr) -> int value:
if( (value =fl_writeImagePage(decoded) ) )
{
break;
}
value = 0; // no error
break;
case flash_if[int i].finish_firmware_update() -> int value:
fl_disconnect();
value = 0; // no error
break;

Re: XUEF216-512-TQ128-C20 Field update

Posted: Wed Sep 05, 2018 6:56 am
by mon2
Hi. What is the version of your xtimecomposer tool?

Please also review the following tool advisory.

http://www.google.com/url?q=https://www ... DwizKo8aEV

Re: XUEF216-512-TQ128-C20 Field update

Posted: Thu Sep 06, 2018 6:42 am
by asihvo
The problem is not finding next boot image but to replace is. I believe the issue you mentioned is fixed on versions I use.

$ xcc --version
Community_14.3.3 (build 22296, Apr-19-2018)
Compiler version: 14.3.3
Copyright (C) XMOS Limited 2008-2017. All Rights Reserved.

$ xflash --version
Community_14.3.3 (build 22296, Apr-19-2018)
Copyright (C) XMOS Limited 2008-2017. All Rights Reserved.
aps@Dev-Ubuntu-1:~/bf-bridge/xmos/new/bf_prec_bridge_final$

BR
AP

Re: XUEF216-512-TQ128-C20 Field update

Posted: Wed Sep 12, 2018 9:18 am
by colin
Hi asihvo,

If I'm following your thread correctly, the fl_startImageReplace is completing with a return code 0, however when you go on to write into that sector with fl_writeImagePage at some point the write fails.

I guess the first thing to check is if the 0 return from fl_startImageReplace is valid. That is, the image that is to be replaced has been correctly and fully erased from flash memory. You can do this by running your program until fl_startImageReplace returns 0, then read back the contents of flash memory using xflash --read-all --target=mytarget -o read.bin. The contents of flash memory at the address of the upgrade image you just erased should all be 0xFFFFFFFF. If it is not fully erased then we know we have an issue with fl_startImageReplace. If it is fully erased then we know we have an issue with fl_writeImagePage, and we can go from there.

Colin