Error: F03013 SPI flash issues on XK-AUDIO-316-MC-AB and same on custom board

Technical discussions related to any XMOS development kit or reference design. Eg XK-1A, sliceKIT, etc.
XmaCE
Junior Member
Posts: 4
Joined: Fri Sep 19, 2025 1:17 pm

Error: F03013 SPI flash issues on XK-AUDIO-316-MC-AB and same on custom board

Post by XmaCE »

Hi XMOS gurus,

after working with the EVK for a while (XK-AUDIO-316-MC-AB) it stopped accepting SPI commands using xflash. I can still xrun, xgdb etc, but it seems the Xcore reads all 0 from the SPI flash.
next, the same happened on my custom board. I did flash various images and debug just fine, then it stopped working in the same manner.

I searched the forums and found out about the QE bit, and the toolchain issue WRT "--spi-div=8" but that doesn't seem to be my issue. one of the main problems seems to be that even the chip-id cannot be read, it always reports "Site 0 has ID 0x000000"

please help me unbrick the original EVK and my custom board.

In an attempt to do so, I had changed the 10k pull-up resistor to 1k as it's is documented, but that didn't change things.

here's the full log (they're identical for both boards):
% cat xmos_evk.log
% xflash -v --spi-div=8  bin/project/board.xe
XFlash_Options::ListDevices : xrun --list-devices devl-6e9b54cd 
XFlash_Application found _start :80000 on Node 0
XFlash_Application found _DoSyscall :88180 on Node 0
XFlash_Application found _DoException :800c4 on Node 0
XFlash_Application found _start :80000 on Node 0
XFlash_Application found _DoSyscall :822c4 on Node 0
XFlash_Application found _DoException :800c4 on Node 0
XFlash::DoXFlash
XFlash::DoImageProgramming
XFlash::GetDeviceInfo
XFlash_DeviceInfo::GetDeviceInfo_User
XFlash_DeviceInfo::PrintDeviceInfo
  Site 0 (bootFlash) info:
    _device_size 0x400000
    _device_page_size 0x100
    _regular_sector_sizes true
    _device_sector_size 0x1000
    _device_protection_available false
    _device_divider 8
    _device_first_user_sector 0x0
    _device_search_limit 0x400000
XFlash::BuildFlashBinaryFile
XFlash_Builder_S2L::BuildStage2Loaders Factory
Stage2_Loader::Compile : xcc -Wno-bidirectional-buffered-port -Wno-timing -Wno-unused-function -Xmapper --dontenablesodlinks -Xmapper --nochaninit -Xmapper --noinitialtidy -Xmapper --image-base -Xmapper 0x80080 -Xmapper --image-size -Xmapper 0x7ff80 -Xmapper --wno110 -Xmapper --wno226 -Xmapper --wnoXN -std=gnu99 -O2 -target=XU316-1024-FB265-C32 -x none "/home/name/CODE/XMOS/toolchain/XMOS/XTC/15.3.1/target/app/xs3a/stage2loader_SQI.o" -lstage2loader -lsqiaccess -lquadspi -llocks -o s2l-n0-4632bcfe
Stage2Loader found DEVICE_SECTOR_WORD_SIZE : 0x81650 on Node 0
Stage2Loader found pllConfig : 0x815f8 on Node 0
Stage2Loader found otp_disable : 0x81654 on Node 0
Stage2Loader found debug_stop : 0x81658 on Node 0
Stage2Loader found s2l_record_timings : 0x81644 on Node 0
Stage2Loader found s2l_search_by_address : 0x81648 on Node 0
Stage2Loader found s2l_num_addresses : 0x8164c on Node 0
Stage2Loader found s2l_search_addresses : 0x815b8 on Node 0
Stage2Loader found flash_ports : 0x815c8 on Node 0
Stage2Loader found clock_config : 0x815d8 on Node 0
Stage2Loader found qe_config : 0x815f0 on Node 0
Stage2Loader found spanning_routing_id : 0x8250c on Node 0
Stage2Loader found spanning_table : 0x81388 on Node 0
Stage2Loader found num_spanning_tables : 0x82510 on Node 0
Stage2Loader found routing_table : 0x81ab8 on Node 0
Stage2Loader found num_routing_tables : 0x82514 on Node 0
Stage2Loader found link_info : 0x81c48 on Node 0
Stage2Loader found links_table : 0x81e28 on Node 0
Stage2Loader found num_link_tables : 0x82518 on Node 0
Stage2Loader found galaxian_table : 0x82328 on Node 0
Stage2Loader found num_galaxian_tables : 0x8251c on Node 0
Stage2Loader found pll_table : 0x823a0 on Node 0
Stage2Loader found debug_stop : 0x82524 on Node 0
Stage2Loader found secondaryPllConfig : 0x823c0 on Node 0
Stage2Loader found ddrConfig : 0x823d0 on Node 0
Stage2Loader found ddrEnable : 0x82520 on Node 0
XFlash_Builder_Image::BuildImages Factory
XFlash_Builder_Image::BuildImageTable
  master node = 0
    node = 0
