これは何?
Ubuntu18.04でPEX-361316を利用したい。
いくつかモジュールを組み込む必要があるが、カーネルが新しいため、ビルドが必要。ビルドを通す際の記録。
いくつかビルドを通す必要があるが、長くなるため、gpg6204のみを取り上げます。
ビルドを通すまで
Makefileの編集
Makefile
CFILES = penc_drventry.c
obj-m += cp6204.o
cp6204-objs := $(CFILES:.c=.o) ../ver26/bocp6204noreg.o
KBUILD_EXTRA_SYMBOLS = ~/work/PEX-361316/common/dpg0100/src/Module.symvers
all:
make -C /lib/modules/$(shell uname -r)/build M=$(PWD) modules
clean:
make -C /lib/modules/$(shell uname -r)/build M=$(PWD) clean
install:
cp -f cp6204.ko /lib/modules/$(shell uname -r)/misc
penc_drventry.cの編集
penc_drventry.c
static void gpg_timer_fn(struct timer_list *t)
{
return;
}
void gpg_penc_init_timer(void *ext)
{
PPENC_EXTERNAL_STRUCT pExt = (PPENC_EXTERNAL_STRUCT)ext;
// init_timer(&(pExt->timer));
timer_setup((struct timer_list *)(&(pExt->timer)), gpg_timer_fn, 0); // 追加
}
...
void gpg_penc_add_timer(void *ext, void *function,
unsigned long data, unsigned long expires)
{
PPENC_EXTERNAL_STRUCT pExt = (PPENC_EXTERNAL_STRUCT)ext;
// pExt->timer.function = function;
// pExt->timer.data = data;
timer_setup(&(pExt->timer), function, data); // 追加
pExt->timer.expires = expires;
add_timer(&(pExt->timer));
}
...
long gpg_penc_interruptible_sleep_on_timeout(void *ext, long timeout)
{
PPENC_EXTERNAL_STRUCT pExt = (PPENC_EXTERNAL_STRUCT)ext;
long lret=0;
// lret = interruptible_sleep_on_timeout(&(pExt->wait), timeout);
lret = gpg_interruptible_sleep_on_timeout(&(pExt->wait), timeout);
return lret;
}
...
# if (LINUX_VERSION_CODE >= VERSION(2,6,36))
// static int penc_ioctl(struct file *file, unsigned int iocmd, unsigned long ioarg)
// 戻り値がintからlongに変わっているため、intのままだとエラーになる。
static long penc_ioctl(struct file *file, unsigned int iocmd, unsigned long ioarg)
# else
static int penc_ioctl(struct inode *inode, struct file *file, unsigned int iocmd, unsigned long ioarg)
# endif
{
return gpg_penc_ioctl((void*)file, iocmd, ioarg);
}
いざmake
$ ln ../../../../../common/dpg0100/src/dpg0100.h .
$ ln -s ../../include/fbipenc.h .
$ make
$ sudo make install
cp -f cp6204.ko /lib/modules/5.3.0-26-generic/misc
ロード
$ sudo depmod -a
$ sudo modprobe cp3300
$ dmesg
...
[ 2344.919532] ---[ end trace f91d2f1f146998e4 ]---
[ 2344.919798] pci 0000:05:0c.0: enabling device (0000 -> 0002)
[ 2344.919918] cp6204:Interface 3-Mode Pulse Counter Device Driver (Ver4.10.17.00) loaded.
$