FREER issue

Technical questions regarding the xTIMEcomposer, xSOFTip Explorer and Programming with XMOS.
MarcAntigny
Active Member
Posts: 43
Joined: Tue Feb 13, 2018 2:50 pm

FREER issue

Postby MarcAntigny » Tue Jul 31, 2018 10:23 am

Hello,

I'm developing on Xcore 200 (XU232) from the reference design USB audio 2.0.
I have 2 parallel threads that are synchronized through a channel, c_sync. The task1 and task2 run until task1 receive a command message from its channel c1. It then sends a message to task2 through c_sync to tell task2 to end. Then task1 returns the command.

Code: Select all

unsigned foo(chanend c1, chanend c2)
{
   chan c_sync;
   unsigned command;
   doSomeInit();
   par{
           {
               command = task1(c1, c_sync);
           }
           {
                task2(c2, c_sync);
           }
       }
   doSomeStuff();
    return command;
}

The issue appears in debug mode. The code breaks before the return command (on doSomeStuff() for example which as nothing to do with the channel) with the following message
Suspended: Signal 'ET_ILLEGAL_RESOURCE' received. Description: Resource exception.

When I looked at the disassembly, the code breaks on :
000426fc: freer (1r) res[r7] *

With some trace in memory and registers reading, I found that the r7 register contains the channel c_aud_sync identifier. So I guess, at the function return, the code try to free this resource (the channel c_aud_sync ) but can't so raise en exception. However, the channel is empty and no other threads call it, so the FREER instruction should be OK.
I searched through documentation but the only information I got is "r is referring to a channel end on which no terminating CT END token has been input and/or output, or which has data pending for input, or which has a thread waiting for input or output." in XS1 documentation. I tried to had control token (XS1_CT_END) to end the communication but it changed nothing, the same exception happened.

Has anybody been in such situation or know something on FREER instruction ?

Thanks.
Marc
User avatar
mon2
XCore Legend
Posts: 1254
Joined: Thu Jun 10, 2010 11:43 am
Contact:

Postby mon2 » Tue Jul 31, 2018 12:13 pm

MarcAntigny
Active Member
Posts: 43
Joined: Tue Feb 13, 2018 2:50 pm

Postby MarcAntigny » Tue Jul 31, 2018 1:15 pm

Hi mon,
mon2 wrote:http://www.xcore.com/viewtopic.php?f=26&t=2440

I already read this thread, and I actually have no problem when I flash. However, even with no xscope link in the Makefile and in the .xn, the debug leads to the same exception.
Do you think there could be other reference to xscope link that I should delete ? (I did a search in the project and didn't find others).
Thanks,
Marc
User avatar
mon2
XCore Legend
Posts: 1254
Joined: Thu Jun 10, 2010 11:43 am
Contact:

Postby mon2 » Tue Jul 31, 2018 4:26 pm

Not really sure of the root cause but from reading the above thread, on the raised exception:


This is usually caused by boot mode selection issues.

As was mentioned earlier by segher, the exception you are seeing (ILLEGAL_RESOURCE on freeing of a channel) indicates that the channel still has data in it. This should only happen if something (e.g. boot modes or XN file) mean the system boots incorrectly for the actual system you have.


Can you post your .XN file for a review?

Also, how are you booting this custom PCB? Is it through an external flash or something else?

From Peter's comments...

Can you confirm that when you reset the board, and then run:

Code: Select all

xgdb -ex "connect" -ex "info threads"


You get the PCs at the right location. Something like this:

0xffffc070 in ?? ()
2 tile[1] core[0] 0xffffc070 in ?? ()
* 1 tile[0] core[0] 0xffffc070 in ?? ()
MarcAntigny
Active Member
Posts: 43
Joined: Tue Feb 13, 2018 2:50 pm

Postby MarcAntigny » Tue Jul 31, 2018 5:17 pm

The PCB boots from an external Flash with QuadSPI (https://www.xmos.com/support/appnotes/AN00185).
I'll post an extract of the .XN file tomorrow.
About PCs, I got the right location with the xgdb command.
MarcAntigny
Active Member
Posts: 43
Joined: Tue Feb 13, 2018 2:50 pm

Postby MarcAntigny » Wed Aug 01, 2018 2:30 pm

Hi,
At last, I managed to make it work. I needed to add a send of XS1_CT_END control token between task1 and task2 to close the channel c_sync.
Thanks mon for your help. Even I am not completely sure I understand entirely the control token use, at least it works.
Marc

Who is online

Users browsing this forum: No registered users and 39 guests