XFlash_Builder_Image::BuildImageTable num cores for image table = 2
XFlash_Builder_Image::CalculateBufferSize Starting calculation _total_image_size=0
XFlash_Builder_Image::CalculateBufferSize Add Image Header _total_image_size=38
XFlash_Builder_Image::CalculateBufferSize Add Switch Setup header _total_image_size=40
XFlash_Builder_Image::CalculateBufferSize Add Per Core header _total_image_size=80
XFlash_Builder_Image::CalculateBufferSize_SwitchSetup _total_image_size=25ac
XFlash_Builder_Image::CalculateBufferSize_Application application size = c9c0 _total_image_size = ef6c
XFlash_Builder_Image::CalculateBufferSize_Application application size = 4094 _total_image_size = 13000
XFlash_Builder_Image::BuildImageTable allocated image buffer size = 13000
XFlash_Builder_Image::WriteBuffer_ImageHeader
XFlash_Builder_Image::WriteBuffer_SwitchSetup current switch setup table offset : 38
XFlash_Builder_Image::WriteBuffer_SwitchSetup current application data offset : 80
XFlash_Builder_Image::WriteBuffer_SwitchSetup size : 2528
XFlash_Builder_Image::WriteBuffer_SwitchSetup aligned_size : 252c
XFlash_Builder_Image::WriteBuffer_SwitchSetup init_vec_shift : 0
XFlash_Builder_Image::WriteBuffer_Application
XFlash_Builder_Image::WriteBuffer_Application for node : 0
XFlash_Builder_Image::WriteBuffer_Application for core : 0
XFlash_Builder_Image::WriteBuffer_Application current core table offset : 40
XFlash_Builder_Image::WriteBuffer_Application current application data offset : 25ac
XFlash_Builder_Image::WriteBuffer_Application size : c9bc
XFlash_Builder_Image::WriteBuffer_Application aligned_size : c9c0
XFlash_Builder_Image::WriteBuffer_Application init_vec_shift : 0
XFlash_Builder_Image::WriteBuffer_Application chan end : 80020002
XFlash_Builder_Image::WriteBuffer_Application for core : 1
XFlash_Builder_Image::WriteBuffer_Application current core table offset : 60
XFlash_Builder_Image::WriteBuffer_Application current application data offset : ef6c
XFlash_Builder_Image::WriteBuffer_Application size : 4090
XFlash_Builder_Image::WriteBuffer_Application aligned_size : 4094
XFlash_Builder_Image::WriteBuffer_Application init_vec_shift : 0
XFlash_Builder_Image::WriteBuffer_Application chan end : 80030002
XFlash_Builder_Image::WriteBuffer_SwMem
XFlash_Builder_Image::WriteBuffer_SwMem for node : 0
XFlash_Builder_Image::WriteBuffer_SwMem for core : 0
XFlash_Builder_Image::WriteBuffer_SwMem current core table offset : 40
XFlash_Builder_Image::WriteBuffer_SwMem current application data offset : 13000
XFlash_Builder_Image::WriteBuffer_SwMem for core : 1
XFlash_Builder_Image::WriteBuffer_SwMem current core table offset : 60
XFlash_Builder_Image::WriteBuffer_SwMem current application data offset : 13000
XFlash_Builder_Image::WriteBuffer_ExtMem
XFlash_Builder_Image::WriteBuffer_ExtMem for node : 0
XFlash_Builder_Image::WriteBuffer_ExtMem for core : 0
XFlash_Builder_Image::WriteBuffer_ExtMem current core table offset : 40
XFlash_Builder_Image::WriteBuffer_ExtMem current application data offset : 13000
XFlash_Builder_Image::WriteBuffer_ExtMem for core : 1
XFlash_Builder_Image::WriteBuffer_ExtMem current core table offset : 60
XFlash_Builder_Image::WriteBuffer_ExtMem current application data offset : 13000
XFlash_Builder_Image::WriteBuffer_CRC
XFlash_Builder_Binary::BuildBinary
XFlash_Builder_Binary::CalculateBufferSize_Factory
XFlash_Builder_Binary::CalculateBufferSize_Factory : Adding s2l size word (4)4
XFlash_Builder_Binary::CalculateBufferSize_Factory : Adding s2l app (1668) 166c
XFlash_Builder_Binary::CalculateBufferSize_Factory : Adding s2l crc (4)1670
XFlash_Builder_Binary::CalculateBufferSize_Factory : Adding factory app (13000) 14670
XFlash_Builder_Binary::CalculateBufferSize_Factory : Adding sector padding (990) 15000
XFlash_Builder_Binary::CalculateBufferSize_Factory : First User Sector offset = 15000
XFlash_Builder_Binary::GetSearchLimitPadding : current size (15000) 0
XFlash_Builder_Binary::CalculateBufferSize_Data
XFlash_Builder_Binary::BuildBinary : Allocating buffer - 15000
XFlash_Builder_Binary::GetSearchLimitPadding : current size (15000) 0
XFlash_Builder_Binary::WriteBufferToBinary : flash_bin_node0
XFlash_Builder_Storage_PPB::BuildStorage
XFlash_Programmer_Write::DoWrite
XFlash_Programmer_Write::IssueCompileCommand
xcc -w -Xmapper --dontenablesodlinks -Xmapper --errdemote130 -Xmapper --errdemote131 -x xn "target-xn-v0-6b3fe8a9" -O2 -lquadflash -llocks -D xnPORT_SQI_CS0=PORT_SQI_CS -D xnPORT_SQI_SCLK0=PORT_SQI_SCLK -D xnPORT_SQI_SIO0=PORT_SQI_SIO -x xc "fw-b72a2060" -o "fw-2ad6d7da" 
XFlash_Utils::BuildRunCommand : xrun --io fw-2ad6d7da 
Site 0 has started.         
Site 0 has ID   0x000000.   
Site 0 erase    0x00000000. 
Site 0 write    0x00000000. 
Verify failed for page 0x00000000, offset 0x0000 (read 0x00, expected 0xa9).

