RTOS and atmega128 ?

Go To Last Post
10 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Guys,

I tried to port RTOS to atmega128 and I got this ;

Error    3    undefined reference to `vPortYield'  on file tasks.c 

 

Any clues on fixing it ?

thanks

 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

bianchi77 wrote:
I tried to port RTOS

What RTOS?

 

Quote:
Error    3    undefined reference to `vPortYield'  on file tasks.c 

 

Any clues on fixing it ?

Just read the message carefully:

 

It's telling you that you have tried to reference (ie, use) something called 'vPortYield' somewhere in the file tasks.c - but that 'vPortYield' is undefined.

 

Was that not clear?

 

Obviously, the fix for something being undefined is to define it!

 

 

 

Top Tips:

  1. How to properly post source code - see: https://www.avrfreaks.net/comment... - also how to properly include images/pictures
  2. "Garbage" characters on a serial terminal are (almost?) invariably due to wrong baud rate - see: https://learn.sparkfun.com/tutorials/serial-communication
  3. Wrong baud rate is usually due to not running at the speed you thought; check by blinking a LED to see if you get the speed you expected
  4. Difference between a crystal, and a crystal oscillatorhttps://www.avrfreaks.net/comment...
  5. When your question is resolved, mark the solution: https://www.avrfreaks.net/comment...
  6. Beginner's "Getting Started" tips: https://www.avrfreaks.net/comment...
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

What RTOS?

[RTOS Support] an optimization in vPortYield() - FreeRTOS 

from the first Google hit.

 

There must be many many worked examples on the Net for FreeRTOS and Mega128.  Right?

You can put lipstick on a pig, but it is still a pig.

I've never met a pig I didn't like, as long as you have some salt and pepper.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Thanks for the info I got 10 errors, did I download the wrong task.c ?

Error    4    undefined reference to `pvPortMalloc'    tasks.c    1    1    freertosm128

Error    6    undefined reference to `vPortFree'         tasks.c    1    1    freertosm128

Error    7    undefined reference to `pxPortInitialiseStack'   tasks.c    1    1    freertosm128

Error    9    undefined reference to `xPortStartScheduler'    tasks.c    1    1    freertosm128

I can't see anything related with those one column 1 and line 1 ??

To make a clear explaination, I attached the complete project  I've been fiddling, thanks for the time seeing it...

So those definition is not available on tasks.c, where can I find it ? thanks

 

 

 

 

 

 

Attachment(s): 

Last Edited: Sun. Apr 26, 2015 - 10:36 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Have you read the manual? 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I tried to read manual, but don't know which part of manual related with it ? memory management ?

Or I can't use ATMEGA128 with RTOS, since it has 4Kbyte of RAM only, I'm not interested using external RAM...there's no external RAM chip on my PCB...

thanks

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I reckon this one will help....

http://www.freertos.org/a00098.html I'll give it a go later today....

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

WARNING: threat to life force ahead.

 

Ross McKenzie ValuSoft Melbourne Australia

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Ross, that's my job! He's sucked enough of mine- life force that is. HeHeHe.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 1

Bianchi,

 

To fix this kind of problem you are either going to need to:

 

a) lean C and how to generically fix problems

b) learn to read manuals and in particular the FreeRTOS one to fix this specific issue

c) at least learn to use grep and find things in source trees

d) just wait for someone to give you the working code here and go away without actually having really learnt anything.

 

If you look at the unpacked FreeRTOS files you will see that the "generic" files are in FreeRTOS/Source. But it's not enough to just take tasks.c or timers.c or queue.c from that directory and add them to your project and think you suddenly have a complete FreeRTOS project. You don't.

 

Now if you look at your unresolved errors the first is pvPortMalloc. If you grep the source tree for that you will find a number of implementations. Five of them are under Source/portable/MemMang/heap*.c. Now I didn't know why there'd be five so I googled "pvPortMalloc site:freertos.org" and the top hit was this page:

 

http://www.freertos.org/a00111.html

 

So it seems clear to me that you have to pick ONE of those heap_N.c files and add it to your project. If feeling adventurous you could provide your own implementation of pvPortMalloc and vPortFree() that simply map the calls to the AVR-LibC implementations of malloc() and free() - in fact this could actually be the easiest solution.

 

Resolving this actually clears the first two errors in your list of four, The next one is pxPortInitialiseStack. That one is easy to find and highlights the fact that while you took portmacro.h from Source/portable/GCC/ATMega325 for some strange reason you forgot to take the port.c that is there and add it to the files in your Zip. When you do that it will resolve the call to pxPortInitialiseStack.

 

As it happens xPortStartScheduler() is in that port.c too so when you add that you will have cleared all four errors.

 

I have shown you how I diagnosed and fixed the errors here. If you want to have any hope of ever becoming a serious programmer you are going to have to learn to employ the same diagnostic technique. It starts with knowing that the error "undefined reference to ..." basically means "I looked through all the .c files in this project but I cannot find the one that is providing ...". That tells you that you probably forgot to pick up and add some .c file to your project.

 

We now know that you forgot to add two .c files. The second one was easy: grep found that. The first one was maybe not so obvious and required both a bit of grepping and a bit of then reading the FreeRTOS manual to understand why there were a number of heap_N.c files that might be used to satisfy the call to the mallo/free functions.

Last Edited: Mon. Apr 27, 2015 - 08:35 AM