FreeRTOS on ATmega168

Hello, I am trying to get FreeRTOS working on the ATmega168, a chip with 16 k FLASH and 1 kBytes RAM. The program memory is no problem, the RAM usage is. The following is working so far: vStartLEDFlashTasks vStartIntegerMathTasks and the TX part of vAltStartComTestTasks Important for me is it, to get the RX part of the COMTestTasks going. My configuration: #define configUSE_PREEMPTION        1 #define configUSE_IDLE_HOOK            0 #define configCPU_CLOCK_HZ            ( ( unsigned portLONG ) 8000000 ) #define configTICK_RATE_HZ            ( ( portTickType ) 512 ) #define configMAX_PRIORITIES        ( ( unsigned portBASE_TYPE ) 4 ) #define configMINIMAL_STACK_SIZE    ( ( unsigned portSHORT ) 85 ) #define configTOTAL_HEAP_SIZE     ( (size_t ) (500 ) ) // default: 1500 #define configMAX_TASK_NAME_LEN        ( 4 ) // default: 8 #define configUSE_TRACE_FACILITY    0 #define configUSE_16_BIT_TICKS        1 #define configIDLE_SHOULD_YIELD        1 /* Set the following definitions to 1 to include the API function, or zero to exclude the API function. */ #define INCLUDE_vTaskPrioritySet        0 #define INCLUDE_uxTaskPriorityGet        0 #define INCLUDE_vTaskDelete                1 #define INCLUDE_vTaskCleanUpResources    0 #define INCLUDE_vTaskSuspend            0 #define INCLUDE_vTaskDelayUntil            1 #define INCLUDE_vTaskDelay                1 WinAVR reports: (I am using avr-gcc version 3.4.5) Program:    6390 bytes (39,0% Full) (.text + .data + .bootloader) Data:        689 bytes (67,3% Full) (.data + .bss + .noinit) I don’t no yet, where this high ram usage is coming from. Is it right, that statically allocated RAM and the HEAP_SIZE together must be less then 1k RAM? Any hints, how I can optimize the RAM usage are welcome. Uwe Fechner

FreeRTOS on ATmega168

Yes, the HEAP_SIZE is statically allocated, so this together with the other statically allocated variables must be less than 1K. 1K is not very much. On Monday FreeRTOS V4.0.0 will be available.  This will give you the option to use co-routines in place of tasks, which could give you a big RAM saving if appropriate for your application.  This might be better for you on a 1K device. Regards.

FreeRTOS on ATmega168

Well, it is working now. (One blinking LED Task, RX and TX Tasks with 600 Bytes Heap). My application shouldn’t need more than 128 Bytes of RAM, so I can provide 800-872 Bytes for the heap. I hope that this is sufficient for five tasks with two priorities. The heap size is included in the memory usage reported from avr-gcc (other than I thought). My problem was, that a changed heap size was recognized by the compiler only if I run make clean make all and not with a simple make all. Nevertheless I am looking forward to the new release. Regards: Uwe Fechner

FreeRTOS on ATmega168

The update to FreeRTOS 4.0 reduced the memory usage, even without using CoRoutines: V3.2.3: PROGRAM: 7262 Bytes DATA:     981 Bytes V4.0 PROGRAM: 7122 Bytes DATA:     931 Bytes This is a reduced demo application with six tasks. VERY NICE! Keep up the good work! Uwe Fechner

FreeRTOS on ATmega168

I just published my FreeRTOS port in my wiki. http://www.kieltech.de/uweswiki/FreeRTOS The code is not very clean and not very well documented yet. When this is done, the port could be added to the distribution.