[long timeout]

xrun: Error: Timed out. First stage multi-node boot failed, please check XN file and Xmos link connectivity.
Error: F03013 Failed to run : xrun --io fw-2ad6d7da 
xflash -v --spi-div=8 bin/project/board.xe  7.64s user 1.60s system 5% cpu 2:35.70 total

XmaCE
Junior Member
Posts: 4
Joined: Fri Sep 19, 2025 1:17 pm

Post by XmaCE »

in the meantime I read the SPI flash fine using a SOIC8 clip, and a ch341a interface. the flash contents are there, and not all 0 (they also start with 0xa9).

now since I have a proper HW interface to the SPI chip, I also hacked up some python (AI did) to dump the status regs, and I could confirm e.g. the QE bit is correctly set:


% ./ch341a_status_reader.py 
W25Q32JV Status Register Reader (CH341a USB)
============================================
Scanning for CH341a devices...
Found CH341a device
✓ Connected to CH341a successfully
Initializing CH341a...
✓ CH341a initialized in SPI mode

Reading JEDEC ID...
JEDEC ID: EF 40 16
✓ W25Q32JV detected correctly

Reading all status registers...

=== Status Register 1 (0x05) ===
Raw value: 0x00 (0b00000000)
Bit breakdown:
  Bit 7 (SRP0): 0 - Status Register Protect 0
  Bit 6 (SEC):  0 - Sector Protect
  Bit 5 (TB):   0 - Top/Bottom Protect
  Bit 4 (BP2):  0 - Block Protect 2
  Bit 3 (BP1):  0 - Block Protect 1
  Bit 2 (BP0):  0 - Block Protect 0
  Bit 1 (WEL):  0 - Write Enable Latch
  Bit 0 (BUSY): 0 - Busy

