Forum Discussion
BSP fails to build for FreeRTOS on a Nios V with UART
- 2 years ago
In the "freertos/drivers/src/":
- intel_lw_uart_init.c
- line 228~:
if (sp->tx_start == ((sp->tx_end + 1) & ALT_AVALON_UART_BUF_MSK))
{
ALT_FLAG_POST (sp->events,
ALT_UART_WRITE_RDY,
ALT_FLAG_SET);
}
- intel_lw_uart_read.c
- line 205~:
ALT_FLAG_PEND (sp->events,
ALT_UART_READ_RDY,
ALT_FLAG_WAIT_SET_ANY_WITH_CONSUME,
ALT_FLAG_WAIT_MAX_TIMEOUT);
- intel_lw_uart_write.c
- line 192~:
ALT_FLAG_PEND (sp->events,
ALT_UART_WRITE_RDY,
ALT_FLAG_WAIT_SET_ANY_WITH_CONSUME,
ALT_FLAG_WAIT_MAX_TIMEOUT);
- intel_lw_uart_init.c
Hi,
The changes for this error is to change the driver's code "\software\freertos_bsp\drivers\src"and modify the LW_UART HAL API as such (a KDB for this will be published):
- intel_lw_uart_init.c
- intel_lw_uart_read.c
- intel_lw_uart_write.c
However, for MAX 10, making this changes will increase the size of the .elf, and it would not fit the maximum size for MAX 10's OCRAM due to its size. Thus we regret to inform you, that MAX 10 cannot support FreeRTOS due to its memory limitation. You may continue with the Altera HAL or in the future consider a bigger FPGA.
The reason for the large execution size is due to the sneaky call to printf() in the provided vApplicationStackOverflowHook in FreeRTOS:
void vApplicationStackOverflowHook( TaskHandle_t xTask, char *pcTaskName ) { /* To suspress unused argument warning. */ ( void ) xTask; printf("Stack overflow task is %s \r\n",pcTaskName); taskDISABLE_INTERRUPTS(); __asm volatile( "ebreak" ); for( ;; ); }
This pulls in large chunks of the standard library and completely bloats the code. Simply disabling the stack overflow check in the BSP is enough to shrink the code size enough to fit in the OCRAM on a MAX10 no problem. I'd suggest removing this and using one of the ALT_LOG functions going forward.