前言
ftvusbnet是USB_over_Network系列工具在linux下的client端,源码可以从fabulatech官方获取,也可以点我下载ftvusbnet-6.0.21
截至6.0.21版本,ftvusbnet的驱动程序fthc
在ubuntu22_x86_64上编译时会出现以下错误
$ make
make -C /lib/modules/`uname -r`/build M=`pwd` modules
make[1]: Entering directory '/usr/src/linux-headers-5.15.0-56-generic'
CC [M] /home/lmtao/ftvusbnet/module/fthc/main.o
CC [M] /home/lmtao/ftvusbnet/module/fthc/hcd.o
/home/lmtao/ftvusbnet/module/fthc/hcd.c: In function ‘fthc_get_frame’:
/home/lmtao/ftvusbnet/module/fthc/hcd.c:555:24: error: storage size of ‘tv’ isn’ t known
555 | struct timeval tv;
| ^~
/home/lmtao/ftvusbnet/module/fthc/hcd.c:556:9: error: implicit declaration of fu nction ‘do_gettimeofday’; did you mean ‘do_settimeofday64’? [-Werror=implicit-fu nction-declaration]
556 | do_gettimeofday(&tv);
| ^~~~~~~~~~~~~~~
| do_settimeofday64
/home/lmtao/ftvusbnet/module/fthc/hcd.c:555:24: warning: unused variable ‘tv’ [- Wunused-variable]
555 | struct timeval tv;
| ^~
/home/lmtao/ftvusbnet/module/fthc/hcd.c:558:1: error: control reaches end of non -void function [-Werror=return-type]
558 | }
| ^
cc1: some warnings being treated as errors
make[2]: *** [scripts/Makefile.build:297: /home/lmtao/ftvusbnet/module/fthc/hcd. o] Error 1
make[1]: *** [Makefile:1903: /home/lmtao/ftvusbnet/module/fthc] Error 2
make[1]: Leaving directory '/usr/src/linux-headers-5.15.0-56-generic'
make: *** [Makefile:23: all] Error 2
解决方法
这是由于linux5.0以上版本的内核头文件中已经废弃了do_gettimeofday
函数,需要将该函数修改为ktime_get_ts64
函数,打开fthc.c
文件,找到fthc_get_frame
函数,改为以下代码。
static int fthc_get_frame(struct usb_hcd *hcd) {
struct timespec64 tv; // struct timeval tv;
ktime_get_ts64(&tv); // do_gettimeofday(&tv);
return tv.tv_sec; // return tv.tv_usec / 1000;
}
保存,编译,完事~