Project from scrap. Problems MCF51CN

stephman wrote on Monday, April 30, 2012:

Hi everybody,

I’m trying to implement FreeRTOS for MCF51CN128.

First I’ve tried the demo project which unfortunately doesn’t compile. It sound impossible to compile as this demo intended for Coldfire V1 seems to refer to some MSP430 header files…. I’ve been unable to make something working with that and it made me more confused again.

So I try to create a project from scrap and this is not straitfoward also.

I’ve copied the FreeRTOS C files + includes + portable files (port.c + portasm.c + heap_2.c) into my project
I’ve added the FreeRTOSconfig.h to my sources files
Now when compiling, it gives errors regarding fucntions
     - vApplicationTickHook
     - vApplicationStackOverflowHook
from task.c which are not refered.
In task.c their prototype is declared as extern.

When looking at the demo project, I see these functions that I don’t underestand what it is (not really documented) are defined in the main.c file !

So my questions are:
- Are they part of the FreeRTOS kernel as they are called by task.c ? If so why are they located in main.c ? I don’t understand the basic idea behind having a kernel supposed to be portable, with calls to functions declared in a demo project in main.c. How can the user now that it is and how to implement if ?

- Does anyone has achieved to use freeRTOS on MCF51CN128 or to correct the demo project ?

Any help appreciated.
Cheers
Stephane
-

rtel wrote on Monday, April 30, 2012:

First I’ve tried the demo project which unfortunately doesn’t compile.

I assure you that, when used with the compiler/IDE it was created with, it does compile.

It sound impossible to compile as this demo intended for Coldfire V1 seems to refer to some MSP430 header files

Umm, not it doesn’t, but I can see why you might come to that conclusion.

I have just spent x hours downloading and installing the extraordinarily massive Eclipse version of the CodeWarrior tools, and was pleased to see it includes an import wizard.  I was even more pleased when I saw that it appeared to import the classic IDE project without error.  I was less pleased when I realised it only thought it had imported it.  When I tried to build it I get the error:

“the file msp430.h cannot be opened”.

It says that, because it is not including the correct version of portmacro.h.

Now, looking at the include paths I see that “${CW_Project}\…\…\Source\portable\CodeWarrior\ColdFire_V1” is mentioned, and that is indeed where the correct version of portmacro.h lives, so why it is attempting to use the one from the Source\portable\GCC\msp430 one is a mystery, especially as the project explorer even shows the correct file being used, and right clicking on the header file in the include directive also takes you to the correct place.  I think there is some strange dependency scanner issue in the tools (not unusual with Eclipse).

So, I deleted every other copy of portmacro.h (there is one per port), and tried compiling again.  Now it is generating an error because it can’t find a file that is part of the PIC18 port - so that seems like a good point to give up, but I’m in the mood for a challenge, so…

I deleted all the files related to every other port, created a new workspace, and imported the classic project one more time, and hey presto - it built without any errors or warnings this time.  I have no idea if it runs, but it builds.

So, go back to the original, unmodified, V1 project as found in the FreeRTOS download.  Then, in the FreeRTOS\source\portable directory, delete every directory other than the following:

FreeRTOS\portable\MemMang
FreeRTOS\portable\CodeWarrior\ColdFire_V1

Then, delete heap_1.c and heap_2.c from FreeRTOS\portable\MemMang, make sure your Ecplise workspace is completely clean of any trace of the first attempt at importing the project (preferably use a new workspace), and finally use the CodeWarrior import wizard to import the original .mcp file again, and you should be all set.

Now when compiling, it gives errors regarding fucntions
     - vApplicationTickHook
     - vApplicationStackOverflowHook
from task.c which are not refered.
In task.c their prototype is declared as extern.

Look up hook functions in the documentation.  You either need to configure FreeRTOSConfig.h not to look for these functions, or you need to define them.

don’t understand the basic idea behind having a kernel supposed to be portable, with calls to functions declared in a demo project in main.c

These are application definable hook functions (or callback functions, if you prefer).  They are not part of the kernel, but allow the application writer to add code into certain kernel events, if they want to.

Regards.

stephman wrote on Tuesday, May 01, 2012:

Hi,

Many thanks for this long, detailled and valuable answer.

I’m going to try right now to isolate the dedicated files needed for this demo project and compile. I’ll let you know.
However I’m using Codewarrior 6.3 “classic version” and it sounds like you had the same behavior with CW 10.2 under Eclispe. This might be then a problem affecting both version.  Good to know.

Regarding my question for the two calls to Hook functions, I would say that for someone not knowing FreeRTOS like me and trying to use it for the first time, this would be better to have a demo project very minimalist like just blinking few leds in order to understand the core and how to use it.  This is what I’m trying to set.
Then more complex projects could be good when starting to code applications.

But for running FreeRTOS for the first time I would think that a very very simple project showing what are the minimum functions and files to use would be easier and faster to start with, providing then a template frame for new projects. I have to admit that this is quite difficult for me to understand each line/function of the demo project as this is already quite complex.

Moreother, I would probably not reuse a demo project as a start for a new project but I would like to start a new project from scrap in order to include only the files and functions I need. This would definitely not be FMEA compliant otherwise.
The documentation lists the minimum files requested for the kernel and based upon that I’ve tried to set a project. But Then I face the freeRTOSconfig.h and main.c files which are including much more things than requested to start with in demo projects.

Well, back to Codewarriior and I’ll let you know if I can both compile the demo project now and start my new project from scrap by tuning the freeRTOSconfig.h

Thanks again
Stéphane

stephman wrote on Tuesday, May 01, 2012:

