Debugging SPI Boot

Technical questions regarding the XTC tools and programming with XMOS.
bearcat
Respected Member
Posts: 283
Joined: Fri Mar 19, 2010 4:49 am

Debugging SPI Boot

Post by bearcat »

Having a problem with a new multi-tile design. Works just fine from run and debug using XTAG2 from XDE 11.11.1. But after using XFLASH to write the flash, it's not booting properly. XFLASH says verified so would lead me to say flash chip is good (and is a supported one). Same XFLASH options as I have used in the past.

I am seeing flash activity, and lot's of XLINK activity at power on, so I know it's trying to boot. Reset looks good along with power. Design similiar to prior that does work, but are some changes. But could as well be some software issue.

My question is, is there a way to debug SPI boot? What options do I have?


User avatar
infiniteimprobability
XCore Legend
Posts: 1126
Joined: Thu May 27, 2010 10:08 am

Post by infiniteimprobability »

It does sound like FLASH (and reset, power etc.) is well if it's programming, verifying etc.

You say it's multi-tile. Are you sure that the links between the chips are correct? In particular boot and bootee are correct? Otherwise it might not be getting as far as transferring the application across at startup. A quick look at the XN file vs actual topography might help.

The next thing to do is to to attach to the booted device using JTAG and get the state. You can either:

Code: Select all

xrun --dump-state <my-binary.xe> 
or use gdb as follows:

Code: Select all

 gdb <my-binary.xe>
attach
infothreads
or use GUI (attach to running process)..

The key thing is to look at where each of the cores is, and if it has hit an exception, or perhaps is blocked on a channel or whatever. You should be able to see a symbol or line that can trace it back to your source.

If there has been an exception, it is useful to look at the SPC register (saved PC) to see where it was before the exception occurred. That will give you a clue as to the source of the problem..
User avatar
infiniteimprobability
XCore Legend
Posts: 1126
Joined: Thu May 27, 2010 10:08 am

Post by infiniteimprobability »

By the way, this is a really useful thing to do when debugging at this level:-

Code: Select all

xobjdump -d <my-binary.xe> > <my-disassy.txt>
It will disassemble the binary and show you the addresses and symbols..
bearcat
Respected Member
Posts: 283
Joined: Fri Mar 19, 2010 4:49 am

Post by bearcat »

Thanks for the tips, I had never attached to a running process.

Best I can tell its a blocked resource. Below are the relevant sections.

I didn't get very far debugging this. My guess is it's in the boot loader program since the pc is not in my code. I don't have any code or references for the boot loader. Dead end for me. Is the boot loader code available that I can reference?

I took another tack. I had started a very slim "DFU" loader program to install as the factory image for the product. I got this completed. No go. Tried an older version of the design I know boots, No go. Rebuilt the DFU version using XDE 11.2.2. Boots just fine on the older board and my new design.

So... the problem is XDE 11.11.1 boot loader or some other function. Any other reported problems like this?

This has issues. XDE 11.2.2 has some serious shortcomings. I could debug in 11.11.1, and then compile using 11.2.2 for images. I am attempting to get it compiled in 11.2.2, which in the past has worked for me.

I thought I was looking reasonable, but 11.2.2 just gives off some crazy errors that are difficult to locate. Any idea what this might be?
xmap: Error: Symbol (".LDBG5") needed for relocation has been eliminated (missing delimitors in referencer?).
Using 12 or above is not an option. Are there versions after 11.2.2 that I can try before 11.11.1? Thanks for any responses.

Code: Select all

***** Active Threads *****
  6  stdcore[5] hwthread 0  0xffffc0a6 in ?? ()
  5  stdcore[4] hwthread 0  0xffffc0a6 in ?? ()
  4  stdcore[3] hwthread 0  0xffffc0a6 in ?? ()
  3  stdcore[2] hwthread 0  0xffffc0a6 in ?? ()
  2  stdcore[1] hwthread 0  0xffffc0a6 in ?? ()
