flash persistent data to hardware

Technical questions regarding the XTC tools and programming with XMOS.
Post Reply
rafayel.setyan
New User
Posts: 3
Joined: Mon Feb 20, 2023 1:18 pm

flash persistent data to hardware

Post by rafayel.setyan »

Hi there,
I am almost new to XMOS and its related stuff. Also I am not familiar with a lot of hardware related concepts and topics. I am familiar with xmos' sdk and many modules there architecture and functionalities(lib_mic_array, module_vocalfusion ... etc). Currently on my project we would like persistent data for couple of variables which will be set from that data and remain the same even after rebooting(power on/off) of device. So I took a look to the AN00188 and added that reading functionality on my scripts but the fl_connectToDevice fails and returns non zero value during the runtime. So I build my project for XCORE-200-EXPLORER with the xTimeComposer14.3 then I flash with the terminal command

Code: Select all

xflash --factory-version 14.3 --upgrade 1 app.xe -o app.bin --no-compression
then the generated app.bin is used to update the firmware of the device. What I have tried is to flash like in the example

Code: Select all

xflash --no-compression --target-file XCORE-200_EXPLORER.xn --factory app.xe --boot-partition-size 0x80000 --data data.bin
but when I execute with the host computer the fl_connectToDevice does not work. I run with the command

Code: Select all

xrun --io --verbose app.xe
Take into account except that functionality other stuff on the firmware works as expected. I also tried this command and it didn't work

Code: Select all

xflash --factory app.xe --factory-version 14.3 --upgrade 1 app.xe -o app.bin --no-compression --boot-partition-size 0x80000 --data data.bin --verbose
The added function which doesn't work is shown below

Code: Select all

static fl_QSPIPorts ports = {
    PORT_SQI_CS,
    PORT_SQI_SCLK,
    PORT_SQI_SIO,
    on tile[1]: XS1_CLKBLK_1
};

static 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,
};

static void readData(){
    if(fl_connectToDevice(ports, deviceSpecs, sizeof(deviceSpecs)/sizeof(fl_QuadDeviceSpec)) != 0){
        printf("Unable conncet to device\n");
        return;
    }
    printf("Successfully conected\n");
    char chars[NUM_DATA_BYTES];
    if(fl_readData(0, NUM_DATA_BYTES, chars) != 0){
        printf("Unable to read data\n");
        return;
    }
    printf("Successfully read the data\n");
    for(size_t i = 0; i < NUM_DATA_BYTES; ++i){
        printf("%d, ", (int)chars[i]);
    }
    fl_disconnect();
    return;
}
I also attach my XCORE-200-EXPLORER.xn command's log.
Thanks in advance,
Rafayel
Attachments
logs.txt
(8.93 KiB) Downloaded 129 times
logs.txt
(8.93 KiB) Downloaded 129 times
XCORE-200-EXPLORER.xn
(2.51 KiB) Downloaded 128 times
XCORE-200-EXPLORER.xn
(2.51 KiB) Downloaded 128 times


User avatar
fabriceo
XCore Addict
Posts: 181
Joined: Mon Jan 08, 2018 4:14 pm

Post by fabriceo »

just some quick thoughts :
use XTC 14.4.1 as it natively supports S25FL116K (and the generated bin image can be compatible with your option --factory-version 14.3)
you have -lquadflash in the list of compile options in your makefile
try this... : https://www.xcore.com/viewtopic.php?f=26&t=8062
hope this helps
rafayel.setyan
New User
Posts: 3
Joined: Mon Feb 20, 2023 1:18 pm

Post by rafayel.setyan »

Thanks for the reply. Interestingly if I make the separate app which has one main and only reads the data it works properly. I built it then flashed with the command:

Code: Select all

xflash --no-compression --target-file XCORE-200-EXPLORER.xn --factory app_dsp.xe --boot-partition-size 0x80000 --data data.bin --verbose
but if I add the same functionality in my main application the fl_connectToDevice doesn't work. The XCORE-200-EXPLORER.xn files are the same, the makefile xcc flags for flashing are the same, the xflashing command is the same. Any suggestions what can be the cause of the failure. Note : my main application with 2 tiles does BAP AEC and other DSP stuff, also VAD and WakeWord detector.
User avatar
dsteinwe
XCore Addict
Posts: 144
Joined: Wed Jun 29, 2016 8:59 am

Post by dsteinwe »

If you are using the 14.3. the mcus with the new flash are not supported. You on the right way. Add "--spi-spec IS25LP016D.spispec" to the xflash command. The content of the file "IS25LP016D.spispec" should be:

Code: Select all

21,
256,
8192,
3,
4,
0x9F,
0,
3,
0x9D6015,
0x20,
4096,
0x06,
0x04,
PROT_TYPE_NONE,
{{0,0},{0x00,0x00}},
0x02,
0xEB,
1,
SECTOR_LAYOUT_REGULAR,
{4096,{0,{0}}},
0x05,
0x01,
0x01,
User avatar
dsteinwe
XCore Addict
Posts: 144
Joined: Wed Jun 29, 2016 8:59 am

Post by dsteinwe »

Above is an example for a different flash. Please, adopt it for your flash.
rafayel.setyan
New User
Posts: 3
Joined: Mon Feb 20, 2023 1:18 pm

Post by rafayel.setyan »

thanks a lot look like all works properly. Both flashing stuff and read/writing in the persistent data works.
Post Reply