I tried to mout FreeRTOS V7.0.1 on a Fujitsu MB96F356RWB. The project is compiled using Softune (F2MC-16 Family SOFTUNE Workbench V30L35). I started from FreeRTOS released for MB96340. I created a new Softune project using start.asm working on my system. I slightly modief it to be as close as possible to the one contained in the release for MB96340. I added all the files needed except croutine.c and I modified FreeRTOSConfig.h to exclude co-routines.
I implemented memory model contained in heap_3.c (should be a wrapper for standard malloc and free). As first try, I created one task in main() with the following code:
#define CHA_VEH_STATE_MACHINE_TSK_TICK ( (portTickType) (CHA_VEH_STATE_MACHINE_PERIOD_MS / portTICK_RATE_MS) )
void CHA_VEH_StateMachine(void* parParam){
portTickType xLastWaitTime;
for(;;){
/* Wait until next execution */
vTaskDelayUntil(&xLastWaitTime,CHA_VEH_STATE_MACHINE_TSK_TICK);
}
}
The project was compiled and downloded into the micro, bur some problems raised. Micro’s Program Counter jumped to position 0x000000 and was impossible to continue execution or to take micro control via EUROScope (debugger). This problem does not happen without the call to vTaskDelayUntil.
Moreover, the problem does not raise if I create another task with a low priority which is kept running as a fake background task.
With an empirical method of cut code and try I found that the problem is related to the call to vListRemove, in particular to its first lines:
pxItemToRemove->pxNext->pxPrevious = pxItemToRemove->pxPrevious;
pxItemToRemove->pxPrevious->pxNext = pxItemToRemove->pxNext
;
Actually, I do not know deeply FreeRTOS implementation, so I can only make a guess of what is happenning, but I am scared to make some pointer to point to something that does not exist (the task is only one, so there is no next!)In vListRemove I cannot see any check on this possibility. Anyhow, this is only my guess. Because it is not possible to take micro control using the debugger (it does not work) I do not know if my gess is correct or not. So, if someone found similar problem, please tell me how to make a workaround to avoid micro crash. Bye.