ch35_38x_linux 驱动编译

内核及驱动 内核及驱动 1907 人阅读 | 9 人回复 | 2021-10-15

本帖最后由 zytc 于 2021-10-15 10:16 编辑

各位好,我在编译 ch384 的驱动时遇到了函数没有定义的问题。
  CC [M]  /root/ch35_38x_linux/driver/wch_serial.o
/root/ch35_38x_linux/driver/wch_serial.c: In function 'ser_ioctl':
/root/ch35_38x_linux/driver/wch_serial.c:1618:7: error: implicit declaration of function 'kernel_termios_to_user_termios_1'; did you mean 'kernel_termios_to_user_termios'? [-Werror=implicit-function-declaration]
   if (kernel_termios_to_user_termios_1((struct termios __user *)arg, &kterm))
       ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
       kernel_termios_to_user_termios

报错原因是 kernel_termios_to_user_termios_1 这个函数在arch/sw_64/include/asm/termios.h 下没有定义。
root@user-gui:~/linux-4.19.90-uos/arch#  grep -r kernel_termios_to_user_termios_1 .
./sparc/include/asm/termios.h:#define kernel_termios_to_user_termios_1(u, k) \
./ia64/include/asm/termios.h:#define kernel_termios_to_user_termios_1(u, k) copy_to_user(u, k, sizeof(struct termios))
./alpha/include/asm/termios.h:#define kernel_termios_to_user_termios_1(u, k) \
./mips/include/asm/termios.h:static inline int kernel_termios_to_user_termios_1(struct termios __user *u,
./parisc/include/asm/termios.h:#define kernel_termios_to_user_termios_1(u, k) copy_to_user(u, k, sizeof(struct termios))

之后我把 ./alpha/include/asm/termios.h 下的相关定义放到了 arch/sw_64/include/asm/termios.h 下
#define user_termios_to_kernel_termios_1(k, u) \
        copy_from_user(k, u, sizeof(struct termios))

#define kernel_termios_to_user_termios_1(u, k) \
        copy_to_user(u, k, sizeof(struct termios))

编译能通过,但是只要一加载驱动,整个系统就会挂掉,请问能这样改吗?如果不能我该怎么办呢



回复

使用道具 举报

回答|共 9 个

zytc

发表于 2021-10-15 10:15:48 | 显示全部楼层

本帖最后由 zytc 于 2021-10-18 09:42 编辑

驱动代码在 https://github.com/WCHSoftGroup/ch35_38x_linux.git
回复

使用道具 举报

cuiwei

发表于 2021-10-18 11:17:06 | 显示全部楼层

如果不是upstream内核里自带的Driver,可能需要驱动移植适配,Linux Kernel内部的API变化很快。可以把这个Driver再同版本的X86机器上测测看,如果是一样的现象,则说明驱动本身需要适配;如果X86无问题,可再反馈。
回复

使用道具 举报

zytc

发表于 2021-10-18 11:33:09 | 显示全部楼层

x86、飞腾 都可以用的
回复

使用道具 举报

zytc

发表于 2021-10-18 14:08:42 | 显示全部楼层

在飞腾平台的uos上编译、运行是没问题的
回复

使用道具 举报

zytc

发表于 2021-10-18 17:12:42 | 显示全部楼层

我们按照驱动厂家的建议,修改了驱动,现在能编译通过了。
但加载驱动模块时会造成操作系统挂掉,printk调试后发现总在如图光标所示位置出错,很奇怪这里怎么会出错

本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有帐号?立即注册

x
回复

使用道具 举报

zytc

发表于 2021-10-18 17:34:26 | 显示全部楼层

驱动厂家最后的回复是“应该是这个系统不支持PCIe的IO端口访问,访问到了非法地址导致系统出错”,请问申威内核支持PCIe的IO端口访问吗
回复

使用道具 举报

cuiwei

发表于 2021-10-19 17:26:51 | 显示全部楼层

zytc 发表于 2021-10-18 17:34
驱动厂家最后的回复是“应该是这个系统不支持PCIe的IO端口访问,访问到了非法地址导致系统出错”,请问申威 ...

支持的。
回复

使用道具 举报

zytc

发表于 2021-10-20 12:12:02 | 显示全部楼层

还请指导下接下来我们要调试驱动呢,还是内核呢?具体该怎么调试呢?
回复

使用道具 举报

TecSupport

发表于 2022-5-16 10:07:31 | 显示全部楼层

zytc 发表于 2021-10-20 12:12
还请指导下接下来我们要调试驱动呢,还是内核呢?具体该怎么调试呢?

【提示:论坛功能管控受限,建议您移步“申威社区-助力申威-问题反馈”反馈问题,谢谢】
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则