FreeRTOS and xCORE-200 eXplorerKIT Topic is solved

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

FreeRTOS and xCORE-200 eXplorerKIT

Postby tobias.xcore200 » Tue Jan 23, 2018 11:43 pm

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: http://www.xcore.com/viewtopic.php?t=5246, source code can be found here: https://github.com/BiancoZandbergen/XMOS_FreeRTOS

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,
T.

PS: if this is the wrong subforum to post in - feel free to move it somewhere else.
View Solution
jakeh
Posts: 5
Joined: Fri Jul 28, 2017 9:55 am

Postby jakeh » Wed Jan 24, 2018 10:50 am

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,
Jake
tobias.xcore200
Junior Member
Posts: 4
Joined: Tue Jan 23, 2018 5:42 pm

Postby tobias.xcore200 » Sat Jan 27, 2018 12:37 pm

Hi,

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
akp
Respected Member
Posts: 302
Joined: Thu Nov 26, 2015 11:47 pm

Postby akp » Sat Feb 16, 2019 11:00 pm

Hi,

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?


cheers!

Who is online

Users browsing this forum: No registered users and 1 guest