maybe a note should be added in the FreeRTOS distribution in order to mention this problem of paths with codewarrior and that it is mandatory to copy the needed files somewhere else than the FreeRTOS path ?
Stephane

rtel wrote on Tuesday, May 01, 2012:

However I’m using Codewarrior 6.3 “classic version”

That is interesting, because I think the project was originally created with 6.2.2 according to the documentation page for that port.  The latest tools are V10.x.

I would say that for someone not knowing FreeRTOS like me and trying to use it for the first time, this would be better to have a demo project very minimalist like just blinking few leds

This is feedback which is often received, and why all newer demo projects have to configurations, a simple “Blinky” style demo, and a fully featured demo.  The ColdFire demos are relatively old, so pre-date that change though.

There are also these demos too:
http://www.freertos.org/simple-freertos-demos.html

Moreother, I would probably not reuse a demo project as a start for a new project but I would like to start a new project from scrap in order to include only the files and functions I need.

It is always recommended to start with an existing project, to save you time, and give a better “out of the box” experience more than anything, but I still understand the point.

The pages that provide the most help are probably:
http://www.freertos.org/FreeRTOS-porting-guide.html
http://www.freertos.org/porting-a-freertos-demo-to-different-hardware.html

Regards.

stephman wrote on Tuesday, May 01, 2012:

again thanks. I’m going to go deep inside these docs and try to set my simple project for V1.

It seems there is a problem with the FreeRTOS.org website, I can’t access anymore to the download page. (even for downloading the package or the simple FreeRTOS demos you pointed me.

Stephane

stephman wrote on Tuesday, May 01, 2012:

ok, I could achieve to compile the demo project erasing everything and only keeping the following directories :
- Demo\ColdFire_MCF51CN128_CodeWarrior
- Demo\Common
- Source\Portable\Codewarrior
- Source\Portable\MemMang

It might be useful to know for the ones who’d like to test this project.

Now I’m going to focus on creating a minimalist project to start with. Then with these two projects It would be easier then to progress in more advanced functions.

Thanks again
Stéphane

rtel wrote on Tuesday, May 01, 2012:

It seems there is a problem with the FreeRTOS.org website, I can’t access anymore to the download page. (even for downloading the package or the simple FreeRTOS demos you pointed me.

The website has been completely updated, and there are some problems with cached pages.  Please delete your local cache in your browser, and try again.

You might also be able to trick the browser into loading the page again by adding a query to the end of the URL, for example:

http://www.freertos.org/a00104.html?dummy_string

Regards.

stephman wrote on Tuesday, May 01, 2012:

well none of them are working. I’ve just tried from a station where I never wen to FreeRTOS.org and still can’t access the download page.
Stephane

rtel wrote on Tuesday, May 01, 2012:

well none of them are working

To help me debug this I would be grateful if you could provide answer to all the following:

What is happening when you try and open the page?

Are you getting a URL like http://www.freertos.org/index.html?http://www.a00104.html?

If you try it now, what happens?

Regards.

rtel wrote on Tuesday, May 01, 2012:

The URL in my previous post is wrong, but the concept is write, a URL that goes to index, followed by a ? followed by the URL you want.

stephman wrote on Tuesday, May 01, 2012:

It sounds like you have modified sometthing. Initially I had an URL like you gave me above.
Now, If I click on the download page, the link is http://www.freertos.org/a00104.html?1
but it still open the page :

“Please support the FreeRTOS project!
The FreeRTOS project has been generated through many years of hard work - but is provided to you here free of charge. Please show your support by buying a book, or simply making a donation. Thank you.
Documentation
….”

rtel wrote on Tuesday, May 01, 2012:

but it still open the page :

"Please support the FreeRTOS project!

Ah - ok - this is the right page now.  The download link is just below that in the section “RTOS Source Code Downloads”.  I take it that is not what was happening before.

I changed a few things.  One was to put the dummy parameter on the end of the URL, and another was to try and catch the old FreeRTOS.org/index?actual_page.html formatted URLs with some javascript to strip off the beginning part.

Anyway, it sounds like it is working now.  That is a relief, it was always a risk trying to remove the frames that people would run into this type of issue.  Thanks for reporting back.

Regards.

stephman wrote on Wednesday, May 02, 2012:

Hi,
Well, the demo project compiles but doesn’t work.
The code doesn’t go into the timer interrupt for the scheduler…

Well, I’m going to start a project from scrap. I’m spending too much time on the demo project without beeing able to make it working.
Stephane

davedoors wrote on Wednesday, May 02, 2012:

Note what was said before about the V2 compiler change causing problems, and the fix. If the demo compiles but does not run have you looked to see if the issue is the same?

stephman wrote on Wednesday, May 02, 2012:

Hi,

Thanks for answering. However I do not understand your comment on the V2 compiler change ? Is it something discussed in the forum earlier ? I tried a search but found nothing in relation.

Thanks
Stephane

davedoors wrote on Wednesday, May 02, 2012:

See the comment here http://www.freertos.org/a00104.html?1#knownissues

stephman wrote on Wednesday, May 02, 2012:

Thanks,

Then I don’t think this is related as I’m using the classic version of codewarrior 6.3 (not Eclipse based) and V1 core.

Stephane

stephman wrote on Wednesday, May 02, 2012:

Richard,

This link doesn’t work : http://www.freertos.org/simple-freertos-demos.html
it jumps very quickly between two URL from my location.
Cheers
Stephane

rtel wrote on Wednesday, May 02, 2012:

Did you clear your browser cache, as per a previous suggestion when the download page had a problem?

Regards.