This posting is how-to for getting FreeRTOS running inside of TrueSTUDIO using my demo code.
My TrueSTUDIO installation is goofy because I’m running TrueSTUDIO inside a VMWare virtual Windows XP machine. My host machine is Ubuntu 11.xx and I can report the STM32F4 Discovery board USB drivers, passing through to VMWare / Windows, and work just fine. With this setup, I can do all my editing using GVim on the Linux side and my compiling and debug on the Windows side. Strange but true – works for me.
So, to straiten out the project setting takes just a couple of changes. No big deal. The jpg images below should be all you needed to setup the project on your machine, however you have your machine setup.
Note, click the images below to expand to full scale.
Open the “Test1″ demo project which you should have extracted into your Atollic “WorkSpace” directory. On the left hand side of the screen, expand Test1 in the “Project Explorer” panel to see all the files within. The menu option Project / Properties should now be available. Click “Project / Properties” to open the following settings dialog box. Click on “Linked Resources” to verify the settings match your installed paths.
Next, click further down in the same dialog where is says “Environment”. Again, make changes to match your paths.
Last one, Paths & Symbols need checking.
There is one more gotcha. FreeRTOS comes with three different choices for Malloc. However, only one can be included in the project. So, you need to verify only one of the three choices is selected. Actually, you need to verify two, of the three, are marked as “excluded”. Currently, the demo project I wrote uses “heap_1.c” (the simplest version). See the big red circled area below. You can see heap_2.c and heap_3.c are grayed out. Otherwise, the compiler will complain there are multiple definitions of “pvPortMalloc()”.
OK, that’s it. Easy. Right? Click Control-B and all should build without errors.
Post comments below if you have trouble,
Jim