* 1  stdcore[0] hwthread 0  0x0001f1e8 in ?? ()
Thread 1 (stdcore[0] hwthread 0):

***** Call Stack *****
#0  0x0001f1e8 in ?? ()
#1  0x0001f19c in ?? ()
Backtrace stopped: previous frame identical to this frame (corrupt stack?)

***** Disassembly *****
0x1f1e8:	out (r2r)       res[r0], r11 *
0x1f1ea:	add (2rus)      r1, r1, 0x4
0x1f1ec:	sub (2rus)      r2, r2, 0x1
0x1f1ee:	bt (ru6)        r2, -0x5
0x1f1f0:	ldw (2rus)      r9, r4[0x4]

***** Registers *****
r0             0xffff0102	-65278
r1             0x1fa94	129684
r2             0xe	14
r3             0xffff0102	-65278
r4             0x1f9e4	129508
r5             0x18	24
r6             0x88	136
r7             0x0	0
r8             0x0	0
r9             0x16	22
r10            0x1	1
r11            0x9af27f7	162473975
cp             0x1f9cc	129484
dp             0x1f9cc	129484
sp             0x1feec	130796
lr             0x1f19c	127388
pc             0x1f1e8	127464
sr             0x40	64
spc            0x0	0
ssr            0x0	0
et             0x0	0
ed             0x0	0
sed            0x0	0
kep            0x10080	65664
ksp            0x0	0
User avatar
segher
XCore Expert
Posts: 844
Joined: Sun Jul 11, 2010 1:31 am

Post by segher »

CPUs 1..5 are waiting for the first word to come in over a link. CPU 0 is trying to send the third word, but it is blocked. This sounds like your routing tables are messed up. Post your XN file?
bearcat
Respected Member
Posts: 283
Joined: Fri Mar 19, 2010 4:49 am

Post by bearcat »

If it's that easy that would be great. Here it is. The code itself uses all the XLINKS and they are working just fine in code.

