Anyone got FreeRTOS running on the embed ?

30 Nov 2009 . Edited: 30 Nov 2009

Now that i got my hello world up and running on my new board, i want to move onto more complex things. The only way to do that is to have an RTOS. Has anyone got the FreeRTOS running on their board ?

http://www.freertos.org/


01 Dec 2009

Jim,

Have you looked at CoOS? To quote from the web site:

CooCox CoOS is a mini embedded RTOS specially for ARM Cortex M3. It is a real-time multi-task kernel which conforms to CMSIS ( Cortex Microcontroller Software Interface Standard ).

http://www.coocox.org

Paul

01 Dec 2009

No, I will take a look.

I wanted to use FreeRTOS, becasue i have used it many times and i am used to it.

 

01 Dec 2009
I've been trying to port FreeRTOS (to my 2368 version) but didn't have much success yet.
01 Dec 2009

anyone poerted the CooCox CoOS ?

01 Dec 2009

Got CooCox CoBuilder + Codesourcery G++ lite working with my 1768, not tried CoOS, but I tend to write my own anyway.

01 Dec 2009

Hello

I would also like to run FreeRTOS if someone has ported it.

02 Dec 2009

I have had no luck, with FreeRTOS.

I get an error of ""Inline assembler not permitted when generating Thumb code (E1113)" in file "RTOS/FreeRTOS/port.c""

02 Dec 2009

I think we need to call upon the creators of embed to get this FreeRTOS running. They know the compiler best and could probably whip this up in no time.

02 Dec 2009
Jim why wrote:

Now that i got my hello world up and running on my new board, i want to move onto more complex things. The only way to do that is to have an RTOS. Has anyone got the FreeRTOS running on their board ?

There's certainly value in what RTOS do - but you can do some really quite complex things without one. For example, a web server... :)

I'd really encourage you to look at your project's objectives and try to work out how you might do it without an RTOS, if only as a learning exercise. Remember, the OS is only an abstraction from the hardware available to you as a programmer.

02 Dec 2009 . Edited: 02 Dec 2009

I have just managed to get FreeRTOS working on the MBed.

The compiler used was gcc version 4.4.1 (Sourcery G++ Lite 2009q3-68) .

I took the CORTEX_LPC1768_GCC_RedSuite demo , and used the Makefile/makedefs from CORTEX_LM3S811_GCC

I used the rtosdemo_rdb1768_Debug.ld linker script which needed a few changes

Comment out or remove the GROUP line

 

/* GROUP(libgcc.a libc.a) */

 

and correct the last few lines

    .ETHRAM :
    {
    } > AHBSRAM0
   
    .USBRAM :
    {
    } > AHBSRAM1

 

My Makefile looks like

 

include makedefs

RTOS_SOURCE_DIR=../../../Source
DEMO_SOURCE_DIR=../../Common/Minimal
INCS= -I ../../Common/include -I webserver

CFLAGS+=-I hw_include -I . -I ${RTOS_SOURCE_DIR}/include -I ${RTOS_SOURCE_DIR}/portable/GCC/ARM_CM3 ${INCS} -D inline=

VPATH=${RTOS_SOURCE_DIR}:${RTOS_SOURCE_DIR}/portable/MemMang:${RTOS_SOURCE_DIR}/portable/GCC/ARM_CM3:${DEMO_SOURCE_DIR}:init:webserver

OBJS=${COMPILER}/main.o	\
	  ${COMPILER}/list.o    \
      ${COMPILER}/queue.o   \
      ${COMPILER}/tasks.o   \
      ${COMPILER}/port.o    \
      ${COMPILER}/heap_1.o  \
	  ${COMPILER}/BlockQ.o	\
	  ${COMPILER}/PollQ.o	\
	  ${COMPILER}/QPeek.o \
	  ${COMPILER}/GenQTest.o \
	  ${COMPILER}/blocktim.o \
	  ${COMPILER}/flash.o \
	  ${COMPILER}/recmutex.o \
	  ${COMPILER}/integer.o	\
	  ${COMPILER}/semtest.o \
	  ${COMPILER}/emac.o \
	  ${COMPILER}/ParTest.o \
	  ${COMPILER}/syscalls.o \
	  ${COMPILER}/printf-stdarg.o \
	  ${COMPILER}/httpd-cgi.o ${COMPILER}/psock.o ${COMPILER}/uip_arp.o ${COMPILER}/uIP_Task.o \
 	${COMPILER}/httpd.o ${COMPILER}/httpd-fs.o ${COMPILER}/http-strings.o ${COMPILER}/timer.o ${COMPILER}/uip.o


INIT_OBJS= ${COMPILER}/cr_startup_lpc17.o

#
# The default rule, which causes init to be built.
#
all: ${COMPILER}           \
     ${COMPILER}/RTOSDemo.axf \
	 
#
# The rule to clean out all the build products
#

clean:
	@rm -rf ${COMPILER} ${wildcard *.bin} RTOSDemo.axf
	
#
# The rule to create the target directory
#
${COMPILER}:
	@mkdir ${COMPILER}

