How to cross-compile Linux applications and kernel for embedded ARM targets?

Q: How to cross-compile Linux applications and kernel for embedded ARM targets?

Answer

Use a cross-compiler: for ARM64 (aarch64): aarch64-linux-gnu-gcc; for ARM32 (armv7): arm-linux-gnueabihf-gcc. Set CROSS_COMPILE=… and ARCH=arm64 in make commands. Build kernel: make ARCH=arm64 CROSS_COMPILE=aarch64-linux-gnu- defconfig then make ARCH=arm64 CROSS_COMPILE=aarch64-linux-gnu- -j$(nproc) Image dtbs. For Buildroot: add a new package with Config.in and .mk run make -dirclean . Use ccache for faster rebuilds. For Qt cross-compilation install Qt embedded with -sysroot and -device . For IDE support use CMake with toolchain file specifying CMAKE_C_COMPILER and CMAKE_SYSROOT. Test the binary on target with file command to confirm architecture. Debug with gdbserver on target then aarch64-linux-gnu-gdb with target remote :1234.

Filed under: FAQ

Leave a Reply

Your email address will not be published. Required fields are marked *