Problem on fl_getFactoryImage()

Discussions about USB Audio on XMOS devices
Henry
Junior Member
Posts: 7
Joined: Mon Jun 03, 2024 10:19 am

Problem on fl_getFactoryImage()

Post by Henry »

Dear Xcore team,
I got problem on the function fl_getFactoryImage()
My hardware is XU216-512-TQ128, the QSPI flash is UC25H40
When I try to get factory image info by fl_getFactoryImage(), it was stuck, and the function not returned.
The fl_connectToDevice() and fl_getSpiId() functions are OK.
I have download an image to the flash device before doing the test, this image not included my flash testing code, so it works well. The command to download is "xflash bin/2AMi2o2xxxxxx/app.xe".
After adding the testing code, and run with the command "xrun --io bin/2AMi2o2xxxxxx/app.xe", the program stuck in fl_getFactoryImage()

The flash SPIC :

Code: Select all

#define FL_QUADDEVICE_UC25HQ40 \
{ \
    0,                      /* UC25HQ40_QSPI - Just specify 0 as flash_id */\
    256,                    /* page size */\
    2048,                   /* num pages */\
    3,                      /* address size */\
    4,                      /* log2 clock divider */\
    0x9F,                   /* QSPI_RDID */\
    0,                      /* id dummy bytes */\
    3,                      /* id size in bytes */\
    0xB36013,               /* device id */\
    0x20,                   /* QSPI_SE */\
    4096,                   /* Sector erase is always 4KB */\
    0x06,                   /* QSPI_WREN */\
    0x04,                   /* QSPI_WRDI */\
    PROT_TYPE_SR,           /* Protection via SR */\
    {{0x3C,0x00},{0,0}},    /* QSPI_SP, QSPI_SU */\
    0x02,                   /* QSPI_PP */\
    0xEB,                   /* QSPI_READ_FAST */\
    1,                      /* 1 read dummy byte */\
    SECTOR_LAYOUT_REGULAR,  /* mad sectors */\
    {4096,{0,{0}}},         /* regular sector sizes */\
    0x05,                   /* QSPI_RDSR */\
    0x01,                   /* QSPI_WRSR */\
    0x01,                   /* QSPI_WIP_BIT_MASK */\
}
#define DFU_FLASH_DEVICE FL_QUADDEVICE_UC25HQ40
The test code :

Code: Select all

void flash_test(void)
{   
    unsigned data[8] = {0}; 
    int result = 0;
    fl_BootImageInfo bootImageInfo;

    result = fl_connectToDevice(&p_qflash, flash_devices, sizeof(flash_devices) / sizeof(fl_QuadDeviceSpec));
    printhexln(result); // works OK
    
    fl_getSpiId(&p_qflash, 0x9f, (unsigned char *)(&data[1]));    
    printhexln(data[1]); // works OK, the id is correct
    
    result = fl_getFactoryImage(&bootImageInfo); // stuck here, this function not returned ...
    printhexln(result); 
   
    fl_disconnect();
}

Code: Select all

$ xrun --io bin/2AMi2o2xxxxxx/app.xe
xrun: Program received signal ET_ILLEGAL_RESOURCE, Resource exception.
      [Switching to tile[0] core[2]]
      0x00047a02 in fl_int_read ()
I use a logic analyzer to monitor the pins of the flash, I found that during the execution of the function fl_getFactoryImage(), there is no waveform on the flash pins.
In addition, while executing the function fl_connectToDevice(), I found that Xcore reads 4 bytes from 0x0000000C, and the content is 0x00 0x00 0x80 0x00

I guess there's no FactoryImage info stored in flash causing this problem, but I really don't know what exactly is missing.

Thanks in advance.
User avatar
Ross
Verified
XCore Legend
Posts: 1070
Joined: Thu Dec 10, 2009 9:20 pm
Location: Bristol, UK

Post by Ross »

you can check that the flash has been programmed as expected with the --read-all option to xflash
Technical Director @ XMOS. Opinions expressed are my own