RPi3カーネルビルド再び...
前回のカーネルビルドから半年近く経ちましたが、Raspberry Pi Zero(未入手)に無線LANアダプタを付けることを想定して、代替的にRPi3でカーネルビルドを行ないました。
ところが、以前書いた手順に従っても上手くいかなかったのでカーネルビルドの新解釈を今回は記そうと思います。
結論
カーネルビルドは --jobs=2(-j2)で行なうべし。
エラーが出る場合は並列化オプションを外すべし。
いきさつ
過去記事の手順を見て、カーネルビルドを進めていったのだけど、make -j4 zImage modules dtbs でerrorとなってしまった。
そこでRaspberry Pi 公式ページにある手順でやってみたのだけどやはり、make -j4 zImage modules dtbs のところで同様のerrorが出た。
エラーログ(クリックして展開)
CC [M] fs/nilfs2/recovery.o
CC [M] fs/nfsd/nfs4state.o
CC [M] fs/nls/nls_cp950.o
CC [M] fs/nls/nls_cp1250.o
CC [M] fs/nls/nls_cp1251.o
CC [M] fs/nilfs2/the_nilfs.o
CC [M] fs/nls/nls_iso8859-1.o
CC [M] fs/nls/nls_iso8859-2.o
CC [M] fs/nls/nls_iso8859-3.o
CC [M] fs/nls/nls_iso8859-4.o
CC [M] fs/nilfs2/segbuf.o
CC [M] fs/nls/nls_iso8859-5.o
CC [M] fs/nls/nls_iso8859-6.o
CC fs/nfs/nfsroot.o
CC [M] fs/nls/nls_iso8859-7.o
CC [M] fs/nilfs2/segment.o
CC [M] fs/nls/nls_cp1255.o
CC [M] fs/nls/nls_iso8859-9.o
CC fs/nfs/sysctl.o
CC [M] fs/nls/nls_iso8859-13.o
CC [M] fs/nls/nls_iso8859-14.o
CC [M] fs/nls/nls_iso8859-15.o
CC [M] fs/nls/nls_koi8-r.o
CC fs/nfs/fscache.o
CC [M] fs/nls/nls_koi8-u.o
CC [M] fs/nls/nls_koi8-ru.o
CC [M] fs/nfsd/nfs4idmap.o
CC [M] fs/nls/nls_utf8.o
LD fs/nls/built-in.o
CC fs/nfs/fscache-index.o
CC [M] fs/nfsd/nfs4acl.o
CC [M] fs/nilfs2/cpfile.o
CC fs/nfs/nfs2super.o
CC fs/nfs/proc.o
CC [M] fs/nfsd/nfs4callback.o
CC [M] fs/nilfs2/sufile.o
CC fs/nfs/nfs2xdr.o
CC fs/notify/fsnotify.o
CC [M] fs/nfsd/nfs4recover.o
CC fs/notify/notification.o
CC [M] fs/nilfs2/ifile.o
CC fs/nfs/nfs3super.o
CC [M] fs/nilfs2/alloc.o
CC fs/notify/group.o
CC fs/nfs/nfs3client.o
LD [M] fs/nfsd/nfsd.o
CC fs/nfs/nfs3proc.o
CC fs/notify/inode_mark.o
CC fs/notify/mark.o
CC [M] fs/nilfs2/gcinode.o
CC [M] fs/nilfs2/ioctl.o
CC fs/notify/vfsmount_mark.o
LD fs/ntfs/built-in.o
CC fs/nfs/nfs3xdr.o
CC [M] fs/ntfs/aops.o
CC fs/notify/fdinfo.o
CC fs/notify/dnotify/dnotify.o
CC [M] fs/nilfs2/sysfs.o
LD fs/notify/dnotify/built-in.o
CC fs/notify/fanotify/fanotify.o
CC fs/nfs/nfs3acl.o
CC fs/notify/fanotify/fanotify_user.o
CC [M] fs/ntfs/attrib.o
LD [M] fs/nilfs2/nilfs2.o
CC fs/notify/inotify/inotify_fsnotify.o
LD fs/notify/fanotify/built-in.o
CC fs/notify/inotify/inotify_user.o
CC fs/nfs/nfs4proc.o
CC [M] fs/ntfs/collate.o
CC fs/nfs/nfs4xdr.o
LD fs/notify/inotify/built-in.o
LD fs/notify/built-in.o
CC fs/nfs/nfs4state.o
CC [M] fs/ntfs/compress.o
fs/nfs/nfs4xdr.c: In function ‘nfs4_xdr_enc_link’:
fs/nfs/nfs4xdr.c:2187:1: internal compiler error: Segmentation fault
}
^
Please submit a full bug report,
with preprocessed source if appropriate.
See <file:///usr/share/doc/gcc-4.9/README.Bugs> for instructions.
CC [M] fs/ntfs/debug.o
CC [M] fs/ntfs/dir.o
LD fs/ocfs2/built-in.o
CC [M] fs/ocfs2/alloc.o
CC [M] fs/ntfs/file.o
CC [M] fs/ntfs/index.o
The bug is not reproducible, so it is likely a hardware or OS problem.
scripts/Makefile.build:258: recipe for target 'fs/nfs/nfs4xdr.o' failed
make[2]: *** [fs/nfs/nfs4xdr.o] Error 1
scripts/Makefile.build:403: recipe for target 'fs/nfs' failed
make[1]: *** [fs/nfs] Error 2
make[1]: *** Waiting for unfinished jobs....
CC [M] fs/ntfs/inode.o
CC [M] fs/ocfs2/aops.o
CC [M] fs/ocfs2/blockcheck.o
CC [M] fs/ntfs/mft.o
CC [M] fs/ocfs2/buffer_head_io.o
CC [M] fs/ntfs/mst.o
CC [M] fs/ocfs2/dcache.o
CC [M] fs/ocfs2/dir.o
CC [M] fs/ntfs/namei.o
CC [M] fs/ocfs2/dlmglue.o
CC [M] fs/ntfs/runlist.o
CC [M] fs/ocfs2/export.o
CC [M] fs/ocfs2/extent_map.o
CC [M] fs/ntfs/super.o
CC [M] fs/ntfs/sysctl.o
CC [M] fs/ocfs2/file.o
CC [M] fs/ocfs2/heartbeat.o
CC [M] fs/ocfs2/inode.o
CC [M] fs/ocfs2/ioctl.o
CC [M] fs/ntfs/unistr.o
CC [M] fs/ntfs/upcase.o
CC [M] fs/ocfs2/journal.o
CC [M] fs/ntfs/bitmap.o
CC [M] fs/ocfs2/localalloc.o
CC [M] fs/ntfs/lcnalloc.o
CC [M] fs/ocfs2/locks.o
CC [M] fs/ocfs2/mmap.o
CC [M] fs/ntfs/logfile.o
CC [M] fs/ocfs2/namei.o
CC [M] fs/ocfs2/refcounttree.o
CC [M] fs/ntfs/quota.o
CC [M] fs/ocfs2/reservations.o
CC [M] fs/ntfs/usnjrnl.o
LD [M] fs/ntfs/ntfs.o
CC [M] fs/ocfs2/move_extents.o
CC [M] fs/ocfs2/resize.o
CC [M] fs/ocfs2/slot_map.o
CC [M] fs/ocfs2/suballoc.o
CC [M] fs/ocfs2/super.o
CC [M] fs/ocfs2/symlink.o
CC [M] fs/ocfs2/sysfile.o
CC [M] fs/ocfs2/uptodate.o
CC [M] fs/ocfs2/quota_local.o
CC [M] fs/ocfs2/quota_global.o
CC [M] fs/ocfs2/xattr.o
CC [M] fs/ocfs2/acl.o
CC [M] fs/ocfs2/stackglue.o
CC [M] fs/ocfs2/stack_o2cb.o
CC [M] fs/ocfs2/stack_user.o
LD fs/ocfs2/cluster/built-in.o
CC [M] fs/ocfs2/cluster/heartbeat.o
CC [M] fs/ocfs2/cluster/masklog.o
LD fs/ocfs2/dlm/built-in.o
CC [M] fs/ocfs2/dlm/dlmdomain.o
fs/ocfs2/dlm/dlmdomain.c: In function ‘dlm_unregister_domain’:
fs/ocfs2/dlm/dlmdomain.c:691:6: internal compiler error: Segmentation fault
void dlm_unregister_domain(struct dlm_ctxt *dlm)
^
Please submit a full bug report,
with preprocessed source if appropriate.
See <file:///usr/share/doc/gcc-4.9/README.Bugs> for instructions.
CC [M] fs/ocfs2/cluster/sys.o
CC [M] fs/ocfs2/cluster/nodemanager.o
fs/ocfs2/xattr.c: In function ‘ocfs2_xattr_set’:
fs/ocfs2/xattr.c:3659:1: internal compiler error: in pre_and_rev_post_order_compute, at cfganal.c:1022
}
^
Please submit a full bug report,
with preprocessed source if appropriate.
See <file:///usr/share/doc/gcc-4.9/README.Bugs> for instructions.
LD fs/ocfs2/dlmfs/built-in.o
CC [M] fs/ocfs2/dlmfs/userdlm.o
CC [M] fs/ocfs2/dlmfs/dlmfs.o
CC [M] fs/ocfs2/cluster/quorum.o
The bug is not reproducible, so it is likely a hardware or OS problem.
scripts/Makefile.build:258: recipe for target 'fs/ocfs2/dlm/dlmdomain.o' failed
make[3]: *** [fs/ocfs2/dlm/dlmdomain.o] Error 1
scripts/Makefile.build:403: recipe for target 'fs/ocfs2/dlm' failed
make[2]: *** [fs/ocfs2/dlm] Error 2
make[2]: *** Waiting for unfinished jobs....
CC [M] fs/ocfs2/cluster/tcp.o
CC [M] fs/ocfs2/cluster/netdebug.o
LD [M] fs/ocfs2/dlmfs/ocfs2_dlmfs.o
LD [M] fs/ocfs2/cluster/ocfs2_nodemanager.o
The bug is not reproducible, so it is likely a hardware or OS problem.
scripts/Makefile.build:258: recipe for target 'fs/ocfs2/xattr.o' failed
make[2]: *** [fs/ocfs2/xattr.o] Error 1
scripts/Makefile.build:403: recipe for target 'fs/ocfs2' failed
make[1]: *** [fs/ocfs2] Error 2
Makefile:961: recipe for target 'fs' failed
make: *** [fs] Error 2
試しに並列化オプションを外してmakeしてみると、時間はかかるが正常に終了する(公式手順)。『それならば、2並列(make -j2)ならどうか?』と思いやってみると、ログは飛び飛びに出力されてきますが並列化しないmakeのログと比較してみると内容は一致していて正常に終了しています。
というわけで、カーネルビルドの手順を以下にまとめます。
手順詳細
- カーネルビルドに必要なパッケージを導入する。
# apt-get update
# apt-get install git bc - 適当なディレクトリを作り、githubからカーネルソースを入手する。
$ mkdir ~/kernel
$ cd ~/kernel
$ git clone --depth=1 https://github.com/raspberrypi/linux - カーネルビルドの準備をする。
$ cd linux
$ KERNEL=kernel7
$ make bcm2709_defconfig - カーネルビルドする。(100分近くかかります)
make -j2 zImage modules dtbs
ログを残して時間計測をしたい場合は次のように書く
time make -j2 zImage modules dtbs 2>&1 | tee make.log - カーネルをインストールする。(以降は前回の記事と同様)
# make modules_install - dtbを書き換える。
# cp -v arch/arm/boot/dts/*.dtb /boot/
# cp -v arch/arm/boot/dts/overlays/*.dtb* /boot/overlays/
# cp -v arch/arm/boot/dts/overlays/README /boot/overlays/ - カーネルイメージを書き換える。
# cp -v /boot/kernel7.img /boot/kernel7.img.old
# scripts/mkknlimg arch/arm/boot/zImage /boot/kernel7.img - 再起動する。
参考Webページ