Reputation: 73
I am writing an application for the RPU on a Xilinx UltraScale+ ZCU102 device that needs to run a few tasks in FreeRTOS. My application starts by creating an 'start-up' task that will then create the rest of the tasks. After successfully creating my start-up task and calling vTaskStartScheduler() though, the start-up task does not run.
I noticed the FreeRTOS FAQ page (http://www.freertos.org/FAQHelp.html) says:
If the project you have created is compiling, and at least executing up to the point that the scheduler is started, but only a single task is executing or no tasks are executing at all after the call to vTaskStartScheduler(), then it is likely that the interrupt vector table is incorrect.
So I first checked to make sure the interrupt vector table is correct. I am using FreeRTOS 10.0, which is being built as part of the ZCU102 BSP.
In file "port_asm_vectors.S", which is created with the BSP, I have
// port_asm_vectors.S
...
.section .vectors,"a"
_vector_table:
ldr pc,=_boot
ldr pc,=Undefined
ldr pc, _swi
ldr pc,=PrefetchAbortHandler
ldr pc,=DataAbortHandler
NOP /* Placeholder for address exception vector*/
ldr pc, _irq
ldr pc,=FIQHandler
_irq: .word FreeRTOS_IRQ_Handler
_swi: .word FreeRTOS_SWI_Handler
...
In my application's linker script, I have the following
// lscript.ld
...
SECTIONS
{
.vectors : {
KEEP (*(.vectors))
*(.boot)
} > psu_r5_ddr_0_MEM_0
...
Because I'm using files generated by the Xilinx SDK here, I think the interrupt vector table is set up correctly, so I'm thinking that my FreeRTOS configuration my have an issue.
My FreeRTOSConfig.h file is mostly the same as the examples I've seen, although there are some changes I've made, like these:
// FreeRTOSConfig.h
...
#define configMINIMAL_STACK_SIZE (250)
#define configTOTAL_HEAP_SIZE (0xC800)
#define configSUPPORT_STATIC_ALLOCATION 1
#define configUSE_TASK_FPU_SUPPORT 2
...
The minimal stack size and total heap size are larger than the default values, and we only use statically allocated memory. No floats.
At program entry, I call this function:
void prvSetupHardware( void )
{
BaseType_t xStatus;
XScuGic_Config *pxGICConfig;
portDISABLE_INTERRUPTS();
pxGICConfig = XScuGic_LookupConfig( XPAR_SCUGIC_SINGLE_DEVICE_ID );
configASSERT( pxGICConfig );
configASSERT( pxGICConfig->CpuBaseAddress == ( configINTERRUPT_CONTROLLER_BASE_ADDRESS + configINTERRUPT_CONTROLLER_CPU_INTERFACE_OFFSET ) );
configASSERT( pxGICConfig->DistBaseAddress == configINTERRUPT_CONTROLLER_BASE_ADDRESS );
xStatus = XScuGic_CfgInitialize( &xInterruptController, pxGICConfig, pxGICConfig->CpuBaseAddress );
configASSERT( xStatus == XST_SUCCESS );
( void ) xStatus; /* Remove compiler warning if configASSERT() is not defined.
xStatus = XScuGic_SelfTest(&xInterruptController);
configASSERT( xStatus == XST_SUCCESS );
( void ) xStatus; /* Remove compiler warning if configASSERT() is not defined. */
xTxMutex = xSemaphoreCreateMutex();
configASSERT( xTxMutex );
xPort = xSerialPortInitMinimal( configCLI_BAUD_RATE, cmdQUEUE_LENGTH );
/* Disable cache on OCM */
Xil_SetTlbAttributes(OCM_START_ADDR,0x14de2); // S=b1 TEX=b100 AP=b11, Domain=b1111, C=b0, B=b0
}
In my application code, creating the init task is one of the first things that happen after the static memory regions have been created.
TaskHandle_t taskId = xTaskCreateStatic(
task_func, // pointer to task entry code
"STARTUP", // task name
0x3EA, // stack depth
0x00000000, // arguments
1, // priority
task_stack_buffer, // statically allocated task stack buffer
pTaskBuffer); // statically allocated, holds tasks data structures
This call exits successfully, and the call to vTaskStartScheduler happens, and the start-up task is not started. I stepped through the vTaskStartScheduler call, and it saw that it is not quitting early or erroring out.
Any ideas with this? I need the start-up task to start so that the rest of the tasks can be scheduled as well.
As a note: I've run the code I'm working with on other hardware platforms with FreeRTOS v10.0 successfully. All I needed to do is update the BSP, which builds the FreeRTOS library. So I'm not ruling out the problem being in the C code, I just don't think it is as likely as the problem being in project settings or FreeRTOS configurations.
Upvotes: 5
Views: 5443