=== Status Register 2 (0x35) ===
Raw value: 0x02 (0b00000010)
Bit breakdown:
  Bit 7 (SUS):  0 - Suspend Status
  Bit 6 (CMP):  0 - Complement Protect
  Bit 5 (LB3):  0 - Security Register Lock 3
  Bit 4 (LB2):  0 - Security Register Lock 2
  Bit 3 (LB1):  0 - Security Register Lock 1
  Bit 2 (Reserved): 0
  Bit 1 (QE):   1 - Quad Enable
  Bit 0 (SRP1): 0 - Status Register Protect 1

=== Status Register 3 (0x15) ===
Raw value: 0x60 (0b01100000)
Bit breakdown:
  Bit 7 (Reserved): 0
  Bit 6 (Reserved): 1
  Bit 5 (WPS):  1 - Write Protect Selection
  Bit 4 (Reserved): 0
  Bit 3 (Reserved): 0
  Bit 2 (DRV1): 0 - Output Driver Strength 1
  Bit 1 (DRV0): 0 - Output Driver Strength 0
  Bit 0 (Reserved): 0
  Driver Strength: 100%

=== SUMMARY ===
Status Register 1: 0x00
Status Register 2: 0x02
Status Register 3: 0x60

any way I can further debug this from here?
Joe
Verified
XCore Addict
Posts: 129
Joined: Sun Dec 13, 2009 1:12 am

Post by Joe »

This points to a problem with your XN or similar. I would try xflash using the standard binaries included in the latest usb audio release:

https://github.com/xmos/sw_usb_audio/re ... tag/v9.1.0

For a basic check of SPI comms to flash you can run the following command to read the device ID:

xflash --spi-read-id 0x9F --target XU316-1024-TQ128-C24

Cheers,
Joe
XMOS hardware grey beard.
Joe
Verified
XCore Addict
Posts: 129
Joined: Sun Dec 13, 2009 1:12 am

Post by Joe »

One other note would be to ensure you're using the latest 15.3.1 tools which fixed a flash comms issue present on 15.3.0.
XMOS hardware grey beard.
XmaCE
Junior Member
Posts: 4
Joined: Fri Sep 19, 2025 1:17 pm

Post by XmaCE »

hey, thanks for your pointers!
% xflash --spi-read-id 0x9F --target XU316-1024-TQ128-C24
/home/user/CODE/XMOS/toolchain/XMOS/XTC/15.3.1/targets/XU316-1024-TQ128-C24/XU316-1024-TQ128-C24.xn:15 Warning: XN11135 Attribute SystemFrequency is ignored when Oscillator is not specified.
xflash: Error: F03040 Platform definition (XN) does not specify a boot flash device.
so I did a
 xflash --spi-read-id 0x9F --target-file ../../project_fw/project/src/core/board.xn
Response to SPI ID command on tile[0]: 0xef, 0x40, 0x16, 0x0.
and it seems to run fine!

the toolchain is 15.3.1:
% which xflash
/home/user/CODE/XMOS/toolchain/XMOS/XTC/15.3.1/bin/xflash

