Hello,
I am running freeRTOS together with LWIP on a SAME70Q19.
I implemented freeRTOS out of the ASF in my AtmelStudio 7.0.
My Problem:
When I create a new task, my application stucks in the Function
vTaskStartScheduler(): Subfunction: xPortStartScheduler() Subfunction
prvPortStartFirstTask() From here the application jumps with hardfault
error to the dummy interrupt handler.
I noticed that this must be a problem with the heap memory.
When I increase configTOTAL
HEAPSIZE to 40000 I cannot receive
CAN messages any longer. Although the application jumps into the
RX Interrupt, the Mailboxes stay empty (0x00) When I decrease
the Heap size, I receive proper data. Very strange to me!!
I am using heap4.c and I configured freeRTOS as following:
~~~
define configUSE_PREEMPTION 1
define configUSEIDLEHOOK 0
define configUSETICKHOOK 0
define configCPUCLOCKHZ ( sysclkgetcpu_hz() )
define configTICKRATEHZ ( ( portTickType ) 1000 )
define configMAXPRIORITIES ( ( unsigned portBASETYPE ) 7 )
define configMINIMALSTACKSIZE ( ( unsigned short ) 130 )
define configTOTALHEAPSIZE ( ( size_t ) ( 28000 ) )
define configMAXTASKNAME_LEN ( 10 )
define configUSETRACEFACILITY 1
define configUSE16BIT_TICKS 0
define configIDLESHOULDYIELD 1
define configUSE_MUTEXES 1
define configQUEUEREGISTRYSIZE 8
define configCHECKFORSTACK_OVERFLOW 0
define configUSERECURSIVEMUTEXES 1
define configUSEMALLOCFAILED_HOOK 0 //1
define configUSEAPPLICATIONTASK_TAG 0
define configUSECOUNTINGSEMAPHORES 1
/* Co-routine definitions. */
define configUSECOROUTINES 0
define configMAXCOROUTINE_PRIORITIES ( 2 )
/* Software timer definitions. */
define configUSE_TIMERS 1
define configTIMERTASKPRIORITY ( configMAX_PRIORITIES – 1 )
define configTIMERQUEUELENGTH 5
define configTIMERTASKSTACKDEPTH ( configMINIMALSTACK_SIZE * 2 )
/* Set the following definitions to 1 to include the API function, or zero
to exclude the API function. */
define INCLUDE_vTaskPrioritySet 1
define INCLUDE_uxTaskPriorityGet 1
define INCLUDE_vTaskDelete 1
define INCLUDE_vTaskCleanUpResources 1
define INCLUDE_vTaskSuspend 1
define INCLUDE_vTaskDelayUntil 1
define INCLUDE_vTaskDelay 1
/* FreeRTOS+CLI definitions. */
/* Dimensions a buffer into which command outputs can be written. The buffer
can be declared in the CLI code itself, to allow multiple command consoles to
share the same buffer. For example, an application may allow access to the
command interpreter by UART and by Ethernet. Sharing a buffer is done purely
to save RAM. Note, however, that the command console itself is not re-entrant,
so only one command interpreter interface can be used at any one time. For
that reason, no attempt at providing mutual exclusion to the buffer is
attempted. */
define configCOMMANDINTMAXOUTPUTSIZE 400
/* Cortex-M specific definitions. */
ifdef __NVICPRIOBITS
/* __BVIC_PRIO_BITS will be specified when CMSIS is being used. */
#define configPRIO_BITS __NVIC_PRIO_BITS
else
#define configPRIO_BITS 4 /* 15 priority levels */
endif
/* The lowest interrupt priority that can be used in a call to a “set priority”
function. */
define configLIBRARYLOWESTINTERRUPT_PRIORITY 0x0f
/* The highest interrupt priority that can be used by any interrupt service
routine that makes calls to interrupt safe FreeRTOS API functions. DO NOT CALL
INTERRUPT SAFE FREERTOS API FUNCTIONS FROM ANY INTERRUPT THAT HAS A HIGHER
PRIORITY THAN THIS! (higher priorities are lower numeric values. */
define configLIBRARYMAXSYSCALLINTERRUPTPRIORITY 10
/* Interrupt priorities used by the kernel port layer itself. These are generic
to all Cortex-M ports, and do not rely on any particular library functions. */
define configKERNELINTERRUPTPRIORITY ( configLIBRARYLOWESTINTERRUPTPRIORITY << (8 – configPRIOBITS) )
define configMAXSYSCALLINTERRUPTPRIORITY ( configLIBRARYMAXSYSCALLINTERRUPTPRIORITY << (8 – configPRIOBITS) )
/* Normal assert() semantics without relying on the provision of an assert.h
header file. */
define configASSERT( x ) if( ( x ) == 0 ) { taskDISABLE_INTERRUPTS(); for( ;; ) __asm volatile( “NOP” ); }
define INCLUDEMODULETEST 0
define FREERTOS_USED
~~~
My Tasks are:
~~~
xTaskCreate(task
led, “test”,
TASKLED
STACKSIZE, NULL,
TASK
LEDSTACK_PRIORITY, NULL);
xTaskCreate(CAN_to_ETH_TASK, "CANTOETH",
TASK_CAN_TO_ETH_STACK_SIZE, NULL,
TASK_CAN_TO_ETH_STACK_PRIORITY, NULL);
xTaskCreate(CAN0_Task, "CAN0",
CAN_TASK_STACK_SIZE, NULL,
CAN_TASK_STACK_PRIORITY, NULL);
xTaskCreate(vStartEthernetTask, "ETHLAUNCH",
configMINIMAL_STACK_SIZE, NULL,
tskIDLE_PRIORITY + 4, NULL);
~~~
Here the defines:
~~~
define TASKMONITORSTACK_SIZE 50
define TASKMONITORSTACKPRIORITY (tskIDLEPRIORITY)
define TASKLEDSTACK_SIZE 50
define TASKLEDSTACKPRIORITY (tskIDLEPRIORITY)
define TASKCANTOETHSTACK_SIZE 500
define TASKCANTOETHSTACKPRIORITY (tskIDLEPRIORITY)+6
define CANTASKSTACK_SIZE 400
define CANTASKSTACKPRIORITY (tskIDLEPRIORITY)+6
/*! define stack size for WEB server task */
define lwipBASICWEBSERVERSTACKSIZE 512
/*! define stack size for TFTP server task */
define lwipBASICTFTPSERVERSTACKSIZE 2048
/*! define stack size for SMTP Client task */
define lwipBASICSMTPCLIENTSTACKSIZE 256
/*! define stack size for lwIP task */
define lwipINTERFACESTACKSIZE 2048
/*! define stack size for netif task */
define netifINTERFACETASKSTACK_SIZE 2048
/*! define WEB server priority */
define lwipBASICWEBSERVERPRIORITY (tskIDLEPRIORITY + 2)
/*! define TFTP server priority */
define lwipBASICTFTPSERVERPRIORITY (tskIDLEPRIORITY + 3)
/*! define SMTP Client priority */
define lwipBASICSMTPCLIENTPRIORITY (tskIDLEPRIORITY + 5)
/*! define lwIP task priority */
define lwipINTERFACETASKPRIORITY (configMAX_PRIORITIES – 1)
/*! define netif task priority */
define netifINTERFACETASKPRIORITY (configMAX_PRIORITIES – 1)
~~~
Can somebody help me with this issue? How much Heap should I use? How is it possible that
the CAN-Bus doesn’t receive messages any longer with greater heap size?
Why can’t I add new Tasks without jumping into hard fault error?
I am looking forward to your answers.