Tuesday, August 2, 2016

Cross Compiling Linux kernel for ARM

  • Get latest stable kernel source code
     git clone https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git 
    To get kernel-next branch clone
     git clone https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git 
  • Get toolchain, e.g you can download linaro toolchain from Linaro toolchain for arm
  • set your path variable /path/to/linaro/binary/linaro/aarch64-unknown-linux-gnu_4.9-2014.05-01/bin
     export PATH=$PATH:/path/to/linaro/binary/linaro/aarch64-unknown-linux-gnu_4.9-2014.05-01/bin 
  • Setup defconfig file
     make ARCH=arm64 CROSS_COMPILE=aarch64-unknown-linux-gnu- O=output defconfig 
  • Make kernel image
     make ARCH=arm64 CROSS_COMPILE=aarch64-unknown-linux-gnu- O=output -j8 
  • To modify kernel configuration use
  •  make ARCH=arm64 CROSS_COMPILE=aarch64-unknown-linux-gnu- O=output menuconfig 
  • To save your modified defconfig file
     make ARCH=arm64 CROSS_COMPILE=aarch64-unknown-linux-gnu- O=output savedefconfig 
    This will create defconfig file in output directory. Copy this file to your arch/arm64/configs directory

  • No comments:

    Post a Comment