Quality RTOS & Embedded Software

 Real time embedded FreeRTOS RSS feed 
Quick Start Supported MCUs PDF Books Trace Tools Ecosystem


Loading

Self-built arm-none-eabi toolchain issues

Posted by Stuart Longland on January 11, 2010
Hi all

I was wondering what magic patches people use to build the CORTEX_LM3Sxxxx_Eclipse demo for Luminary Micro's LM3S8962 development/evaluation board. I've successfully built it using a demo of the CodeSourcery toolchain on my laptop at work (running Windows XP), so I know the code works, just need to sort out my toolchain (to use the CS toolchain, one just needs to point Makefile at arm-stellaris-eabi-gcc and arm-stellaris-eabi-objcopy).

The host computer is a Lemote Yeeloong (MIPS-like CPU architecture... not i386 compatible), and thus, unable to run the CodeSourcery toolchain. I don't mind using a Win32 system to do devel at work, but at home, I like the comfort of the Linux tools.

If I try to build the aforementioned demo, it bombs out at the link stage:
arm-none-eabi-gcc -g -I . -I ../../../Source/include -I ../../../Source/portable/GCC/ARM_CM3 -I ../../Common/include -D GCC_ARMCM3_LM3S102 -D inline= -mthumb -mcpu=cortex-m3 -O0 -Tstandalone.ld -D PACK_STRUCT_END=__attribute\(\(packed\)\) -D ALIGN_STRUCT_END=__attribute\(\(aligned\(4\)\)\) -D sprintf=usprintf -D snprintf=usnprintf -D printf=uipprintf -I ../../Common/ethernet/uIP/uip-1.0/uip -I ./webserver -ffunction-sections -fdata-sections -I ../../Common/drivers/LuminaryMicro main.o timertest.o ./ParTest/ParTest.o rit128x96x4.o osram128x64x4.o formike128x128x16.o ../../Common/drivers/LuminaryMicro/ustdlib.o ../../Common/Minimal/BlockQ.o ../../Common/Minimal/blocktim.o ../../Common/Minimal/death.o ../../Common/Minimal/integer.o ../../Common/Minimal/PollQ.o ../../Common/Minimal/semtest.o ../../Common/Minimal/GenQTest.o ../../Common/Minimal/QPeek.o ../../Common/Minimal/recmutex.o ../../Common/Minimal/IntQueue.o ./IntQueueTimer.o ./webserver/uIP_Task.o ./webserver/emac.o ./webserver/httpd.o ./webserver/httpd-cgi.o ./webserver/httpd-fs.o ./webserver/http-strings.o ../../Common/ethernet/uIP/uip-1.0/uip/uip_arp.o ../../Common/ethernet/uIP/uip-1.0/uip/psock.o ../../Common/ethernet/uIP/uip-1.0/uip/timer.o ../../Common/ethernet/uIP/uip-1.0/uip/uip.o ../../../Source/list.o ../../../Source/queue.o ../../../Source/tasks.o ../../../Source/portable/GCC/ARM_CM3/port.o ../../../Source/portable/MemMang/heap_2.o startup.o ../../Common/drivers/LuminaryMicro/arm-none-eabi-gcc/libdriver.a ../../Common/drivers/LuminaryMicro/arm-none-eabi-gcc/libgr.a -nostartfiles -Xlinker -oRTOSDemo.axf -Xlinker -M -Xlinker -Map=rtosdemo.map -Xlinker --no-gc-sections
/usr/libexec/gcc/arm-none-eabi/ld: section .eh_frame loaded at [0000000000014294,00000000000143e3] overlaps section .data loaded at [0000000000014294,00000000000143e7]
collect2: ld returned 1 exit status
make: *** [RTOSDemo.axf] Error 1

I have no idea where to look for possible fixes to this issue, but it seems something is not right -- and it's my toolchain because I can build it elsewhere. Anyone struck this and know a solution they can share?

RE: Self-built arm-none-eabi toolchain issues

Posted by Richard on January 11, 2010
Sorry - I know nothing about building GCC. I have previously come across a problem with eh_frame that was caused by a bug in the linker script, but I didn't understand the solution so that does not help. You might be better off asking on a GCC forum.

