Compiler errors with ATSAMD51J20A and FreeRTOS

guggech wrote on Wednesday, April 25, 2018:

I am trying to compile a bare bone project with the FreeRTOS files for a ATSAMD51J20A processor, Atmel Studio 7.0 and GCC compiler and getting the following errors:

https://imgur.com/7QNwXGx

Here are my compiler settings:
https://imgur.com/dGvFUdy

I tried to use the port from ARM_CM3, ARM_CM3_MPU, ARM_CM4_MPU and ARM_CM4F without success.

Any ideas?
Thanks,
Charles

rtel wrote on Wednesday, April 25, 2018:

The part you are using has a floating point unit, so the correct port to
use is FreeRTOS/Source/portable/GCC/ARM_CM4F. However your command line
is not telling the compiler there is a floating point unit, so it is
balking at the floating point instructions. I suggest having Atmel
Studio create a project for that part to see the command line options it
uses - somewhere it will tell GCC which FPU the chip has - then add that
command line option to your project too.

guggech wrote on Friday, April 27, 2018:

I created a project using ATmel Studio 7.0 with ATSAMD51J20A withous any FreeRTOS files that compile without error. When I bring in the FreeRTOS files with port.c from ARM_CM4F, I get these errors. I checked all the command lines options for the compiler, assemble and Linker and they are the same. It appears that the problem is with xPortPendSVHandler() in line 470 & 497.
Don’t really know how to fix this.
Thanks,
Charles

guggech wrote on Friday, April 27, 2018:

Here are my command line option:
https://imgur.com/h2tesSC
https://imgur.com/P3SOreX
https://imgur.com/xwf222m

guggech wrote on Friday, April 27, 2018:

One more link:
https://imgur.com/nX3joVm

rtel wrote on Friday, April 27, 2018:

https://imgur.com/P3SOreX is the image that shows the important
information, and indeed shows that the command line is not specifying
the part has a floating point unit.

See this thread:
https://www.freertos.org/FreeRTOS_Support_Forum_Archive/December_2012/freertos_STM32F4_GCC_compilation_problems_6404907.html

The relevant options are: -mfpu=fpv4-sp-d16 -mfloat-abi=softfp although
these might not be quite right for your MCU - depending on the type of
FPU unit it has.

guggech wrote on Friday, May 11, 2018:

I added -mfpu=fpv4-sp-d16 and -mfloat-abi=softfp but now I am getting some link errors with port.c ,task.c, timer.c and queue.c

Here are the errors: https://imgur.com/Bc6Mo3M

rtel wrote on Friday, May 11, 2018:

Please paste the errors into a post for prosperity (for people with
similar problems in the future to be able to see) rather than link to
temporary external sites.

guggech wrote on Friday, May 11, 2018:

Not too sure what the best way to show a screen shot. Here it is below…Thanks

