Error in soft_reset: FIXED

Technical questions regarding the XTC tools and programming with XMOS.
User avatar
Paolomio
Experienced Member
Posts: 64
Joined: Tue Oct 05, 2010 7:33 pm

Error in soft_reset: FIXED

Post by Paolomio »

Trying to reset a multiple-L2 system using the published soft_reset function. As written, that code works for a single L2, but breaks when there is more than one L2 in a system (and specified in your XN file).

The problem is that the calculation of the core ID for the 2nd core is incorrect if the first core is anything but 0x0000. Here's an improved version, with a different name to avoid confusion:

Code: Select all

void L2_reset(void)
{
    unsigned int pllVal;
    unsigned int core_id = get_core_id();

    read_sswitch_reg(core_id, 6, pllVal);
    write_sswitch_reg_no_ack((core_id+0x10000) >> 1, 6, pllVal);
    write_sswitch_reg_no_ack(core_id, 6, pllVal);
}


User avatar
segher
XCore Expert
Posts: 844
Joined: Sun Jul 11, 2010 1:31 am

Post by segher »

There is no way in general to calculate the ID of your "sibling" node,
or any other node in the system: your XN file could have any RoutingId
for any node. For simple topologies you can do an educated guess
when you let the tools assign the IDs for you, sure.

Do you really want to reset only two of the cores, not all four (or however
many you have)?
richard
Respected Member
Posts: 318
Joined: Tue Dec 15, 2009 12:46 am

Post by richard »

You can avoid hardcoding the routing ID by using write_node_config_reg() instead of write_sswitch_reg(). For example:

Code: Select all

void L2_reset(void) {
    unsigned int pllVal;
    read_node_config_reg(tile[0], 6, pllVal);
    write_node_config_reg_no_ack(tile[1], 6, pllVal);
    write_node_config_reg_no_ack(tile[0], 6, pllVal);
}
(if using the 11.11 tools use stdcore instead of tile).
User avatar
segher
XCore Expert
Posts: 844
Joined: Sun Jul 11, 2010 1:31 am

Post by segher »

Nice. Is that a new call? Introduced in what tools version?
richard
Respected Member
Posts: 318
Joined: Tue Dec 15, 2009 12:46 am

Post by richard »

From what I can remember the function was first introduced in 11.11
User avatar
Paolomio
Experienced Member
Posts: 64
Joined: Tue Oct 05, 2010 7:33 pm

Post by Paolomio »

Interesting solution. Unfortunately, version 11.11 does not properly boot 2 L2's--version 11.11.1 was supposed to fix that bug, but at least in the downloaded version I tried last week it still does not work. I've not heard back from XMOS so far about the state of this problem with 11.11.1 (and have two tickets open for it; one for the original issue and one against 11.11.1). 12.0.0 does work for 2 L2's, but has other problems with my rather large code base that I don't have time right now to debug.

I understand that segher is correct that there is no general algorithm that will calculate the coreID in all configurations. But for two interconnected L2's, I think what I've shown does calculate the ID's correctly. In that case the topology is a linear array, and the core ID's will follow a pattern of 0x0000, 0x8000, 0xC000, 0xE000, etc. At least this is the observed behavior with the direction bits as set by the tools.

Segher, yes I am restarting both L2's (4 cores) using this code--I send a message to the 2nd L2 that causes it to run L2_reset() on it's first core.

The reason I published this code here is I saw a thread on the forum where someone was trying to do the same thing as I was using the published reset code, with no luck, and ended up using a hardware reset line to do the job. In that situation, this modified routine would solve the problem without needing extra hardware resources.

Paul