Restarting a startKIT from SW?

All technical discussions and projects around startKIT
User avatar
aclassifier
Respected Member
Posts: 507
Joined: Wed Apr 25, 2012 8:52 pm

Restarting a startKIT from SW?

Post by aclassifier »

I still have some work to do on my startKITs, even if xCORE-200 Explorer KITs are what I use for newer designs.

I would like to restart the startKIT processor with SW. I have asked similar questions before:
where it was concluded that I could have the processor stop ok, so that the debugger catches it and all.

However, even if if the data sheet [here] does show a watchdog, it is not available for me at the end of the day, when the code is built. Or there is no watchdog on that particular silicon(?)

However, is there an instruction to restart the processor and alternatively also reset the processor?
--
Øyvind Teig
Trondheim (Norway)
https://www.teigfam.net/oyvind/home/
User avatar
mon2
XCore Legend
Posts: 1913
Joined: Thu Jun 10, 2010 11:43 am

Post by mon2 »

Hi. I think it will be best to apply a low cost and external watchdog IC for this purpose:

https://www.xcore.com/viewtopic.php?t=5101
User avatar
aclassifier
Respected Member
Posts: 507
Joined: Wed Apr 25, 2012 8:52 pm

Post by aclassifier »

Thanks. But I guess that would be most relevant if this were a need I had for the xCORE-200. However I was thinking about the startKIT [1].

I see that there is a reset line that comes out of the debug tile and is distributed to J6 and PCIe. This has nothing to do with reset of the processor.

However, on the XSYS link there is a reset line that eventually would reset the processor I guess. But it's not available to me.

So I guess inside my box [2] there is nothing I could do.
Off Topic
However, I am going to persuit the following idea:

I have an external I2C line that reads three temperatures, over a nice plugged cable. I just let that cable go via a watchdog relay box (that I build) that has an I2C output to pulse the watchdog. There is a relay that holds the USB-in to USB-out connector powered. This would simply power down the startKIT for some time (I would have the +5V USB in available at all times) and power it on again should I fail to pulse the watchdog.

I am using all cores with a mix of [[combinable]] and [[distributable]]. The port output task (heat and LED lights plus a beeper) has its own core, and it also functions as a watchdog. It is this task that now beeps to tell that the "main loop" task has blocked. It's the RFM69 radio task that is [[distributable]] that uses the [[distributable]] synchronous lib_spi that for some reason I don't know yet does not return to the main task. I will now make that part asynchronous non-[[distributable]] (so that the RPC call is not running on the caller's stack or is inlined) so that I can detect the concrete blocking of those tasks instead. A detection would be the first stop to finding the real problem.

(Would anybody know if lib_spi synchronous has a mode where it might never return, by the way? I may make a separaret thread on this)

Having tasks with different roles like this is rather interesting. I did make a presentation about this [3]
[1] startKIT Hardware Manual
[2] My aquarium notes
[3] Unravelling XC concepts [[combine]], [[combinable]], [[distribute]], [[distributable]] and [[distributed(..)]] plus par and on..
--
Øyvind Teig
Trondheim (Norway)
https://www.teigfam.net/oyvind/home/
User avatar
akp
XCore Expert
Posts: 580
Joined: Thu Nov 26, 2015 11:47 pm

Post by akp »

Disclaimer: I don't have a startKIT. However, I understand it has one user 8 core tile and a second "debug" tile.

If you just want to reset your user tile could you run the reboot function? From https://github.com/xcore/sc_avb/blob/ma ... /reboot.xc
This is for multi-tile design so you could probably simplify it for single user tile. If you have sufficient cores and timers you could write your own watchdog. Or if there is some other signal you want to wait on to reset then go ahead. But maybe this isn't what you want. If so then I apologize for wasting your time.

Code: Select all

/* Reboots XMOS device by writing to the PLL config register */
void device_reboot(void)
{
    unsigned int pllVal;
    unsigned int localTileId = get_local_tile_id();
    unsigned int tileId;
    unsigned int tileArrayLength;

    asm volatile ("ldc %0, tile.globound":"=r"(tileArrayLength));

    /* Reset all remote tiles */
    for(int i = 0; i < tileArrayLength; i++)
    {
        /* Cannot cast tileref to unsigned */
        tileId = get_tile_id(tile[i]);

        /* Do not reboot local tile yet */
        if (localTileId != tileId)
        {
            read_sswitch_reg(tileId, 6, pllVal);
            write_sswitch_reg_no_ack(tileId, 6, pllVal);
        }
    }

    /* Finally reboot this tile */
    read_sswitch_reg(localTileId, 6, pllVal);
    write_sswitch_reg_no_ack(localTileId, 6, pllVal);

}
User avatar
aclassifier
Respected Member
Posts: 507
Joined: Wed Apr 25, 2012 8:52 pm

Post by aclassifier »

(I think this got posted to somewhere else? So this is second try:)

Thanks, akp!

I have tested this code, FLASHed on both the startKIT end the xCORE-200 eXplorerKIT.

On the startKIT the task that the code runs in stops (or maybe it's that core), and my watchdog task (running on another core) does not get fed and then starts to blink with the LED. There is no associated restart.

On the xCORE-200 nothing happens. The code runs and continues like nothing.

I feel, maybe we're almost there? On some track?
Off Topic
akp: don't ever think you waste my time! I asked the question and is happy for any idea or pondering over the theme. Even some offtopics!
--
Øyvind Teig
Trondheim (Norway)
https://www.teigfam.net/oyvind/home/
User avatar
akp
XCore Expert
Posts: 580
Joined: Thu Nov 26, 2015 11:47 pm

Post by akp »

Refer to this code that might work on xCORE-200 eXplorerKIT
https://github.com/xmos/lib_tsn/blob/ma ... /reboot.xc
User avatar
aclassifier
Respected Member
Posts: 507
Joined: Wed Apr 25, 2012 8:52 pm

Post by aclassifier »

akp, thank you very much for the digging! You found this in lib_tsn. Impressed!

This code restarts an xCORE-200! However, not the startKIT. It just stops the local logical core I think.

The "reboot.h" just contains the template for device_reboot, so it's not needed. I just pasted the code in and commented out the function heading, leaving only the block.

There were two lines added to this code that worked on the xCORE-200. See attachment.
Off Topic
Larry Snizek (https://github.com/larry-xmos), if you are listening, is there any similar restart code for the startKIT?
You do not have the required permissions to view the files attached to this post.
--
Øyvind Teig
Trondheim (Norway)
https://www.teigfam.net/oyvind/home/
User avatar
akp
XCore Expert
Posts: 580
Joined: Thu Nov 26, 2015 11:47 pm

Post by akp »

I work with lib_tsn pretty much every day for a living so it's not that impressive, to be honest. Good luck with the startKIT!
User avatar
aclassifier
Respected Member
Posts: 507
Joined: Wed Apr 25, 2012 8:52 pm

Post by aclassifier »

Giving the fact that you're giving time and engagement.. - again thanks!
Off Topic
By the way, how should I have known about that library? I couldn't find it from the Librariies window in xTIMEcomposer(?) However, once I knew the name I found it here: https://www.xmos.com/developer/search/lib_tsn

Is there a list of all available libraries some place? And why didn't that list appear in xTIMEcomposer? (Alternatively: how do I make it appear there?)
--
Øyvind Teig
Trondheim (Norway)
https://www.teigfam.net/oyvind/home/
User avatar
aclassifier
Respected Member
Posts: 507
Joined: Wed Apr 25, 2012 8:52 pm

Post by aclassifier »

I now have designed and built a USB watchdog box!

See My USB watchdog (and relay output) box
--
Øyvind Teig
Trondheim (Norway)
https://www.teigfam.net/oyvind/home/