Basic Led Blink with external flasher

Technical questions regarding the xTIMEcomposer, xSOFTip Explorer and Programming with XMOS.
maxmatteo
Junior Member
Posts: 4
Joined: Wed Dec 30, 2020 8:11 pm
Location: Hamburg

Basic Led Blink with external flasher

Postby maxmatteo » Sun Jan 10, 2021 5:05 pm

Hey everyone,

i have a custom xmos board here which uses an external SPI flash (no qspi / fast one)
They default firmware it came with works, so i am planning to build a quick led blink example.

i have xcc, xflash and xmake running.

attached are my xn config and my xc. any hints on what is wrong?

Code: Select all

➜  led-blink xmake
Checking build modules
No build modules used.
Compiling led-blink.xc
Rebuild .build/_obj.rsp
Creating led-blink.xe
Build Complete

➜  led-blink xflash bin/led-blink.xe -o led-blink.bin
spiinfo-4d694af4:10:3: error: parse error before ',' token
  ,
  ^
spiinfo-4d694af4:108:12: error: index of array exceeds its upper bound
    on tile[0]:
           ^~~
spiinfo-4d694af4:140:28: error: use of undeclared identifer `portHolder_0'
                           portHolder_0,
                           ^
spiinfo-4d694af4:135:12: error: index of array exceeds its upper bound
    on tile[0]:
           ^~~
Error: F03010 Failed to compile flash inquisitor.
my external flash is an old micron 512kb. flashrom detects it as an Micron "M25P40-old"

so i probably need a custom spi-spec file i guess. but trying "ST_M25PE20" for now.

cheers max
You do not have the required permissions to view the files attached to this post.
RitchRock
XCore Addict
Posts: 132
Joined: Tue Jan 17, 2017 9:25 pm

Postby RitchRock » Tue Jan 12, 2021 12:20 am

Hi there,

A port is declared like:

Code: Select all

on tile[0]: out port p_LEDS = XS1_PORT_1A;
A main needs to be written like:

Code: Select all

int main()
{
    par
    {
        on tile [0]: LED_test();
    }
    return 0;
}
Where the function LED_test() would be something like:

Code: Select all

void LED_test()
{
    while(1){
        p_LEDS <: 0;
        delay_milliseconds (1000) ;
        p_LEDS <: 1;
        delay_milliseconds (1000) ;
    }
}
 
Or you could simply do

Code: Select all

int main () {
     while (1) {
          p_LEDS <: 0;
          delay_milliseconds (1000) ;
          pp_LEDS <: 1;
          delay_milliseconds (1000) ;
     }
     return 0;
}
Hope this helps you get going a bit. Sorry I can't help on the flash issue.
User avatar
CousinItt
XCore Addict
Posts: 212
Joined: Wed May 31, 2017 6:55 pm

Postby CousinItt » Wed Jan 13, 2021 5:00 pm

The M25PE20 is a single-bit device, so try using Class="SPIFlash" rather than Class="SQIFlash" in your XN file device spec.
maxmatteo
Junior Member
Posts: 4
Joined: Wed Dec 30, 2020 8:11 pm
Location: Hamburg

Postby maxmatteo » Mon Jan 18, 2021 10:13 am

thank you for the responses so far!

I bought myself a fresh supported SST_SST25VF040 flash chip to remove that issue out of the equation :)

unfortunately i am still not able to get a version compiled.

i think its somehow the the tiles and nodes config in some form.

any hints?

Code: Select all

➜  led-blink xmake
Checking build modules
No build modules used.
Creating led-blink.xe
.././XU208-128-TQ64-C10.xn: Error: XN11188 Network is not fully connected (no route from node "0" to node "1")
xmake[1]: *** [bin//led-blink.xe] Error 1
xmake: *** [bin//led-blink.xe] Error 2
my xn file:

Code: Select all

<?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>Device</Type>
  <Name>XU208-128-TQ64-C10 Device</Name>

  <Declarations>
    <Declaration>tileref tile[1]</Declaration>
    <Declaration>tileref usb_tile</Declaration>
  </Declarations>

  <Packages>
    <Package id="0" Type="XS2-UnA-128-TQ64">
      <Nodes>
        <Node Id="0" InPackageId="0" Type="XS2-L8A-128" Oscillator="24MHz" SystemFrequency="500MHz">
          <Boot>
            <Source Location="bootFlash"/>
          </Boot>
          <Tile Number="0" Reference="tile[1]">
            <Port Location="XS1_PORT_1B" Name="PORT_SPI_SS"/>
            <Port Location="XS1_PORT_1C" Name="PORT_SPI_CLK"/>
            <Port Location="XS1_PORT_4B" Name="PORT_SPI_MISO"/>
            <Port Location="XS1_PORT_1D" Name="PORT_SPI_MOSI"/>
          </Tile>
        </Node>
        <Node Id="1" InPackageId="1" Type="periph:XS1-SU" Reference="usb_tile" Oscillator="24MHz" />
      </Nodes>
    </Package>
  </Packages>

  <ExternalDevices>
    <Device NodeId="0" Tile="0" Class="SPIFLASH" Name="bootFlash" Type="SST_SST25VF040">
      <Attribute Name="PORT_SPI_MISO" Value="PORT_SPI_MISO"/>
      <Attribute Name="PORT_SPI_SS" Value="PORT_SPI_SS"/>
      <Attribute Name="PORT_SPI_CLK" Value="PORT_SPI_CLK"/>
      <Attribute Name="PORT_SPI_MOSI" Value="PORT_SPI_MOSI"/>
    </Device>
  </ExternalDevices>

  <JTAGChain>
    <JTAGDevice NodeId="0"/>
  </JTAGChain>

</Network>
my source code:

Code: Select all

#include <xs1.h>
#include <stdio.h>
#include <platform.h>
#include <flash.h>
#include <timer.h>

on tile[0] : out port led1 = XS1_PORT_1A;

int main () {
     while (1) {
          led1 <: 0;
          delay_milliseconds (1000);
          led1 <: 1;
          delay_milliseconds (1000);
     }
     return 0;
}
User avatar
CousinItt
XCore Addict
Posts: 212
Joined: Wed May 31, 2017 6:55 pm

Postby CousinItt » Mon Jan 18, 2021 1:34 pm

Your XN file is missing the link information.

Code: Select all

      <Links>
        <Link Encoding="5wire">
          <LinkEndpoint NodeId="0" Link="8" Delays="52clk,52clk"/>
          <LinkEndpoint NodeId="1" Link="XL0" Delays="1clk,1clk"/>
        </Link>
      </Links>
Take a look at the XN file for the XU208 that is supplied with xTimeComposer, either by poking around in the installation directories, or you can create a new project for that device which includes the XN file.

Who is online

Users browsing this forum: No registered users and 6 guests