${COMPILER}/RTOSDemo.axf: ${INIT_OBJS} ${OBJS} ${LIBS}
SCATTER_RTOSDemo=rtosdemo_rdb1768_Debug.ld

#
#
# Include the automatically generated dependency files.
#
-include ${wildcard ${COMPILER}/*.d} __dummy__

A few changes needed to makedefs

 

#
# The flags passed to the assembler.
#
AFLAGS=-mthumb         \
       -mcpu=cortex-m3 \
       -MD

#
# The flags passed to the compiler.
#
CFLAGS=-mthumb         \
       -mcpu=cortex-m3 \
       -O1             \
	-D PACK_STRUCT_END=__attribute\(\(packed\)\) -D ALIGN_STRUCT_END=__attribute\(\(aligned\(4\)\)\) \
       -MD


#
# Get the location of libgcc.a from the GCC front-end.
#
LIBGCC=${shell ${CC} -mthumb -mcpu=cortex-m3 -print-libgcc-file-name}
#
# Get the location of libc.a from the GCC front-end.
LIBC=${shell ${CC} -mthumb -mcpu=cortex-m3 -print-file-name=libc.a}

 

 

My file list looks like

./core_cm3.h
./Makefile
./FreeRTOSConfig.h
./makedefs
./rtosdemo_rdb1768_Debug.ld
./ParTest.c
./webserver
./webserver/http-strings.c
./webserver/uipopt.h
./webserver/clock-arch.h
./webserver/uip_arch.h
./webserver/timer.c
./webserver/EthDev.h
./webserver/httpd-cgi.h
./webserver/timer.h
./webserver/http-strings
./webserver/uip.c
./webserver/uip-conf.h
./webserver/psock.h
./webserver/clock.h
./webserver/httpd-cgi.c
./webserver/emac.c
./webserver/httpd.h
./webserver/lc-switch.h
./webserver/uip_arp.h
./webserver/httpd-fs.c
./webserver/uIP_Task.c
./webserver/uip.h
./webserver/httpd.c
./webserver/EthDev_LPC17xx.h
./webserver/httpd-fs.h
./webserver/http-strings.h
./webserver/httpd-fs
./webserver/httpd-fs/404.html
./webserver/httpd-fs/runtime.shtml
./webserver/httpd-fs/tcp.shtml
./webserver/httpd-fs/stats.shtml
./webserver/httpd-fs/io.shtml
./webserver/httpd-fs/index.shtml
./webserver/httpd-fs/index.html
./webserver/httpd-fsdata.h
./webserver/pt.h
./webserver/webserver.h
./webserver/uip_arp.c
./webserver/psock.c
./webserver/makefsdata
./webserver/makestrings
./webserver/httpd-fsdata.c
./webserver/lc.h
./printf-stdarg.c
./main.c
./system_LPC17xx.h
./LPC17xx.h
./init
./init/cr_startup_lpc17.c
./syscalls.c

A few changes are needed to ParTest.c to correct the GPIO lines for the onboard LEDs

 

I've probably forgotten something - but at the moment it seems to work for me ( including the webserver !! )

02 Dec 2009

Obviously you'll need the FreeRTOS source code in the correct place.

See the Makefile

RTOS_SOURCE_DIR=../../../Source
DEMO_SOURCE_DIR=../../Common/Minimal
INCS= -I ../../Common/include -I webserver
02 Dec 2009

And finally copy the file gcc/RTOSDemo.bin to your MBed.

( You'll probably need to set the IP address in FreeRTOSConfig.h for your own network before you build the project ).

02 Dec 2009

Great job Andy. Very nice.

So you took the RedSuite demo but used CodeSourcery toolchain.

Just a question here: Does one require RedSuite for some scripts etc.? Or can you just run "make" after having properly setup the Sourcery toolchain?

 

Thanks again

Asif

02 Dec 2009 . Edited: 02 Dec 2009

I don't have RedSuite.

Yep - just type make

 

 

  CC    init/cr_startup_lpc17.c
  CC    main.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    ../../Common/Minimal/BlockQ.c
  CC    ../../Common/Minimal/PollQ.c
  CC    ../../Common/Minimal/QPeek.c
  CC    ../../Common/Minimal/GenQTest.c
  CC    ../../Common/Minimal/blocktim.c
  CC    ../../Common/Minimal/flash.c
  CC    ../../Common/Minimal/recmutex.c
  CC    ../../Common/Minimal/integer.c
  CC    ../../Common/Minimal/semtest.c
  CC    webserver/emac.c
  CC    ParTest.c
  CC    syscalls.c
  CC    printf-stdarg.c
  CC    webserver/httpd-cgi.c
  CC    webserver/psock.c
  CC    webserver/uip_arp.c
  CC    webserver/uIP_Task.c
  CC    webserver/httpd.c
  CC    webserver/httpd-fs.c
  CC    webserver/http-strings.c
  CC    webserver/timer.c
  CC    webserver/uip.c
  LD    gcc/RTOSDemo.axf

As far as I understand it - RedSuite uses GCC but with an Eclipse front end.

Ignore the CreateProjectDirectoryStructure.bat instructions - and remove the #error from main.c

The Makefile pulls in code from FreeRTOS rather than copying it locally as the batch file does.

 

02 Dec 2009

I knew I would forget to mention something :-)

You'll need to edit main.c to remove the items which don't exist :-) ( LCD ! )

02 Dec 2009

I'm confuseilated, If the compiler is online how does one mess with the makefile ?

02 Dec 2009 . Edited: 02 Dec 2009

The compiler used was gcc version 4.4.1 (Sourcery G++ Lite 2009q3-68) .

Offline - NOT the Online compiler.

02 Dec 2009

Presumably you are using port.c from Source/portable/RVDS/ARM_CM3/port.c ?

And the compiler is refusing to deal with the inline assembly in that file ?

Any clue as to which line is the first reported error ?

02 Dec 2009

See

http://infocenter.arm.com/help/index.jsp?topic=/com.arm.doc.dui0282b/CHDGDDCJ.html

Error:  #1113: Inline assembler not permitted when generating Thumb code

If you want to include inline assembly in code to be compiled for Thumb, enclose the functions containing inline assembler code between #pragma arm and #pragma thumb statements (see Pragmas controlling code generation). For example:

#pragma arm
int add(int i, int j) {
    int res;
    __asm {
        ADD   res, i, j   // add here
    }
    return res;
}
#pragma thumb
02 Dec 2009

Thanks Andy, Yes i am using the online compiler. Will give it a try.

02 Dec 2009

Hello Andy

I followed all the instructions and when I try to compile it as:

cs-make

I get the following error:

C:\FreeRTOS\Demo\CORTEX_LPC1768_GCC_MBED\src>cs-make
process_begin: CreateProcess(NULL, uname -s, ...) failed.
'x' was unexpected at this time.
cs-make: *** [gcc/cr_startup_lpc17.o] Error 255

 

I am trying to figure it out.

02 Dec 2009 . Edited: 02 Dec 2009

Okay, I finally compiled it. The error above results from the fact that Makefile and makedefs are written for Linux environment. So I switched to Ubuntu.

In addition to the changes documented above, I had to do the following to successfully compile it:

1. Remove all references to vUSBTask

2. Remove the following Linker flags from the makedefs:

--entry ${ENTRY_${notdir ${@:.axf=}}} \
${LDFLAGSgcc_${notdir ${@:.axf=}}}    \

These lines are followed by a map (-Map gcc/out.map) direction. As the ENTRY is not specified, the linker command results in:

LD    gcc/RTOSDemo.axf
arm-none-eabi-ld -T rtosdemo_rdb1768_Debug.ld    \
--entry  \
\
-Map gcc/out.map -o gcc/RTOSDemo.axf gcc/cr_startup_lpc17.o gcc/main.o gcc/list.o (OTHER *.o FILES, etc.)

which results in the following error:

arm-none-eabi-ld: gcc/out.map: No such file: No such file or directory

LDFLAGSgcc is also not defined so it is no harm removing these flags as well.

3. Make following name changes (AHBSRAM0 and AHBSRAM1) to rtosdemo_rdb1768_Debug.ld

MEMORY
{
FLASH (rx) : ORIGIN = 0x0 LENGTH = 0x80000
SRAM (rwx) : ORIGIN = 0x10000000, LENGTH = 0x8000
AHBSRAM0   : ORIGIN = 0x2007c000, LENGTH = 0x4000
AHBSRAM1   : ORIGIN = 0x20080000, LENGTH = 0x4000
}

 

The generated binary size is 46148 Bytes. I have not yet run it. I shall do it tomorrow.

03 Dec 2009 . Edited: 03 Dec 2009

I presume cs-make is NOT GNU make compatible :-) ,

 

I think the differences are because I am using version 5.4.0 of FreeRTOS.

( The USB code appears new in 6.0.x ) - and there is an appropriate ENTRY in 5.4.0 linker script.

ENTRY(ResetISR)

Anway - I will be downloading the latest as well - and will also see if the USB code compiles cleanly.

03 Dec 2009

Just confirmed - FreeRTOS 6.0.1 works - The USB CDC driver also compiled - and the task is running - but I cannot confirm if it actually works ( my USB pins are not connected at the moment ).

05 Dec 2009 . Edited: 05 Dec 2009

I finally ran the compiled binary. It works fine. The webserver is also running smoothly. Here is the sample output:

 

Webserver running on FreeRTOS on mbed board

26 Mar 2010

Thanks for that, will have to get more of the I/O working now, so we can use the MBED board in our lab sessions here

at the university.

23 Apr 2010

Hey Andy C or Asif Iqbal, would you mind posting a zip/tar/something of your source tree for FreeRTOS + webserver demo?

Many thanks,

Hugo Vincent

24 Apr 2010

Actually, this at least builds now:

http://github.com/hugovincent/mbed-lpc2368-freertos

 

I'll have a go at fixing the serial driver and adding some flashing LEDs in the morning.

 

Hugo

24 Apr 2010

And finally, timers, LED flashing, interrupts, boot code, linker script and so on is all working now. Next on the TODO: ethernet and UART support. Ethernet is 90% done, serial 20%.

http://github.com/hugovincent/mbed-lpc2368-freertos