Home > Tech > Getting FreeRTOS to work with GCC and LPC2129

Getting FreeRTOS to work with GCC and LPC2129

FreeRTOS is a good OS to start with, if you have some fairly good hardware, like an LPC2129, ARM based chip. FreeRTOS is aimed to work with different processor architectures. The OS has two parts – a set of architecture independent codes, and a set of architecture specific codes called ports. The syntax for non standard functionalities like interrupt handling and inline assembly will be different for different compilers. Interrupt Service Routines and inline assembly are typically necessary for the architecture dependent files. Therefore, a port will be specific to a compiler and a target chip. But the present version of FreeRTOS doesn’t have a port for LPC2129 – GCC combination.

I assume that you have a working gcc compiler and other tools already installed. Refer to ARM Development under Ubuntu 10.04, for how to setup tools under Linux. Download FreeRTOS from sourceforge.net. Unzip into a convenient location.

The files you will need to compile are

  • list.c, queue.c, task.c and croutine.c from Source/
  • port.c and portISR.c form Source/portable/GCC/ARM7_LPC2000
  • heap_2.c from Source/portable/MemMang
  • A file containing the main() routine
  • boot.s and lpc2106-rom.ld from Demo/ARM7_LPC2106_GCC
  • LPC21xx.h from Demo/ARM7_LPC2138_Rowley

Rename lpc2106-rom.ld to LPC2129-ROM.ld, and open it using text editor. You will see the following at the start of the file.

Change these lines as displayed in the following figure. The size of the Flash and RAM are modified to that of the LPC2129.A simple main file will look like

#include “FreeRTOS.h”
#include “task.h”

int main(void)

unsigned char para0, para1;
para0 = 0;
xTaskCreate( foobar, “NAME”, configMINIMAL_STACK_SIZE, &para0, tskIDLE_PRIORITY, ( xTaskHandle * ) NULL );
para1 = 1;
xTaskCreate( foobar, “NAME”, configMINIMAL_STACK_SIZE, &para1, tskIDLE_PRIORITY, ( xTaskHandle * ) NULL );


void foobar( void* pvParameters )

unsigned char *flag;
flag=(unsigned char*)pvParameters;
while (1){


//do something


//do something else




(Thanks to my friends Abhishek and Nisarg for the original main file)

Now you can compile and link all the files specified above, along with the libc.a , specified by linker option -lc, and chip specification -TLPC2129-ROM.ld. Also add Source/include directory to your include/compiler search path.

The generated elf file can be converted to hex file using arm-elf-objcopy command (if you have followed ARM Development under Ubuntu 10.04 ). The program can be dumped into the LPC2129 chip through the serial connection using command lpc21isp

eg:- lpc21isp -control -hex trial.hex /dev/ttyS0 9600 12000 will program trial.hex into the chip, through serial port ttyS0 at 9600 baud per second. 12000 is the frequency of the crystal (in kHz) used for the LPC2129 chip.

Categories: Tech Tags: , , ,
  1. No comments yet.
  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: