FreeRTOS on STR750 for GCC

grummlatsf wrote on Monday, November 23, 2009:

I am trying for weeks now to build a environment for FreeRTOS with STR750 uC for a GCC crosscompiler.
As this is my first experience with creating makefiles, I did not get it to work by now.

Has anyone a makefile lying around for me or could give me a hint whats wrong with mine?!

Thank you!

<pre><code>

SOURCE_DIR=./source/
LIB_SOURCE_DIR=./STLibrary/src/

CC = arm-none-eabi-gcc
OBJCOPY=arm-none-eabi-objcopy

LDSCRIPT=systemfiles/STR75xFx0_FLASH_FreeRTOS.ld

#LINKER_FLAGS=-mthumb -nostartfiles -Xlinker -oRTOSDemo.elf -gc-section  -Xlinker -M -Xlinker -Map=rtosdemo.map
LINKER_FLAGS=-nostartfiles -Xlinker -oRTOSDemo.elf -gc-section  -Xlinker -M -Xlinker -Map=rtosdemo.map
 
DEBUG=-g
OPTIM=-O0

CFLAGS= $(DEBUG) \
$(OPTIM) \
-T$(LDSCRIPT) \
-I . \
-I ./include \
-I ./STLibrary/inc \
-mcpu=arm7tdmi-s \
-D PACK_STRUCT_END=__attribute\(\(packed\)\) \
-D ALIGN_STRUCT_END=__attribute\(\(aligned\(4\)\)\) \
-fomit-frame-pointer \
-ffunction-sections

THUMB_SOURCE= \
source/main.c

ARM_SOURCE= \
$(SOURCE_DIR)main.c \
$(SOURCE_DIR)ParTest.c \
$(SOURCE_DIR)serial.c \
$(SOURCE_DIR)serialISR.c \
$(SOURCE_DIR)croutine.c \
$(SOURCE_DIR)list.c \
$(SOURCE_DIR)port.c \
$(SOURCE_DIR)portISR.c \
$(SOURCE_DIR)queue.c \
$(SOURCE_DIR)tasks.c \
$(SOURCE_DIR)portISR.c \
$(SOURCE_DIR)integer.c \
$(SOURCE_DIR)blocktim.c \
$(SOURCE_DIR)BlockQ.c \
$(SOURCE_DIR)comtest.c \
$(SOURCE_DIR)dynamic.c \
$(SOURCE_DIR)flash.c \
$(SOURCE_DIR)heap_2.c \
$(LIB_SOURCE_DIR)75x_adc.c \
$(LIB_SOURCE_DIR)75x_can.c \
$(LIB_SOURCE_DIR)75x_cfg.c \
$(LIB_SOURCE_DIR)75x_dma.c \
$(LIB_SOURCE_DIR)75x_eic.c \
$(LIB_SOURCE_DIR)75x_extit.c \
$(LIB_SOURCE_DIR)75x_gpio.c \
$(LIB_SOURCE_DIR)75x_i2c.c \
$(LIB_SOURCE_DIR)75x_it.c \
$(LIB_SOURCE_DIR)75x_lib.c \
$(LIB_SOURCE_DIR)75x_mrcc.c \
$(LIB_SOURCE_DIR)75x_pwm.c \
$(LIB_SOURCE_DIR)75x_rtc.c \
$(LIB_SOURCE_DIR)75x_smi.c \
$(LIB_SOURCE_DIR)75x_ssp.c \
$(LIB_SOURCE_DIR)75x_tb.c \
$(LIB_SOURCE_DIR)75x_tim.c \
$(LIB_SOURCE_DIR)75x_uart.c \
$(LIB_SOURCE_DIR)75x_wdg.c \
$(LIB_SOURCE_DIR)lcd.c

THUMB_OBJS = $(THUMB_SOURCE:.c=.o)
ARM_OBJS = $(ARM_SOURCE:.c=.o)