Regards.

RE: Self-built arm-none-eabi toolchain issues

Posted by Stuart Longland on January 11, 2010
No worries... will do. If I find a solution I shall report back so that others here may benefit.

RE: Self-built arm-none-eabi toolchain issues

Posted by Stuart Longland on January 17, 2010
Okay... after a bit of investigation, it seems this is a known bug in GCC that has been fixed in recent releases.

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=40521 is the bug report on GCC Bugzilla.
http://www.codesourcery.com/archives/arm-gnu/msg03167.html is my query to CodeSourcery regarding the issue, where the aforementioned bug was discussed.

One way around it that avoids having to recompile everything is to run:

find . -type f -name \*.o -exec arm-stellaris-eabi-strip -R .eh_frame {} \;

in the top-level FreeRTOS directory. This ditches the .eh_frame section that's causing the issue. A second approach is to build the binaries with the -fno-dwarf2-cfi-asm option. The third approach I am investigating now -- that is adjusting the build environment when compiling gcc. I will have an updated Makefile if this works.

Regards,
Stuart Longland

RE: Self-built arm-none-eabi toolchain issues

Posted by Stuart Longland on January 27, 2010
Finally nailed this issue... if you recompile gcc and still strike this issue, chances are it's the C library that's hiding the last remnants of the .eh_frames. You need to then recompile and reinstall newlib. The following is the Makefile I use to generate a toolchain from CodeSourcery sources. I've been using it successfully on a mipsel-unknown-linux-gnu host for a while now, and it builds many of the examples just fine, so I shall share it with everyone.

Hopefully this site doesn't mangle it too much! :-)
# CodeSourcery Toolchain version
CS_VER=2009q3-68

# Target for toolchain
TARGET=arm-stellaris-eabi

# Build host type -- this automatically detects the local host type
# use CROSS_COMPILE=foo- to set the build toolchain to use.
BUILD=$(shell $(CROSS_COMPILE)gcc -dumpmachine)
HOST=$(BUILD)

# Source tarball directory ... assumed to be same dir as Makefile
SRCDIR=$(PWD)

# Unpack directory
UNPACKDIR=$(PWD)/unpack

# Build working directory
WORKDIR=$(PWD)/build

# Toolchain prefix directory -- all components will be installed here
PREFIX=/usr/local

# Build Library Prefix -- libraries will be built here
BLPREFIX=$(PWD)/buildlibs

# Build Library Prefix -- libraries will be built here
BLPREFIX=$(PWD)/buildlibs

# Superuser access command... if needed
SUDO=

# Package naming to use (DO NOT brand your custom toolchain as "CodeSourcery")
PKGVERSION="Luminary Micro Stellaris Toolchain; Eze Corp Build"
BUGURL=http://a64/wiki/

# Package directory names
BINUTILS=binutils-stable
CLOOG=cloog-0.15
EXPAT=expat-mirror
GCC=gcc-4.4
GDB=gdb-stable
MPFR=mpfr-stable
NEWLIB=newlib-stable
PPL=ppl-0.10.2

##### Tasks begin here #####

.PHONY: all

all: $(WORKDIR)/gdb/.install

%/.md:
-mkdir $(@D)
[ -f $@ ] || touch $@

$(UNPACKDIR)/$(MPFR)/.unpacked: $(SRCDIR)/mpfr-$(CS_VER).tar.bz2 $(UNPACKDIR)/.md
tar -C $(UNPACKDIR) -xjvf $<
[ -f $@ ] || touch $@

$(UNPACKDIR)/$(PPL)/.unpacked: $(SRCDIR)/ppl-$(CS_VER).tar.bz2 $(UNPACKDIR)/.md
tar -C $(UNPACKDIR) -xjvf $<
[ -f $@ ] || touch $@

$(UNPACKDIR)/$(CLOOG)/.unpacked: $(SRCDIR)/cloog-$(CS_VER).tar.bz2 $(UNPACKDIR)/.md
tar -C $(UNPACKDIR) -xjvf $<
[ -f $@ ] || touch $@

