Tuesday, June 28, 2011

Porting FreeRTOS on miniSTM32

FreeRTOS source comes with a bunch of demos for various boards. You can choose the project for Atollic (CORTEX_STM32F100_Atollic) for your starting point. Atollic TrueSTUDIO is nothing but Eclipse with GCC, so it is almost ready to go if you are using gnu tool-chain. Besides, it has recent version of ST peripheral library. Actually this is only ST library compliant with CMSIS standard among the FreeRTOS demos.

First, gather the source code you need and put them under the ST peripheral library tree (stm32f10x_stdperiph_lib). There is a batch file in the CORTEX_STM32F100_Atollic directory:

$ CreateProjectDirectoryStructure.bat

So, you just fire it up then it will do the job for you. It collects the FreeRTOS source files and put them in the

$ FreeRTOS_Source

directory. Copy this directory under the ST library tree. Also create a demo project directory(you can use CodeLite as described in the previous post) and copy these two files:

$ Simple_Demo\FreeRTOSConfig.h
$ main.c


into the project directory. Then the directory structure would be


In the above tree, FreeRTOS_Demo is the project directory. Other file you need in the project directory is

$ stm32f10x_conf.h

Unlike other project,

$ stm32f10x_it.c
$ stm32f10x_it.h


are not used here. It's routines are replaced by FreeRTOS.

As usual, prepare Makefile and a linker script. Be sure to include the following paths

$ INCLUDEPATHS += -I ../../FreeRTOS_Source/include
$ INCLUDEPATHS += -I ../../FreeRTOS_Source/portable/GCC/ARM_CM3


in your INCLUDEPATHES and the following source codes

$ C_SRC += ../../FreeRTOS_Source/list.c
$ C_SRC += ../../FreeRTOS_Source/queue.c
$ C_SRC += ../../FreeRTOS_Source/tasks.c
$ C_SRC += ../../FreeRTOS_Source/timers.c
$ C_SRC += ../../FreeRTOS_Source/portable/GCC/ARM_CM3/port.c
$ C_SRC += ../../FreeRTOS_Source/portable/MemMang/heap_1.c


in your source list to compile. Others are pretty much the same with other projects.

In order to run the demo, you will need BSP(board support package) for your board. Fortunately, ST library comes with plenty of BSP source code for varous STM32 evaluation board and it is quite well organized. So, it is easy to make a BSP by yourself. Create a directory under Utilities/STM32_EVAL tree for miniSTM32


and write your BSP files there. STM32100E_EVAL source would be a good reference. If there is no error in the BSP, FreeRTOS demo code will be compiled with no problem.

No comments:

Post a Comment