all: RTOSDemo.bin

RTOSDemo.bin : RTOSDemo.elf
$(OBJCOPY) RTOSDemo.elf -O binary RTOSDemo.bin

RTOSDemo.elf : $(THUMB_OBJS) $(ARM_OBJS) Makefile
$(CC) $(CFLAGS) $(ARM_OBJS) $(THUMB_OBJS) $(LIBS) systemfiles/crt0_STR75x_FreeRTOS.s $(LINKER_FLAGS)

$(THUMB_OBJS) : %.o : %.c Makefile FreeRTOSConfig.h
$(CC) -c $(CFLAGS) $< -o $@

$(ARM_OBJS) : %.o : %.c Makefile FreeRTOSConfig.h
$(CC) -c $(CFLAGS) $< -o $@

clean :
rm $(THUMB_OBJS)
rm $(ARM_OBJS)
touch Makefile
rm RTOSDemo.elf

</code></pre>

grummlatsf wrote on Monday, November 23, 2009:

PS: My last error looks like this:

<pre><code>
/home/bene/CodeSourcery/Sourcery_G++_Lite/bin/…/lib/gcc/arm-none-eabi/4.4.1/…/…/…/…/arm-none-eabi/bin/ld: section .text.vPortISRStartFirstTask loaded at  overlaps section .data loaded at
</pre></code>

davedoors wrote on Tuesday, November 24, 2009:

This is not a FreeRTOS problem and probably not a makefile problem, but a linker script problem. Either the linker script does not correctly describe the memory map of your microcontroller, or the built code size is too big to fit in the microcontroller flash.

Check the linker script is correct. It looks like you are already removing unreferenced code so the other option to reduce the built code size it to simply remove some code. Try taking out some of the demo tasks as a lot are included.

grummlatsf wrote on Tuesday, November 24, 2009:

Thanks for you answer.
I rechecked the linker and startup code, and it is directly copied from the STR750 demo project for GCC/Raisonance IDE.
Following the map output from the makefile. There is something strange going on, it is remapping the ram to the flash or something strange I do not understand.
Furthermore I tried to cut everything out I could, the error still resists till now.

Any idea what’s going on here?
<pre><code>
.text.UART_ClearITPendingBit
                0x2000602c       0x1c
.text.UART_ClearITPendingBit
                0x2000602c       0x1c ./STLibrary/src/75x_uart.o
                0x2000602c                UART_ClearITPendingBit
.data           0x40000000       0x38 load address 0x20000c00
                0x40000000                . = ALIGN (0x4)
                0x40000000                _sdata = .
*(.data)
.data          0x40000000        0x4 ./source/portISR.o
                0x40000000                ulCriticalNesting
.data          0x40000004        0x0 ./source/main.o
.data          0x40000004       0x30 ./source/ParTest.o
.data          0x40000034        0x4 ./source/serial.o
</pre></code>

grummlatsf wrote on Tuesday, November 24, 2009:

Today I tried ride7 IDE with this raisonance envirenment. The project file and the systemfiles coming with freertos did not work with this tools either. I followed the instructions on the freertos website and also needed to chance other options to get it compiling at all.
At the end this error is coming up.