Hi Jim,
It’s good, I succeeded FreeRTOS running inside of TrueSTUDIO with your demo code !
Now I must understand the code to make my project. For the moment, I study the FreeRTOS with the course (http://www.mikrocontroller.net/attachment/95930/FreeRTOSPaper.pdf). Do you have links to FreeRTOS course ?
Otherwise, I have an other question. Where are comments on the code size (it is only available in TrueStudio Professional) ?
Thanks,
Ronan.
Ronan,
That’s great news! Glad to hear your up and running.
I had not seen course document before. Looks really good. Lots of good information. I actually bought the FreeRTOS manual from their web site. The PDF you linked to looks as good, or better.
Yeah, you can see lots and lots of detail in the “map” file. Each time you build the project the compiler updates the map file. You can find it inside the directory “Test1/Debug”. The file is actually called “Test1.map” and there is a ton of info in there.
Scanning through the map file you can see all the functions and static variables and their flash memory locations (look for addresses starting with 0×08000000). Looks to me that the demo + FreeRTOS is consuming about 22k of flash.
RAM starts at memory address 0×20000000. Looks like the current build uses about 6.6k of RAM.
Both tiny numbers compared to whats available on the STM32F4!
Good luck,
Jim
Hi Jim,
Ok, thanks for your answer, I found info on the code size :
Start Flash : 0×08000000
Stop Flash : 0x080057d4
There are 0x57D4 addresses used so this demo is consoming about 22 Ko of flash !
But now I have a new problem
When I import your project, I build the code without problems but when I create my project with the same files I have a errors during compilation.
**** Internal Builder is used for build ****
arm-atollic-eabi-gcc -c -mthumb -mcpu=cortex-m4 -mfpu=fpv4-sp-d16 -DSTM32F4XX -DUSE_STDPERIPH_DRIVER -I../src -I..\Libraries\CMSIS\Include -I..\Libraries\Device\STM32F4xx\Include -I..\Libraries\STM32F4xx_StdPeriph_Driver\inc -IC:\Users\ronan\Documents\AtollicTrueSTUDIO\Projet\FreeRTOS_stm32f4_2\src\FreeRTOS\include -IC:\Users\ronan\Documents\AtollicTrueSTUDIO\Projet\FreeRTOS_stm32f4_2\src\FreeRTOS\portable\GCC\ARM_CM4F -O0 -ffunction-sections -fdata-sections -g -Wall -osrc\FreeRTOS\portable\GCC\ARM_CM4F\port.o ..\src\FreeRTOS\portable\GCC\ARM_CM4F\port.c
C:\Users\ronan\AppData\Local\Temp\cciUC19c.s: Assembler messages:
C:\Users\ronan\AppData\Local\Temp\cciUC19c.s:403: Error: selected processor does not support Thumb mode `vstmdbeq r0!,{s16-s31}’
C:\Users\ronan\AppData\Local\Temp\cciUC19c.s:404: Error: instruction not allowed in IT block — `stmdb r0!,{r14}’
C:\Users\ronan\AppData\Local\Temp\cciUC19c.s:420: Error: selected processor does not support Thumb mode `vldmiaeq r0!,{s16-s31}’
C:\Users\ronan\AppData\Local\Temp\cciUC19c.s:421: Error: instruction not allowed in IT block — `ldmia r0!,{r4-r11}’
I found this solution : http://sourceforge.net/projects/freertos/forums/forum/382005/topic/4761747
But I don’t know how to change the option ? Trying to change I had a new errors !!
**** Internal Builder is used for build ****
arm-atollic-eabi-gcc -c -mcpu=cortex-m4 -mfpu=fpv4-sp-d16 -IC:\Users\ronan\Documents\AtollicTrueSTUDIO\Projet\FreeRTOS_stm32f4\src -IC:\Users\ronan\Documents\AtollicTrueSTUDIO\Projet\FreeRTOS_stm32f4\Libraries\CMSIS\Include -IC:\Users\ronan\Documents\AtollicTrueSTUDIO\Projet\FreeRTOS_stm32f4\Libraries\Device\STM32F4xx\Include -IC:\Users\ronan\Documents\AtollicTrueSTUDIO\Projet\FreeRTOS_stm32f4\Libraries\STM32F4xx_StdPeriph_Driver\inc -IC:\Users\ronan\Documents\AtollicTrueSTUDIO\Projet\FreeRTOS_stm32f4\src\FreeRTOS\include -IC:\Users\ronan\Documents\AtollicTrueSTUDIO\Projet\FreeRTOS_stm32f4\src\FreeRTOS\portable\GCC\ARM_CM4F -IC:\Users\ronan\Documents\AtollicTrueSTUDIO\Projet\FreeRTOS_stm32f4\Utilities\STM32F4-Discovery -O0 -g -Wall -oLibraries\STM32F4xx_StdPeriph_Driver\src\misc.o ..\Libraries\STM32F4xx_StdPeriph_Driver\src\misc.c
..\Libraries\STM32F4xx_StdPeriph_Driver\src\misc.c:1:0: error: target CPU does not support ARM mode
Build error occurred, build is stopped
Time consumed: 167 ms.
Thanks,
Ronan.
Ronan,
Sorry to hear your having problems. I did a little investigating since your email arrived.
First, are you using the latest version of TrueSTUDIO from Atollic? They are adding new STM32 chips all the time. The STM32F4 is rather new and is not supported in older versions of TrueSTUDIO. I’m using version 2.2 and 2.3 is already available – I need to upgrade too.
Second, are you using floating point calculation in your new code? I have not yet taken the big step of trying to work with the FPU by using floating point calculations.
I did get a message from Thomas Kindler indicating my demo should include the directive “-fsingle-precision-constant”.
Here is the quote from Thomas:
While you’re at it, you should use the -fsingle-precision-constant option to treat floating point literals as single precision (makes code more readable – no more 1.234f constants).
I added the directive above and recompiled without any problem. I also added a floating point calulation into a task and it ran without any problem.
Sounds like you need to take care to make sure all floating point calculations are done in single precision. Any double precision calculation will revert back to be being done by the CPU instead of the FPU.
Note, I did not try a double precision calculation to see what would happen.
Sorry I’m not more help – I just an old embedded coder who is new to a FPU. Still, can’t wait to take the FPU out for a spin!
Good luck,
Jim
Hi Jim,
In any case, Thank you for your help !
I ‘m using version 2.3 of Atollic TrueStudio for STMicroelectronics STM32 Lite and I ‘m using exactely the same code that in your project.
Here’s how I create a project :
1 – File -> new “C project”
2 – Project type -> Embedded C project
3 – TrueStudio Build Settings
Evaluation board -> STM32F4_Discovery
Floting point -> Software implementation
4 – TrueStudio Misc Settings
ST-LINK
5 – Copy FreeRTOS folder and the missing files
6 – Exclude for build : heap_2 and heap_3
7 – Properties for FreeRTOS_stm32f4
C/C++ General -> Paths and Symbols
(includes) Add -> FreeRTOS/include, FreeRTOS/Portable/GCC/Arm_CM4F
(Symbols) Add -> USE_STM32F4_DISCOVERY, STM32F4XX, USE STDPERIPH_DRIVER
8 – Build Project !!
Result : Error !!
I think I forget to configure settings but where ???
Thanks,
Ronan
Ronan,
Your step #3 sounds fishy. I’m no expert, are you sure you want “Floating point -> software implementation”? The whole point of the STM32F4 having a FPU is to do hardware floating point. The error messages look like the compiler is trying to use some fancy assembly language instructions that are not available in the Cortex-M4.
I did not set “Floting point -> Software implementation” in my demo project. However, I did select the STM32F4 which Atollic had setup in a list. Choosing the STM32F4 from the list, I assume (I know – a bad idea) that Atollic should make all the right chooses in terms of Cortext-M4 and FPU settings for the F4 chip.
As a work around, you can simply copy the whole directory “Test1″ over to a new name in your Atollic workspace. Next time you open TrueSTUDIO you will see your new project which will be an exact dumplicate of the original. You can then cut and hack on the copy to make it into your own.
Or maybe, just try and build the project after your step #4. The bare bones set of files put together by TrueSTUDIO should build and run OK.
Hope this helps Ronan,
Jim
Jim,
It is the good solution! The Floating point -> hardware floating point !!!
I used the same configuration of the example provides in the user manual (getting start whith software and firmware environments for the STM32F4DISCOVERY Kit). It is a stupid error because I knew that the STM32F4 had a FPU.
Once again, thanks for your help
I can finally move forward in my project!
Ronan.
Hello Jim,
works fine. Good Job !!!
Greetings
Joerg
Awesome. Thanks for the feedback.
Hi Jim !
I finally bought the FreeRTOS Tutorial Books of Richard Barry.
So, I ‘m testing differents applications to manipulate tasks. For the moment, to know what tasks is running, I turn on or off the LEDS. Another way is to use an DAC pin and to change the voltage for the different task.
Otherwise in the tutorial, there is the function “vPrintString” but it didn’t explain ! it allows to display string in the consol. Do you use this function ?
Regards,
Ronan.
Ronan,
No, I never used the vPrintString function from FreeRTOS. Sorting out how it all worked got to complicated. Also, when I first started using FreeRTOS I was using it on a micro that only have 4k of RAM. So, including all the capabilities of printf was just to much.
So, have a look at the code in “debug.c”. There is a simple “vDebugPrintf” function that can help a lot with debugging. It’s a stripped down printf function. The debug task can also be modified to allow you to control scrolling debug messages. Very handy stuff for debugging a realtime OS.
I wrote the debug code in the hope that it would not interfer with the main application’s main tasks. Thereofore, the debug task runs at the lowest priority. Sending character out of the serial port is also done without using interrupts. Again, the idea is to not get in the way of the main tasks. This should all work good if you don’t send too many debug messages too quickly.
Hope this helps,
Jim