LoginSignup
2
0

More than 5 years have passed since last update.

NanoPi-NEO2用 kernel build (linaro gccで)

Last updated at Posted at 2018-02-04

概要

buildrootを使えば、kernel,rootfilesystem,bootloaderとシステムに必要なものは一気につくることができます。私の場合、kernel modulesを使わないシステムづくりをしていますので、kernelやbootloaderだけは別にツールチェーンを使ってビルドして、buildrootでつくったrootfilesystemと組み合わせる、なんてこともやります。今回は、linaro gccを使ってkernel buildをした手順をメモしておきます。

linaro gccの入手

https://releases.linaro.org/components/toolchain/binaries/latest/aarch64-linux-gnu/
から

gcc-linaro-7.2.1-2017.11-x86_64_aarch64-linux-gnu.tar.xz

をダウンロードして適当なディレクトリに展開しておきます。

kernelの入手

http://wiki.friendlyarm.com/wiki/index.php/Mainline_U-boot_and_Linux
から
NanoPi-NEO2のdownloadリンクをたどり

linux_4.14.0_20171212.tar.gz

をダウンロードして適当なディレクトリに展開しておきます。

patchをあてる

kernelのソースは/home/linux/、patchは/home/patch/にあるものとします。

$ cd ~/linux
$ cat ../patch/patch-4.14.15 | patch -p1
$ cat ../patch/patch-4.14.15-rt13.patch | patch -p1

最適化オプションの設定

パパリウスさんに教えてもらったのですが、kernelに対するNanoPi-NEO2用の最適化オプションの設定はkernelソースのmakefileを直接編集することにより行います。

/linux/Makefileの編集内容

KBUILD_CFLAGS   += -O2 $(call cc-disable-warning,maybe-uninitialized,)
else
KBUILD_CFLAGS   += -O3 -pipe -ftree-vectorize <---追加

endif

/linux/arch/arm64/Makefileの編集内容

KBUILD_CFLAGS   += $(call cc-option,-mabi=lp64)
KBUILD_AFLAGS   += $(call cc-option,-mabi=lp64)
KBUILD_CFLAGS += -march=armv8-a+fp+simd <---追加
KBUILD_CFLAGS += -mtune=cortex-a53    <---追加
KBUILD_CFLAGS += -mcpu=cortex-a53+fp+simd <---追加

makeする

linaro gccは/home/gcc-linaro-7.2.1-2017.11-x86_64_aarch64-linux-gnu/にあるものとします。

$ make sunxi_arm64_defconfig ARCH=arm64 CROSS_COMPILE=/home/gcc-linaro-7.2.1-2017.11-x86_64_aarch64-linux-gnu/bin/aarch64-linux-gnu-
$ make menuconfig ARCH=arm64 CROSS_COMPILE=/home/gcc-linaro-7.2.1-2017.11-x86_64_aarch-linux-gnu/bin/aarch64-linux-gnu-
$ make ARCH=arm64 CROSS_COMPILE=/home/gcc-linaro-7.2.1-2017.11-x86_64_aarch-linux-gnu/bin/aarch64-linux-gnu- Image dtbs -j4
2
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
0