<pre><code>
Running: LD
“C:\Programme\Raisonance\Ride\arm-gcc\bin\arm-none-eabi-gcc.exe” -mcpu=arm7tdmi  -Wl,-T -Xlinker “C:\Dokumente und Einstellungen\ben\Desktop\FreeRTOSV6.0.1\Demo\ARM7_STR75x_GCC\rtosdemo.elf.ld” -u _start -Wl,-static -Wl,-gc-sections -nostartfiles -Wl,-Map -Xlinker “C:\Dokumente und Einstellungen\ben\Desktop\FreeRTOSV6.0.1\Demo\ARM7_STR75x_GCC\rtosdemo.map”  
C:\Dokumente und Einstellungen\ben\Desktop\FreeRTOSV6.0.1\Demo\ARM7_STR75x_GCC\crt0_str75x_freertos.o: In function `_startup’: 
(.text+0x0): multiple definition of `_start’ 
C:\Dokumente und Einstellungen\ben\Desktop\FreeRTOSV6.0.1\Demo\ARM7_STR75x_GCC\crt0_str75x_freertos.o:(.text+0x0): first defined here 
C:\Dokumente und Einstellungen\ben\Desktop\FreeRTOSV6.0.1\Demo\ARM7_STR75x_GCC\crt0_str75x_freertos.o: In function `_startup’: 
(.text+0x0): multiple definition of `_startup’ 
C:\Dokumente und Einstellungen\ben\Desktop\FreeRTOSV6.0.1\Demo\ARM7_STR75x_GCC\crt0_str75x_freertos.o:(.text+0x0): first defined here 
C:\Dokumente und Einstellungen\ben\Desktop\FreeRTOSV6.0.1\Demo\ARM7_STR75x_GCC\crt0_str75x_freertos.o: In function `__wrongvector’: 
(.text+0x40): multiple definition of `__wrongvector’ 
C:\Dokumente und Einstellungen\ben\Desktop\FreeRTOSV6.0.1\Demo\ARM7_STR75x_GCC\crt0_str75x_freertos.o:(.text+0x40): first defined here 
c:/programme/raisonance/ride/arm-gcc/bin/…/lib/gcc/arm-none-eabi/4.3.2/…/…/…/…/arm-none-eabi/bin/ld.exe: section .text.vPortISRStartFirstTask  overlaps section .data  
c:/programme/raisonance/ride/arm-gcc/bin/…/lib/gcc/arm-none-eabi/4.3.2/…/…/…/…/arm-none-eabi/bin/ld.exe: section .bss  overlaps section .text.vPortISRStartFirstTask  
c:/programme/raisonance/ride/arm-gcc/bin/…/lib/gcc/arm-none-eabi/4.3.2/…/…/…/…/arm-none-eabi/bin/ld.exe: section .text.vPortEnterCritical  overlaps section .bss  
c:/programme/raisonance/ride/arm-gcc/bin/…/lib/gcc/arm-none-eabi/4.3.2/…/…/…/…/arm-none-eabi/bin/ld.exe: section .text.vCheckTask  overlaps section ._usrstack  
collect2: ld returned 1 exit status 
</code></pre>

I am wondering how other freertos users get this working. Any hint is welcome :slight_smile:

grummlatsf wrote on Wednesday, November 25, 2009:

Another few hours playing around with freertos and crosscompilers, I discovered something.

It took a while, but I found RIDE6, that was used to create the demo project in 2006. It worked quite out-of-the box and ran in a few minutes on my board.
As they use GCC 3.3 and a WINARM envirenment, I think it is anywhere incompatible with recent buildtools. I found more recent startup files and linker scripts, but the scheduler does not start with these.

Does anyone have more recent linker and startup files or some modified I could use? I’ve no idea where to proceed so far :\

Thanks for any help!

rtel wrote on Wednesday, November 25, 2009:

Strange, I thought I had updated it to RIDE 7.  I will have to check that.

Regards.

grummlatsf wrote on Thursday, December 10, 2009:

Thank you richardbarry for your answer. I appreciate, that you want to have a look at my concern.
Did you discovery anything yet? I am still stuck at the old and unstable RIDE6. A recent gcc crosscompiler support would surely help others too.

Thanks

grummlatsf wrote on Monday, January 25, 2010:

After days of working on it, I rebuilt a makefile, extracting compiling options out of the logfile from ride6.
Is not compatible anymore with the original freertos data structure, also created not very carefully, but at least it works.
For anyone that is running in the same problem like me, here my creation.
Thanks for comments, have fun with it.

