Stm32f303 ARM GCC Compilir issue on port file

namcho wrote on Saturday, May 23, 2015:

Hello,

I’m trying write Wrapper Class for FreeRTOS with ARM GCC on eclipse platform.
I had worked same Wrapper Class on Keil MDK-ARM v5.14.

I’m using stm32f303vc which is cortex-m4 and it has got Hardware FPU.

So I have included Source\portable\GCC\ARM_CM4F port files to my project.
I dont invoke any freertos functions in my main.cpp just compiled empty project.

Here is my compilier output:

18:05:27 **** Incremental Build of configuration Release for project RtosWrapper ****
make all 
Building file: ../system/src/stm32f3-stdperiph/stm32f30x_gpio.c
Invoking: Cross ARM C Compiler
arm-none-eabi-gcc -mcpu=cortex-m4 -mthumb -Os -fmessage-length=0 -fsigned-char -ffunction-sections -fdata-sections -ffreestanding -Wall -Wextra  -g -DOS_USE_TRACE_SEMIHOSTING_DEBUG -DSTM32F30X -DUSE_STDPERIPH_DRIVER -DHSE_VALUE=8000000 -I"../include" -I"../system/include" -I"../system/include/cmsis" -I"../system/include/stm32f3-stdperiph" -I"D:\Elektronik ve Meslekle\Projelerim\2015\RtosWrapper\system\include\FreeRTOSh" -std=gnu11 -MMD -MP -MF"system/src/stm32f3-stdperiph/stm32f30x_gpio.d" -MT"system/src/stm32f3-stdperiph/stm32f30x_gpio.o" -c -o "system/src/stm32f3-stdperiph/stm32f30x_gpio.o" "../system/src/stm32f3-stdperiph/stm32f30x_gpio.c"
Finished building: ../system/src/stm32f3-stdperiph/stm32f30x_gpio.c
 
Building file: ../system/src/stm32f3-stdperiph/stm32f30x_rcc.c
Invoking: Cross ARM C Compiler
arm-none-eabi-gcc -mcpu=cortex-m4 -mthumb -Os -fmessage-length=0 -fsigned-char -ffunction-sections -fdata-sections -ffreestanding -Wall -Wextra  -g -DOS_USE_TRACE_SEMIHOSTING_DEBUG -DSTM32F30X -DUSE_STDPERIPH_DRIVER -DHSE_VALUE=8000000 -I"../include" -I"../system/include" -I"../system/include/cmsis" -I"../system/include/stm32f3-stdperiph" -I"D:\Elektronik ve Meslekle\Projelerim\2015\RtosWrapper\system\include\FreeRTOSh" -std=gnu11 -MMD -MP -MF"system/src/stm32f3-stdperiph/stm32f30x_rcc.d" -MT"system/src/stm32f3-stdperiph/stm32f30x_rcc.o" -c -o "system/src/stm32f3-stdperiph/stm32f30x_rcc.o" "../system/src/stm32f3-stdperiph/stm32f30x_rcc.c"
Finished building: ../system/src/stm32f3-stdperiph/stm32f30x_rcc.c
 
Building file: ../system/src/newlib/_cxx.cpp
Invoking: Cross ARM C++ Compiler
arm-none-eabi-g++ -mcpu=cortex-m4 -mthumb -Os -fmessage-length=0 -fsigned-char -ffunction-sections -fdata-sections -ffreestanding -Wall -Wextra  -g -DOS_USE_TRACE_SEMIHOSTING_DEBUG -DSTM32F30X -DUSE_STDPERIPH_DRIVER -DHSE_VALUE=8000000 -I"../include" -I"../system/include" -I"../system/include/cmsis" -I"../system/include/stm32f3-stdperiph" -I"D:\Elektronik ve Meslekle\Projelerim\2015\RtosWrapper\system\include\FreeRTOSh" -std=gnu++11 -fabi-version=0 -fno-exceptions -fno-rtti -fno-use-cxa-atexit -fno-threadsafe-statics -MMD -MP -MF"system/src/newlib/_cxx.d" -MT"system/src/newlib/_cxx.o" -c -o "system/src/newlib/_cxx.o" "../system/src/newlib/_cxx.cpp"
Finished building: ../system/src/newlib/_cxx.cpp
 
