How to create a data partition on flash device with XU316?

Technical discussions around xCORE processors (e.g. xcore-200 & xcore.ai).
Henry
Member
Posts: 14
Joined: Mon Jun 03, 2024 10:19 am

How to create a data partition on flash device with XU316?

Post by Henry »

Hello everyone, my goal is to create a data partition on the device to temporarily store the firmware of another device during DFU. However, I encountered a problem when creating the data partition.
XMOS Device: XU316-1024-QF60B
QSPI Flash: W25Q64JW, 64 Mbits
XTC: 15.2.1
I have use the --data option while downloading the firmware, but still get errors:
1. fl_getDataPartitionSize() returns 0
2. fl_eraseDataSector(0) returns non-zero.
3. fl_readDataPage(0, pagedata) returns non-zero.
It seem that there are no data partition in the flash device.

The fl_connectToDevice() returns 0, it's OK.
fl_readData(0,16,pagedata) returns 0, it's OK.
My test code:

Code: Select all

void flash_test()
{    
    int result;
    result = fl_connectToDevice(p_qflash1, flash_devices1, sizeof(flash_devices1) / sizeof(fl_QuadDeviceSpec));
    if (result)
    {
        printstrln("open flash error");
    }
    else
    {    
        unsigned s;
        s = fl_getDataPartitionSize();
        printstrln("DataPartitionSize");
        printintln(s);
        
        if (fl_eraseDataSector(0) != 0)
        {
            printstrln("erase err");
        }       
        
        unsigned char pagedata[256];
        if (//fl_readDataPage(0, pagedata)
            fl_readData(0,16,pagedata)
            )
        {
            printstrln("read data error");
        }
        else
        {
            printhexln(pagedata[0]);
            printhexln(pagedata[1]);
            printhexln(pagedata[2]);
            printhexln(pagedata[3]);
        }
        fl_disconnect();
    }
}
Flashing the device with this command:

Code: Select all

xflash --factory bin/app.xe --boot-partition-size 0x80000 --data src/data.bin
The data.bin size is 16 bytes.
User avatar
Ross
Verified
XCore Legend
Posts: 1251
Joined: Thu Dec 10, 2009 9:20 pm
Location: Bristol, UK

Post by Ross »

What do you get as results for these:
fl_getFlashSize()
fl_getBootPartitionSize()

(underneath fl_fl_getDataPartitionSize() returns fl_getFlashSize() - fl_getBootPartitionSize())

I guess your SPI spec is incorrect if these are unexpected values.

Assuming the flash supports SFDP you just connect without a spec with fl_connect(p_qflash1);
Technical Director @ XMOS. Opinions expressed are my own
Henry
Member
Posts: 14
Joined: Mon Jun 03, 2024 10:19 am

Post by Henry »

Thanks Ross!
Both fl_getFlashSize() and fl_getBootPartitionSize() returns 8388608.
After using fl_connect(p_qflash1) instead, it works correctly.
This proves that there are some errors in my SPI SPEC.

I guess it's caused by incorrect readCommand and readDummyBytes.

Code: Select all

 
 /** Command used to read data. */
  int readCommand;
  /**
   * The number of dummy bytes returned by the device after a read
   * command before the first byte of data.
   */
  int readDummyBytes;
I have try the different read commands, but all fails:
03H (1-1-1 Read Data + 0 bytes dummy)
BootPartitionSize() => 8388608
DataPartitionSize() => 0
fl_readDataPage(0, pagedata) => error

0BH (1-1-1 Fast Read + 1 bytes dummy)
BootPartitionSize() => 524288
DataPartitionSize() => 7864320
fl_readDataPage(0, pagedata) => 0, but the data read out is incorrect

6BH (1-1-4 Fast Read Quad Output + 4 bytes dummy)
BootPartitionSize() => 8388608
DataPartitionSize() => 0
fl_readDataPage(0, pagedata) => error

EBH (1-4-4 Fast Read Quad Output + 3 bytes dummy)
BootPartitionSize() => 8388608
DataPartitionSize() => 0
fl_readDataPage(0, pagedata) => error
User avatar
Ross
Verified
XCore Legend
Posts: 1251
Joined: Thu Dec 10, 2009 9:20 pm
Location: Bristol, UK

Post by Ross »

I would just use SFDP unless you really need to get binary size down.
Technical Director @ XMOS. Opinions expressed are my own