#/***********************************************
#
# FDDrumSpine Makefile
#
# FreeRTOS V6.0.1
#
# Target STR750
#
#***********************************************/
 

CORE_SOURCE_DIR = ./core/
TASKS_SOURCE_DIR = ./tasks/
LIB_SOURCE_DIR = ./STLibrary/src/

CC = arm-elf-gcc
OBJCOPY = arm-elf-objcopy

LDSCRIPT = systemfiles/STR75xFx0_FLASH_FreeRTOS.ld
STARTSCRIPT = systemfiles/crt0_STR75x_FreeRTOS.s

LDFLAGS = \
-mcpu=arm7tdmi \
-nostartfiles -Wl,-Map=Output.map,-cref \
-Xlinker \
-oOUTPUT.elf

ASFLAGS= -mcpu=arm7tdmi \
-DSTR75X_GCC \
-Wa,-I -Xassembler ./STLibrary/inc \
-Wa,-I -Xassembler ./include \
-Wa,-I -Xassembler ./ \
-c \
-Wa,-EL

CFLAGS= \
-DSTR75X_GCC \
                -mcpu=arm7tdmi \
                -I$(CORE_SOURCE_DIR) \
-I$(TASKS_SOURCE_DIR) \
                -I./ \
                -I./STLibrary/inc \
-c \
-g \
-mlittle-endian \
-funsigned-char \
-O2 \
-Wall \
-Wshadow \
-Wswitch \
-Wunused \
-fomit-frame-pointer \
-fno-dwarf2-cfi-asm 

ARM_SOURCE= \
main.c \
$(TASKS_SOURCE_DIR)adc.c \
$(TASKS_SOURCE_DIR)spidac.c \
$(TASKS_SOURCE_DIR)peltierfb.c \
$(TASKS_SOURCE_DIR)canbus.c \
$(CORE_SOURCE_DIR)misc_stringop.c \
$(CORE_SOURCE_DIR)serial.c \
$(CORE_SOURCE_DIR)serialISR.c \
$(CORE_SOURCE_DIR)list.c \
$(CORE_SOURCE_DIR)port.c \
$(CORE_SOURCE_DIR)queue.c \
$(CORE_SOURCE_DIR)tasks.c \
$(CORE_SOURCE_DIR)heap_2.c \
$(CORE_SOURCE_DIR)portISR.c \
$(LIB_SOURCE_DIR)75x_adc.c \
$(LIB_SOURCE_DIR)75x_can.c \
$(LIB_SOURCE_DIR)75x_ssp.c \
$(LIB_SOURCE_DIR)75x_mrcc.c \
$(LIB_SOURCE_DIR)75x_gpio.c \
$(LIB_SOURCE_DIR)75x_tb.c \
$(LIB_SOURCE_DIR)75x_it.c \
$(LIB_SOURCE_DIR)75x_cfg.c \
$(LIB_SOURCE_DIR)75x_eic.c \
$(LIB_SOURCE_DIR)75x_uart.c

ARM_OBJS = $(ARM_SOURCE:.c=.o)

START_OBJ = $(STARTSCRIPT:.s=.o)

all: OUTPUT.bin

OUTPUT.bin : OUTPUT.elf
$(OBJCOPY) OUTPUT.elf -O binary OUTPUT.bin

OUTPUT.elf :  $(ARM_OBJS) $(START_OBJ) Makefile
$(CC) $(LDFLAGS) $(START_OBJ) $(ARM_OBJS) -T $(LDSCRIPT)

$(ARM_OBJS) : %.o : %.c Makefile FreeRTOSConfig.h
$(CC) $(CFLAGS) $< -o $@

$(START_OBJ) : $(STARTSCRIPT)
$(CC) $(ASFLAGS) $(STARTSCRIPT) -o $@

clean :
rm -f $(START_OBJ)
rm -f $(ARM_OBJS)
touch Makefile
rm -f OUTPUT.elf
rm -f OUTPUT.bin