FreeRTOS for STM32VL Discovery

letanphuc wrote on Sunday, June 16, 2013:

Hi everyone, I try to port Free RTOS to my STM32F100. I folder of freeRTOS, I found an example CORTEX_STM32F100_Atollic but it is written by TrueStudio which is not free. I have downloaded a limit version of 8 kB so it is not enough to port a OS. I try to use Keil, I have modified something to build successfully, but when I load to my board, it does not work.
Can anyone answer me some question:
1 - I do not see where is code initilize some thing used by OS such as: SVCall, SystemStick, … in demo. How can OS use it if it is not defined?
2 - If someone have finished it, can give me a demo which can work? I try many time but my  task is not running.
Here is my project, hope anyone see and help me (written in Keil) https://www.dropbox.com/s/45v1jmhyimnl416/CORTEX_STM32F100.rar
Thanks a lot!

davedoors wrote on Sunday, June 16, 2013:

FAQ 1 on this page http://www.freertos.org/FAQHelp.html covers your SVCall and SysTick question.

letanphuc wrote on Sunday, June 16, 2013:

Hello davedoors,
I have read it. I think we must initilize SVCall, Systemstick… but I cannot found it in demo code. I am sure that my code can run to vTaskStartScheduler but no task run. Do you have any idea about initilize SVcall, Systemstick?

davedoors wrote on Sunday, June 16, 2013:

I don’t think I understand what you are asking.

The page I linked to tells you to map the SVCall function to the FreeRTOS SVC handler. Have you done that? It does not need any other initialization.

When you run to vTaskStartScheduler, does it get as far as calling PortStartScheduler()? If so, step through there and you will get the the SWI call that starts the scheduler. If you step over the SWI call which handler does it jump to?

rtel wrote on Sunday, June 16, 2013:

Using the #defines in the FreeRTOSConfig.h assumes the vector table is using the CMSIS names for the SVC, SysTick and PendSV functions - which in this case I suspect it is.  If not however you can install the FreeRTOS handler functions for these three interrupts directly into the vector table and just omit the #defines altogether (that means update the system files directly).  I think that is explained on the link already posted though.

Regards.

letanphuc wrote on Monday, June 17, 2013:

Thank all,
I have read FAQs, I have done vector table by both #define and in startup file but it does not work. My question is: to make something running, me must set related registers. For example, to make system stick running, we must call SysTick_Config function. But I can not find the same in source code of FreeRTOS.

letanphuc wrote on Monday, June 17, 2013:

I do not modify start up file (.s file) and add these lines of code to FreeRTOSConfig.h:

#define vPortSVCHandler SVC_Handler
#define xPortPendSVHandler PendSV_Handler
#define xPortSysTickHandler SysTick_Handler

letanphuc wrote on Monday, June 17, 2013:

I have changed

#define configTOTAL_HEAP_SIZE ( ( size_t ) ( 6 * 1024 ) )

to make it build successfully, if not

freeRTOS.axf: Error: L6406E: No space in execution regions with .ANY selector matching tasks.o(.bss).

rtel wrote on Monday, June 17, 2013:

For example, to make system stick running, we must call SysTick_Config function. But I can not find the same in source code of FreeRTOS.

The kernel does all that for you.  The only thing you have to do is ensure the FreeRTOS interrupt handler for SysTick (and SVC and PendSV) are installed correctly.

This has been mentioned already, but you didn’t provide an answer:  In port.c, place a break point in xPortStartScheduler(), then step through the code from there.  You will probably reach a function called prvPortStartFirstTask() which will jump to a little piece of assembly code.  In that assembly code you will see an SVC instruction.  Step over that instruction.  Which function executes - if you have the vector table set up correctly it should jump to the FreeRTOS SVC handler.

If not, please provide more information as to exactly how far into the code you are getting because so far this thread has been all about interrupt vectors, but your problem might not be anything to do with that.  Your description of your problem is too vague to know.

to make it build successfully, if not
freeRTOS.axf: Error: L6406E: No space in execution regions with .ANY selector matching tasks.o(.bss).

Are you saying your code is not even building?  In which case you can discard all the other posts in this thread.

Regards.

fjrg76 wrote on Thursday, July 18, 2013:

There are open source (some free) to work with FreeRTOS and such a microcontroller.

http://fjrg76.wordpress.com/2013/05/21/eclipse-gcc-tool-chain-and-how-i-saved-5500-usd/
http://fjrg76.wordpress.com/2012/09/23/stm32f0-discovery-coocox-iii-english-version/

and the CooCox project.

As a matter of fact, I’m using GCC+FreeRTOS+Eclipse for a commercial project based on the STM32L1xx processor from ST (and you know what? it works great!), and while making to work the toolchain, I was using the Discovery boards for the STM32L152 and STM32F051 processors.

If someone is interested I can upload such a project.