Building file: ../system/src/newlib/_exit.c
Invoking: Cross ARM C Compiler
arm-none-eabi-gcc -mcpu=cortex-m4 -mthumb -Os -fmessage-length=0 -fsigned-char -ffunction-sections -fdata-sections -ffreestanding -Wall -Wextra  -g -DOS_USE_TRACE_SEMIHOSTING_DEBUG -DSTM32F30X -DUSE_STDPERIPH_DRIVER -DHSE_VALUE=8000000 -I"../include" -I"../system/include" -I"../system/include/cmsis" -I"../system/include/stm32f3-stdperiph" -I"D:\Elektronik ve Meslekle\Projelerim\2015\RtosWrapper\system\include\FreeRTOSh" -std=gnu11 -MMD -MP -MF"system/src/newlib/_exit.d" -MT"system/src/newlib/_exit.o" -c -o "system/src/newlib/_exit.o" "../system/src/newlib/_exit.c"
Finished building: ../system/src/newlib/_exit.c
 
Building file: ../system/src/newlib/_sbrk.c
Invoking: Cross ARM C Compiler
arm-none-eabi-gcc -mcpu=cortex-m4 -mthumb -Os -fmessage-length=0 -fsigned-char -ffunction-sections -fdata-sections -ffreestanding -Wall -Wextra  -g -DOS_USE_TRACE_SEMIHOSTING_DEBUG -DSTM32F30X -DUSE_STDPERIPH_DRIVER -DHSE_VALUE=8000000 -I"../include" -I"../system/include" -I"../system/include/cmsis" -I"../system/include/stm32f3-stdperiph" -I"D:\Elektronik ve Meslekle\Projelerim\2015\RtosWrapper\system\include\FreeRTOSh" -std=gnu11 -MMD -MP -MF"system/src/newlib/_sbrk.d" -MT"system/src/newlib/_sbrk.o" -c -o "system/src/newlib/_sbrk.o" "../system/src/newlib/_sbrk.c"
Finished building: ../system/src/newlib/_sbrk.c
 
Building file: ../system/src/newlib/_startup.c
Invoking: Cross ARM C Compiler
arm-none-eabi-gcc -mcpu=cortex-m4 -mthumb -Os -fmessage-length=0 -fsigned-char -ffunction-sections -fdata-sections -ffreestanding -Wall -Wextra  -g -DOS_USE_TRACE_SEMIHOSTING_DEBUG -DSTM32F30X -DUSE_STDPERIPH_DRIVER -DHSE_VALUE=8000000 -DOS_INCLUDE_STARTUP_INIT_MULTIPLE_RAM_SECTIONS -I"../include" -I"../system/include" -I"../system/include/cmsis" -I"../system/include/stm32f3-stdperiph" -I"D:\Elektronik ve Meslekle\Projelerim\2015\RtosWrapper\system\include\FreeRTOSh" -std=gnu11 -MMD -MP -MF"system/src/newlib/_startup.d" -MT"system/src/newlib/_startup.d" -c -o "system/src/newlib/_startup.o" "../system/src/newlib/_startup.c"
Finished building: ../system/src/newlib/_startup.c
 
Building file: ../system/src/newlib/_syscalls.c
Invoking: Cross ARM C Compiler
arm-none-eabi-gcc -mcpu=cortex-m4 -mthumb -Os -fmessage-length=0 -fsigned-char -ffunction-sections -fdata-sections -ffreestanding -Wall -Wextra  -g -DOS_USE_TRACE_SEMIHOSTING_DEBUG -DSTM32F30X -DUSE_STDPERIPH_DRIVER -DHSE_VALUE=8000000 -I"../include" -I"../system/include" -I"../system/include/cmsis" -I"../system/include/stm32f3-stdperiph" -I"D:\Elektronik ve Meslekle\Projelerim\2015\RtosWrapper\system\include\FreeRTOSh" -std=gnu11 -MMD -MP -MF"system/src/newlib/_syscalls.d" -MT"system/src/newlib/_syscalls.o" -c -o "system/src/newlib/_syscalls.o" "../system/src/newlib/_syscalls.c"
Finished building: ../system/src/newlib/_syscalls.c
 
