Quality RTOS & Embedded Software

 Real time embedded FreeRTOS RSS feed 
Quick Start Supported MCUs PDF Books Trace Tools Ecosystem


How to port FreeRTOS to AT91SAM9G20

Posted by brilliantdt on April 19, 2015

Hi, I am trying to port FreeRTOS to AT91SAM9G20. It is based on the integration of an ARM926EJ-S processor. I have managed the AT91SAM9G20 development board normally in the IAR without FreeRTOS, but how can I port FreeRTOS to AT91SAM9G20. Who can give me detailed instructions? Thanks a lot!!!

How to port FreeRTOS to AT91SAM9G20

Posted by rtel on April 19, 2015

I would suggest starting with the existing SAM9 IAR demo: http://www.freertos.org/ARM9-AT91SAM9-RTOS-Demo.html

then re-targeting to your hardware: http://www.freertos.org/porting-a-freertos-demo-to-different-hardware.html

Things to watch out for:

Make sure you install the FreeRTOS interrupt handlers, exactly as they are in the existing SAM9 board.

If the timer peripherals are different on your hardware to the existing SAM9 demo then you will have to update the prvSetupTimerInterrupt() function in port.c.


How to port FreeRTOS to AT91SAM9G20

Posted by brilliantdt on April 21, 2015

Hi, Thanks for your reply. However, after I modified the demo and ported it to the AT91SAM9G20, I found some problems. First,if I create two simple tasks as the following, only one task can be running(In the following example, only led1 is light). And the task can only run two times, then stops(Because "LED1" can only be printed two times). /-----------------------------------------------------------/ xTaskCreate( vLED0Task, ( signed portCHAR * )"LED0", configMINIMALSTACKSIZE, NULL, configMAXPRIORITIES - 1, NULL ); xTaskCreate( vLED1Task, ( signed portCHAR * )"LED1", configMINIMALSTACKSIZE, NULL, configMAXPRIORITIES - 1, NULL ); vTaskStartScheduler(); /-----------------------------------------------------------/ static void vLED0Task( void *pvParameters )
for( ;; )
LED0_ON; printf("LED0n"); }

static void vLED1Task( void pvParameters )
for( ;; )
LED1_ON; printf("LED1n"); }
} /-----------------------------------------------------------*/

I do not think I have correctly modified the demo and ported it the AT91SAM9G20, but what is the problem with my codes? which codes should I modify? I hope for detailed instructions. Tnanks very much!

How to port FreeRTOS to AT91SAM9G20

Posted by rtel on April 21, 2015

My first suggestion is to remove the calls to printf() - unless you are 100% sure they are thread safe and know how they are implemented (for example, do they call malloc(), where is the output sent, which drivers are used to perform the output, etc., is newlib being used which would require specific settings in FreeRTOSConfig.h, etc.). You can add printf() back in, which the necessary precautions, once you are sure the RTOS port is running correctly.

Change the task implementation so it does nothing more than increment a volatile variable that can be inspected in the debugger. Each of the two tasks increments a different volatile variable - so if both tasks are running the two variables will increment at a very fast rate.

If you then find only one of the two variables is incrementing it is likely the tick interrupt is not executing. That can be checked by placing a break point in the timer ISR, or by viewing the xTickCount variable in the debugger (inside the FreeRTOS/Source/task.c file).

If the tick count is not incrementing then check the timer is being initialised correctly and its IRQ handler installed correctly. That can be done without the RTOS first just a main() function that does nothing but initialise the timer, then sit in an infinite loop. The timer's ISR can then be set to just increment a variable, again so you can see if it is executing at the expected frequency.


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

Copyright (C) Amazon Web Services, Inc. or its affiliates. All rights reserved.

Latest News

NXP tweet showing LPC5500 (ARMv8-M Cortex-M33) running FreeRTOS.

Meet Richard Barry and learn about running FreeRTOS on RISC-V at FOSDEM 2019

Version 10.1.1 of the FreeRTOS kernel is available for immediate download. MIT licensed.

View a recording of the "OTA Update Security and Reliability" webinar, presented by TI and AWS.


FreeRTOS and other embedded software careers at AWS.

FreeRTOS Partners

ARM Connected RTOS partner for all ARM microcontroller cores

Espressif ESP32

IAR Partner

Microchip Premier RTOS Partner

RTOS partner of NXP for all NXP ARM microcontrollers


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

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

OpenRTOS and SafeRTOS

Xilinx Microblaze and Zynq partner