$(UNPACKDIR)/$(BINUTILS)/.unpacked: $(SRCDIR)/binutils-$(CS_VER).tar.bz2 $(UNPACKDIR)/.md
tar -C $(UNPACKDIR) -xjvf $<
[ -f $@ ] || touch $@

$(UNPACKDIR)/$(GCC)/.unpacked: $(SRCDIR)/gcc-$(CS_VER).tar.bz2 $(UNPACKDIR)/.md
tar -C $(UNPACKDIR) -xjvf $<
[ -f $@ ] || touch $@

$(UNPACKDIR)/$(NEWLIB)/.unpacked: $(SRCDIR)/newlib-$(CS_VER).tar.bz2 $(UNPACKDIR)/.md
tar -C $(UNPACKDIR) -xjvf $<
[ -f $@ ] || touch $@

$(UNPACKDIR)/$(EXPAT)/.unpacked: $(SRCDIR)/expat-$(CS_VER).tar.bz2 $(UNPACKDIR)/.md
tar -C $(UNPACKDIR) -xjvf $<
[ -f $@ ] || touch $@

$(UNPACKDIR)/$(GDB)/.unpacked: $(SRCDIR)/gdb-$(CS_VER).tar.bz2 $(UNPACKDIR)/.md
tar -C $(UNPACKDIR) -xjvf $<
[ -f $@ ] || touch $@

$(WORKDIR)/mpfr/.md: $(WORKDIR)/.md
$(WORKDIR)/mpfr.deps-installed:
touch $@

$(WORKDIR)/mpfr/.config: $(UNPACKDIR)/$(MPFR) $(WORKDIR)/mpfr/.md $(BLPREFIX)/.md $(WORKDIR)/mpfr.deps-installed
cd $(@D) ; \
CC_FOR_BUILD=$(CROSS_COMPILE)gcc \
CC=$(CROSS_COMPILE)gcc \
AR=$(CROSS_COMPILE)ar \
RANLIB=$(CROSS_COMPILE)ranlib \
$(UNPACKDIR)/$(MPFR)/configure \
--build=$(BUILD) \
--target=$(TARGET) \
--host=$(HOST) \
--prefix=$(BLPREFIX) \
--disable-shared
touch $@

$(WORKDIR)/ppl/.md: $(WORKDIR)/.md
$(WORKDIR)/ppl.deps-installed:
touch $@

$(WORKDIR)/ppl/.config: $(UNPACKDIR)/$(PPL)/.unpacked $(WORKDIR)/ppl/.md $(BLPREFIX)/.md $(WORKDIR)/ppl.deps-installed
cd $(@D) ; \
CC_FOR_BUILD=$(CROSS_COMPILE)gcc \
CC=$(CROSS_COMPILE)gcc \
AR=$(CROSS_COMPILE)ar \
RANLIB=$(CROSS_COMPILE)ranlib \
$(UNPACKDIR)/$(PPL)/configure \
--build=$(BUILD) \
--target=$(TARGET) \
--host=$(HOST) \
--prefix=$(BLPREFIX) \
--disable-shared \
--disable-nls
touch $@

$(WORKDIR)/cloog/.md: $(WORKDIR)/.md
$(WORKDIR)/cloog.deps-installed:$(WORKDIR)/ppl/.install
touch $@

$(WORKDIR)/cloog/.config: $(UNPACKDIR)/$(CLOOG)/.unpacked $(WORKDIR)/cloog/.md $(BLPREFIX)/.md $(WORKDIR)/cloog.deps-installed
cd $(@D) ; \
CC_FOR_BUILD=$(CROSS_COMPILE)gcc \
CC=$(CROSS_COMPILE)gcc \
AR=$(CROSS_COMPILE)ar \
RANLIB=$(CROSS_COMPILE)ranlib \
$(UNPACKDIR)/$(CLOOG)/configure \
--build=$(BUILD) \
--target=$(TARGET) \
--host=$(HOST) \
--prefix=$(BLPREFIX) \
--disable-shared \
--disable-nls \
--with-ppl=$(BLPREFIX)
touch $@

