3

I'm currently implementing a FreeRTOS-based program on the Arduino platform.

I would like to use the Arduino MEGA 2560 Rev3 (which is based on an ATmega2560) for this project, but I couldn't find a working port.c file.

Could anyone please share a working port.c ?

I'm using Eclipse IDE, WinAVR, AVR Plugin, Arduino Lib, FreeRTOS 7.6.0 (I will eventually switch to v8.0.0) and C++ as the main programming language.

Thanks.

EDIT:

I've came across avrfreertos which generates a FreeRTOS static library for the ATmega2560, but when I link my project against it, I get the following error:

c:/winavr-20100110/bin/../lib/gcc/avr/4.3.3/../../../../avr/bin/ld.exe: section .task [00003282 -> 0000328f] overlaps section .data [00003282 -> 0000339d]
make: *** [MY_PROJECT_NAME.elf] Error 1

EDIT:

I found a fix for the linking problem

maddouri
  • 3,737
  • 5
  • 29
  • 51

1 Answers1

3

Your issue is resolved by the change to avr6.x as you found. There is a .task attribute included in the portmacro.h file, which is needed to keep the freeRTOS task you define in the lower part of flash.

Good news. There are some updates in the latest avrbinutils and avrlibc 1.8.0 that include a .lowtext attribute, which has similar functionality to the .task attribute I added to the avr6.x file.

In the port for freeRTOS800 I changed the attribute defined in portmacro.h to point to .lowtext. This means there is no need to change the avr6.x file any more.

Either, change to use the freeRTOS800 port AVRfreeRTOS or just make the change in portmacro.h yourself.

For further reference, I've made an Arduino Library that can be included in Arduino to get experience with freeRTOS on any AVR device.

feilipu
  • 146
  • 5
  • Thanks for replying feilipu :) I wanted to use the freeRTOS800 port but I don't seem to find the eclipse project files in `freeRTOS800_All_Files/freeRTOS800`. Also, since I'm using WinAVR, I don't have access to the latest avrbinutils nor avrlibc (I didn't find any recent AVR toolchain on windows or ubuntu) so I'll have to stick with the 7.5.0 for now. – maddouri Jan 26 '14 at 10:48
  • If it's ok with you, I would like to ask you 2 last questions: 1. Is it necessary to include all the `lib_*` parts when compiling AVRfreeRTOS (I would like to have a "minimal" freeRTOS in my project, with only tasks, time/delay functions, queues and sem/mutexes) ? 2. Is it possible to extract only the port-specific files (i.e. `port.c` and `portmacro.h`) and use them with the official FreeRTOS release ? And if so, how would I proceed ? (I already tried to use the files you provided but they had dependencies to "time.h") – maddouri Jan 26 '14 at 10:48
  • Yes it is possible to delete everything in the lib_* files. They're added value. The time.h stuff is relevant to an upstream version of avrlibc that is not released yet. I sucked it into the port.c because I want to have a system clock (tick) that counted seconds, and therefore could do some cool time based calculations for timers etc. – feilipu Jan 28 '14 at 02:29
  • If you want to go back in time and get freeRTOS730_All_Files.zip from sourceforge, I think that this pre-dates the time.h stuff. Simply do a diff on the files remaining to see what to remove from port.c and portmacro.h. freeRTOS is really only a few files you noted. What I've added is just the extensions that make my life easier addressing different hardware. You just need the files you mentioned, the includes for the files, their headers, Memory Management (of which only one file should be active at each time), and the portable files port.c and portmacro.h. – feilipu Jan 28 '14 at 02:30
  • To the tool chain. If you're using Ubuntu as a development platform, then it is possible to raid debian Sid repositories for good stuff. [gcc-avr](http://packages.debian.org/sid/gcc-avr) [avr-libc](http://packages.debian.org/sid/avr-libc) [binutils-avr](http://packages.debian.org/sid/binutils-avr) all of which work well on Ubuntu LTS currently. – feilipu Jan 28 '14 at 02:34