Shop OBEX P1 Docs P2 Docs Learn Events
Cross compiling propeller-load, success and problems. — Parallax Forums

Cross compiling propeller-load, success and problems.

Heater.Heater. Posts: 21,230
edited 2014-07-29 11:20 in Propeller 1
I have been cross-compiling the loader from proogcc for targets such as the MIPS based router boxed running OpenWRT, the Raspberry Pi and Emscripten (I'd really like to see a Chrome App programming a Propeller!).

So far these compiles work although I have not tested the resulting loaders yet.

Here is my procedure:
$ export PATH=$PATH:/home/heater/openwrt/staging_dir/toolchain-mipsel_24kec+dsp_gcc-4.8-linaro_uClibc-0.9.33.2/bin

$ OS=linux CC=mipsel-openwrt-linux-gcc make

There are couple of issues with this:

1) The Makefile contains "CC=gcc" which I have to remove in order to get the cross-compiler used.

2) Without some modifications the build fails with:
binary obj/propeller/p2loader.bin
./bin/linux/bin2c: 1: ./bin/linux/bin2c: Syntax error: "(" unexpected
Makefile:278: recipe for target 'obj/linux/p2loader.c' failed
make: *** [obj/linux/p2loader.c] Error 2

Of course, the ./bin/linux/bin2c has just been built for the MIPS and so does not run.

Currently I get around that by building for x86, copying bin2c to /usr/bin, and removing the $BINDIR from in front of the bin2C commands in the Makefile. Or some variant of that.

No urgency but it would be nice if this worked out of the box.

Comments

  • ersmithersmith Posts: 6,054
    edited 2014-07-28 06:27
    The current trunk has a Makefile with define TOOLCC which is used to build the loader itself (I guess it really should be called CROSSCC or something), whereas the code to run on the original host (like bin2c) gets built with CC. You can look at the top level propgcc Makefile to see how the loader Makefile is invoked for cross compilation. Right now we just have targets for x86 linux -> raspberry pi and x86 linux -> windows, but adding other ones should be easy.
  • Heater.Heater. Posts: 21,230
    edited 2014-07-28 13:13
    eric,

    I'm using the default branch. It already has some changes in it for using the UART's, together with a GPIO on ARM and other SoCs like the Raspi.

    In the top level make file there is:
    $(BUILD)/loader/loader-built:   $(BUILD)/loader/loader-created
            @$(ECHO) Building propeller-load
            @$(MAKE) -C loader TARGET=$(PREFIX) BUILDROOT=$(BUILD)/loader TOOLCC=$(CROSSCC)
    
    I take that as meaning that in the loader directory I can do:
    $ OS=linux TOOLCC=/home/heater/openwrt/staging_dir/toolchain-mipsel_24kec+dsp_gcc-4.8-linaro_uClibc-0.9.33.2/bin/mipsel-openwrt-linux-gcc make
    
    However that produces a x86 loader executable not a MIPS one.

    In the loader Makefile we have:
    CC=gcc
    TOOLCC=$(CC)
    
    So I don't see how my build can ever work out of the box.
  • ersmithersmith Posts: 6,054
    edited 2014-07-29 08:17
    I'm pretty sure that if you do:
    make CC=foo
    
    this will override any definition of CC in the Makefile. Note that this is *not* equivalent to
    CC=foo make
    
    which puts the definition of CC in the environment rather than on the make command line; I'm not sure what the precedence is for environment variables, but it may well be lower than Makefile defines.
  • Heater.Heater. Posts: 21,230
    edited 2014-07-29 11:20
    eric,

    Brilliant! That is just the little make detail I needed.

    $ make OS=linux TOOLCC=mipsel-openwrt-linux-uclibc-gcc

    Does indeed create a MIPS executable.

    It is possible I did once get confused because we end up with a bin directory with both x86 and MIPS binaries in it:
    $ file bin/linux/*
    bin/linux/bin2c:                    ELF 64-bit LSB executable, x86-64, version 1 (SYSV), dynamically linked (uses shared libs), for GNU/Linux 2.6.32, BuildID[sha1]=08c763e3dba64cf68603904b376c71356a26af8b, not stripped
    bin/linux/dir-created:              empty
    bin/linux/propeller-elf-image-size: ELF 32-bit LSB executable, MIPS, MIPS32 rel2 version 1, dynamically linked (uses shared libs), not stripped
    bin/linux/propeller-load:           ELF 32-bit LSB executable, MIPS, MIPS32 rel2 version 1, dynamically linked (uses shared libs), not stripped
    
    Never mind all is good now.
Sign In or Register to comment.