Building file: ../system/src/newlib/assert.c
Invoking: Cross ARM C Compiler
arm-none-eabi-gcc -mcpu=cortex-m4 -mthumb -Os -fmessage-length=0 -fsigned-char -ffunction-sections -fdata-sections -ffreestanding -Wall -Wextra  -g -DOS_USE_TRACE_SEMIHOSTING_DEBUG -DSTM32F30X -DUSE_STDPERIPH_DRIVER -DHSE_VALUE=8000000 -I"../include" -I"../system/include" -I"../system/include/cmsis" -I"../system/include/stm32f3-stdperiph" -I"D:\Elektronik ve Meslekle\Projelerim\2015\RtosWrapper\system\include\FreeRTOSh" -std=gnu11 -MMD -MP -MF"system/src/newlib/assert.d" -MT"system/src/newlib/assert.o" -c -o "system/src/newlib/assert.o" "../system/src/newlib/assert.c"
Finished building: ../system/src/newlib/assert.c
 
Building file: ../system/src/diag/Trace.c
Invoking: Cross ARM C Compiler
arm-none-eabi-gcc -mcpu=cortex-m4 -mthumb -Os -fmessage-length=0 -fsigned-char -ffunction-sections -fdata-sections -ffreestanding -Wall -Wextra  -g -DOS_USE_TRACE_SEMIHOSTING_DEBUG -DSTM32F30X -DUSE_STDPERIPH_DRIVER -DHSE_VALUE=8000000 -I"../include" -I"../system/include" -I"../system/include/cmsis" -I"../system/include/stm32f3-stdperiph" -I"D:\Elektronik ve Meslekle\Projelerim\2015\RtosWrapper\system\include\FreeRTOSh" -std=gnu11 -MMD -MP -MF"system/src/diag/Trace.d" -MT"system/src/diag/Trace.o" -c -o "system/src/diag/Trace.o" "../system/src/diag/Trace.c"
Finished building: ../system/src/diag/Trace.c
 
Building file: ../system/src/diag/trace_impl.c
Invoking: Cross ARM C Compiler
arm-none-eabi-gcc -mcpu=cortex-m4 -mthumb -Os -fmessage-length=0 -fsigned-char -ffunction-sections -fdata-sections -ffreestanding -Wall -Wextra  -g -DOS_USE_TRACE_SEMIHOSTING_DEBUG -DSTM32F30X -DUSE_STDPERIPH_DRIVER -DHSE_VALUE=8000000 -I"../include" -I"../system/include" -I"../system/include/cmsis" -I"../system/include/stm32f3-stdperiph" -I"D:\Elektronik ve Meslekle\Projelerim\2015\RtosWrapper\system\include\FreeRTOSh" -std=gnu11 -MMD -MP -MF"system/src/diag/trace_impl.d" -MT"system/src/diag/trace_impl.o" -c -o "system/src/diag/trace_impl.o" "../system/src/diag/trace_impl.c"
Finished building: ../system/src/diag/trace_impl.c
 
Building file: ../system/src/cortexm/_initialize_hardware.c
Invoking: Cross ARM C Compiler
arm-none-eabi-gcc -mcpu=cortex-m4 -mthumb -Os -fmessage-length=0 -fsigned-char -ffunction-sections -fdata-sections -ffreestanding -Wall -Wextra  -g -DOS_USE_TRACE_SEMIHOSTING_DEBUG -DSTM32F30X -DUSE_STDPERIPH_DRIVER -DHSE_VALUE=8000000 -I"../include" -I"../system/include" -I"../system/include/cmsis" -I"../system/include/stm32f3-stdperiph" -I"D:\Elektronik ve Meslekle\Projelerim\2015\RtosWrapper\system\include\FreeRTOSh" -std=gnu11 -MMD -MP -MF"system/src/cortexm/_initialize_hardware.d" -MT"system/src/cortexm/_initialize_hardware.o" -c -o "system/src/cortexm/_initialize_hardware.o" "../system/src/cortexm/_initialize_hardware.c"
Finished building: ../system/src/cortexm/_initialize_hardware.c
 
