Cortex-M3 / GCC Port
for Luminary Micros Stellaris microcontrollers
[RTOS Ports]
|
|
There are currently four FreeRTOS ports for Luminary Micro Stellaris Cortex based embedded microcontrollers - one that uses
the Sourcery G++ (GCC) tools, one for Rowley CrossWorks,
another for the IAR tools, and one that uses the
ARM Keil tools.
This page relates only to the GCC based port. It is very similar to the page relating to the ARM Keil port down to the section providing build
instructions.
Stellaris is a new range of microcontrollers - the first to be commercially available with a Cortex-M3 core. The LM3S102 is a low cost, low pin count device. It has
2KBytes of RAM and 8KBytes of ROM on chip. An ideal candidate to demonstrate the new co-routine functionality included with FreeRTOS V4.0.0.
|
The Cortex GCC demo relies on a driver library and makefile which is licensed separately from FreeRTOS. The license conditions are included within the comments at the
top of the library header files located in the Demo/CORTEX_LM3S102_GCC/hw_include directory.
As per the Keil port, the GCC port was developed using the DK-LMS102 development board.
Upgrading to FreeRTOS.org V4.8.0: Prior to V4.8.0 the FreeRTOS.org kernel did not make use of the SVCall interrupt. From V4.8.0 onwards it does.
Therefore, to upgrade an older project to the V4.8.0 standard, a small edit to the startup code is required. To do this, simply install
vPortSVCHandler() in the SVCall position within the interrupt vector table (contained in the startup source file). The demo projects included in the
FreeRTOS.org download have already been updated so these can be used as an example.
IMPORTANT! Notes on using the Cortex-M3 GCC port
Please read all the following points before using this RTOS port.
- Source Code Organization
- The Demo Application
- Configuration and Usage Details
See also the FAQ My application does not run, what could be wrong?
Source Code Organization
The FreeRTOS download contains the source code for all the FreeRTOS ports so contains many more files that used by this demo.
See the Source Code Organization section for a description of the
downloaded files and information on creating a new project.
The GCC makefile for the Luminary Micro port is located in the FreeRTOS/Demo/CORTEX_LM3S102_GCC directory.
The Demo Application
The FreeRTOS source code download includes two demos for this port which include both fully preemptive tasks and co-routines. Demo-1 creates 3 tasks (including the idle task)
and 6 co-routines. Demo-2 creates 2 tasks and 7 co-routines. Due to the ROM and RAM constraints the standard demo tasks are not used.
Demo application hardware setup
All the DK-LMS102 jumpers can remain in their default positions.
The demo application includes an interrupt driven UART test where a co-routine transmits characters that are then received by a task. For correct operation
of this functionality a loopback connector must be fitted to the SER0 connector of the DK-LMS102 prototyping board (pins 2 and 3
must be connected together on the 9Way connector).
The USB enable jumper must be connected in order to use the direct USB debug facility.
The demo application uses the LEDs built into the prototyping board so no other hardware setup is required.
Functionality
When executing correctly the Demo-1 application will behave as follows:
- LEDs marked LED0 to LED4 are under control of the 'flash' co-routines. Each will flash at a constant frequency, with LED0 being
the fastest and LED 4 being the slowest.
- LED5 will flash each time a character is transmitted on the serial port.
- LED6 will flash each time a character is received and validated on the serial port (though the loopback connector).
- LED7 is used to indicate an error has been detected and should remain off.
- The LCD will display a rotating message indicating which demo is executing.
The demo includes functionality that checks all the tasks and co-routines are executing as expected. If an error is located in any task or co-routine
LED7 will come on. This functionality can be tested by removing the loopback connector while the demo is executing.
The Demo-2 application has similar functionality but tests different features of the RTOS port. To switch to Demo-2 simply copy the files from the
FreeRTOS/Demo/CORTEX_LM3S102_GCC/Demo2 into the FreeRTOS/Demo/CORTEX_LM3S102_GCC directory.
Building and executing the demo application
These instructions assume the GCC compiler and related tools (make.exe, etc.) have been previously installed and their location included in the PATH
environment variable.
To build the application.
- Using a command prompt, navigate to the FreeRTOS/Demo/CORTEX_LM3S102_GCC directory.
- Type "make" to build the application using the existing makefile and linker script. The application
should build with no warnings or errors as below:
$ make
CC init/startup.c
CC main.c
CC hw_include/pdc.c
CC ../../Source/list.c
CC ../../Source/queue.c
CC ../../Source/tasks.c
CC ../../Source/portable/GCC/ARM_CM3/port.c
CC ../../Source/portable/MemMang/heap_1.c
CC ParTest/ParTest.c
CC ../Common/Minimal/crflash.c
CC ../../Source/croutine.c
LD gcc/RTOSDemo.axf
The build files are placed into a subdirectory called GCC.
The DK-LMS102 evaluation board contains a USB interface that allows the application to be downloaded to the target flash directly. The Sourcery G++ manual
provides further details. To debug the application:
- In the command prompt navigate to the FreeRTOS/Demo/CORTEX_LM3S102_GCC/GCC directory.
- Start the debugger by typing "arm-stellaris-eabi-gdb RTOSDemo.axf"
- Connect to the target board by typing "(gdb) target extended-remote | armswd -s 2 -f lmi.dll stdio" (where "(gdb)" is the command prompt).
- Download the the RTOSDemo.axf file by simply typing "(gdb) load". Output similar to that shown below should be observed.
Loading section .text, size 0x1fd4 lma 0x0
Loading section .data, size 0x10 lma 0x1fd4
Start address 0x61, load size 8164
Transfer rate: xxxxx bits/sec, xxx bytes/write.
- After downloading the image, type "run" to start the application. GDB asks you if you
want to start from the beginning, enter "y" to continue. You will then be stopped at
ResetISR, which is the entry point for the application.
The program being debugged has been started already.
Start it from the beginning? (y or n) y
Starting program:c:\FreeRTOS\Demo\CORTEX_LM3S102_GCC\gcc/RTOSDemo.axf
Reloaded SP/PC from 0, reset xPSR and LR
Stopped at entry.
Program received SIGTRAP, Trace/breakpoint trap.
0x00000060 in ResetISR()
- The demo can now be executed by typing "continue".
More information on using GDB can be found in the GDB user manual.
RTOS Port specific configuration
Configuration items specific to this port are contained in FreeRTOS/Demo/CORTEX_LM3S102_GCC/FreeRTOSConfig.h. The
constants defined in this file can be edited to suit your application. In particular - the definition
configTICK_RATE_HZ is used to set the frequency of the RTOS tick. The supplied value of 1000Hz is useful for
testing the kernel functionality but is faster than most applications require. Lowering this value will improve efficiency.
Each port #defines 'portBASE_TYPE' to equal the most efficient data type for that processor. This port defines
portBASE_TYPE to be of type long.
Note that vPortEndScheduler() has not been implemented.
Interrupt service routines
The interrupt vector table is contained within FreeRTOS/Demo/CORTEX_LM3S102_GCC/init/startup.c and can be populated as required. In the demo applications
the vector table remains in flash.
Unlike most ports, interrupt service routines that cause a context switch have no special requirements and can be written as per the compiler documentation.
The macro portEND_SWITCHING_ISR() can be used to request a context switch from within an ISR. This mechanism is demonstrated by the UART ISR defined within
main.c (see the function vUART_ISR()).
Switching between the pre-emptive and co-operative real time kernels
Set the definition configUSE_PREEMPTION within FreeRTOS/Demo/CORTEX_LM3S102_GCC/FreeRTOSConfig.h to 1 to use pre-emption or 0
to use co-operative. The demo application will only execute correctly with configUSE_PREEMPTION set to 0 if configIDLE_SHOULD_YIELD is set to 1.
Compiler options
As with all the ports, it is essential that the correct compiler options are used. The best way to ensure this is to base your
application on the provided demo application files.
Memory allocation
Source/Portable/MemMang/heap_1.c is included in the ARM Cortex-M3 demo application project to provide the memory
allocation required by the real time kernel.
Please refer to the Memory Management section of the API documentation for
full information.
Serial port driver
It should also be noted that the serial drivers are written to test some of the real time kernel features - and they are not
intended to represent an optimized solution.
Copyright (C) 2003 - 2008 Richard Barry
Any and all data, files, source code, html content and documentation included in the FreeRTOS distribution or available on this site are the exclusive property of Richard Barry.
See the files license.txt (included in the distribution) and this
copyright notice for more information. FreeRTOS
TM and FreeRTOS.org
TM are trade marks of Richard Barry.