pipsoft wrote on Friday, April 29, 2011:
Hello,
I see a problem with my queues under FreeRTOS V6.1.0
I’m compiling for ARM7 and execute it on an ARM Instruction Set Simulator (OVP, Open Virtual Platform)
But that should not be the Problem (I hope and think so).
1.)
It does not work when my code looks like below.
I create two queues with a length of 2 and 128 Bytes of size. I check if I receive a pointer to these queue and printf the values.
#define uxQueueItemSize 128
#define uxQueueLengthDefault 2
tdAllQueueHandles *pAllQueueHandles = ( tdAllQueueHandles * ) pvPortMalloc( sizeof( tdAllQueueHandles ) );
pAllQueueHandles->qhDISPin = xQueueCreate(uxQueueLengthDISP, uxQueueItemSize);
pAllQueueHandles->qhRTBPAin = xQueueCreate(uxQueueLengthRTBPA, uxQueueItemSize);
printf("%x\n", pAllQueueHandles->qhDISPin);
printf("%x\n", pAllQueueHandles->qhRTBPAin);
if (pAllQueueHandles->qhDISPin == NULL){taskMessage(“F”, PREFIX, “Not enough memory to create queue for Dispatcher!”);}
if (pAllQueueHandles->qhRTBPAin == NULL){taskMessage(“F”, PREFIX, “Not enough memory to create queue for Real Time Board Protocol Abstraction!”);}
The Simulation (execution of code) will show:
400009ec
40000b64
Info (OFFIS FreeRTOS task DISP) Starting Dispatcher task!
Info (OFFIS FreeRTOS task DISP) Stack left to use is: 40
Processor Exception (PC_PRX) Processor ‘CPU1’ 0x392c: e585100c str r1,
Processor Exception (PC_WPX) No write access at 0xbc8c
That is true, since oxbc8c is far from Flash or RAM memory of my simulated ARM!
From what I see here right now, this is caused by trying to work with the queue in the Dispatcher task.
if ( xQueueReceive( pAllQueueHandles->qhDISPin,
( void * ) &ucQueueItem,
DISP_PERIOD
) == pdPASS )
2.)
Now the really funny part! One could asume that somehow in case 1.) there is not enough memory or so (but the API did not
complain and did not return NULL as documented in case of not enough mem). But if I create even more queues
it suddenly works (at least for the first queues.):
tdAllQueueHandles *pAllQueueHandles = ( tdAllQueueHandles * ) pvPortMalloc( sizeof( tdAllQueueHandles ) );
pAllQueueHandles->qhDISPin = xQueueCreate(uxQueueLengthDISP, uxQueueItemSize);
pAllQueueHandles->qhRTBPAin = xQueueCreate(uxQueueLengthRTBPA, uxQueueItemSize);
pAllQueueHandles->qhEGin = xQueueCreate(uxQueueLengthEG, uxQueueItemSize);
pAllQueueHandles->qhUIin = xQueueCreate(uxQueueLengthUI, uxQueueItemSize);
pAllQueueHandles->qhDSin = xQueueCreate(uxQueueLengthDS, uxQueueItemSize);
printf("%x\n", pAllQueueHandles->qhDISPin);
printf("%x\n", pAllQueueHandles->qhRTBPAin);
if (pAllQueueHandles->qhDISPin == NULL){taskMessage(“F”, PREFIX, “Not enough memory to create queue for Dispatcher!”);}
if (pAllQueueHandles->qhRTBPAin == NULL){taskMessage(“F”, PREFIX, “Not enough memory to create queue for Real Time Board Protocol Abstraction!”);}
if (pAllQueueHandles->qhEGin == NULL){taskMessage(“F”, PREFIX, “Not enough memory to create queue for Event Generator!”);}
if (pAllQueueHandles->qhUIin == NULL){taskMessage(“F”, PREFIX, “Not enough memory to create queue for User Interface!”);}
if (pAllQueueHandles->qhDSin == NULL){taskMessage(“F”, PREFIX, “Not enough memory to create queue for Data Storage!”);}
The Simulation (execution of code) will show:
400009ec
40000b64
Info (OFFIS FreeRTOS task DISP) Starting Dispatcher task!
Info (OFFIS FreeRTOS task DISP) Stack left to use is: 40
Info (OFFIS FreeRTOS task EG) Starting Event Generator task!
Info (OFFIS FreeRTOS task EG) Stack left to use is: 70
Info (OFFIS FreeRTOS task EG) It is time to request readout of physical patient sensors.
Info (OFFIS FreeRTOS task DISP) Data in Dispatcher queue!
Info (OFFIS FreeRTOS task DISP) Package ID is: ucStartPeriodicPhysicalSensorRead!
Info (OFFIS FreeRTOS task DISP) Forwarded ucStartPeriodicPhysicalSensorRead to RTBPA.
Info (OFFIS FreeRTOS task DISP) Stack left to use is: 40
Info (OFFIS FreeRTOS task EG) Informed Dispatcher to process Periodic Physical Sensor Read.
Info (OFFIS FreeRTOS task DISP) No message for very long time. This doesn’t look good!!!!
Info (OFFIS FreeRTOS task DISP) Stack left to use is: 40
…
blablabla -> works perfect as desired!
QUESTION:
Is it possible, that the FreeRTOS queue functionality is not working correctly? Maybe someone has an idea of the problem.
Otherwise I will have to step/debug through the FreeRTOS stuff. I would love to avoid that.
Regards,
Frank Poppen