FreeRTOS and xCORE-200 eXplorerKIT Topic is solved

Technical discussions related to any XMOS development kit or reference design. Eg XK-1A, sliceKIT, etc.
Junior Member
Posts: 4
Joined: Tue Jan 23, 2018 5:42 pm

FreeRTOS and xCORE-200 eXplorerKIT

Post by tobias.xcore200 »

Hi there,

first of all I apologize for apologize for all misspelling I'll do in this post, I am not a native english speaker.

So, for my bachelor thesis I should port FreeRTOS to the XS2 architecture. This kind of went very smooth, because there already exists a
port here:, source code can be found here:

So, now I am facing a problem when using "printf" after starting the scheduler. I know, RTOS and printf is not how it is intended to be used,
but it is quite ok/comfortable for debugging I guess. So, to provide some more techical details I tried to debug it with XGDB and ended up here:

tile[0]@0- -SI Ai.----00042c20 (vfprintf + 68) : bl 0xdd8 @27027
tile[0]@0- -SI Ai.----000447d4 (__swsetup + 0) : entsp 0x8 S[0x48c44] @27032
tile[0]@0-*-SI Ai.----000447d8 (__swsetup + 4) : std r5(0x48db4), r4(0x47460), sp[0x1] S[0x48c2c] @27037
tile[0]@0 *000447d8 : TRAP ET: 5, SPC: 000447d8, SSR: 2, ED: 00048c2c (LOAD_STORE)

What maps to (ABI Definition of STD):
► Show Spoiler
So I guess, that b (the stack) is not double word aligned. I have no idea what to do here, because I think I can not change the code.

================================= MORE INFORMATION =================================

I tested something a minute ago, I compiled the code with -O3 (and -O1, -O2, -Os) and then the program failed at the vTaskDelay (FreeRTOS) function,
also right after extending the stack and calling the instruction "STW". I guess there is something messed up with my stack, but
has anyone an idea what to do or what it could be?
Note that in the given port of FreeRTOS the function "pxPortInitialiseStack" (called when a task is created, initializes the stack for that task with values that
will be restored when the scheduler of FreeRTOS is (context) switching to that function. The stack (to be more pecise, the registers r0 - r11) gets initialized
with the values 1 to 11.
I don't know if this is the problem or not, I changed the values the registers are initialized with but nothing changed.
To be honest, I have no idea what to do next...

Have a nice evening,

PS: if this is the wrong subforum to post in - feel free to move it somewhere else.

View Solution
Posts: 5
Joined: Fri Jul 28, 2017 9:55 am

Post by jakeh »

Hi Tobias,

It does look like a stack pointer alignment issue.
In your port you define the byte alignment as 4 here.

If you change this to 8, it might resolve this issue.

Kind Regards,
Junior Member
Posts: 4
Joined: Tue Jan 23, 2018 5:42 pm

Post by tobias.xcore200 »


this actually did it! Thank you very much.
It really was the stack pointer that has to be double word aligned but was not. The defined portBYTE_ALIGNMENT has to be 8.
User avatar
XCore Expert
Posts: 567
Joined: Thu Nov 26, 2015 11:47 pm

Post by akp »


Sorry this is an old topic. Very helpful insight from Jake, thank you! I have found that even with this fix, I need to set the -mno-dual-issue compiler directive for the code to work. My gut tells me this down to the port_asm.S? Any tips or tricks I should look at to enable the RTOS to work even if the core is in dual issue mode?