Program xcore-200 explorer kit without using xTimeComposer Software

Technical discussions related to any XMOS development kit or reference design. Eg XK-1A, sliceKIT, etc.
jems
Member++
Posts: 17
Joined: Tue Jun 25, 2019 1:23 pm

Program xcore-200 explorer kit without using xTimeComposer Software

Postby jems » Thu Feb 20, 2020 11:25 am

I had compiled the program and even flashed using xTimecomposer software.
I tried to program using Xmos-Command tool and it works fine using the xflash one.
Is there any other way to program my board using the ".bin " without software usage.
I hope anyone has an idea of this kind of work.
User avatar
mon2
XCore Legend
Posts: 1747
Joined: Thu Jun 10, 2010 11:43 am

Postby mon2 » Thu Feb 20, 2020 11:38 am

Hi. The target flash is only a SPI / QSPI device. Respectively you can use SPI / QSPI code to reflash the same target device.

I have posted a related solution on how to program the spi flash using the StartKit by XMOS. The same code can be used on any Xmos CPU. The premise is that, take your binfile and use a free hex editor to read in the bin file -> save as a c style hex array and export to a text file -> then use this array of value to reflash your target.

Write back if you need more info.

Also I was told by XMOS crew that if you press control-c while using the tools to flash the target, you will abort the process and will be left with temp files. One of the temp files will be the c code that does the same as above. You may wish to hunt for these temp files which are deleted after the process.
Schatz143
Member++
Posts: 31
Joined: Mon Jan 20, 2020 9:54 am

Postby Schatz143 » Mon Feb 24, 2020 12:26 pm

Hi mon2!
i am trying to run this code as SPI master on xcore 200 explorer kit.I cannot see any output on D24,D25 and D34 and D35.
And also the code terminates faster before i can check.I tried on simulation but cannot see anything.Am i missing something here.Thanks

Code: Select all



#include <xs1.h>
#include <spi.h>
#include <syscall.h>
#include <timer.h>
#include <print.h>
#include <platform.h>

/* These ports are used for the SPI master */
out buffered port:32   p_sclk  = on tile[0]: XS1_PORT_1I;//D24
out port               p_ss[1] = on tile[0]: {XS1_PORT_1J};//d25
in buffered port:32    p_miso  = on tile[0]: XS1_PORT_1K;//d34
out buffered port:32   p_mosi  = on tile[0]: XS1_PORT_1L;//d35

clock clk0 = on tile[0]: XS1_CLKBLK_1;
clock clk1 = on tile[0]: XS1_CLKBLK_2;


void app(client spi_master_if spi)
{
    uint8_t val;
    printstrln("Sending SPI traffic");
    delay_microseconds(30);
    spi.begin_transaction(0, 100, SPI_MODE_0);
    val = spi.transfer8(0xab);
    val = spi.transfer32(0xcc);
    val = spi.transfer8(0xfe);
    spi.end_transaction(100);

    delay_microseconds(40);
    spi.begin_transaction(0, 100, SPI_MODE_0);
    val = spi.transfer8(0x22);
    spi.end_transaction(100);

    printstrln("Done.");
    _exit(0);
}


void async_app(client spi_master_async_if spi)
{
    uint8_t indata[10];
    uint8_t outdata[10];
    uint8_t * movable inbuf = indata;
    uint8_t * movable outbuf = outdata;

    printstrln("Sending SPI traffic (async)");
    delay_microseconds(30);

    // Fill the out buffer with data
    outbuf[0] = 0xab;
    outbuf[1] = 0xcc;
    outbuf[2] = 0; outbuf[3] = 0; outbuf[4] = 0;
    outbuf[5] = 0xfe;
    spi.begin_transaction(0, 100, SPI_MODE_0);

  
    spi.init_transfer_array_8(move(inbuf),
                              move(outbuf),
                              6);

   
    select {
        case spi.transfer_complete():
           // Once the transfer is complete, we can retrieve the
           // buffers back into the inbuf and outbuf pointer variables
           spi.retrieve_transfer_buffers_8(inbuf, outbuf);
           break;
    }

    spi.end_transaction(100);


    delay_microseconds(40);
    spi.begin_transaction(0, 100, SPI_MODE_0);
    outbuf[0] = 0x22;
    spi.init_transfer_array_8(move(inbuf),
                              move(outbuf),
                              1);
    select {
        case spi.transfer_complete():
           spi.retrieve_transfer_buffers_8(inbuf, outbuf);
           break;
    }
    spi.end_transaction(100);

    printstrln("Done.");
    _exit(0);
}

int main(void) {
  interface spi_master_if i_spi[1];
  par {
    on tile[0]: app(i_spi[0]);
    on tile[0]: spi_master(i_spi, 1,
                           p_sclk, p_mosi, p_miso, p_ss, 1,
                           null);
  }
  return 0;
}


User avatar
mon2
XCore Legend
Posts: 1747
Joined: Thu Jun 10, 2010 11:43 am

Postby mon2 » Mon Feb 24, 2020 12:54 pm

Hi. Start with something simple to debug this code by inserting before your par construct in the main routine with a permanent loop that just toggles one of your SPI port pins. Does that works? Then proceed to test another port pin. Just be sure that you are not driving the SPI port pin at the same time as the external flash. That is, do not enable the SPI flash when testing this new year code. Best to monitor on the hardware but could test on the simulation.

You can also try with a permanent loop on the par construct:

Code: Select all

While (1) // place before the line with the par keyword
Then monitor for activity.

Who is online

Users browsing this forum: No registered users and 6 guests