2012-02-07 23 views
-2

當它嘗試訪問結構數據時,我在幾個函數中有一個運行時錯誤,一般作爲參數傳遞給函數。bf561運行時錯誤指向結構數據時的COREB FreeRTOS實現

問題的第一個實例是:

signed portBASE_TYPE xQueueGenericReceive(xQueueHandle pxQueue, void * const p\ 

vBuffer, portTickType xTicksToWait, portBASE_TYPE xJustPeeking) 

{ 

.............. 



if(pxQueue->uxMessagesWaiting > (unsigned portBASE_TY\ 

PE) 0) 



....................... 



} 

其中pxQueue是這樣的結構:

typedef xQUEUE * xQueueHandle; 

與:

typedef struct QueueDefinition 

{ 

     signed char *pcHead;       /*< Points to the begin\ 

ning of the queue storage area. */ 

    signed char *pcTail;       /*< Points to the byte \ 

at the end of the queue storage area. Once more byte is allocated than necessa\ 

ry to store the queue items, this is used as a marker. */ 



     signed char *pcWriteTo;       /*< Points to the free \ 

next place in the storage area. */ 

     signed char *pcReadFrom; 
        /*< Points to the last \ 

place that a queued item was read from. */ 


     xList xTasksWaitingToSend;        /*< List of tas\ 

ks that are blocked waiting to post onto this queue. Stored in priority order.\ 

*/ 
     xList xTasksWaitingToReceive;     /*< List of tasks that \ 

are blocked waiting to read from this queue. Stored in priority order. */ 


     volatile unsigned portBASE_TYPE uxMessagesWaiting;/*< The number of ite\ 

ms currently in the queue. */ 
     unsigned portBASE_TYPE uxLength;    /*< The length of the q\ 

ueue defined as the number of items it will hold, not the number of bytes. */ 
     unsigned portBASE_TYPE uxItemSize;    /*< The size of each it\ 

ems that the queue will hold. */ 


     signed portBASE_TYPE xRxLock;     /*< Stores the number o\ 

f items received from the queue (removed from the queue) while the queue was lo\ 

cked. Set to queueUNLOCKED when the queue is not locked. */ 
     signed portBASE_TYPE xTxLock;     /*< Stores the number o\ 

f items transmitted to the queue (added to the queue) 

while the queue was locke\ 

d. Set to qu....................... 



} 

其中pxQueue是這樣的結構:

typedef xQUEUE * xQueueHandle; 

有:

typedef struct QueueDefinition 

{ 

     signed char *pcHead;       /*< Points to the begin\ 

ning of the queue storage area. */ 

    signed char *pcTail;       /*< Points to the byte \ 

at the end of the queue storage area. Once more byte is allocated than necessa\ 

ry to store the queue items, this is used as a marker. */ 



     signed char *pcWriteTo;       /*< Points to the free \ 

next place in the storage area. */ 

     signed char *pcReadFrom; 
        /*< Points to the last \ 

place that a queued item was read from. */ 


     xList xTasksWaitingToSend;        /*< List of tas\ 

ks that are blocked waiting to post onto this queue. Stored in priority order.\ 

*/ 
     xList xTasksWaitingToReceive;     /*< List of tasks that \ 

are blocked waiting to read from this queue. Stored in priority order. */ 


     volatile unsigned portBASE_TYPE uxMessagesWaiting;/*< The number of ite\ 

ms currently in the queue. */ 
     unsigned portBASE_TYPE uxLength;    /*< The length of the q\ 

ueue defined as the number of items it will hold, not the number of bytes. */ 
     unsigned portBASE_TYPE uxItemSize;    /*< The size of each it\ 

ems that the queue will hold. */ 


     signed portBASE_TYPE xRxLock;     /*< Stores the number o\ 

f items received from the queue (removed from the queue) while the queue was lo\ 

cked. Set to queueUNLOCKED when the queue is not locked. */ 
     signed portBASE_TYPE xTxLock;     /*< Stores the number o\ 

f items transmitted to the queue (added to the queue) 

while the queue was locke\ 

d. Set to queueUNLOCKED when the queue is not locked. */ 



} xQUEUE; 
eueUNLOCKED when the queue is not locked. */ 



} xQUEUE; 

運行時錯誤是:

..... 
COREB: start xQueueGenericReceive           
COREB: execption 24 addr 3c00384            
COREB: coreb dump stack              
COREB: found fp: ff700900             
COREB: call frame 0 -12 feb055e2           
COREB: call frame 0 -11 00000000           
COREB: call frame 0 -9 00000000            
COREB: call frame 0 -8 ff7008d0  

...... 

同樣,我已經用下面的函數相同的問題:

void vListRemove(xListItem *pxItemToRemove) 

{ 

xList * pxList; 



    pxItemToRemove->pxNext->pxPrevious = pxItemToRemove->pxPrevious; 

     pxItemToRemove->pxPrevious->pxNext = pxItemToRemove->pxNext; 

} 

其中pxItemToRemove-> pxPrevious能被讀取但不是pxItemToRemove-> pxNext-> px上一頁

它的結構是:

struct xLIST_ITEM 

{ 

    portTickType xItemValue;        /*< The value b\ 

eing listed. In most cases this is used to sort the list in descending order. \ 

*/ 

     volatile struct xLIST_ITEM * pxNext; /*< Pointer to the next xListIt\ 

em in the list. */ 

     volatile struct xLIST_ITEM * pxPrevious;/*< Pointer to the previous xLi\ 

stItem in the list. */ 

