-
Notifications
You must be signed in to change notification settings - Fork 117
Raspberry Pi Cross Build
Supported host Platforms:
- Raspberry Pi
- Windows
- Linux
- macOS
Environment Variables:
- USE_TOOLCHAIN: unset/empty, clang path, or simply clang(on macOS, it's xcode'c clang)
- SYSROOT
Download toolchains and sysroot
- http://gnutoolchains.com/raspberry/ (windows, sysroot included)
- http://www.jaredwolff.com/toolchains/ (macOS gcc 5.2.0)
- https://github.com/pretyman/raspberrypi2-mac-crosscompiler (macOS gcc4.9.2)
- https://github.com/raspberrypi/tools/tree/master/arm-bcm2708 (linux)
The default gcc is arm-linux-gnueabihf-gcc, sysroot is gcc sysroot. Set PATH
to include gcc dir export PATH=$GCC_BIN_DIR:$PATH
. Run ./avbuild.sh rpi ["arch1 arch2..."]
or CROSS_PREFIX=gcc_prefix SYSROOT=your_sysroot ./avbuild.sh rpi ["arch1 arch2..."]
. arch*
can be armv6, armv7 and armv8
Cross build using clang supports all host platforms, i.e. you can build on windows, linux, macOS for pi.
Requirements:
Ubuntu install: apt install clang-8 lld-8 # latest release. WARNING:lld-9 and later may result in invalid executable on armv6, maybe it's an lld bug
Homebrew install(for Apple clang + lld build): brew install llvm
If lld is found, gcc cross toolchain and CROSS_PREFIX
is not required. You can build on any host such as windows, linux and macOS
If lld is not found, gcc cross toolchain is required to invoke binutils such as strip, ld.
Examples:
- opensource clang + gcc binutils:
CROSS_PREFIX=gcc_prefix SYSROOT=your_sysroot ./avbuild.sh rpi armv6-clang-8
- system clang(apple on mac) + lld:
SYSROOT=your_sysroot ./avbuild.sh rpi armv7-clang