the XN is
<?xml version="1.0" encoding="UTF-8"?>
<Network xmlns="http://www.xmos.com"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://www.xmos.com http://www.xmos.com">
  <Type>Board</Type>
  <Name>boardname</Name>

  <Declarations>
    <Declaration>tileref tile[2]</Declaration>
  </Declarations>

  <Packages>
    <Package id="0" Type="XS3-UnA-1024-TQ128">
      <Nodes>
        <Node Id="0" InPackageId="0" Type="XS3-L16A-1024" Oscillator="24MHz" SystemFrequency="600MHz" ReferenceFrequency="100MHz">
          <Boot>
            <Source Location="bootFlash"/>
          </Boot>
          <Tile Number="0" Reference="tile[0]">
            <Port Location="XS1_PORT_1B" Name="PORT_SQI_CS"/>
            <Port Location="XS1_PORT_1C" Name="PORT_SQI_SCLK"/>
            <Port Location="XS1_PORT_4B" Name="PORT_SQI_SIO"/>

            <!-- Various ctrl signals -->
            <Port Location="XS1_PORT_8D"  Name="PORT_CTRL"/>

            <!-- I2C -->
            <Port Location="XS1_PORT_1L"  Name="PORT_I2C_SCL"/>
            <Port Location="XS1_PORT_1M"  Name="PORT_I2C_SDA"/>

            <!-- Clocking --> 
            <Port Location="XS1_PORT_16B" Name="PORT_MCLK_COUNT"/>
            <Port Location="XS1_PORT_1D"  Name="PORT_MCLK_IN_USB"/>
            <Port Location="XS1_PORT_1A"  Name="PORT_PLL_REF"/>

            <!-- Audio Ports: Digital -->
            <Port Location="XS1_PORT_1O"  Name="PORT_ADAT_IN"/>   <!-- N: Coax O: Optical -->
            <Port Location="XS1_PORT_1N"  Name="PORT_SPDIF_IN"/>  <!-- N: Coax O: Optical -->

          </Tile>
          <Tile Number="1" Reference="tile[1]">
            <!-- Audio Ports: I2S -->
            <Port Location="XS1_PORT_1D"  Name="PORT_MCLK_IN"/>
            <Port Location="XS1_PORT_16B" Name="PORT_MCLK_COUNT_2"/>
            <Port Location="XS1_PORT_1B"  Name="PORT_I2S_LRCLK"/>
            <Port Location="XS1_PORT_1C"  Name="PORT_I2S_BCLK"/>
            <Port Location="XS1_PORT_1P"  Name="PORT_I2S_DAC0"/>
            <port Location="XS1_PORT_1O"  Name="PORT_I2S_DAC1"/>
            <port Location="XS1_PORT_1N"  Name="PORT_I2S_DAC2"/>
            <port Location="XS1_PORT_1M"  Name="PORT_I2S_DAC3"/>
            <Port Location="XS1_PORT_1I"  Name="PORT_I2S_ADC0"/>
            <Port Location="XS1_PORT_1J"  Name="PORT_I2S_ADC1"/>
            <Port Location="XS1_PORT_1K"  Name="PORT_I2S_ADC2"/>
            <Port Location="XS1_PORT_1L"  Name="PORT_I2S_ADC3"/>

          </Tile>
        </Node>
      </Nodes>
    </Package>
  </Packages>
  <Nodes>
    <Node Id="2" Type="device:" RoutingId="0x8000">
      <Service Id="0" Proto="xscope_host_data(chanend c);">
        <Chanend Identifier="c" end="3"/>
      </Service>
    </Node>
  </Nodes>
  <Links>
    <Link Encoding="2wire" Delays="5clk" Flags="XSCOPE">
      <LinkEndpoint NodeId="0" Link="XL0"/>
      <LinkEndpoint NodeId="2" Chanend="1"/>
    </Link>
  </Links>
  <ExternalDevices>
      <Device NodeId="0" Tile="0" Class="SQIFlash" Name="bootFlash" PageSize="256" SectorSize="4096" NumPages="16384">
      <Attribute Name="PORT_SQI_CS" Value="PORT_SQI_CS"/>
      <Attribute Name="PORT_SQI_SCLK"   Value="PORT_SQI_SCLK"/>
      <Attribute Name="PORT_SQI_SIO"  Value="PORT_SQI_SIO"/>
      <Attribute Name="QE_REGISTER" Value="quad_spi_qe_location_status_reg_1"/>
      <Attribute Name="QE_BIT" Value="quad_spi_qe_bit_1"/>
    </Device>
  </ExternalDevices>
  <JTAGChain>
    <JTAGDevice NodeId="0"/>
  </JTAGChain>

