I'm trying to build freertos for atmega2560. When I try to build unoBlink application I get the following error while linking:
Building target: UnoBlink.elf
Invoking: AVR C Linker
avr-gcc -Wl,-Map,UnoBlink.map -Wl,--gc-sections -mmcu=atmega2560 -o "UnoBlink.elf" ./main.o C:/Users/Niclas/Downloads/freertos/freeRTOS730/Debug/libfreeRTOS730.a -lm
c:/avr-gcc-4.7.2-mingw32/bin/../lib/gcc/avr/4.7.2/../../../../avr/bin/ld.exe: section .task loaded at [000021a4,000021b9] overlaps section .data loaded at [000021a4,000021c3]
collect2.exe: error: ld returned 1 exit status
make: *** [UnoBlink.elf] Error 1
How can I fix this?
the issue is that your linker doesn't know about the .task attribute used to keep freeRTOS tasks in low memory of the AVR. The provided linker file avr6.x needs to be substituted for the standard avr6.x file provided with the avr-libc libraries. The .task attribute is described in my post on using freeRTOS with the Mega platform (large memory only applies to the ATmega2560 platform) at http://feilipu.me/2012/01/15/ethermega-arduino-mega-2560-and-freertos/
I used the linker's -T -L flags to point to the provided avr6.x file. Now the linking works.
Note that with the release of avrlibc 1.8 and and freeRTOS800, I've changed the linker to use attribute ((section (".lowtext")))
This attribute is now included in the linker automatically, so there is now no need to have a special version of avr6.x.