Jump to content

Raspberry Pi

From HW wiki
Revision as of 10:18, 16 October 2014 by Pisa (talk | contribs)

Raspberry Pi Based Projects

* Raspberry Pi minimal components DC motor servo control
* The small robotic arm control with use of Simulink CAN blocks with ERT Linux target

GCC Tool-chain for Cross-Compilation

There are more suggestion of different arm-gnueabihf toolchains variants to use for cross-build of applications for Raspberry Pi platform. But all of them which I have easily found do not correctly match ARMv6 BCM2835 target. The unfortunate selection of arm-linux-gnueabihf as GNU triplet for Raspbian build clashes with official arm-linux-gnueabihf tool-chains which target ARMv7 architecture and produced binaries are less or more incompatible with RPi hardware and GLIBC build.

I have decided to define separate/non-classing GCC architecture arm-rpi-linux-gnueabihf variant and use original Raspbian GLIBC binaries to ensure best compatibility for build tool-chain. The simple approach is to put whole Raspbian root filesystem copy to /usr/arm-rpi-linux-gnueabihf/sys-root. The mosts of the files are not required in fact so reduction to subset of /lib, /lib/arm-linux-gnueabihf, /lib/arm-linux-gnueabihf/libnfsidmap, /lib/arm-linux-gnueabihf/security, /usr/include, /usr/lib, /usr/lib/arm-rpi-linux-gnueabihf is enough. Other option is to use debootstrap with correct parameters to install base Raspbian libraries and development files in /usr/arm-rpi-linux-gnueabihf/sys-root directory. Some symbolic links has to be adapted to point correctly to target files by changing paths to relative. Then libc.so prepared for relative paths and cross-compilation needs to be provided. Create file /usr/arm-rpi-linux-gnueabihf/lib/libc.so with next content

/* GNU ld script
  Use the shared library, but some functions are only in
  the static library, so try that secondarily.  */
OUTPUT_FORMAT(elf32-littlearm)
GROUP ( libc.so.6 libc_nonshared.a  AS_NEEDED ( ld-linux.so.3 ) )

This should be enough for environment for standard binutils and GCC build. binutils-2.24 has been used without any changes. gcc-4.9.1 with statically included gmp-5.1.2, mpc-1.0.1 and mpfr-3.1.2 has been patched by subset of Debian patches

alpha-no-ev4-directive.diff
boehm-gc-getnprocs.diff
note-gnu-stack.diff
gcc-target-include-asm.diff
pr57653.diff
pr61046.diff
pr61336.diff
gcc-setmultilib-fix.diff
pr61841.diff

Then binutils and GCC has been compiled and installed with next configuration

../../../src/gcc-4.9/configure -v \
        --enable-languages=c,c++ \
        --prefix=/usr \
        --with-system-zlib \
        --without-included-gettext \
        --enable-threads=posix \
        --enable-shared \
        --disable-nls \
        --enable-clocale=gnu \
        --enable-objc-gc \
        --enable-mpfr \
        --enable-tls \
        --enable-secureplt \
        --enable-targets=arm-linux-gnu \
        --enable-symvers=gnu \
        --enable-checking=release \
        --build=x86_64-linux-gnu \
        --host=x86_64-linux-gnu \
        --target=arm-rpi-linux-gnueabihf \
        --enable-version-specific-runtime-libs \
        --disable-libgomp \
        --with-headers=/usr/arm-rpi-linux-gnueabihf/sys-include \
        --with-sysroot=/usr/arm-rpi-linux-gnueabihf/sys-root \
        \
        --enable-linker-build-id \
        --enable-libstdcxx-time=yes \
        --enable-gnu-unique-object \
        --enable-plugin \
        --enable-multiarch \
        --disable-sjlj-exceptions \
        --with-arch=armv6 \
        --with-fpu=vfp \
        --with-float=hard

The build binaries for x86_64/amd64 Debian based systems are provided in our DEB tool-chains collection

* http://rtime.felk.cvut.cz/debian/pool/main/b/binutils-2.24/binutils-arm-rpi-linux-gnueabihf_2.24-1_amd64.deb
* http://rtime.felk.cvut.cz/debian/pool/main/g/gcc-4.9.1/gcc-arm-rpi-linux-gnueabihf_4.9.1-1_amd64.deb