     void * pvOwner;             /*< Poi\ 

nter to the object (normally a TCB) that contains the list item. There is ther\ 

efore a two way link between the object containing the list item and the list i\ 

tem itself. */ 

     void * pvContainer;            /*< Poi\ 

nter to the list in which this list item is placed (if any). */ 

}; 

typedef struct xLIST_ITEM xListItem;   /* For some reason lint wants t\ 

his as two separate definitions. */ 

運行時錯誤是:

COREB: got to vTaskDelete             
COREB: pxTCB GLI prev: a5a5a5a5            
COREB: sent to list: 3d02004             
COREB: list_rem px prev: a5a5a5a5           
COREB: execption 24 addr 3c05444            
COREB: coreb dump stack              
COREB: found fp: ff7008fc             
COREB: call frame 0 -12 feb055e2           
COREB: call frame 0 -11 00000000           
COREB: call frame 0 -9 00000000            
COREB: call frame 0 -8 ff7008cc            
COREB: call frame 0 -7 ff700ff4  

預先感謝您。

威廉


進一步調試用gdb我有pxQueue:

p/x *pxQueue 

$9 = {pcHead = 0xadadadad, pcTail = 0xadadadad, pcWriteTo = 0xadadadad, 

    pcReadFrom = 0xadadadad, xTasksWaitingToSend = { 

    uxNumberOfItems = 0xadadadad, pxIndex = 0xadadadad, xListEnd = { 

     xItemValue = 0xadad, pxNext = 0xadadadad, pxPrevious = 0xadadadad}}, 

    xTasksWaitingToReceive = {uxNumberOfItems = 0xadadadad, 

    pxIndex = 0xadadadad, xListEnd = {xItemValue = 0xadad, 

     pxNext = 0xadadadad, pxPrevious = 0xadadadad}}, 

    uxMessagesWaiting = 0xadadadad, uxLength = 0xadadadad, 

    uxItemSize = 0xadadadad, xRxLock = 0xadadadad, xTxLock = 0xadadadad} 

這是很奇怪的,結構的所有參數具有相同的值:0xadadadad

當我進一步調試並將信號量創建看作創建隊列函數中的隊列對象時,我得到了正常值:

p *pxNewQueue 

$7 = {pcHead = 0x3d17000 "", pcTail = 0x3d17000 "", pcWriteTo = 0x3d17000 "", 

    pcReadFrom = 0x3d17000 "", xTasksWaitingToSend = {uxNumberOfItems = 0, 

    pxIndex = 0x3d16018, xListEnd = {xItemValue = 65535, pxNext = 0x3d16018, 

     pxPrevious = 0x3d16018}}, xTasksWaitingToReceive = {uxNumberOfItems = 0, 

    pxIndex = 0x3d1602c, xListEnd = {xItemValue = 65535, pxNext = 0x3d1602c, 

     pxPrevious = 0x3d1602c}}, uxMessagesWaiting = 0, uxLength = 1, 

    uxItemSize = 0, xRxLock = -1, xTxLock = -1} 

感謝,

威廉

+3

請格式化您的代碼。沒有人喜歡讀一個毫不費力的問題。 – bitmask 2012-02-07 00:43:03

+0

您是否檢查過所有指針以確保它們都不是NULL? – 2012-02-07 07:25:47

+1

嘿位掩碼你不能看到它被格式化...我不喜歡你說我把零努力,如果你再看看你可以看到我把相關的代碼並刪除了非相關的代碼。我已經提出了每個結構問題:函數中的代碼,相關的結構以及運行時調試的輸出。爲了清晰你還想要什麼? – 2012-02-07 22:37:48

回答

0

什麼是你正在嘗試做的,以及如何。什麼是COREB?

您是否從官方FreeRTOS代碼中修改了代碼片段的功能?代碼通常被編譯並鏈接到一個可執行文件中,所以你不會得到任何這樣的運行時錯誤。如果有任何問題,你只會得到編譯/鏈接錯誤。如果你得到運行時錯誤,那麼你是否試圖解釋代碼而不是編譯它?

+0

FreeRTOS不支持模擬設備Blackfin不幸的是..... BF561是一個雙核心,我正在CoreB(第二個核心)上運行freeRTOS,使用FreeRTOS for Blackfin的一個貢獻者(請參閱您的網站)編譯在VDSP中,我將它轉換爲GCC編譯器。在這個貢獻中出現了很多錯誤,但現在我已經接近它的工作。只有隊列和列表結構存在問題。也許是一個對齊問題.....由於缺少標籤功能和掛鉤功能實施等......我不得不放手。相信我,我寧願不要 – 2012-02-07 22:44:36

+0

實際上,你可以真正幫助我,因爲你是來自免費的RTOS。我認爲問題來自xTaskCallApplicationTaskHook(pxCurrentTCB,pxCurrentTCB-> pxStack);我已經把 - > pxStack,但我一定是錯的。 TCB結構中的pvParameter是什麼意思? – 2012-02-08 04:42:30

0

我找到了答案,

基本上,他們是沒有FreeRTOS操作系統文檔吧,我用gdb並創建任務時認準pvParameter,並期待它已被存儲在堆棧中。然後當我觸發任務與taskhook功能我給後面的參數:

void *param = *(pxCurrentTCB->pxTopOfStack+31); 

       //  xTaskCallApplicationTaskHook(pxCurrentTCB, pxCurrent\ 
TCB->pxTopOfStack);                
       xTaskCallApplicationTaskHook(pxCurrentTCB,param); 

那麼對於semafor隊列及待被調用時,它指向正確的地址。並檢索數據結構。