nobody wrote on Tuesday, April 24, 2007:
Hey Guys!
Currently I’m trying to get FreeRTOS working under MPLAB 7.52 using
C18 v3.10 on a PIC18F4620.
Despite a few compiler warnings, and a few extra typecasts, all is working weel, exept for 1 really big problem (in my eyes).
I’m pretty new to RTOS, but during my testing, I found a disturbing issue.
The RTOS documentation says for the portSAVE_CONETXT macro
"
* The compiler uses some locations at the bottom of the memory for temporary
* storage during math and other computations. This is especially true if
* 32bit data types are utilised (as they are by the scheduler). The .tmpdata
* and MATH_DATA sections have to be stored in there entirety as part of a task
* context. This macro stores from data address 0x00 to
* sysCOMPILER_MANAGED_MEMORY_SIZE. This is sufficient for the demo
* applications but you should check the map file for your project to ensure
* this is sufficient for your needs. It is not clear whether this size is
* fixed for all compilations or has the potential to be program specific.
"
Well, this gave me a little headache, because when I execute the code, some variables declared in port.c are overwritten by crap during the first portRESTORE_CONTEXT.
I’m not very good in assembler, but when I look at my map file, I don’t think
the MATH_DATA and .tmpdata sections are stored at the bottom (0x00):
Snippet from map file:
"
Section Info
Section Type Address Location Size(Bytes)
--------- --------- --------- --------- ---------
//---------------------------------------------------------------------
.udata_tasks.o udata 0x000000 data 0x00004c
.tmpdata udata 0x00004c data 0x000010
MATH_DATA udata 0x00005c data 0x000004
etc.
"
now, lets see whats un .udata_task.o:
"
Symbols - Sorted by Address
Name Address Location Storage
--------- --------- --------- --------- ---------
pxReadyTasksLists 0x000000 data extern
xDelayedTaskList1 0x000024 data static
xDelayedTaskList2 0x00002d data static
pxDelayedTaskList 0x000036 data static
pxOverflowDelayedTaskList 0x000038 data static
xPendingReadyList 0x00003a data static
xSuspendedTaskList 0x000043 data static
__tmp_0 0x00004c data static
__tmp_0 0x00004c data static
etc…
"
So to my opinion, when retoring the first context for the first task,
my ReadyTasklists and other VERY HANDYDANDY variables are overwritten with
bugus. Stepping with my debugger conforms this.
My question is, is this behaviour known and if so, is there a simple cure?
When building demo projects, the linker places the the .tmpdata and MATH_DATA sections at will in all differrent locations in memory. So none of the
samples worked (they all crash landed).
Thankx in advance!