Code: Select all

  <Declarations>
    <Declaration>core stdcore[6]</Declaration>
  </Declarations>

  <Nodes>
    <Node id="USB" Type="XS1-L1A" oscillator="13Mhz" systemfrequency="500MHz" referencefrequency="100MHz">
      <Core Number="0" Reference="stdcore[0]">
        <Port Location="XS1_PORT_1A" Name="PORT_SPI_MISO"/>
        <Port Location="XS1_PORT_1B" Name="PORT_SPI_SS"/>
        <Port Location="XS1_PORT_1C" Name="PORT_SPI_CLK"/> 
        <Port Location="XS1_PORT_1D" Name="PORT_SPI_MOSI"/>
      </Core>
      <Boot>
        <Source Location="SPI:bootFlash"/>
        <Bootee NodeId="AUDIO"/>
        <Bootee NodeId="IOAB"/>
        <Bootee NodeId="IOCD"/>
        <Bootee NodeId="IOEF"/>
        <Bootee NodeId="IOGH"/>
      </Boot>
    </Node>
    <Node id="AUDIO" Type="XS1-L1A" oscillator="12288KHz" systemfrequency="500MHz" referencefrequency="100MHz">
      <Core Number="0" Reference="stdcore[1]">
      </Core>
      <Boot>
        <Source Location="XMOSLINK"/>
      </Boot>
    </Node>
    <Node id="IOAB" Type="XS1-L1A" oscillator="12288KHz" systemfrequency="500MHz" referencefrequency="100MHz">
      <Core Number="0" Reference="stdcore[2]">
      </Core>
      <Boot>
        <Source Location="XMOSLINK"/>
      </Boot>
    </Node>
    <Node id="IOCD" Type="XS1-L1A" oscillator="12288KHz" systemfrequency="500MHz" referencefrequency="100MHz">
      <Core Number="0" Reference="stdcore[3]">
      </Core>
      <Boot>
        <Source Location="XMOSLINK"/>
      </Boot>
    </Node>
    <Node id="IOEF" Type="XS1-L1A" oscillator="12288KHz" systemfrequency="500MHz" referencefrequency="100MHz">
      <Core Number="0" Reference="stdcore[4]">
      </Core>
      <Boot>
        <Source Location="XMOSLINK"/>
      </Boot>
    </Node>
    <Node id="IOGH" Type="XS1-L1A" oscillator="12288KHz" systemfrequency="500MHz" referencefrequency="100MHz">
      <Core Number="0" Reference="stdcore[5]">
      </Core>
      <Boot>
        <Source Location="XMOSLINK"/>
      </Boot>
    </Node>
  </Nodes>

  <Links>
    <Link Encoding="2wire" Delays="6,6">
      <LinkEndpoint NodeId="USB" Link="X0LC"/>
      <LinkEndpoint NodeId="AUDIO" Link="X0LB"/>
    </Link>
    <Link Encoding="2wire" Delays="6,6">
      <LinkEndpoint NodeId="AUDIO" Link="X0LA"/>
      <LinkEndpoint NodeId="IOAB" Link="X0LB"/>
    </Link>
    <Link Encoding="2wire" Delays="6,6">
      <LinkEndpoint NodeId="IOAB" Link="X0LC"/>
      <LinkEndpoint NodeId="IOCD" Link="X0LB"/>
    </Link>
    <Link Encoding="2wire" Delays="6,6">
      <LinkEndpoint NodeId="IOCD" Link="X0LC"/>
      <LinkEndpoint NodeId="IOEF" Link="X0LB"/>
    </Link>
    <Link Encoding="2wire" Delays="6,6">
      <LinkEndpoint NodeId="IOEF" Link="X0LC"/>
      <LinkEndpoint NodeId="IOGH" Link="X0LB"/>
    </Link>
  </Links>

  <ExternalDevices>
    <Device Nodeid="USB" Core="0" Class="SPIFlash" Name="bootFlash" Type="AT25DF041A">
      <Attribute Name="PORT_SPI_MISO" Value="XS1_PORT_1A"/>
      <Attribute Name="PORT_SPI_SS"   Value="XS1_PORT_1B"/>
      <Attribute Name="PORT_SPI_CLK"  Value="XS1_PORT_1C"/>
      <Attribute Name="PORT_SPI_MOSI" Value="XS1_PORT_1D"/>
    </Device>
  </ExternalDevices>

  <Packages>
    <Package id="USB" Type="XS1-L1A-TQ48">
      <Component NodeId="USB" InPackage="0"/>
    </Package>
    <Package id="AUDIO" Type="XS1-L1A-LQ64">
      <Component NodeId="AUDIO" InPackage="0"/>
    </Package>
    <Package id="IOAB" Type="XS1-L1A-TQ48">
      <Component NodeId="IOAB" InPackage="0"/>
    </Package>
    <Package id="IOCD" Type="XS1-L1A-TQ48">
      <Component NodeId="IOCD" InPackage="0"/>
    </Package>
    <Package id="IOEF" Type="XS1-L1A-TQ48">
      <Component NodeId="IOEF" InPackage="0"/>
    </Package>
    <Package id="IOGH" Type="XS1-L1A-TQ48">
      <Component NodeId="IOGH" InPackage="0"/>
    </Package>
  </Packages>

  <JTAGChain>
     <JTAGDevice Nodeid="USB"   Position="0"/>
     <JTAGDevice Nodeid="AUDIO" Position="1"/>
     <JTAGDevice Nodeid="IOAB"  Position="2"/>
     <JTAGDevice Nodeid="IOCD"  Position="3"/>
     <JTAGDevice Nodeid="IOEF"  Position="4"/>
     <JTAGDevice Nodeid="IOGH"  Position="5"/>
  </JTAGChain>

</Network>
Here it it for the slim DFU program, that also doesn't boot in 11.11.1

