Skip to content

4. カーネルのビルド

takobozu edited this page Aug 18, 2018 · 2 revisions

準備

gcc

https://releases.linaro.org/components/toolchain/binaries/latest/aarch64-linux-gnu/gcc-linaro-7.3.1-2018.05-x86_64_aarch64-linux-gnu.tar.xz(ダウンロード後展開)

kernel

$ git clone --depth 1 -b sunxi-4.14.y https://github.com/friendlyarm/linux.git

i2s driver source

$ git clone https://github.com/blue777/NanoPi-NEO2-I2S_MCLK

patch

https://mirrors.edge.kernel.org/pub/linux/kernel/projects/rt/4.14/patch-4.14.59-rt37.patch.gz(展開後はpatch-4.14.59-rt37.patch)

https://mirrors.edge.kernel.org/pub/linux/kernel/v4.x/patch-4.14.59.xz(展開後はpatch-4.14.59)

https://mirrors.edge.kernel.org/pub/linux/kernel/v4.x/patch-4.14.52.xz(展開後はpatch-4.14.52)

ビルド

上記のディレクトリ配置を以下のとおりと仮定して話を進める。([]書きはディレクトリ)

[linux] [gcc-linaro-7.3.1-2018.05-x86_64_aarch64-linux-gnu] [NanoPi-NEO2-I2S_MCLK] patch-4.14.59-rt37.patch  patch-4.14.59  patch-4.14.52

上記でとってきたkernel source [linux]はバージョンが4.14.52に上がってしまっているのでこのままでは4.14.59にアップできない。そのため以下のようにする。

$ cd linux

$ patch -p1 -R < ../patch-4.14.52

$ patch -p1 < ../patch-4.14.59(rejファイルが3つできるが無視しても俺のシステムでは問題なし)

$ patch -p1 < ../patch-4.14.59-rt37.patch

[NanoPi-NEO2-I2S_MCLK]-[linux_4.14.0_20171212]にはカーネルソースの中で入れ替えるべきファイルが配置されているので[linux]のファイルと入れ替えていく。

最後の仕上げ

$ cd linux

$ make ARCH=arm64 CROSS_COMPILE=../gcc-linaro-7.3.1-2018.05-x86_64_aarch64-linux-gnu/bin/aarch64-linux-gnu- sunxi_arm64_defconfig

$ make ARCH=arm64 CROSS_COMPILE=../gcc-linaro-7.3.1-2018.05-x86_64_aarch64-linux-gnu/bin/aarch64-linux-gnu- menuconfig

ここでカーネルオプションをいじくる。不要と思われるものは削除したり、必要なものは追加したり。この時点での留意点をあげておく。

General setup --->Timer subsystem ---> Timer tic handling(Full dynticks system(tickless))

これは、cpu1,2,3をtickless動作させるための設定である。

[ ]Enable loadable module support

モジュールを使わないためチェックをはずす。

Kernel Features ---> Preemption Model (Fully Preemptible Kernel(RT))

せっかくrt-patchを当てたのでfull rtで動作させる。

CPU Power Management --->CPU Frequency scaling ---> Default CPUFreq governor (performance)

最高のパフォーマンスで動作させる。後で変更可能だけどね。

Networking support ---> Networking options ---> [*]Network Packet filterling framework(Netfilter)

iptbalesを使ってNATの設定をするのに必要。

Device Drivers ---> [*]Network device support ---> [*]USB Network Adapters ---> [*]Realtek RTL8152/RTL8153 Based USB Ethernet Adapters

usb-etherアダプタのドライバをチェックする。

Sound card support --->[*]Advanced Linux Sound Architecture --->[*]ALSA for SoC audio support ---> Allwinner SoC Audio support --->[*]Allwinner sun8i I2S Support

上記のカーネルの修正をしていれば、Allwinner sun8i I2S Supportがあるはず、これがi2sドライバである。チェックを忘れずに。

Imageとdtbをつくる。

$ make ARCH=arm64 CROSS_COMPILE=../gcc-linaro-7.3.1-2018.05-x86_64_aarch64-linux-gnu/bin/aarch64-linux-gnu- Image dtbs

無事エラーもなく完了すれば

arch/arm64/boot/Image

arch/arm64/boot/dts/allwinner/sun50i-h5-nanopi-neo2.dtb

ができているはず。これが今回のシステムに必要なものの一部である。

Clone this wiki locally