</Network>
now it gets interesting; I could flash an original `app_usb_aud_xk_316_mc_2AMi8o8xxxxxx.xe` seemingly fine, but then the EVK appeared with my own USB DID and descriptor.
% xflash app_usb_aud_xk_316_mc_2AMi8o8xxxxxx.xe 
Site 0 has finished successfully.        
% lsusb
[...]
Bus 001 Device 103: ID 20b1:f7d5 XMOS Ltd XMOS XTAG-4
Bus 001 Device 104: ID 20b1:adda XMOS Ltd my own product string
but from now on further flashing attempts fail:
% xflash app_usb_aud_xk_316_mc_2AMi8o8xxxxxx.xe
Site 0 has finished successfully.        
xrun: Internal error: Target connection failed. xdbg call xdbg_continue(xcore, 0) on line 272 of file /jenkins/workspace/xmos-int_xgdb_combined_master/tools_xgdbserver_c/gdbserver/backend/xdbg/xdbg_shim.cpp returned error.
So I guess I am seeing some issue related to A/B image failover?
markp
Verified
Active Member
Posts: 35
Joined: Thu Jan 10, 2019 6:07 pm

Post by markp »

So in the final failure above, is this on your custom board, or the XMOS XK-AUDIO-316-MC-AB board?
Or both?

Can you get the ID out on both boards with:
% xflash --spi-read-id 0x9F --target XCORE-AI-EXPLORER

Then a full erase with
% xflash --erase--all --target XCORE-AI-EXPLORER

And the same two commands with the XN file supplied with sw_usb_audio

% xflash --spi-read-id 0x9F --target-file sw_usb_audio/app_usb_aud_xk_316_mc/src/core/xk-audio-316-mc.xn
% xflash --erase-all --target-file sw_usb_audio/app_usb_aud_xk_316_mc/src/core/xk-audio-316-mc.xn

Can you then try the ".xe" file delivered in the SW USB AUDIO zip file (sw_usb_audio-_sw_9_1_0.zip\sw_usb_audio\app_usb_aud_xk_316_mc\bin\2AMi8o8xxxxxx\app_usb_aud_xk_316_mc_2AMi8o8xxxxxx.xe).

It looks like your first xflash step after "now it gets interesting..." picked up a modified binary because it lists with "my own product string".

Not sure what you mean by the A/B failover - the xflash commands you have used should flash the factory image - and the erase step above should make sure there is no DFU image present in the higher flash region which may get selected for boot.
XmaCE
Junior Member
Posts: 4
Joined: Fri Sep 19, 2025 1:17 pm

Post by XmaCE »

my last post was all on the XMOS XK-AUDIO-316-MC-AB board, but previously I had started FW development on it and changed e.g. USB DID and descriptors. but to my understanding that flashing shoud've overwritten my FW (I had downloaded and unzipped the binary, not even built it myself).
% xflash --spi-read-id 0x9F --target XCORE-AI-EXPLORER
Response to SPI ID command on tile[0]: 0xef, 0x40, 0x16, 0x0.
% xflash --erase-all --target XCORE-AI-EXPLORER
Site 0 has finished successfully.        
% xflash --spi-read-id 0x9F --target-file sw_usb_audio/app_usb_aud_xk_316_mc/src/core/xk-audio-316-mc.xn
Response to SPI ID command on tile[0]: 0xef, 0x40, 0x16, 0x0.
% xflash --erase-all --target-file sw_usb_audio/app_usb_aud_xk_316_mc/src/core/xk-audio-316-mc.xn 
Site 0 has finished successfully.
% xflash sw_usb_audio/app_usb_aud_xk_316_mc/bin/2AMi8o8xxxxxx/app_usb_aud_xk_316_mc_2AMi8o8xxxxxx.xe 
Site 0 has finished successfully.        
xrun: Internal error: Target connection failed. xdbg call xdbg_continue(xcore, 0) on line 272 of file /jenkins/workspace/xmos-int_xgdb_combined_master/tools_xgdbserver_c/gdbserver/backend/xdbg/xdbg_shim.cpp returned error.
% lsusb|grep 20b1 
Bus 001 Device 114: ID 20b1:0016 XMOS Ltd XMOS xCORE.ai MC (UAC2.0)
Bus 001 Device 117: ID 20b1:f7d5 XMOS Ltd XMOS XTAG-4
so now it seems to have properly flashed. thanks for your helping hands!

that's really useful, now I can start debugging, where my modifications tripped the bad behavior. my design is just a basic i8o8, no i2cmux, no ext clock synthesizer/PLL, no clock mux, no MIDI, no ADAT/optical/SPDIF etc. some modification along the way must have rendered my device unusable for a plain "xflash my.xe"