Building file: ../system/src/cortexm/_reset_hardware.c
Invoking: Cross ARM C Compiler
arm-none-eabi-gcc -mcpu=cortex-m4 -mthumb -Os -fmessage-length=0 -fsigned-char -ffunction-sections -fdata-sections -ffreestanding -Wall -Wextra  -g -DOS_USE_TRACE_SEMIHOSTING_DEBUG -DSTM32F30X -DUSE_STDPERIPH_DRIVER -DHSE_VALUE=8000000 -I"../include" -I"../system/include" -I"../system/include/cmsis" -I"../system/include/stm32f3-stdperiph" -I"D:\Elektronik ve Meslekle\Projelerim\2015\RtosWrapper\system\include\FreeRTOSh" -std=gnu11 -MMD -MP -MF"system/src/cortexm/_reset_hardware.d" -MT"system/src/cortexm/_reset_hardware.o" -c -o "system/src/cortexm/_reset_hardware.o" "../system/src/cortexm/_reset_hardware.c"
Finished building: ../system/src/cortexm/_reset_hardware.c
 
Building file: ../system/src/cortexm/exception_handlers.c
Invoking: Cross ARM C Compiler
arm-none-eabi-gcc -mcpu=cortex-m4 -mthumb -Os -fmessage-length=0 -fsigned-char -ffunction-sections -fdata-sections -ffreestanding -Wall -Wextra  -g -DOS_USE_TRACE_SEMIHOSTING_DEBUG -DSTM32F30X -DUSE_STDPERIPH_DRIVER -DHSE_VALUE=8000000 -I"../include" -I"../system/include" -I"../system/include/cmsis" -I"../system/include/stm32f3-stdperiph" -I"D:\Elektronik ve Meslekle\Projelerim\2015\RtosWrapper\system\include\FreeRTOSh" -std=gnu11 -MMD -MP -MF"system/src/cortexm/exception_handlers.d" -MT"system/src/cortexm/exception_handlers.o" -c -o "system/src/cortexm/exception_handlers.o" "../system/src/cortexm/exception_handlers.c"
Finished building: ../system/src/cortexm/exception_handlers.c
 
Building file: ../system/src/cmsis/system_stm32f30x.c
Invoking: Cross ARM C Compiler
arm-none-eabi-gcc -mcpu=cortex-m4 -mthumb -Os -fmessage-length=0 -fsigned-char -ffunction-sections -fdata-sections -ffreestanding -Wall -Wextra  -g -DOS_USE_TRACE_SEMIHOSTING_DEBUG -DSTM32F30X -DUSE_STDPERIPH_DRIVER -DHSE_VALUE=8000000 -I"../include" -I"../system/include" -I"../system/include/cmsis" -I"../system/include/stm32f3-stdperiph" -I"D:\Elektronik ve Meslekle\Projelerim\2015\RtosWrapper\system\include\FreeRTOSh" -std=gnu11 -MMD -MP -MF"system/src/cmsis/system_stm32f30x.d" -MT"system/src/cmsis/system_stm32f30x.o" -c -o "system/src/cmsis/system_stm32f30x.o" "../system/src/cmsis/system_stm32f30x.c"
Finished building: ../system/src/cmsis/system_stm32f30x.c
 
Building file: ../system/src/cmsis/vectors_stm32f30x.c
Invoking: Cross ARM C Compiler
arm-none-eabi-gcc -mcpu=cortex-m4 -mthumb -Os -fmessage-length=0 -fsigned-char -ffunction-sections -fdata-sections -ffreestanding -Wall -Wextra  -g -DOS_USE_TRACE_SEMIHOSTING_DEBUG -DSTM32F30X -DUSE_STDPERIPH_DRIVER -DHSE_VALUE=8000000 -I"../include" -I"../system/include" -I"../system/include/cmsis" -I"../system/include/stm32f3-stdperiph" -I"D:\Elektronik ve Meslekle\Projelerim\2015\RtosWrapper\system\include\FreeRTOSh" -std=gnu11 -MMD -MP -MF"system/src/cmsis/vectors_stm32f30x.d" -MT"system/src/cmsis/vectors_stm32f30x.o" -c -o "system/src/cmsis/vectors_stm32f30x.o" "../system/src/cmsis/vectors_stm32f30x.c"
Finished building: ../system/src/cmsis/vectors_stm32f30x.c
 
