目次: Linux
独自のカーネルモジュールをビルドしたかったのですがスマートな方法が良く分からず、力ずくでやってしまいました。
まずaptでLinuxのソースコードを持ってきました。apt-get installだけだと /usr/srcにtarballが置かれるだけなので、手で展開します。
# apt-get install linux-source-3.16 Reading package lists... Done Building dependency tree Reading state information... Done Suggested packages: libqt4-dev pkg-config The following NEW packages will be installed: linux-source-3.16 0 upgraded, 1 newly installed, 0 to remove and 0 not upgraded. Need to get 0 B/83.6 MB of archives. After this operation, 83.7 MB of additional disk space will be used. Selecting previously unselected package linux-source-3.16. (Reading database ... 54876 files and directories currently installed.) Preparing to unpack .../linux-source-3.16_3.16.7-ckt25-2_all.deb ... Unpacking linux-source-3.16 (3.16.7-ckt25-2) ... Setting up linux-source-3.16 (3.16.7-ckt25-2) ... # cd /usr/src # ls linux-config-3.16 linux-source-3.16.tar.xz # tar xf linux-source-3.16.tar.xz # ln -s linux-source-3.16 linux
カーネルバージョンを見るか、Debianのカーネルパッケージのバージョンを確認して、適切なカーネルのconfigファイルを展開します。
# cd /usr/src # uname -a Linux vbox-blackbird 3.16.0-4-amd64 #1 SMP Debian 3.16.7-ckt25-2 (2016-04-08) x86_64 GNU/Linux # cp linux-config-3.16/config.amd64_none_amd64.xz linux/ # cd /usr/src/linux # xz -d config.amd64_none_amd64.xz # mv config.amd64_none_amd64 .config
ビルドします。Debianのカーネルコンフィグはやたらめったらドライバをビルドするので、かなりビルドに時間が掛かります…。
# cd /usr/src/linux # make -j 4 bzImage modules ...
ビルドが終わったら、独自カーネルモジュールをビルドします。
# cd /home/username/hoge_module # make ...
生成された*.koをinsmodして文句言われなければ成功です。
# insmod hoge.ko insmod: ERROR: could not insert module hoge.ko: Invalid module format
こんな風に怒られる時は、昔のバージョンのtarballを展開したときのコードが残っているなど、カーネルのソースコードが古いか、コンフィグを選び間違っていますので、確認しましょう…。
この記事にコメントする
| < | 2016 | > | ||||
| << | < | 04 | > | >> | ||
| 日 | 月 | 火 | 水 | 木 | 金 | 土 |
| - | - | - | - | - | 1 | 2 |
| 3 | 4 | 5 | 6 | 7 | 8 | 9 |
| 10 | 11 | 12 | 13 | 14 | 15 | 16 |
| 17 | 18 | 19 | 20 | 21 | 22 | 23 |
| 24 | 25 | 26 | 27 | 28 | 29 | 30 |
23年5月15日
26年7月22日
26年7月14日
26年7月19日
21年12月28日
26年7月13日
23年6月1日
23年9月11日
25年1月31日
26年7月11日
24年2月7日
26年6月27日
26年7月3日
26年7月1日
26年6月26日
20年2月22日
26年6月18日
26年6月23日
26年6月11日
26年4月29日
wiki
Linux JM
Java API
2002年
2003年
2004年
2005年
2006年
2007年
2008年
2009年
2010年
2011年
2012年
2013年
2014年
2015年
2016年
2017年
2018年
2019年
2020年
2021年
2022年
2023年
2024年
2025年
2026年
過去日記について
アクセス統計
サーバ一覧
サイトの情報合計:
本日: