XUEF216-512-TQ128-C20 Field update

Technical questions regarding the XTC tools and programming with XMOS.
Post Reply
asihvo
Junior Member
Posts: 6
Joined: Tue Aug 28, 2018 10:57 am

XUEF216-512-TQ128-C20 Field update

Post 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


User avatar
mon2
XCore Legend
Posts: 1913
Joined: Thu Jun 10, 2010 11:43 am
Contact:

Post 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
asihvo
Junior Member
Posts: 6
Joined: Tue Aug 28, 2018 10:57 am

Post by asihvo »

I managed to pinpoint the problem to fl_startImageReplace, If I use fl_startImageAdd (without the while loop) everything works perfectly.
asihvo
Junior Member
Posts: 6
Joined: Tue Aug 28, 2018 10:57 am

Post 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.
User avatar
mon2
XCore Legend
Posts: 1913
Joined: Thu Jun 10, 2010 11:43 am
Contact:

Post by mon2 »

Hi. Can you post exactly what you are doing and also the results that you see after your process?
asihvo
Junior Member
Posts: 6
Joined: Tue Aug 28, 2018 10:57 am

Post 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;
User avatar
mon2
XCore Legend
Posts: 1913
Joined: Thu Jun 10, 2010 11:43 am
Contact:

Post 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
asihvo
Junior Member
Posts: 6
Joined: Tue Aug 28, 2018 10:57 am

Post 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
colin
Experienced Member
Posts: 74
Joined: Mon Dec 16, 2013 12:14 pm

Post 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
Post Reply