FreeRTOS

XCore Project reviews, ideas, videos and proposals.
jhrose
Active Member
Posts: 40
Joined: Mon Dec 14, 2009 11:18 am

Post by jhrose »

Hei,
Which errors did you got and on which board did you test?
I tested on my XC-1 using the Windows IDE.

I changed the definition of vParTestSetLED in partest.h to

Code: Select all

int vParTestSetLED( unsigned portBASE_TYPE xValue );
because this is how you use it in ParTest.xc; the effect is to set xValue correctly. And I changed the definition of vParTestInitialise in partest.h

Code: Select all

int vParTestInitialise( void );
as it is used.
A more important issue is the use of global variables by the kernel which makes running multiple kernels next to each other without modifying all references impossible. I tried to leave as much of the shared code intact as possible.
I saw the earlier posts and don't see any benefit in running multiple kernel threads on a single core, apart from the curiosity, and agree you should leave the shared code intact. What I mean though is when you have a single bootable image to be loaded onto multiple cores; so on one core you would have 1 freeRtos thread and 7 real-time threads, and independently on another core (and another memory space) you would have a similar arrangement, but with different configuration entries in the common FreeRTOSConfig.h for the two (or more) cores - then #if sections would be useful. Another solution would provide a FreeRTOSConfig.h per core and specify different include search paths for them.

I look forward to seeing your new design, and the task-to-thread communication method.


User avatar
Bianco
XCore Expert
Posts: 754
Joined: Thu Dec 10, 2009 6:56 pm
Contact:

Post by Bianco »

I see that there are three implicit function declarations. I will fix them in the next release.
They weren't showing up with the default warning level.

They were showing up as errors at your side?
androider
Member++
Posts: 24
Joined: Sat Sep 18, 2010 4:05 am
Contact:

Post by androider »

I've downloaded the code and put it into a new Eclipse project in the XCORE IDE.

I get an error about references to undefined functions. Could you be so kind as to walk us through the steps I need to take to get the OS to build? Thanks in advance..

Here's the error in my console output:

'Building target: XS1FreeRTOS.xe'
'Invoking: Mapper/Linker'
xcc -Werror=timing-syntax -o "XS1FreeRTOS.xe" ./src/croutine.o ./src/heap_3.o ./src/list.o ./src/port.o ./src/port_asm.o ./src/port_xc.o ./src/queue.o ./src/tasks.o ../XDK.xn
crt1.S: Error: Undefined reference to 'main'
../src/tasks.c: Error: Undefined reference to 'vApplicationIdleHook'
xmake: *** [XS1FreeRTOS.xe] Error 1



Thanks.

Richard
androider
Member++
Posts: 24
Joined: Sat Sep 18, 2010 4:05 am
Contact:

Post by androider »

Never mind. I figured it out.

Here's what I did.

1. Opened the shell.
2. Navigated to the directory with the makefile.
3. ran
xmake

That's it.

Nice Job.

I also did get it working in Eclipse as well. I just had to set the paths of the include files, and only import either the simple demo or the multithreaded demo.

Cheers.
User avatar
Bianco
XCore Expert
Posts: 754
Joined: Thu Dec 10, 2009 6:56 pm
Contact:

Post by Bianco »

Great :)
dimitris
Active Member
Posts: 37
Joined: Tue Feb 19, 2013 5:07 pm

Post by dimitris »

Hi Bianco or any other XMOS/FreeRTOS enthusiasts,

I am trying to run your project in other devices as I need to run it on a SliceKit. I had some initial errors with a SliceKit and an XK-1A device and thought they would be device oriented. However, i tried to run your project on the simulator for the default XC-1 device and it fails at init. For all devices I get the same result:

First, I tried to run it:

Code: Select all

xrun: Program received signal ET_ILLEGAL_RESOURCE, Resource exception.
      init_system_ () at ../../../Source/portable/XCC/XMOS_XS1/port_asm.S:225
Then I switched to the simulator to get some more details and the reply was:

Code: Select all

stdcore[0]@0- -A-.----0001102a (init_system_        +  0) : ldap    r11(0x10fa0), -0x47 @38051
stdcore[0]@0- -A-.----0001102e (init_system_        +  4) : ldw     r1(0x0), dp[0x63] L[0x11ad8] @38059
stdcore[0]@0-*-A-.----00011032 (init_system_        +  8) : setv    res[r1(0x0)], r11(0x10fa0) @38063
stdcore[0]@0 *00011032 : TRAP ET: 4, SPC: 00011032, SSR: 0, ED: 00000000 (ILLEGAL_RESOURCE: Invalid resource id used)
stdcore[0]@0- -A-.--k-00010080 (_TrapHandler        +  0) : bu      0xabf @38067
stdcore[0]@0- -A-.--k-00011602 (_DoException        +  0) : clre     @38071
Unhandled exception: ILLEGAL_RESOURCE, data: 0x00000000
The assembly file looks pretty clear. however I still can't get it to run. Any ideas?