Building file: ../system/src/FreeRTOSc/croutine.c
Invoking: Cross ARM C Compiler
arm-none-eabi-gcc -mcpu=cortex-m4 -mthumb -Os -fmessage-length=0 -fsigned-char -ffunction-sections -fdata-sections -ffreestanding -Wall -Wextra  -g -DOS_USE_TRACE_SEMIHOSTING_DEBUG -DSTM32F30X -DUSE_STDPERIPH_DRIVER -DHSE_VALUE=8000000 -I"../include" -I"../system/include" -I"../system/include/cmsis" -I"../system/include/stm32f3-stdperiph" -I"D:\Elektronik ve Meslekle\Projelerim\2015\RtosWrapper\system\include\FreeRTOSh" -std=gnu11 -MMD -MP -MF"system/src/FreeRTOSc/croutine.d" -MT"system/src/FreeRTOSc/croutine.o" -c -o "system/src/FreeRTOSc/croutine.o" "../system/src/FreeRTOSc/croutine.c"
Finished building: ../system/src/FreeRTOSc/croutine.c
 
Building file: ../system/src/FreeRTOSc/event_groups.c
Invoking: Cross ARM C Compiler
arm-none-eabi-gcc -mcpu=cortex-m4 -mthumb -Os -fmessage-length=0 -fsigned-char -ffunction-sections -fdata-sections -ffreestanding -Wall -Wextra  -g -DOS_USE_TRACE_SEMIHOSTING_DEBUG -DSTM32F30X -DUSE_STDPERIPH_DRIVER -DHSE_VALUE=8000000 -I"../include" -I"../system/include" -I"../system/include/cmsis" -I"../system/include/stm32f3-stdperiph" -I"D:\Elektronik ve Meslekle\Projelerim\2015\RtosWrapper\system\include\FreeRTOSh" -std=gnu11 -MMD -MP -MF"system/src/FreeRTOSc/event_groups.d" -MT"system/src/FreeRTOSc/event_groups.o" -c -o "system/src/FreeRTOSc/event_groups.o" "../system/src/FreeRTOSc/event_groups.c"
Finished building: ../system/src/FreeRTOSc/event_groups.c
 
Building file: ../system/src/FreeRTOSc/heap_1.c
Invoking: Cross ARM C Compiler
arm-none-eabi-gcc -mcpu=cortex-m4 -mthumb -Os -fmessage-length=0 -fsigned-char -ffunction-sections -fdata-sections -ffreestanding -Wall -Wextra  -g -DOS_USE_TRACE_SEMIHOSTING_DEBUG -DSTM32F30X -DUSE_STDPERIPH_DRIVER -DHSE_VALUE=8000000 -I"../include" -I"../system/include" -I"../system/include/cmsis" -I"../system/include/stm32f3-stdperiph" -I"D:\Elektronik ve Meslekle\Projelerim\2015\RtosWrapper\system\include\FreeRTOSh" -std=gnu11 -MMD -MP -MF"system/src/FreeRTOSc/heap_1.d" -MT"system/src/FreeRTOSc/heap_1.o" -c -o "system/src/FreeRTOSc/heap_1.o" "../system/src/FreeRTOSc/heap_1.c"
Finished building: ../system/src/FreeRTOSc/heap_1.c
 
Building file: ../system/src/FreeRTOSc/list.c
Invoking: Cross ARM C Compiler
arm-none-eabi-gcc -mcpu=cortex-m4 -mthumb -Os -fmessage-length=0 -fsigned-char -ffunction-sections -fdata-sections -ffreestanding -Wall -Wextra  -g -DOS_USE_TRACE_SEMIHOSTING_DEBUG -DSTM32F30X -DUSE_STDPERIPH_DRIVER -DHSE_VALUE=8000000 -I"../include" -I"../system/include" -I"../system/include/cmsis" -I"../system/include/stm32f3-stdperiph" -I"D:\Elektronik ve Meslekle\Projelerim\2015\RtosWrapper\system\include\FreeRTOSh" -std=gnu11 -MMD -MP -MF"system/src/FreeRTOSc/list.d" -MT"system/src/FreeRTOSc/list.o" -c -o "system/src/FreeRTOSc/list.o" "../system/src/FreeRTOSc/list.c"
Finished building: ../system/src/FreeRTOSc/list.c
 
