Quality RTOS & Embedded Software

 Real time embedded FreeRTOS RSS feed 
Real time embedded FreeRTOS mailing list 
Quick Start Supported MCUs PDF Books Trace Tools Ecosystem TCP & FAT Training




Loading

freeRTOS + SAME70 = HEAP Problem

Posted by rtimenoob on March 28, 2017

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 configTOTALHEAPSIZE 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 _NVICPRIO_BITS
/* __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(taskled, "test", TASKLEDSTACKSIZE, NULL, TASKLEDSTACK_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.


freeRTOS + SAME70 = HEAP Problem

Posted by rtel on March 28, 2017

First question. You say the first task doesn't start unless you set the heap to 40000. Does that mean that with this change to the heap size the first task does start, and the system runs ok other than the CAN interrupts?

Have you ever seen the CAN interrupts working, and if so, is it only when you use FreeRTOS that they don't work?

If the CAN interrupts only don't work when you are using FreeRTOS, are you talking about them not working before the scheduler starts or after the scheduler starts?


[ Back to the top ]    [ About FreeRTOS ]    [ Sitemap ]    [ ]




Copyright (C) 2004-2010 Richard Barry. Copyright (C) 2010-2016 Real Time Engineers Ltd.
Any and all data, files, source code, html content and documentation included in the FreeRTOSTM distribution or available on this site are the exclusive property of Real Time Engineers Ltd.. See the files license.txt (included in the distribution) and this copyright notice for more information. FreeRTOSTM and FreeRTOS.orgTM are trade marks of Real Time Engineers Ltd.

Latest News:

FreeRTOS V9.0.0 is now available for download.


Free TCP/IP and file system demos for the RTOS


Sponsored Links

⇓ Now With No Code Size Limit! ⇓
⇑ Free Download Without Registering ⇑


FreeRTOS Partners

ARM Connected RTOS partner for all ARM microcontroller cores

Renesas Electronics Gold Alliance RTOS Partner.jpg

Microchip Premier RTOS Partner

RTOS partner of NXP for all NXP ARM microcontrollers

Atmel RTOS partner supporting ARM Cortex-M3 and AVR32 microcontrollers

STMicro RTOS partner supporting ARM7, ARM Cortex-M3, ARM Cortex-M4 and ARM Cortex-M0

Xilinx Microblaze and Zynq partner

Silicon Labs low power RTOS partner

Altera RTOS partner for Nios II and Cortex-A9 SoC

Freescale Alliance RTOS Member supporting ARM and ColdFire microcontrollers

Infineon ARM Cortex-M microcontrollers

Texas Instruments MCU Developer Network RTOS partner for ARM and MSP430 microcontrollers

Cypress RTOS partner supporting ARM Cortex-M3

Fujitsu RTOS partner supporting ARM Cortex-M3 and FM3

Microsemi (previously Actel) RTOS partner supporting ARM Cortex-M3

Atollic Partner

IAR Partner

Keil ARM Partner

Embedded Artists