Replace Factory Image

New to XMOS and XCore? Get started here.
Post Reply
jzw
Member++
Posts: 24
Joined: Sat Nov 14, 2015 3:53 pm

Replace Factory Image

Post by jzw »

I am using part XUF216-512-FB236.
I am trying to write some code that will replace the factory image with a programme downloaded from the host PC so that the system can be dynamically updated in the field. I have found various documents that address this requirement but none of them are consistent. I can access the factory image for read using a sequence as below to read data, but if I use fl_startImageReplace(b,256) or fl_startDeleteImage(b) I get a -ve error value.

Any help appreciated!

fl_connectToDevice(ports, deviceSpecs, sizeof(deviceSpecs)/sizeof(fl_QuadDeviceSpec))
fl_getFactoryImage(b);
iStatus = 1;
while (iStatus != 0)
{
// iStatus = fl_startImageReplace(b,256);
// iStatus = fl_startDeleteImage(b);
iStatus = fl_startImageRead(b);
if (iStatus < 0)
{
printf("Upgrade : startimagereplace error %d\n",iStatus);
return -1;
}
}
iStatus = fl_readImagePage(page);
for (i=0 ; i<16 ; i++) printf("%02x ",page);
printf("\n");

fl_disconnect();


User avatar
Ross
XCore Expert
Posts: 962
Joined: Thu Dec 10, 2009 9:20 pm
Location: Bristol, UK

Post by Ross »

Deleting the factory image is pretty dangerous..

Why are you not using the normal procedure of writing to an upgrade image?
jzw
Member++
Posts: 24
Joined: Sat Nov 14, 2015 3:53 pm

Post by jzw »

OK Maybe I'm going down the wrong path. I want to be able to upgrade firmware by downloading over a USB connection. I can programme the flash using xflash or from xtime but this uses the jtag link which is not available on the final product. I am quite happy to use this to load something that will enable another boot image to run on power up if that is the way to do it.
jzw
Member++
Posts: 24
Joined: Sat Nov 14, 2015 3:53 pm

Post by jzw »

I am using the following sequence

Programme device with

xflash --factory DATSSolo123.xe --upgrade 1 DATSSolo456.xe

If I read the image back all data is set to valid values.

I then try and update the first update image by

fl_QuadDeviceSpec deviceSpecs[] =
{
FL_QUADDEVICE_SPANSION_S25FL116K,
FL_QUADDEVICE_SPANSION_S25FL132K,
FL_QUADDEVICE_SPANSION_S25FL164K,
FL_QUADDEVICE_ISSI_IS25LQ080B,
FL_QUADDEVICE_ISSI_IS25LQ016B,
FL_QUADDEVICE_ISSI_IS25LQ032B,
};
if(fl_connectToDevice(ports, deviceSpecs, sizeof(deviceSpecs)/sizeof(fl_QuadDeviceSpec)) != 0)
{
return -1;
}
memset(&b,0,sizeof(fl_BootImageInfo));
iStatus = fl_getFactoryImage(b);
if (iStatus != 0)
{
return -2;
}

iStatus = fl_getNextBootImage(b);
if (iStatus != 0)
{
return -5;
}

iStatus = 1;
while (iStatus != 0)
{
iStatus = fl_startImageReplace(b, 0xc000);
if (iStatus < 0)
{
return -6;
}
}

Get data from .bin file
if (fl_writeImagePage(chData) != 0) return -1;
Get next 256 bytes of data from .bin file
if (fl_writeImagePage(chData) != 0) return -1;

The second writeimage always fails. If I read the image data back the second 256 bytes are all 0xff.

Any help greatly appreciated
User avatar
Ross
XCore Expert
Posts: 962
Joined: Thu Dec 10, 2009 9:20 pm
Location: Bristol, UK

Post by Ross »

jzw wrote:
xflash --factory DATSSolo123.xe --upgrade 1 DATSSolo456.xe


At this point you have programmed a factory image AND an upgrade image into the flash.

The device will be running DATSolo456 (assuming it is valid)

Was that your intention?
jzw
Member++
Posts: 24
Joined: Sat Nov 14, 2015 3:53 pm

Post by jzw »

When I use the sequence
fl_connectToDevice()
fl_getFactoryImage();
fl_getNextBootImage();
fl_startImageReplace();

in one subroutine and then
fl_writeImagePage();

in a separate subroutine I can write the first ImagePage sucesfully but subsequent calls fail

If I combine writeImagePage in the first subroutine with a flag to go through the setup sequence on first calling and writing to the image on subsequent calls I can overwrite the first upgrade succesfully, which satisfies my requirement. This is after preloading the first upgrade with xflash.

If I just write the factory image with xflash and then try and use

fl_startImageAdd();

or

fl_startImageAddAt();

to write the first upgrade I get an error return from either call.

There may be something to do with the size of the factory image and/or the upgrade which I have not found yet. Are there specific sizes maybe associated with the flash type in use? I have tried multiples of 256 and 4096 but have not found a size that works.
Post Reply