LoginSignup
1
1

More than 3 years have passed since last update.

Ubuntu18.04でdpg0101のビルド

Last updated at Posted at 2020-01-11

これは何?

Ubuntu18.04でPEX-361316を利用したい。
いくつかモジュールを組み込む必要があるが、カーネルが新しいため、ビルドが必要。ビルドを通す際の記録。
いくつかビルドを通す必要があるが、長くなるため、dpg0101のみを取り上げます。

ビルドを通すまで

$ cd ~/work/PEX-361316/common/dpg0101/src

Makefileを編集。

CFLAGS += -I$(INCLUDEDIR)
CFLAGS += -fno-pie # 追加

dpg0101.cを編集。

dpg0101.c
#include <linux/kconfig.h> // 追加
#include <linux/module.h>

makeするとdpg0101.mod.cが生成され、ビルドエラーで止まる。
dpg0101.mod.cを編集。

dpg0101.mod.c
#include <linux/kconfig.h> // 追加
#include <linux/build-salt.h>

ビルドが通る。

$ make
…
ld -m elf_x86_64 -r -o dpg0101.ko dpg0101.o dpg0101.mod.o
$ sudo make install
mkdir -p /lib/modules/5.0.0-37-generic/misc
cp -f dpg0101.ko /lib/modules/5.0.0-37-generic/misc
$

カーネル 5.0.37 から 5.3.26 への対応

カーネルの変化でビルドの通し方がちょっと変わった。
以下以外は5.0.37と同じです。

dpg0101.c
#include <linux/kconfig.h>
typedef long long __kernel_time64_t; // 追加
dpg0101.mod.c
#include <linux/kconfig.h> // 追加( 5.0.37の時も )
typedef long long __kernel_time64_t; // 追加

ロード

$ sudo depmod -a
$ sudo modprobe dpg0101
$ dmesg 
...
[  612.428485] dpg0101: module license 'unspecified' taints kernel.
[  612.428486] Disabling lock debugging due to kernel taint
[  612.428507] dpg0101: module verification failed: signature and/or required key missing - tainting kernel
[  612.429001] dpg0101:Interface Common Device Driver (Ver1.50.06.00) loaded.
$

ワーニングはでるものの、ロードできているようです。

参考ページ

1
1
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
1
1