$(WORKDIR)/binutils/.md: $(WORKDIR)/.md
$(WORKDIR)/binutils.deps-installed: $(WORKDIR)/mpfr/.install $(WORKDIR)/ppl/.install $(WORKDIR)/cloog/.install
touch $@

$(WORKDIR)/binutils/.config: $(UNPACKDIR)/$(BINUTILS)/.unpacked $(WORKDIR)/binutils/.md $(WORKDIR)/binutils.deps-installed
cd $(@D) ; \
CC_FOR_BUILD=$(CROSS_COMPILE)gcc \
CC=$(CROSS_COMPILE)gcc \
AR=$(CROSS_COMPILE)ar \
RANLIB=$(CROSS_COMPILE)ranlib \
$(UNPACKDIR)/$(BINUTILS)/configure \
--build=$(BUILD) \
--target=$(TARGET) \
--prefix=$(PREFIX) \
--host=$(HOST) \
--with-pkgversion=$(PKGVERSION) \
--with-bugurl=$(BUGURL) \
--with-mpfr=$(BLPREFIX) \
--with-ppl=$(BLPREFIX) \
--with-cloog=$(BLPREFIX) \
--disable-nls
touch $@

$(WORKDIR)/binutils/.install: $(WORKDIR)/binutils/.build
sudo $(MAKE) -C $(@D) \
installdirs \
install-host \
install-target
touch $@

# task [055/174] /$(CROSS_COMPILE)/toolchain/gcc_first/configure

$(WORKDIR)/gcc-s1/.md: $(WORKDIR)/.md
$(WORKDIR)/gcc-s1.deps-installed: $(WORKDIR)/binutils/.install $(WORKDIR)/mpfr/.install $(WORKDIR)/ppl/.install $(WORKDIR)/cloog/.install
touch $@

$(WORKDIR)/gcc-s1/.config: $(UNPACKDIR)/$(GCC)/.unpacked $(WORKDIR)/gcc-s1/.md $(WORKDIR)/gcc-s1.deps-installed
cd $(@D) ; \
CC_FOR_BUILD=$(CROSS_COMPILE)gcc \
CC=$(CROSS_COMPILE)gcc \
AR=$(CROSS_COMPILE)ar \
RANLIB=$(CROSS_COMPILE)ranlib \
AR_FOR_TARGET=arm-none-eabi-ar \
NM_FOR_TARGET=arm-none-eabi-nm \
OBJDUMP_FOR_TARET=arm-none-eabi-objdump \
STRIP_FOR_TARGET=arm-none-eabi-strip \
gcc_cv_as_cfi_directive=no \
$(UNPACKDIR)/$(GCC)/configure \
--build=$(BUILD) \
--host=$(HOST) \
--target=$(TARGET) \
--disable-libmudflap \
--disable-libstdcxx-pch \
--enable-extra-sgxxlite-multilibs \
--with-gnu-as \
--with-gnu-ld \
'--with-specs=%{O2:%{!fno-remove-local-statics: -fremove-local-statics}} %{O*:%{O|O0|O1|O2|Os:;:%{!fno-remove-local-statics: -fremove-local-statics}}}' \
--disable-lto \
--with-newlib \
--with-pkgversion=$(PKGVERSION) \
--with-bugurl=$(BUGURL) \
--disable-nls \
--prefix=$(PREFIX) \
--disable-shared \
--disable-threads \
--disable-libssp \
--disable-libgomp \
--without-headers \
--with-newlib \
--disable-decimal-float \
--disable-libffi \
--enable-languages=c \
--with-mpfr=$(PREFIX) \
--with-ppl=$(PREFIX) \
'--with-host-libstdcxx=-static-libgcc -Wl,-Bstatic,-lstdc++,-Bdynamic -lm' \
--with-cloog=$(PREFIX) \
--disable-libgomp
touch $@

$(WORKDIR)/gcc-s1/.build: $(WORKDIR)/gcc-s1/.config
gcc_cv_as_cfi_directive=no \
$(MAKE) -C $(WORKDIR)/gcc-s1 all-gcc
touch $@

