0

FreeRTOS on Cortex-A FVP ARM DS-5

Here is an implementation of the FreeRTOS ARM Cortex-A port on the DS-5 Cortex-A8 Fixed Virtual Platform. You can now evaluate FreeRTOS on a Cortex-A series processor without the need to purchase additional hardware. Students and professionals can also explore RTOS concepts / design methodologies or even tweak the OS, try real nasty things.Compiled and tested in ARM DS-5 Ultimate Edition (Evaluation) Version: 5.21.0 Build number: 5210017

This article assumes that you now how to use the ARM DS-5 tool-chain/IDE.

 

Import this project into DS-5. Compile and create a Debug Configuration for the Cortex-A8 FVP Bare-Metal debug.

The system is configured for a maximum 32 interrupts. The FVP has 64 interrupt sources out of which the first 16 are SGIs. More information on interrupt priority assignments on Cortex-A series specific to this OS can be found here.

 

I am using the SP804 Timer Module 0 to generate the tick interval. The timer is configured as a 32-bit counter, periodic timer. timer_init.s has a minimal assembly implementation.

 

The port for the Cortex-A series can be found in the FreeRTOS portable directory - \FreeRTOSV8.2.1\FreeRTOS\Source\portable\RVDS\ARM_CA9.

 

configCPU_CLOCK_HZ and configPERIPHERAL_CLOCK_HZ would really not matter in the simulation. The tick timer has been configured with a value of 0x3e8. The FreeRTOSConfig.h file has been used by modifying the one in Renesas demo project.

 

As this will be running on a Cortex-A8 FVP, the Cortex-A8 startup file can be found in the bare-metal examples directory in the DS-5 installation. This file has been modified for the current implementation by adding stack initialization, enabling GIC etc.


Additional changes in port.c for handling the tick and setting API for clearing the timer interrupt.

main.c implements 3 tasks for demonstration:
RollingLEDSTask - This task nudges the LEDs in the CLCD window one at a time, prints the number of times it's called and goes to sleep for 1 tick.

PrintHelloTask - Prints hello world to the console and the number of times it is called and goes to sleep for 5 ticks.

PrintKeyboardTask - I was looking for a method to externally trigger events in the DS-5 debugger. Unfortunately the GPIO controller in the FVP lacks this capability. Therefore the only method was to use the PL050 implementation in the FVP to trigger events using the keyboard connected to the computer :P
PL050.c therefore contains a minimal implementation of the driver for this FVP peripheral. the PrintKeyboardTask blocks on a semaphore on start up. If a key is pressed on the keyboard while the CLCD window is active, the PL050 generates 3 interrupts. The 3 bytes sent in sequence are [scancode], [0xF0], [scancode] Leave a comment below if you know why 3 bytes. The first byte is indeed the scan-code but i have no idea what the second byte is. Ideally it should be the shift key status. On the third interrupt the semaphore is released from the IRQ handler of the peripheral which activates the task to print out to the console. To get the ascii value of the key, you might have to convert the scancode to the corresponding ascii value. For character - a, i was getting scan code of 0x1C which might differ based on your locale / keyboard type.
P.S: Most files are in assembly and not in C e.g the timer and GIC APIs, the reason being - i already had these ready from earlier projects, hence used the same. You can use your own implementation in C if you require. 
To enable FreeRTOS awareness in DS-5 please enable the flags mentioned in this article on ARM Infocenter.



FreeRTOS-DS-5.zip

0 comments

Please sign in to leave a comment.