Building file: ../system/src/FreeRTOSc/port.c
Invoking: Cross ARM C Compiler
arm-none-eabi-gcc -mcpu=cortex-m4 -mthumb -Os -fmessage-length=0 -fsigned-char -ffunction-sections -fdata-sections -ffreestanding -Wall -Wextra  -g -DOS_USE_TRACE_SEMIHOSTING_DEBUG -DSTM32F30X -DUSE_STDPERIPH_DRIVER -DHSE_VALUE=8000000 -I"../include" -I"../system/include" -I"../system/include/cmsis" -I"../system/include/stm32f3-stdperiph" -I"D:\Elektronik ve Meslekle\Projelerim\2015\RtosWrapper\system\include\FreeRTOSh" -std=gnu11 -MMD -MP -MF"system/src/FreeRTOSc/port.d" -MT"system/src/FreeRTOSc/port.o" -c -o "system/src/FreeRTOSc/port.o" "../system/src/FreeRTOSc/port.c"
C:\Users\Namcho\AppData\Local\Temp\cc5F19lf.s: Assembler messages:
C:\Users\Namcho\AppData\Local\Temp\cc5F19lf.s:372: Error: selected processor does not support Thumb mode `vstmdbeq r0!,{s16-s31}'
C:\Users\Namcho\AppData\Local\Temp\cc5F19lf.s:374: Error: instruction not allowed in IT block -- `stmdb r0!,{r4-r11,r14}'
C:\Users\Namcho\AppData\Local\Temp\cc5F19lf.s:395: Error: selected processor does not support Thumb mode `vldmiaeq r0!,{s16-s31}'
C:\Users\Namcho\AppData\Local\Temp\cc5F19lf.s:397: Error: instruction not allowed in IT block -- `msr psp,r0'
make: *** [system/src/FreeRTOSc/port.o] Error 1
system/src/FreeRTOSc/subdir.mk:39: recipe for target 'system/src/FreeRTOSc/port.o' failed

18:05:31 Build Finished (took 3s.613ms)

rtel wrote on Saturday, May 23, 2015:

This is a compiler command line problem. The compiler is complaining about floating point instructions because you have not told it that the processor has a floating point unit.

I’m not sure if the flags in this post are correct for you, but you get the idea:
http://www.freertos.org/FreeRTOS_Support_Forum_Archive/December_2012/freertos_STM32F4_GCC_compilation_problems_6404907.html

Regards.

namcho wrote on Tuesday, May 26, 2015:

Thanks for your help It worked.
Here is my Processor settings:
-Float ABI = softfp(I was trying with hard option because stm32f303 has got hard-FPU unit. I dont figure out yet why this option isn’t working.)
-FPU Type = fpv4-sp-d16
-Instruction set = thumb