C:\Users\cguggenheim\Documents\Atmel Studio\7.0\FT4X32\FT4X32\FreeRTOS\port.c(738,1): error: undefined reference to __SRAM_segment_start__' C:\Users\cguggenheim\Documents\Atmel Studio\7.0\FT4X32\FT4X32\FreeRTOS\port.c(738,1): error: undefined reference to SRAM_segment_end
C:\Users\cguggenheim\Documents\Atmel Studio\7.0\FT4X32\FT4X32\FreeRTOS\port.c(738,1): error: undefined reference to __privileged_data_start__' C:\Users\cguggenheim\Documents\Atmel Studio\7.0\FT4X32\FT4X32\FreeRTOS\port.c(738,1): error: undefined reference to privileged_data_end
FreeRTOS/port.o: In function xPortStartScheduler': C:\Users\cguggenheim\Documents\Atmel Studio\7.0\FT4X32\FT4X32\FreeRTOS\port.c(418,1): error: undefined reference to FLASH_segment_start
C:\Users\cguggenheim\Documents\Atmel Studio\7.0\FT4X32\FT4X32\FreeRTOS\port.c(418,1): error: undefined reference to __FLASH_segment_end__' C:\Users\cguggenheim\Documents\Atmel Studio\7.0\FT4X32\FT4X32\FreeRTOS\port.c(418,1): error: undefined reference to privileged_functions_end
C:\Users\cguggenheim\Documents\Atmel Studio\7.0\FT4X32\FT4X32\FreeRTOS\port.c(418,1): error: undefined reference to __privileged_data_start__' C:\Users\cguggenheim\Documents\Atmel Studio\7.0\FT4X32\FT4X32\FreeRTOS\port.c(418,1): error: undefined reference to privileged_data_end
FreeRTOS/tasks.o: In function xTaskCreate': C:\Users\cguggenheim\Documents\Atmel Studio\7.0\FT4X32\FT4X32\FreeRTOS\tasks.c(814,1): error: undefined reference to pvPortMalloc’
C:\Users\cguggenheim\Documents\Atmel Studio\7.0\FT4X32\FT4X32\FreeRTOS\tasks.c(814,1): error: undefined reference to vPortFree' FreeRTOS/tasks.o: In function xTaskCreateRestricted’:
C:\Users\cguggenheim\Documents\Atmel Studio\7.0\FT4X32\FT4X32\FreeRTOS\tasks.c(724,1): error: undefined reference to pvPortMalloc' FreeRTOS/tasks.o: In function xTaskIncrementTick’:
C:\Users\cguggenheim\Documents\Atmel Studio\7.0\FT4X32\FT4X32\FreeRTOS\tasks.c(2593,1): error: undefined reference to vApplicationTickHook' FreeRTOS/tasks.o: In function vTaskSwitchContext’:
C:\Users\cguggenheim\Documents\Atmel Studio\7.0\FT4X32\FT4X32\FreeRTOS\tasks.c(2896,1): error: undefined reference to vApplicationStackOverflowHook' FreeRTOS/tasks.o: In function prvIdleTask’:
C:\Users\cguggenheim\Documents\Atmel Studio\7.0\FT4X32\FT4X32\FreeRTOS\tasks.c(3266,1): error: undefined reference to vApplicationIdleHook' FreeRTOS/timers.o: In function xTimerCreate’:
C:\Users\cguggenheim\Documents\Atmel Studio\7.0\FT4X32\FT4X32\FreeRTOS\timers.c(303,1): error: undefined reference to pvPortMalloc' FreeRTOS/timers.o: In function prvProcessReceivedCommands’:
C:\Users\cguggenheim\Documents\Atmel Studio\7.0\FT4X32\FT4X32\FreeRTOS\timers.c(695,1): error: undefined reference to vPortFree' FreeRTOS/queue.o: In function vQueueDelete’:
C:\Users\cguggenheim\Documents\Atmel Studio\7.0\FT4X32\FT4X32\FreeRTOS\queue.c(1958,1): error: undefined reference to vPortFree' FreeRTOS/queue.o: In function xQueueGenericCreate’:
C:\Users\cguggenheim\Documents\Atmel Studio\7.0\FT4X32\FT4X32\FreeRTOS\queue.c(403,1): error: undefined reference to `pvPortMalloc’
collect2.exe(0,0): error: ld returned 1 exit status
make: *** [FT4X32.elf] Error 1
The command exited with code 2.
Done executing task “RunCompilerTask” – FAILED.
Done building target “CoreBuild” in project “FT4X32.cproj” – FAILED.
Done building project “FT4X32.cproj” – FAILED.

Build FAILED.
========== Build: 0 succeeded or up-to-date, 1 failed, 0 skipped ==========

rtel wrote on Friday, May 11, 2018:

C:\Users\cguggenheim\Documents\Atmel
Studio\7.0\FT4X32\FT4X32\FreeRTOS\port.c(738,1): error: undefined
reference to |SRAM_segment_start

This, and similar errors, looks like you are building FreeRTOS MPU -
which is the version of FreeRTOS that supports both privileged and
unprivileged tasks. Was that intentional (it’s not normal).

Studio\7.0\FT4X32\FT4X32\FreeRTOS\tasks.c(814,1): error: undefined
reference to|pvPortMalloc’

This, and similar errors, looks like the file
FreeRTOS/Source/portable/MemMang/heap_x.c is missing from your build:

Studio\7.0\FT4X32\FT4X32\FreeRTOS\tasks.c(2896,1): error: undefined
reference to |vApplicationStackOverflowHook’ FreeRTOS/tasks.o: In
function|prvIdleTask’:
C:\Users\cguggenheim\Documents\Atmel
Studio\7.0\FT4X32\FT4X32\FreeRTOS\tasks.c(3266,1): error: undefined
reference to |vApplicationIdleHook’ FreeRTOS/timers.o: In
function|xTimerCreate’:

These look like you have FreeRTOSConfig.h set to use hook (callback)
functions, but have not provided the implementations of those functions.
Any function that includes “Application” in the name is expected to be
provided by the application writer:

guggech wrote on Friday, May 11, 2018:

I am just trying to get the simplest plain vanilla application with FreeRTOS and the ATSAMD51 chip.

rtel wrote on Saturday, May 12, 2018:

In which case it looks like you are using the wrong port layer files.

If this is a Cortex-M3 or a Cortex-M4 without a floating point unit then
use the files in FreeRTOS/Source/portable/GCC/ARM_CM3

If this is a Cortex-M4 with a floating point then use the port files
from FreeRTOS/Source/portable/GCC/ARM_CM4F

If this is an M0 or M0+ use the files in
FreeRTOS/Source/portable/GCC/ARM_CM0