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

More memory on ATMega128

Posted by Nobody/Anonymous on December 11, 2004
Would you mind giving me a hand on FreeRTOS?

The FreeRTOS works fine to me in a project based on ATmega128 until recently that I would like to create one more task. It shows errCOULD_NOT_ALLOCATE_REQUIRED_MEMORY when it is asked to create a new
task.

I look at the output map file. There is still 1k not used. So look up the API, it is saying to change portTOTAL_HEAP_SIZE in portmacro.h. I could not find portTOTAL_HEAP_SIZE in it. Instead, I find

#define heapNUM_SMALL_BLOCKS ( 16 )
#define heapNUM_LARGE_BLOCKS ( 10 )

in portheap.c.

1. Are these the arrays that need changing?

2. How do the array sizes relate to the number of tasks created? In another word, how many heapNUM_SMALL_BLOCKS and heapNUM_LARGE_BLOCKS need being allocated for one task?

3. Does the kernel reserve some blocks?

Thanks in advance.

RE: More memory on ATMega128

Posted by Richard on December 11, 2004
Hi,

It sounds like you are using an older version of FreeRTOS. The portheap.c you mention was replaced in version 2.5.0 with three sample (and simple) memory management schemes.

If you are using the portheap.c as directly downloaded on an ATMega128 then I suspect you have a lot of unused memory you can make use of.


First I will answer the questions relating to your current version, then make some suggestions as how you can upgrade:

> 1. Are these the arrays that need changing?

Basically yes. The old portheap.c you are using maintained two pools of fixed size memory blocks. When the kernel wanted to allocated some memory it would use a block from the array of small blocks if appropriate, or the array of large blocks if there were no small blocks left of the allocation required a large block anyway.

>2. How do the array sizes relate to the number of tasks created? In another word, how many heapNUM_SMALL_BLOCKS and heapNUM_LARGE_BLOCKS need being allocated for one task?

Normally one small block and one large block for each task. Blocks are also used for queues and semaphores so there is not a one to one relationship.

>3. Does the kernel reserve some blocks?

Every call to pvPortMalloc() obtains a block from either array. The kernel call pvPortMalloc() when a task, queue or semaphore is created.



V2.5.0 onwards of FreeRTOS has replaced the portheap.c files with heap_1.c, heap_2.c and heap_3.c. These are described here:

http://www.freertos.org/a00111.html

Have a look at this page and decide which scheme is best for you. They all use one single array of memory from which blocks of any size can be allocated. The total size of the array is set by the constant portTOTAL_HEAP_SIZE, making configuration a lot easier as you only have one constant to set.

I suggest you download the latest version of FreeRTOS and either:

1) Use the latest version in it’s entirety – this would be the preferred solution.

Or

2) Just take the heap_x.c file from the latest version and use it in your project in place of portheap.c. You may need to replace the vTaskSuspendAll() and cTaskResumeAll() in heap_x.c with calls to portENTER_CRITICAL() and portEXIT_CRITICAL() respectively.

The other alternative of course is to keep the files you are using and increase the heapNUM_SMALL_BLOCKS and heapNUM_LARGE_BLOCKS constants.

I also suggest taking a look at the version history:

http://www.freertos.org/History.txt

Regards,
Richard.


[ 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