Skip to content

Raspberry Pi Cross Build

WangBin edited this page Mar 19, 2020 · 9 revisions

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

GCC

Download toolchains and sysroot

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

Clang

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