これは何?
Ubuntu18.04でPEX-361316を利用したい。
いくつかモジュールを組み込む必要があるが、カーネルが新しいため、ビルドが必要。ビルドを通す際の記録。
いくつかビルドを通す必要があるが、長くなるため、gpg3300のみを取り上げます。
ビルドを通すまで
da_drventry.c
...
MODULE_AUTHOR("Interface Corporation <http://www.interface.co.jp>");
MODULE_LICENSE("GPL"); // 追加( 追加の必要性/危険性等は、 https://qiita.com/ProjectM_TACCMI/items/7360b26d70cc2c866efb#%E3%83%AD%E3%83%BC%E3%83%89 にあります。 )
...
extern long gpg_interruptible_sleep_on_timeout(void *q, long timeout);
/* 加えて、interruptible_sleep_on_timeout を gpg_interruptible_sleep_on_timeout に名称変更(4箇所) */
...
static void gpg_timer_fn(struct timer_list *t)
{
return;
}
void gpg_da_init_timer(void *ext)
{
PDA_EXTERNAL_STRUCT pExt = (PDA_EXTERNAL_STRUCT)ext;
//init_timer(&(pExt->timer));
timer_setup((struct timer_list *)(&(pExt->timer)), gpg_timer_fn, 0); // 追加
}
...
void gpg_da_add_timer(void *ext, void *function, unsigned long data, unsigned long expires)
{
PDA_EXTERNAL_STRUCT pExt = (PDA_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));
}
...
int gpg_da_MINOR_f(void *file)
{
//return MINOR(((struct file *)file)->f_dentry->d_inode->i_rdev);
return MINOR(((struct file *)file)->f_path.dentry->d_inode->i_rdev);
}
...
static struct file_operations da_fops = {
# if (LINUX_VERSION_CODE >= VERSION(2,4,0))
//THIS_MODULE, ( 下に置き換え )
.owner = THIS_MODULE,
# endif
...
Makefileを編集。
Makefile
CFILES = da_drventry.c
obj-m += cp3300.o
cp3300-objs := $(CFILES:.c=.o) ../ver26/bocp3300noreg.o
VERBOSE = 0
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 cp3300.ko /lib/modules/$(shell uname -r)/misc
$ ln -s ../../include/fbida.h .
$ make
...
/home/projectm/work/PEX-361316/gpg3300/gpg3300/x86_64/linux/drivers/src/da_drventry.c: In function ‘gpg_da_printk’:
/home/projectm/work/PEX-361316/gpg3300/gpg3300/x86_64/linux/drivers/src/da_drventry.c:1237:1: warning: the frame size of 1056 bytes is larger than 1024 bytes [-Wframe-larger-than=]
}
^
...
WARNING: modpost: missing MODULE_LICENSE() in /home/projectm/work/PEX-361316/gpg3300/gpg3300/x86_64/linux/drivers/src/cp3300.o
see include/linux/module.h for more information
WARNING: could not find /home/projectm/work/PEX-361316/gpg3300/gpg3300/x86_64/linux/drivers/src/../ver26/.bocp3300noreg.o.cmd for /home/projectm/work/PEX-361316/gpg3300/gpg3300/x86_64/linux/drivers/src/../ver26/bocp3300noreg.o
CC /home/projectm/work/PEX-361316/gpg3300/gpg3300/x86_64/linux/drivers/src/cp3300.mod.o
LD [M] /home/projectm/work/PEX-361316/gpg3300/gpg3300/x86_64/linux/drivers/src/cp3300.ko
make[1]: ディレクトリ '/usr/src/linux-headers-5.3.0-26-generic' から出ます
$ sudo make install
cp -f cp3300.ko /lib/modules/5.3.0-26-generic/misc
$
ロード
$ sudo depmod -a
$ sudo modprobe cp3300
$ dmesg
...
[17484.414814] ------------[ cut here ]------------
[17484.414814] Attribute cp3300_version_disp: Invalid permissions 01
[17484.414820] WARNING: CPU: 11 PID: 10563 at /build/linux-hwe-3HpQOB/linux-hwe-5.3.0/fs/sysfs/group.c:60 internal_create_group+0x32d/0x3a0
[17484.414821] Modules linked in: cp3300(OE+) cp3100(POE) dpg0100(OE) dpg0101(PE) rndis_host cdc_ether usbnet mii nls_utf8 isofs uas usb_storage btrfs xor zstd_compress raid6_pq ufs qnx4 hfsplus hfs minix ntfs msdos jfs xfs libcrc32c snd_hda_codec_hdmi snd_hda_codec_realtek snd_hda_codec_generic ledtrig_audio intel_rapl_msr intel_rapl_common x86_pkg_temp_thermal intel_powerclamp sof_pci_dev snd_sof_intel_hda_common snd_sof_intel_hda coretemp snd_sof_intel_byt snd_sof_intel_ipc snd_sof snd_sof_xtensa_dsp snd_soc_skl snd_soc_hdac_hda snd_hda_ext_core snd_soc_skl_ipc kvm snd_soc_sst_ipc irqbypass snd_soc_sst_dsp nls_iso8859_1 snd_soc_acpi_intel_match snd_soc_acpi snd_soc_core snd_compress ac97_bus snd_pcm_dmaengine snd_hda_intel snd_hda_codec crct10dif_pclmul snd_hda_core crc32_pclmul snd_hwdep ghash_clmulni_intel mei_hdcp snd_pcm i915 snd_seq_midi aesni_intel snd_seq_midi_event aes_x86_64 snd_rawmidi crypto_simd cryptd glue_helper snd_seq drm_kms_helper intel_cstate input_leds drm joydev
[17484.414833] snd_seq_device intel_rapl_perf snd_timer eeepc_wmi i2c_algo_bit asus_wmi snd fb_sys_fops wmi_bmof sparse_keymap mxm_wmi syscopyarea mei_me soundcore sysfillrect mei sysimgblt ie31200_edac mac_hid acpi_pad sch_fq_codel parport_pc ppdev lp parport ip_tables x_tables autofs4 hid_generic usbhid hid e1000e ahci libahci wmi video [last unloaded: cp3300]
[17484.414840] CPU: 11 PID: 10563 Comm: modprobe Tainted: P W OE 5.3.0-26-generic #28~18.04.1-Ubuntu
[17484.414840] Hardware name: System manufacturer ROG STRIX Z390-F GAMING/ROG STRIX Z390-F GAMING, BIOS 0224 08/14/2018
[17484.414841] RIP: 0010:internal_create_group+0x32d/0x3a0
[17484.414842] Code: 54 8a 89 4d b4 e8 e3 aa d2 ff 0f 0b 4b 8b 34 ec 8b 4d b4 e9 8b fe ff ff 48 8b 36 48 c7 c7 60 df 54 8a 89 4d b4 e8 c3 aa d2 ff <0f> 0b 49 8b 36 8b 4d b4 e9 bd fd ff ff 4c 89 f7 89 45 c0 e8 3b b9
[17484.414843] RSP: 0018:ffffa59d43867c60 EFLAGS: 00010282
[17484.414843] RAX: 0000000000000000 RBX: ffff926208ea6608 RCX: 0000000000000006
[17484.414843] RDX: 0000000000000007 RSI: 0000000000000082 RDI: ffff92620dad7440
[17484.414844] RBP: ffffa59d43867cb0 R08: 0000000000000558 R09: 0000000000000004
[17484.414844] R10: ffff92609d663628 R11: 0000000000000001 R12: 0000000000000000
[17484.414844] R13: ffffffffc0d70610 R14: ffff92614dbe3390 R15: 0000000000000000
[17484.414845] FS: 00007f3f1fb08540(0000) GS:ffff92620dac0000(0000) knlGS:0000000000000000
[17484.414845] CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033
[17484.414846] CR2: 00007fff85e5bfc8 CR3: 0000000740916003 CR4: 00000000003606e0
[17484.414846] DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000
[17484.414846] DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400
[17484.414847] Call Trace:
[17484.414849] sysfs_create_group+0x13/0x20
[17484.414850] module_param_sysfs_setup+0x85/0xc0
[17484.414852] load_module+0x197e/0x2140
[17484.414853] __do_sys_finit_module+0xfc/0x120
[17484.414854] ? __do_sys_finit_module+0xfc/0x120
[17484.414856] __x64_sys_finit_module+0x1a/0x20
[17484.414857] do_syscall_64+0x5a/0x130
[17484.414858] entry_SYSCALL_64_after_hwframe+0x44/0xa9
[17484.414859] RIP: 0033:0x7f3f1f625839
[17484.414860] Code: 00 f3 c3 66 2e 0f 1f 84 00 00 00 00 00 0f 1f 40 00 48 89 f8 48 89 f7 48 89 d6 48 89 ca 4d 89 c2 4d 89 c8 4c 8b 4c 24 08 0f 05 <48> 3d 01 f0 ff ff 73 01 c3 48 8b 0d 1f f6 2c 00 f7 d8 64 89 01 48
[17484.414860] RSP: 002b:00007fff85e5f228 EFLAGS: 00000246 ORIG_RAX: 0000000000000139
[17484.414861] RAX: ffffffffffffffda RBX: 00005559af133ce0 RCX: 00007f3f1f625839
[17484.414861] RDX: 0000000000000000 RSI: 00005559ad8bcd2e RDI: 0000000000000003
[17484.414861] RBP: 00005559ad8bcd2e R08: 0000000000000000 R09: 0000000000000000
[17484.414861] R10: 0000000000000003 R11: 0000000000000246 R12: 0000000000000000
[17484.414862] R13: 00005559af133ca0 R14: 0000000000040000 R15: 00005559af133ce0
[17484.414862] ---[ end trace 7ec9d28b98d32dbf ]---
[17484.415697] cp3300:Interface Digital-Analog Device Driver (Ver4.62.43.00) loaded.