FreeRTOS "Hello, World." Not working with Xilinx SDK Repository

razed11 wrote on Tuesday, September 29, 2015:

Please disregard this thread. The issue is related to building with -DUSE_AMP=1. I will start another thread. This can be deleted.

I noticed that asking a task to delay is not working in my application with the Xilinx SDK Repository that I recently installed. So I created the FreeRTOS “Hello” program and it’s not working there either. If I comment out the delay the task queues work just fine so I think the interrupt table is not being installed and the system tick is not happening.

In the example application I didn’t see a call to setup hardware and install the vector table as with the standalone example (that does not make use of the repository)–it just creates the tasks and starts the scheduler.

What else must be called?

razed11 wrote on Wednesday, September 30, 2015:

In portZynq7000.c the routine below statically defines an XScuGic. Per the comment this routine expects XScuGic_CfgInitialize() to be called by the application but that routine requires an address to the XScuGic data structure. Is this an issue? Now there will be two instances of that data structure hanging around.

void FreeRTOS_SetupTickInterrupt( void )
{
static XScuGic xInterruptController; 	/* Interrupt controller instance */
BaseType_t xStatus;
extern void FreeRTOS_Tick_Handler( void );
XScuTimer_Config *pxTimerConfig;
XScuGic_Config *pxGICConfig;
const uint8_t ucRisingEdge = 3;

	/* This function is called with the IRQ interrupt disabled, and the IRQ
	interrupt should be left disabled.  It is enabled automatically when the
	scheduler is started. */

	/* Ensure XScuGic_CfgInitialize() has been called.  In this demo it has
	already been called from prvSetupHardware() in main(). */
	pxGICConfig = XScuGic_LookupConfig( XPAR_SCUGIC_SINGLE_DEVICE_ID );
	xStatus = XScuGic_CfgInitialize( &xInterruptController, pxGICConfig, pxGICConfig->CpuBaseAddress );
	configASSERT( xStatus == XST_SUCCESS );
	( void ) xStatus; /* Remove compiler warning if configASSERT() is not defined. */

	/* The priority must be the lowest possible. */
	XScuGic_SetPriorityTriggerType( &xInterruptController, XPAR_SCUTIMER_INTR, portLOWEST_USABLE_INTERRUPT_PRIORITY << portPRIORITY_SHIFT, ucRisingEdge );

	/* Install the FreeRTOS tick handler. */
	xStatus = XScuGic_Connect( &xInterruptController, XPAR_SCUTIMER_INTR, (Xil_ExceptionHandler) FreeRTOS_Tick_Handler, ( void * ) &xTimer );
	configASSERT( xStatus == XST_SUCCESS );
	( void ) xStatus; /* Remove compiler warning if configASSERT() is not defined. */

	/* Initialise the timer. */
	pxTimerConfig = XScuTimer_LookupConfig( XPAR_SCUTIMER_DEVICE_ID );
	xStatus = XScuTimer_CfgInitialize( &xTimer, pxTimerConfig, pxTimerConfig->BaseAddr );
	configASSERT( xStatus == XST_SUCCESS );
	( void ) xStatus; /* Remove compiler warning if configASSERT() is not defined. */

	/* Enable Auto reload mode. */
	XScuTimer_EnableAutoReload( &xTimer );

	/* Ensure there is no prescale. */
	XScuTimer_SetPrescaler( &xTimer, 0 );

	/* Load the timer counter register. */
	XScuTimer_LoadTimer( &xTimer, XSCUTIMER_CLOCK_HZ / configTICK_RATE_HZ );

	/* Start the timer counter and then wait for it to timeout a number of
	times. */
	XScuTimer_Start( &xTimer );

	/* Enable the interrupt for the xTimer in the interrupt controller. */
	XScuGic_Enable( &xInterruptController, XPAR_SCUTIMER_INTR );

	/* Enable the interrupt in the xTimer itself. */
	FreeRTOS_ClearTickInterrupt();
	XScuTimer_EnableInterrupt( &xTimer );
}

razed11 wrote on Wednesday, September 30, 2015:

The tick handler is still not being called. I added the routine below to initialize the GIC configuration and as I mentioned above I have referencing a different copy of the XScuGic structure.

The scheduler appears to call FreeRTOS_SetupTickInterrupt() so that is taken care of.

void zynq_initialize(void)
{
    BaseType_t status;

    XScuGic_Config *configuration;

    // Ensure no interrupts execute while the scheduler is in an inconsistent state. Interrupts are
    // automatically enabled when the scheduler is started.
    portDISABLE_INTERRUPTS();

    // Obtain the configuration of the GIC.
    configuration = XScuGic_LookupConfig(XPAR_SCUGIC_SINGLE_DEVICE_ID);

    // Sanity check the FreeRTOSConfig.h settings are correct for the hardware.
    configASSERT(configuration);

    configASSERT(configuration->CpuBaseAddress == CPU_BASE_ADDRESS);

    configASSERT(configuration->DistBaseAddress == GIC_BASE_ADDRESS);

    // Install a default handler for each GIC interrupt.
    status = XScuGic_CfgInitialize(&_gic, configuration, configuration->CpuBaseAddress);

    configASSERT(status == XST_SUCCESS);

    (void) status;

    // Switch to use the FreeRTOS vector table defined in port_asm_vectors.S in the RTOS library
    // source.
    
    vPortInstallFreeRTOSVectorTable();
}