Readback --idstr

Technical questions regarding the XTC tools and programming with XMOS.
lmariotti
Active Member
Posts: 42
Joined: Mon Nov 21, 2022 5:38 pm

Readback --idstr

Post by lmariotti »

Hi everyone,

I'm using the xflash command as follow:

Code: Select all

xflash my_program.xe --idstr message
I'm looking for a way to read back the written message, I've checked the xflash documentation https://www.xmos.com/documentation/XM-0 ... anual.html but didn't find anything usefull.

I've tried to dump memory to file, but wasn't able to detect my message

Code: Select all

xflash --read-all --target-file my_config_file.xn -o temp.bin 
Any suggestion?

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

Post by Ross »

Technical Director @ XMOS. Opinions expressed are my own
lmariotti
Active Member
Posts: 42
Joined: Mon Nov 21, 2022 5:38 pm

Post by lmariotti »

Hi Ross,

thanks for your reply.
I'm trying to use the idstr as Serial Number adding it to XUA_Endpoint0, so far I've tried as follow:

Code: Select all

void flash_get_serial_number(char* serial_number, int max_len)
{
  int result = fl_connect(&p_qflash);

  if(result == 0)
  {
    fl_getFlashIdStr(serial_number, max_len);
  }

  fl_disconnect();
}

void XUA_Endpoint0_set_serial_number(void)
{
  char serial_number[XUA_MAX_STR_LEN];
  memset(serial_number, '\0', sizeof(serial_number));
  
  flash_get_serial_number(serial_number, 8);

  if(strnlen(serial_number, sizeof(serial_number)) > 0)
  {
    XUA_Endpoint0_setSerialStr(serial_number);
  }
}


calling XUA_Endpoint0_set_serial_number() just before XUA_Endpoint0_init(...) in XUA_Endpoint0(...)

This implementation trigger an XCore Exception ET_ILLEGAL_RESOURCE (DI Resource Lane) on a random task that runs on tile0 (XUD_TILE = 0).
Replacing flash_get_serial_number with a fixed string works just fine.

Any suggestion?
User avatar
Ross
Verified
XCore Legend
Posts: 1260
Joined: Thu Dec 10, 2009 9:20 pm
Location: Bristol, UK

Post by Ross »

ooh thats nasty

are the ports turned on and enabled? (how did you declare p_qflash?)
Technical Director @ XMOS. Opinions expressed are my own
lmariotti
Active Member
Posts: 42
Joined: Mon Nov 21, 2022 5:38 pm

Post by lmariotti »

Hi Ross,

I guess ports are enabled by default, I'm using -DXUA_QUAD_SPI_FLASH=1 and calling flash_cmd_enable_ports with that define act exactly as a standard connection.
About p_qflash definition I've:

Code: Select all

fl_QSPIPorts p_qflash =
{
  PORT_SQI_CS,     //  <Port Location="XS1_PORT_1B" Name="PORT_SQI_CS"/>  
  PORT_SQI_SCLK,   //  <Port Location="XS1_PORT_1C" Name="PORT_SQI_SCLK"/>
  PORT_SQI_SIO,    //  <Port Location="XS1_PORT_4B" Name="PORT_SQI_SIO"/>
  CLKBLK_FLASHLIB
}; 
DFU_FLASH_DEVICE is not defined.

Anyway the string is readed just fine but then tile 0 crash, here my xgdb, Tile0_adc_task is a simple i2s master loopback that runs (100% fine) on tile 0

Code: Select all

Thread 1.1 hit Breakpoint 1, XUA_Endpoint0_set_serial_number ()
    at .../lib_xua/lib_xua/src/core/endpoint0\xua_endpoint0.c:1272
1272      memset(serial_number, '\0', sizeof(serial_number));
(gdb) n
[New tile[0] core[5]]
[New tile[0] core[6]]
1274      flash_get_serial_number(serial_number, 8);
(gdb) n
1276      if(strnlen(serial_number, sizeof(serial_number)) > 0)
(gdb) p serial_number
$1 = "MYSERIAL", '\000' <repeats 23 times>
(gdb) c
Continuing.
[Switching to tile[0] core[5]]

Thread 1.6 hit Catchpoint -1 (XCore Exception ET_ILLEGAL_RESOURCE (DI Resource Lane)), 0x00080498 in Tile0_adc_task (clk=<optimized out>)
    at .../lib_i2s/lib_i2s/src\i2s_frame_master_impl.h:82
82              p_lrclk @ 1 <: lr_mask
The crash occours on p_lrck that is on X0D38 aka PORT_1O so I can't find any relation

Disabling the Tile0_adc_task everything works fine and the serial is correctly displayed:
From Thesycon USB Descriptor Dumper:

Code: Select all

------------------------------
Device Descriptor:
------------------------------
0x12	bLength
0x01	bDescriptorType
0x0201	bcdUSB
0xEF	bDeviceClass      (Miscellaneous device)
0x02	bDeviceSubClass   
0x01	bDeviceProtocol   
0x40	bMaxPacketSize0   (64 bytes)
0x20B1	idVendor
0x0018	idProduct
0x0900	bcdDevice
0x01	iManufacturer   "MANUFACTURER"
0x03	iProduct        "PRODUCT"
0x02	iSerialNumber   "MYSERIAL"
0x01	bNumConfigurations
lmariotti
Active Member
Posts: 42
Joined: Mon Nov 21, 2022 5:38 pm

Post by lmariotti »

Hi Ross,

nevermind I've found the bug.

I had:

Code: Select all

// From uac_hwresources.h
#define CLKBLK_FLASHLIB    XS1_CLKBLK_3

// From main.xc
on tile[0] : clock adc_i2s_clock = XS1_CLKBLK_3;
So both flashlib and my i2s task shared the same clock resources (shame on me)
This change seems to have solved the problem:

Code: Select all

-#define CLKBLK_FLASHLIB    XS1_CLKBLK_3
+#define CLKBLK_FLASHLIB    XS1_CLKBLK_1
User avatar
Ross
Verified
XCore Legend
Posts: 1260
Joined: Thu Dec 10, 2009 9:20 pm
Location: Bristol, UK

Post by Ross »

Brilliant, well done. The XC compiler would have spotted this, one drawback of using C.
Technical Director @ XMOS. Opinions expressed are my own