Substituting arm-none-eabi-gcc with ellcc

Home Forums Forum Substituting arm-none-eabi-gcc with ellcc

This topic contains 7 replies, has 2 voices, and was last updated by  Stephan 7 years, 5 months ago.

Viewing 8 posts - 1 through 8 (of 8 total)
  • Author
    Posts
  • #77623

    Stephan

    Hi,

    I would like to give ellcc a try for compiling the “circle” bare metal environment for the Raspberry Pi:

    https://github.com/rsta2/circle

    Currently I’m compiling with the “GNU Tools ARM Embedded” gcc toolchain with the following flags:

    -march=armv6j -mtune=arm1176jzf-s -mfloat-abi=hard

    I would like to use ellcc with the standard C and C++ libraries with the bare metal environment. If I understand it correctly Which flags would I need with ellcc? I’ve downloaded ellcc-x86_64-w64-mingw32-0.1.28.tgz.

    Thanks
    Stephan

    #77624

    rich
    Keymaster

    Hi Stephan,

    I took a quick look at building circle and I was able to build it for the Raspberry Pi 1 and 2 With the following changes to Rules.mk and sample/Rules.mk.
    I have not tried to run the final executables, however. The Pi 3 build fails because of assembler weirdness. Maybe modifying the ellcc/libecc/config/arm64v8-linux config file no not use the integrated assembler would help.

    I hope this helps.

    rich@dev:~/circle$ diff -u -r circle-master circle-master-ellcc/
    Only in circle-master-ellcc/: .README.md.swp
    diff -u -r circle-master/Rules.mk circle-master-ellcc/Rules.mk
    --- circle-master/Rules.mk      2016-10-15 05:45:58.000000000 -0500
    +++ circle-master-ellcc/Rules.mk        2016-10-29 15:38:38.023205633 -0500
    @@ -24,21 +24,35 @@
     
     -include $(CIRCLEHOME)/Config.mk
     
    -RASPPI ?= 1
    -PREFIX ?= arm-linux-gnueabihf-
    +RASPPI ?= 3
    +ELLCC=~/ellcc
    +PREFIX ?= $(ELLCC)/bin/
    +ELLCCLIBS = $(ELLCC)/libecc/lib/$(TARGET)
     
    -CC     = $(PREFIX)gcc
    -CPP    = $(PREFIX)g++
    +CC     = $(PREFIX)ecc
    +CPP    = $(PREFIX)ecc++
     AS     = $(CC)
    -LD     = $(PREFIX)ld
    -AR     = $(PREFIX)ar
    +LD     = $(PREFIX)ecc-ld $(LDFLAGS)
    +AR     = $(PREFIX)ecc-ar
    +OBJDUMP = $(PREFIX)ecc-objdump
    +OBJCOPY = $(PREFIX)ecc-objcopy
    +CXXFILT = $(PREFIX)ecc-c++filt
     
     ifeq ($(strip $(RASPPI)),1)
    -ARCH   ?= -march=armv6j -mtune=arm1176jzf-s -mfloat-abi=hard 
    +TARGET = arm32v6-linux
    +ARCH   ?= -target $(TARGET) -march=armv6j -mtune=arm1176jzf-s \
    +            -mfloat-abi=soft
    +LDFLAGS = -m armelf_linux_eabi -L $(ELLCCLIBS)
     else ifeq ($(strip $(RASPPI)),2)
    -ARCH   ?= -march=armv7-a -mtune=cortex-a7 -mfpu=neon-vfpv4 -mfloat-abi=hard
    +TARGET = arm32v6-linux
    +ARCH   ?= -target $(TARGET) -march=armv7-a -mtune=cortex-a7 \
    +           -mfpu=neon-vfpv4 -mfloat-abi=soft
    +LDFLAGS = -m armelf_linux_eabi -L $(ELLCCLIBS)
     else
    -ARCH   ?= -march=armv8-a -mtune=cortex-a53 -mfpu=neon-fp-armv8 -mfloat-abi=hard
    +TARGET = arm64v8-linux
    +ARCH   ?= -target $(TARGET) -march=armv8-a -mtune=cortex-a53 \
    +           -mfpu=neon-fp-armv8 -mfloat-abi=soft
    +LDFLAGS = -m aarch64linux -L $(ELLCCLIBS)
     endif
     
     INCLUDE        += -I $(CIRCLEHOME)/include -I $(CIRCLEHOME)/addon -I $(CIRCLEHOME)/app/lib
    Only in circle-master-ellcc/: .Rules.mk.swp
    diff -u -r circle-master/sample/Rules.mk circle-master-ellcc/sample/Rules.mk
    --- circle-master/sample/Rules.mk       2016-10-15 05:45:58.000000000 -0500
    +++ circle-master-ellcc/sample/Rules.mk 2016-10-29 15:30:40.785993359 -0500
    @@ -27,9 +27,9 @@
     endif
     
     kernel.img: $(OBJS) $(LIBS)
    -       $(LD) -o kernel.elf -Map kernel.map -T $(CIRCLEHOME)/circle.ld $(CIRCLEHOME)/lib/startup.o $(OBJS) $(LIBS)
    -       $(PREFIX)objdump -d kernel.elf | $(PREFIX)c++filt > kernel.lst
    -       $(PREFIX)objcopy kernel.elf -O binary kernel.img
    +       $(LD) -o kernel.elf -Map kernel.map -T $(CIRCLEHOME)/circle.ld $(CIRCLEHOME)/lib/startup.o $(OBJS) $(LIBS) -lcompiler-rt
    +       $(OBJDUMP) -d kernel.elf | $(CXXFILT) > kernel.lst
    +       $(OBJCOPY) kernel.elf -O binary kernel.img
            wc -c kernel.img
     
     include $(CIRCLEHOME)/Rules.mk
    rich@dev:~/circle$ 
    
    #77625

    rich
    Keymaster

    One more thing. Using the standard C and C++ libraries in a bare metal environment like this is not yet implemented. Someday soon, I hope.

    -Rich

    #77626

    Stephan

    Hi Rich,

    wow, thank you for taking the time to build circle yourself! I will reproduce your steps tomorrow and I will test whether the resulting executable runs on my Raspberry Pi Zero.

    A follow up question regarding using the standard the standard C and C++ libraries: I had read your blog posts about ellcc and musl:

    An ARM Bare Metal Hello World Using Musl

    ELLCC and the musl Standard C Library

    That gave me the impression that at least linking with the the standard C and C++ libraries should be possible in a bare metal environment. My main motivation would be to be able to use the STL part of the C++ standard library, and it would be no problem for me if stdio and C++ streams and other system-dependent parts of the standard libraries would simply return error codes.

    Maybe I’m understanding something wrong, but isn’t the ELK system itself a bare metal environment that includes the C and C++ standard libraries?


    Stephan

    #77628

    Stephan

    Hello Rich,

    I’m now trying to build with the flags you suggested, but the -target option does not work for me. For example for the very first file built in the “circle/libs/ directory the following happens (I’m building with RASPI=1 for the Raspberry Pi Zero):

    PS C:\Users\stm\Documents\GitHub\circle\lib> make
    "C:\Users\stm\local\ellcc-x86_64-w64-mingw32-0.1.28\bin\ecc.exe" -target arm32v6-linux -march=armv6j -mtune=arm1176jzf-s -mfloat-abi=soft -DRASPPI=1 -I ../include -I ../addon -I ../app/lib -c -o startup.o startup.S
    ecc.exe: warning: argument unused during compilation: '-march=armv6j'
    ecc.exe: warning: argument unused during compilation: '-mfloat-abi=soft'
    error: unknown target triple 'arm32v6--linux', please use -triple or -arch
    make: *** [startup.o] Fehler 1

    Is this a problem of the older ellcc-x86_64-w64-mingw32-0.1.28 build versus the current ellcc 0.1.33 build on the other platforms?


    Stephan

    #77629

    rich
    Keymaster

    Hi Stephan,

    Yes, that is exactly the problem. After the 0.1.28 version, the config file names were changed, as were the build rules that use them. Unfortunately 0.1.28 was the last successful build of the mingw-w64 tool chain. Something changed in clang or libc++ that causes the clang build to fail. I’ve been trying to figure out what is going wrong, but I haven’t been able to spend a lot of time on it.

    Sorry about that. Maybe you could run the Linux version in a virtual machine until a fix is available?

    -Rich

    #77630

    Stephan

    Hello Rich,

    Sorry about that. Maybe you could run the Linux version in a virtual machine until a fix is available?

    sure, no problem, thanks for clarifying this. So do I understand it correctly that it is not possible at all to build for Raspberry Pi with ellcc-x86_64-w64-mingw32-0.1.28, or would it work with a different target name?

    Do you also have any comment about my follow-up question regarding the standard C and C++ libraries? Should it be possible to use the ELK environment with circle?

    Thank you
    Stephan

    #77632

    Stephan

    Sorry about that. Maybe you could run the Linux version in a virtual machine until a fix is available?

    I was now able to build the circle library and some of the sample applications with ellcc-x86_64-linux-0.1.33 using the compiler and linker flags suggested by you. But so far the sample applications won’t run. Except for a single blink of the on-board LED nothing happens…


    Stephan

Viewing 8 posts - 1 through 8 (of 8 total)

You must be logged in to reply to this topic.