Quality RTOS & Embedded Software

 Real time embedded FreeRTOS RSS feed 
Real time embedded FreeRTOS mailing list 
Quick Start Supported MCUs PDF Books Trace Tools Ecosystem TCP & FAT Training




Loading

Rowley threads.js support for FreeRTOS

Posted by Angus Og on February 19, 2007
Hello,

I’m currently using Rowley with FreeRTOS on an ATMEL SAM7X. I would like to create tasking support for FreeRTOS within Rowley. Has anyone done this? I have created a threads.js that is viewing all the tasks and I have the general layout working. The area where I need a little help is with the FreeRTOS stack structure and I’m guessing a little help on how this works under ARM.
In particular I don’t fully understand how the program counter (pc) is tracked. I have looked at portRESTORE_CONTEXT() and I don’t fully see how the stack is lined up with the register values I’m expecting to see.

I’m including the threads.js code, but it is still very rough. In particular what I can’t get working is the registerContext restore. Any help would be greatly appreciated.

Thanks,
Angus

The following is my initial pass at threads.js for FreeRTOS:
function registersFromContext(sp)
{
var a = new Array();
for (i=0;i<=16;i++)
{
a = Debug.evaluate("*(unsigned*)0x"+sp.toString(16));
sp+=4;
}
return a;
}

function ConvertToString(data)
{
var str = "";

for(i=0;i<=16;i++)
{
if(tcb.pcTaskName == 0)
break;
str += String.fromCharCode(tcb.pcTaskName);
}
return str;
}

function listTasks(listName, listIndex)
{
var i=0;
y=Debug.evaluate(listIndex);

yy=Debug.evaluate("*(xList *)0x"+y.toString(16));
pxIndex = Debug.evaluate("*(xListItem *)0x"+yy.pxIndex.toString(16));
numItems = yy.uxNumberOfItems;
while(/*x &&*/ i<numItems && ((numItems < 50) && (numItems > 0)))
{
if (i==0)
Threads.newqueue(listName);
tcb = Debug.evaluate("*(tskTCB *)0x"+pxIndex.pvOwner.toString(16));
name = ConvertToString(tcb.pcTaskName);
pri = tcb.uxPriority;
registers = registersFromContext(tcb.pxStack+((tcb.usStackDepth-16)*4));
Threads.add(name, pri, pxIndex.pvOwner.toString(16), registers);
pxIndex = Debug.evaluate("*(xListItem *)0x"+pxIndex.pxNext.toString(16));
i++;
}
}

function update()
{
Threads.clear();

listTasks("DelayedTaskList", "*(int *)pxDelayedTaskList");
listTasks("OverflowDelayedTaskList", "*(int *)pxOverflowDelayedTaskList");
listTasks("PendingTaskList", "xPendingReadyList");

Threads.newqueue("TaskList");

topPri = Debug.evaluate("*(char *)uxTopReadyPriority");

var i=0;
var j=topPri;
while(j >= 0)
{
y=Debug.evaluate("pxReadyTasksLists");
y+=(20*j);
yy=Debug.evaluate("*(xList *)0x"+y.toString(16));
pxIndex = Debug.evaluate("*(xListItem *)0x"+yy.pxIndex.toString(16));
i=0;
numItems = yy.uxNumberOfItems;
while(i<numItems && ((numItems < 100) && (numItems > 0)))
{
tcb = Debug.evaluate("*(tskTCB *)0x"+pxIndex.pvOwner.toString(16));
name = ConvertToString(tcb.pcTaskName);
pri = tcb.uxPriority;
registers = registersFromContext(tcb.pxTopOfStack+(2*4));
Threads.add(name, pri, pxIndex.pvOwner.toString(16), registers);
pxIndex = Debug.evaluate("*(xListItem *)0x"+pxIndex.pxNext.toString(16));

i++;
}
j--;
}
}

RE: Rowley threads.js support for FreeRTOS

Posted by Nobody/Anonymous on February 19, 2007
There is a threads.js in the download. Does this do what you want?

RE: Rowley threads.js support for FreeRTOS

Posted by Angus Og on February 19, 2007
This is exactly what I was looking for. I guess it would have helped to perform a full search on the download ;)

Thanks,
Angus

RE: Rowley threads.js support for FreeRTOS

Posted by Angus Og on February 19, 2007
After some testing of the threads.js included in the dowmload, I have a few questions.

When placing a breakpoint I get the Task containing the breakpoint marked as executing. I would expect the registers at the breakpoint to match the registers at the top of the Task’s stack, but they don’t. When a task is executing are the register values poped off the tasks stack?

Also I get the occasional odd (looks corrupted) names for one or some of the tasks when I place a breakpoint in specific tasks. Anyone else seen this? Code continues to execute fine, and it does not look like the task linked lists are corrupted. Also tasks that have garbled names could be fine a subsequent breaks in the code.

(For this test I was just running the standard IwIP_Demo_Rowley_ARM7 from the download.)

Thanks,
Angus

RE: Rowley threads.js support for FreeRTOS

Posted by Nobody/Anonymous on February 19, 2007
The registers are saved to the stack when the task is not running. When the task is running the values that were on the stack will be overwritten by normal stack variables, and the values in the registers themselves with obviously change. There is no reason why the two would be the same, unless your breakpoint is at the end of the portRESTORE_CONTEXT macro.


[ Back to the top ]    [ About FreeRTOS ]    [ Sitemap ]    [ ]




Copyright (C) 2004-2010 Richard Barry. Copyright (C) 2010-2016 Real Time Engineers Ltd.
Any and all data, files, source code, html content and documentation included in the FreeRTOSTM distribution or available on this site are the exclusive property of Real Time Engineers Ltd.. See the files license.txt (included in the distribution) and this copyright notice for more information. FreeRTOSTM and FreeRTOS.orgTM are trade marks of Real Time Engineers Ltd.

Latest News:

FreeRTOS V9.0.0 is now available for download.


Free TCP/IP and file system demos for the RTOS


Sponsored Links

⇓ Now With No Code Size Limit! ⇓
⇑ Free Download Without Registering ⇑


FreeRTOS Partners

ARM Connected RTOS partner for all ARM microcontroller cores

Renesas Electronics Gold Alliance RTOS Partner.jpg

Microchip Premier RTOS Partner

RTOS partner of NXP for all NXP ARM microcontrollers

Atmel RTOS partner supporting ARM Cortex-M3 and AVR32 microcontrollers

STMicro RTOS partner supporting ARM7, ARM Cortex-M3, ARM Cortex-M4 and ARM Cortex-M0

Xilinx Microblaze and Zynq partner

Silicon Labs low power RTOS partner

Altera RTOS partner for Nios II and Cortex-A9 SoC

Freescale Alliance RTOS Member supporting ARM and ColdFire microcontrollers

Infineon ARM Cortex-M microcontrollers

Texas Instruments MCU Developer Network RTOS partner for ARM and MSP430 microcontrollers

Cypress RTOS partner supporting ARM Cortex-M3

Fujitsu RTOS partner supporting ARM Cortex-M3 and FM3

Microsemi (previously Actel) RTOS partner supporting ARM Cortex-M3

Atollic Partner

IAR Partner

Keil ARM Partner

Embedded Artists