$(WORKDIR)/gcc-s1/.install: $(WORKDIR)/gcc-s1/.build
sudo $(MAKE) -C $(@D)/gcc \
install-common \
install-cpp \
install- \
install-driver
touch $@

# task [059/174] /$(CROSS_COMPILE)/toolchain/newlib/configure

$(WORKDIR)/newlib/.md: $(WORKDIR)/.md
$(WORKDIR)/newlib.deps-installed: $(WORKDIR)/gcc-s1/.install
touch $@

$(WORKDIR)/newlib/.config: $(UNPACKDIR)/$(NEWLIB)/.unpacked $(WORKDIR)/newlib/.md $(WORKDIR)/newlib.deps-installed
cd $(@D) ; \
CC_FOR_BUILD=$(CROSS_COMPILE)gcc \
CC=$(CROSS_COMPILE)gcc \
AR=$(CROSS_COMPILE)ar \
RANLIB=$(CROSS_COMPILE)ranlib \
CFLAGS_FOR_TARGET='-g -O2 -fno-unroll-loops -fno-dwarf2-cfi-asm' \
$(UNPACKDIR)/$(NEWLIB)/configure \
--build=$(BUILD) \
--target=$(TARGET) \
--prefix=$(PREFIX) \
--host=$(HOST) \
--enable-newlib-io-long-long \
--disable-newlib-supplied-syscalls \
--disable-libgloss \
--disable-newlib-supplied-syscalls \
--disable-nls
touch $@

# task [063/174] /$(CROSS_COMPILE)/toolchain/gcc_final/configure
$(WORKDIR)/gcc-s2/.md: $(WORKDIR)/.md
$(WORKDIR)/gcc-s2.deps-installed: $(WORKDIR)/newlib/.install
touch $@

$(WORKDIR)/gcc-s2/.config: $(UNPACKDIR)/$(GCC)/.unpacked $(WORKDIR)/gcc-s2/.md $(WORKDIR)/gcc-s2.deps-installed
cd $(@D) ; \
CC_FOR_BUILD=$(CROSS_COMPILE)gcc \
CC=$(CROSS_COMPILE)gcc \
AR=$(CROSS_COMPILE)ar \
RANLIB=$(CROSS_COMPILE)ranlib \
AR_FOR_TARGET=arm-none-eabi-ar \
NM_FOR_TARGET=arm-none-eabi-nm \
OBJDUMP_FOR_TARET=arm-none-eabi-objdump \
STRIP_FOR_TARGET=arm-none-eabi-strip \
gcc_cv_as_cfi_directive=no \
$(UNPACKDIR)/$(GCC)/configure \
--build=$(BUILD) \
--host=$(HOST) \
--target=$(TARGET) \
--enable-threads \
--disable-libmudflap \
--disable-libssp \
--disable-libstdcxx-pch \
--enable-extra-sgxxlite-multilibs \
--with-gnu-as \
--with-gnu-ld \
'--with-specs=%{O2:%{!fno-remove-local-statics: -fremove-local-statics}} %{O*:%{O|O0|O1|O2|Os:;:%{!fno-remove-local-statics: -fremove-local-statics}}}' \
--enable-languages=c,c++ \
--disable-shared \
--disable-lto \
--with-newlib \
--with-pkgversion=$(PKGVERSION) \
--with-bugurl=$(BUGURL) \
--disable-nls \
--prefix=$(PREFIX) \
--with-headers=yes \
--with-mpfr=$(PREFIX) \
--with-ppl=$(PREFIX) \
'--with-host-libstdcxx=-static-libgcc -Wl,-Bstatic,-lstdc++,-Bdynamic -lm' \
--with-cloog=$(PREFIX) \
--disable-libgomp
touch $@

$(WORKDIR)/gcc-s2/.build: $(WORKDIR)/gcc-s2/.config
gcc_cv_as_cfi_directive=no \
$(MAKE) -C $(WORKDIR)/gcc-s2 all-gcc
touch $@

$(WORKDIR)/gcc-s2/.install: $(WORKDIR)/gcc-s2/.build
sudo $(MAKE) -C $(@D)/gcc \
install-common \
install-cpp \
install- \
install-driver
touch $@