So after that correction I have worked simple led blink example with using C++.
Anyone can take a look my source code from bitbucket(https://bitbucket.org/Namcho/freertos_gcc_stm32f3/src). The led blink example written in Demo.cpp class file.

Then I have tryed to do same think for FreeRTOS but I failed.
Source code: https://bitbucket.org/Namcho/freertos_gcc_stm32f3/src/404ab212c4acb806a6b18037739adf0f7668cdb9/src/main.cpp?at=develop

Here is compiler output:

    10:42:55 **** Incremental Build of configuration Release for project freeRtos_gcc_stm32f3 ****
    make all 
    Building target: freeRtos_gcc_stm32f3.elf
    Invoking: Cross ARM C++ Linker
    arm-none-eabi-g++ -mcpu=cortex-m4 -mthumb -mfloat-abi=softfp -mfpu=fpv4-sp-d16 -Os -fmessage-length=0 -fsigned-char -ffunction-sections -fdata-sections -ffreestanding -Wall -Wextra  -g -T mem.ld -T libs.ld -T sections.ld -nostartfiles -Xlinker --gc-sections -L"../ldscripts" -Wl,-Map,"freeRtos_gcc_stm32f3.map" --specs=nano.specs -o "freeRtos_gcc_stm32f3.elf"  ./system/src/stm32f3-stdperiph/stm32f30x_gpio.o ./system/src/stm32f3-stdperiph/stm32f30x_rcc.o  ./system/src/newlib/_cxx.o ./system/src/newlib/_exit.o ./system/src/newlib/_sbrk.o ./system/src/newlib/_startup.o ./system/src/newlib/_syscalls.o ./system/src/newlib/assert.o  ./system/src/freeRTOS/croutine.o ./system/src/freeRTOS/event_groups.o ./system/src/freeRTOS/heap_4.o ./system/src/freeRTOS/list.o ./system/src/freeRTOS/port.o ./system/src/freeRTOS/queue.o ./system/src/freeRTOS/tasks.o ./system/src/freeRTOS/timers.o  ./system/src/diag/Trace.o ./system/src/diag/trace_impl.o  ./system/src/cortexm/_initialize_hardware.o ./system/src/cortexm/_reset_hardware.o ./system/src/cortexm/exception_handlers.o  ./system/src/cmsis/system_stm32f30x.o ./system/src/cmsis/vectors_stm32f30x.o  ./src/Demo.o ./src/TaskOOP.o ./src/_write.o ./src/main.o   
    c:/program files (x86)/gnu tools arm embedded/4.9 2015q1/bin/../lib/gcc/arm-none-eabi/4.9.3/../../../../arm-none-eabi/bin/ld.exe: freeRtos_gcc_stm32f3.elf section `.bss' will not fit in region `RAM'
    c:/program files (x86)/gnu tools arm embedded/4.9 2015q1/bin/../lib/gcc/arm-none-eabi/4.9.3/../../../../arm-none-eabi/bin/ld.exe: region `RAM' overflowed by 36520 bytes
    collect2.exe: error: ld returned 1 exit status
    make: *** [freeRtos_gcc_stm32f3.elf] Error 1
    makefile:63: recipe for target 'freeRtos_gcc_stm32f3.elf' failed
    
    10:42:58 Build Finished (took 2s.403ms)

When I make comment ledObj.create(“LED1”,configMINIMAL_STACK_SIZE,1); that line, the code is compiled without any errors.

davedoors wrote on Tuesday, May 26, 2015:

That is a linker error not a compiler error. Somehow including that line has increased the RAM footprint by more thank 30K.

namcho wrote on Tuesday, May 26, 2015:

Yes, I examine mem.ld and sections.ld linker file but I cant figure out anything yet.
Could you give me some hint to solve that issue.

davedoors wrote on Tuesday, May 26, 2015:

First see if it is the C++ that is causing the linker error or just that you are creating a task which then brings in the heap array. Try replacing the call to ledObj.create with a direct xTaskCreate() call. Do you still get the linker error?

namcho wrote on Tuesday, May 26, 2015:

Yes I’m still getting the linker error(36520 bytes overflow). I’ve tryed this in main.cpp file.

In addition I’ve created C project then compiled just xTaskCreate(vTask1,“LED1”,configMINIMAL_STACK_SIZE,NULL,1,NULL); function

Here is the output:

    13:29:06 **** Incremental Build of configuration Release for project freeRTOS_gcc_stm32f3_c ****
    make all 
    Building file: ../src/main.c
    Invoking: Cross ARM C Compiler
    arm-none-eabi-gcc -mcpu=cortex-m4 -mthumb -mfloat-abi=softfp -mfpu=fpv4-sp-d16 -Os -fmessage-length=0 -fsigned-char -ffunction-sections -fdata-sections -ffreestanding -Wall -Wextra  -g -DOS_USE_TRACE_SEMIHOSTING_DEBUG -DSTM32F30X -DUSE_STDPERIPH_DRIVER -DHSE_VALUE=8000000 -I"../include" -I"../system/include" -I"../system/include/cmsis" -I"../system/include/stm32f3-stdperiph" -I../system/include/freeRTOS -std=gnu11 -MMD -MP -MF"src/main.d" -MT"src/main.o" -c -o "src/main.o" "../src/main.c"
    Finished building: ../src/main.c
     
    Building target: freeRTOS_gcc_stm32f3_c.elf
    Invoking: Cross ARM C++ Linker
    arm-none-eabi-g++ -mcpu=cortex-m4 -mthumb -mfloat-abi=softfp -mfpu=fpv4-sp-d16 -Os -fmessage-length=0 -fsigned-char -ffunction-sections -fdata-sections -ffreestanding -Wall -Wextra  -g -T mem.ld -T libs.ld -T sections.ld -nostartfiles -Xlinker --gc-sections -L"../ldscripts" -Wl,-Map,"freeRTOS_gcc_stm32f3_c.map" --specs=nano.specs -o "freeRTOS_gcc_stm32f3_c.elf"  ./system/src/stm32f3-stdperiph/stm32f30x_gpio.o ./system/src/stm32f3-stdperiph/stm32f30x_rcc.o  ./system/src/newlib/_cxx.o ./system/src/newlib/_exit.o ./system/src/newlib/_sbrk.o ./system/src/newlib/_startup.o ./system/src/newlib/_syscalls.o ./system/src/newlib/assert.o  ./system/src/freeRTOS/croutine.o ./system/src/freeRTOS/event_groups.o ./system/src/freeRTOS/heap_4.o ./system/src/freeRTOS/list.o ./system/src/freeRTOS/port.o ./system/src/freeRTOS/queue.o ./system/src/freeRTOS/tasks.o ./system/src/freeRTOS/timers.o  ./system/src/diag/Trace.o ./system/src/diag/trace_impl.o  ./system/src/cortexm/_initialize_hardware.o ./system/src/cortexm/_reset_hardware.o ./system/src/cortexm/exception_handlers.o  ./system/src/cmsis/system_stm32f30x.o ./system/src/cmsis/vectors_stm32f30x.o  ./src/_write.o ./src/main.o   
    c:/program files (x86)/gnu tools arm embedded/4.9 2015q1/bin/../lib/gcc/arm-none-eabi/4.9.3/../../../../arm-none-eabi/bin/ld.exe: freeRTOS_gcc_stm32f3_c.elf section `.bss' will not fit in region `RAM'
    c:/program files (x86)/gnu tools arm embedded/4.9 2015q1/bin/../lib/gcc/arm-none-eabi/4.9.3/../../../../arm-none-eabi/bin/ld.exe: region `RAM' overflowed by 36408 bytes
    collect2.exe: error: ld returned 1 exit status
    make: *** [freeRTOS_gcc_stm32f3_c.elf] Error 1
    makefile:63: recipe for target 'freeRTOS_gcc_stm32f3_c.elf' failed
    
    13:29:07 Build Finished (took 1s.188ms)

As you see just overflowed byte quantity is incresed to 36408 bytes in C.

rtel wrote on Tuesday, May 26, 2015:

Which heap_n.c file are you using (http://www.freertos.org/a00111.html)?
What is configTOTAL_HEAP_SIZE set to?

Regards.

namcho wrote on Tuesday, May 26, 2015:

I wasn’t looked TOTAL_HEAP_SIZE.

Here is the default defination:
#define configTOTAL_HEAP_SIZE ( ( size_t ) ( 75 * 1024 ) )

So it was 75k bytes :slight_smile:

I’ve reduced heap to 1k now everything is alright.

Thanks for your helps.

rtel wrote on Tuesday, May 26, 2015:

As configTOTAL_HEAP_SIZE is making a difference I guess you are not
using heap_3 - in which case you will need more than 1K. Increase the
size gradually until you get linker errors again, then reduce it a bit
so it links. After that you can use xPortGetFreeHeapSize() and
potentially xPortGetMinimumEverFreeHeapSize() to determine how much heap
space you are actually using, and adjust configTOTAL_HEAP_SIZE accordingly.

Regards.

namcho wrote on Tuesday, May 26, 2015:

Yes I’m using heap_4.

Thank you for this important information.

Regards.