Code: Select all

 <Declarations>
    <Declaration>core stdcore[2]</Declaration>
  </Declarations>

  <Nodes>
    <Node id="USB" Type="XS1-L1A" oscillator="13Mhz" systemfrequency="500MHz" referencefrequency="100MHz">
      <Core Number="0" Reference="stdcore[0]">
        <Port Location="XS1_PORT_1A" Name="PORT_SPI_MISO"/>
        <Port Location="XS1_PORT_1B" Name="PORT_SPI_SS"/>
        <Port Location="XS1_PORT_1C" Name="PORT_SPI_CLK"/> 
        <Port Location="XS1_PORT_1D" Name="PORT_SPI_MOSI"/>
      </Core>
      <Boot>
        <Source Location="SPI:bootFlash"/>
        <Bootee NodeId="AUDIO"/>
      </Boot>
    </Node>
    <Node id="AUDIO" Type="XS1-L1A" oscillator="12288KHz" systemfrequency="500MHz" referencefrequency="100MHz">
      <Boot>
        <Source Location="XMOSLINK"/>
      </Boot>
      <Core Number="0" Reference="stdcore[1]">
      </Core>
    </Node>
  </Nodes>

  <Links>
    <Link Encoding="2wire" Delays="6,6">
      <LinkEndpoint NodeId="USB" Link="X0LC"/>
      <LinkEndpoint NodeId="AUDIO" Link="X0LB"/>
     </Link>
  </Links>

  <ExternalDevices>
    <Device Nodeid="USB" Core="0" Class="SPIFlash" Name="bootFlash" Type="AT25DF041A">
      <Attribute Name="PORT_SPI_MISO" Value="XS1_PORT_1A"/>
      <Attribute Name="PORT_SPI_SS"   Value="XS1_PORT_1B"/>
      <Attribute Name="PORT_SPI_CLK"  Value="XS1_PORT_1C"/>
      <Attribute Name="PORT_SPI_MOSI" Value="XS1_PORT_1D"/>
    </Device>
  </ExternalDevices>

  <Packages>
    <Package id="USB" Type="XS1-L1A-TQ48">
      <Component NodeId="USB" InPackage="0"/>
    </Package>
    <Package id="AUDIO" Type="XS1-L1A-LQ64">
      <Component NodeId="AUDIO" InPackage="0"/>
    </Package>
  </Packages>

  <JTAGChain>
     <JTAGDevice Nodeid="USB" Position="0"/>
     <JTAGDevice Nodeid="AUDIO" Position="1"/>
  </JTAGChain>

</Network>
bearcat
Respected Member
Posts: 283
Joined: Fri Mar 19, 2010 4:49 am

Post by bearcat »

Does the boot loader run the XLINKS at the delay specified (or slower)?

If by chance 11.11.1 changed something there, it will have problems at higher speeds in my design.

I might take a look at the speed on a OScope, just to verify.
User avatar
segher
XCore Expert
Posts: 844
Joined: Sun Jul 11, 2010 1:31 am

Post by segher »

I see no problems in your XN.

It seems (from some googling) that 11.11 had problems booting multi-node systems. Can you try with 11.2 again? You should be able to avoid that linker error by disabling debugging (remove -g from your compiler flags, or add -g0 at the end).

The good news is your hardware is fine; now you only have to show your software tools who is the boss :-)
User avatar
segher
XCore Expert
Posts: 844
Joined: Sun Jul 11, 2010 1:31 am

Post by segher »

The bootrom sets the bittime to 400 system clock periods, so 800ns. Both sides of the link are completely independent though, so who knows what the init code uses... Eventually it should set up the links with your specified delays, but maybe it does that later. Dunno.
bearcat
Respected Member
Posts: 283
Joined: Fri Mar 19, 2010 4:49 am

Post by bearcat »

Great tip on removing debug. That fixed the XMAP error. I actually should do that if I am not debugging, anyways.

Compiled in 11.2.2 and sure enough it boots up now.

I think it's workable to develop in 11.11.1 and then build the image in 11.2.2. Hopefully the compiled code is very similiar.

The XLINKS work at boot, so I guess the speed is ok for me.

Thanks for the Help!