# task [071/174] /$(CROSS_COMPILE)/toolchain/expat/0/configure
$(WORKDIR)/expat/.md: $(WORKDIR)/.md
$(WORKDIR)/expat.deps-installed: $(WORKDIR)/gcc-s2/.install
touch $@
$(WORKDIR)/expat/.config: $(UNPACKDIR)/$(EXPAT)/.unpacked $(WORKDIR)/expat/.md $(WORKDIR)/expat.deps-installed
cd $(@D) ; \
CC_FOR_BUILD=$(CROSS_COMPILE)gcc \
CC=$(CROSS_COMPILE)gcc \
AR=$(CROSS_COMPILE)ar \
RANLIB=$(CROSS_COMPILE)ranlib \
$(UNPACKDIR)/$(EXPAT)/configure \
--build=$(BUILD) \
--target=$(TARGET) \
--prefix=$(PREFIX) \
--disable-shared \
--host=$(HOST) \
--disable-nls
touch $@

# task [075/174] /$(CROSS_COMPILE)/toolchain/gdb/0/configure
$(WORKDIR)/gdb/.md: $(WORKDIR)/.md
$(WORKDIR)/gdb.deps-installed: $(WORKDIR)/expat/.install
touch $@
$(WORKDIR)/gdb/.config: $(UNPACKDIR)/$(GDB)/.unpacked $(WORKDIR)/gdb/.md $(WORKDIR)/gdb.deps-installed
cd $(@D) ; \
CC_FOR_BUILD=$(CROSS_COMPILE)gcc \
CC=$(CROSS_COMPILE)gcc \
AR=$(CROSS_COMPILE)ar \
RANLIB=$(CROSS_COMPILE)ranlib \
$(UNPACKDIR)/$(GDB)/configure \
--build=$(BUILD) \
--target=$(TARGET) \
--prefix=$(PREFIX) \
--host=$(HOST) \
--with-pkgversion=$(PKGVERSION) \
--with-bugurl=$(BUGURL) \
--disable-nls \
--with-libexpat-prefix=$(PREFIX)
touch $@

$(WORKDIR)/gdb/.install: $(WORKDIR)/gdb/.build
sudo $(MAKE) -C $(@D) \
install-host

$(WORKDIR)/%/.build: $(WORKDIR)/%/.config $(WORKDIR)/%.deps-installed
$(MAKE) -C $(@D)
touch $@

$(WORKDIR)/%/.install: $(WORKDIR)/%/.build
CC_FOR_BUILD=$(CROSS_COMPILE)gcc \
CC=$(CROSS_COMPILE)gcc \
AR=$(CROSS_COMPILE)ar \
RANLIB=$(CROSS_COMPILE)ranlib \
$(SUDO) $(MAKE) -C $(@D) install
touch $@


[ Back to the top ]    [ About FreeRTOS ]    [ Privacy ]    [ Sitemap ]    [ ]


Copyright (C) Amazon Web Services, Inc. or its affiliates. All rights reserved.

Latest News

NXP tweet showing LPC5500 (ARMv8-M Cortex-M33) running FreeRTOS.

Meet Richard Barry and learn about running FreeRTOS on RISC-V at FOSDEM 2019

Version 10.1.1 of the FreeRTOS kernel is available for immediate download. MIT licensed.

View a recording of the "OTA Update Security and Reliability" webinar, presented by TI and AWS.


Careers

FreeRTOS and other embedded software careers at AWS.



FreeRTOS Partners

ARM Connected RTOS partner for all ARM microcontroller cores

Espressif ESP32

IAR Partner

Microchip Premier RTOS Partner

RTOS partner of NXP for all NXP ARM microcontrollers

Renesas

STMicro RTOS partner supporting ARM7, ARM Cortex-M3, ARM Cortex-M4 and ARM Cortex-M0

Texas Instruments MCU Developer Network RTOS partner for ARM and MSP430 microcontrollers

OpenRTOS and SafeRTOS

Xilinx Microblaze and Zynq partner