Regards,
Dimitris

PS: These are the corresponding parts, the clock_init_ and the setup of the timer that fails.

Code: Select all

    ldw    r1,         dp[tickclock]       // get timer resource
    ldw    r2,         dp[next_int]        // get timer value of current interrupt
    ldw    r3,         cp[timertick]       // save value to add to the time at which the interrupt happened 
    add    r2,         r2,             r3  // calculate the time for the next interrupt
    setd   res[r1],    r2                  // set up the timer value for the next interrupt
    stw    r2,         dp[next_int]        // store this value in next_int

Code: Select all

    // setup tick timer
    ldap    r11,        clock_int_                   // get address of interrupt handler
    ldw     r1,         dp[tickclock]                // get timer resource handler
    setv    res[r1],    r11                          // set the interrupt vector of the timer
PS:By the way, I am running the latest command line tools
dimitris
Active Member
Posts: 37
Joined: Tue Feb 19, 2013 5:07 pm

Post by dimitris »

Hi there, sorry to wake up an old thread but I could really use a helping hand here.
So, I am trying t port FreeRTOSv7 on an A8 (StartKit) device.

The original project breaks with an ILLEGAL_RESOURCE at

Code: Select all

ldw     r1,         dp[tickclock]
setv    res[r1],    r11                          // set the interrupt vector of the timer
To make it work, Bianco suggested to change that to

Code: Select all

ldw     r1,         dp[__timers]
setv    res[r1],    r11                          // set the interrupt vector of the timer
Problem 1: why a a timer declared on .xc (tickclock) is considered as an ILLEGAL_RESOURCE?
Problem 2: Trying to read out a timer in XC will halt the execution.

To make it worse, I am trying to port FreeRTOSv7 which is introducing the concept of software timers. For those handy with FreeRTOS, one of the changes is that v6 vTaskIncrementTick has changed in v7 to xTaskIncrementTick.

Code: Select all

// bl vTaskIncrementTick   // increment tick and check for expired delays
bl xTaskIncrementTick   // increment tick and check for expired delays

Problem 3: Taking Bianco's project and removing all the tests, I left a baare version of the FreeRTOSv7 which is only toggling a led on the Startkit. Timing is buggy. The led is NOT on for 0,5 secs which introduces that there is some timing mulfunction.
Problem 4: The run halts every ~21 seconds which is the longest time interval that an XMOS timer can handle.

It looks like an assembly chalenge!
Suggestions, tips, tricks will be highly appreciated!
Thanx in advance.

PS: Original project can be found here http://www.xcore.com/projects/freertos-port
PS: FreeRTOSv7 can be found here http://sourceforge.net/projects/freerto ... OS/V7.6.0/
User avatar
Bianco
XCore Expert
Posts: 754
Joined: Thu Dec 10, 2009 6:56 pm
Contact:

Post by Bianco »

The way timers are implemented has changed in the tools version 13.
Like we have discussed in private, using __timers is a quick workaround to get my tests running, assuming that no other timers are used. __timers is actually the start of some array containing timer references. Using just the __timers label we use offset 0. For some reason we cannot just use the label of the timer declared in XC, it will point to some ' random' memory hence the crashes.

One way to solve this is to not declare the timer in XC but directly allocate it in the FreeRTOS startup code using the GETR instruction, and save that resource ID somewhere in memory.

I will investigate the case further when I have more time in a few weeks and come with a proper solution.
User avatar
davelacey
Experienced Member
Posts: 104
Joined: Fri Dec 11, 2009 8:29 pm

Post by davelacey »

Timers have changed in 13. Unfortunately we have been a bit delayed in getting an update ABI document out.

The __timers array contains 1 timer per logical core. So xC always grabs the same timer on a logical core independent of where it is declared. This was done to reduce overall timer use in a program.
You can mimic this in assembly by grabbing the core local timer whenever you want to use a timer:

Code: Select all

	ldaw r0, dp[__timers]
	get r11, id
	ldw r0, r0[r11]
Since xC code always uses the same timer resource independent of declarations it doesn't store the ID in the variable anymore. This is why you get an illegal resource exception when you try and access one in assembly.

If you want to use a new hardware timer resource and not the one globally allocated to the logical core you can declare a "hardware timer" in xC:

Code: Select all

#include <hwtimer.h>

...
  hwtimer_t tmr;
  my_assembly_function(tmr);
This will allocate a new timer resource an pass on the resource ID as the argument to my_assembly_function.

Dave
User avatar
Bianco
XCore Expert
Posts: 754
Joined: Thu Dec 10, 2009 6:56 pm
Contact:

Post by Bianco »

Thanks for the clarification Dave.

So using hwtimer_t will exhibit the ' old' behaviour and variables of this type will be directly accessible in assembly using the variable name as label?

Also will this type work in other XC statements such as timerafter etcetera?
Post Reply