嵌入式爱好者

查看: 1339|回复: 2

[Linux] OK3568添加PCIE驱动

[复制链接]

3

主题

8

帖子

30

积分

A40i/T3/T507/T527通行证i.MX6UL通行证RK3568通行证

扫一扫,手机访问本帖
发表于 2024-5-29 17:04:34 | 显示全部楼层 |阅读模式
硬件环境OK3568核心板
软件环境Linux5.10
编译环境乌班图 飞凌提供的版本
需求:his driver supports pci to uart chips ch351/ch352/ch353/ch355/ch356/ch357/ch358/ch359, pcie to uart chips ch382/ch384. In fact most chip types above were supported by 8250_pci and parport_serial driver, you can type "dmesg | grep ttyS" to find related tty devices.
When use this vendor driver, the tty devices are named "ttyWCH*". We suggest our customers use this driver cause it supports almost all advanced features.

芯片厂安装指导:
1、Open "Terminal"
2、Type "sudo sh install.sh" to make the driver work permanently
3、Type "sudo sh uninstall.sh" to remove the driver
4、You can refer to the link below to acquire uart application, you can use gcc or Cross-compile with cross-gcc https://github.com/WCHSoftGroup/tty_uart


复制驱动包 “ch35_38x_linux-main”到/home/forlinx/3568/OK3568_Linux_fs/kernel/drivers/
进 “ch35_38x_linux-main”目录      You can modify the uart amount variable "PCIE_UART_MAX" defined in wch_devtable.c at about line 3, modify the number 28 to the actual amount of serial ports. 修改PCIE_UART_MAX 为你实际的串口数量。核对晶振频率 #define CRYSTAL_FREQ 22118400与你实际的值相符。

编辑makefile文件:
原文件为:
DRIVERNAME := wch
all : modules

ifneq ($(KERNELRELEASE),)
obj-m += $(DRIVERNAME).o
$(DRIVERNAME)-y := wch_devtable.o wch_serial.o wch_main.o
else
KERNELDIR := /lib/modules/$(shell uname -r)/build
PWD        := $(shell pwd)

modules:
        $(MAKE) -C $(KERNELDIR) M=$(PWD) modules

clean:
        rm -rf *.mk .tmp_versions Module.symvers *.mod* *.o *.ko .wch* Module.markers modules.order .*.cmd
load:
        insmod $(DRIVERNAME).ko
unload:
        rmmod $(DRIVERNAME)
install : modules
        insmod $(DRIVERNAME).ko || true
        mkdir -p /lib/modules/$(shell uname -r)/kernel/drivers/tty/serial || true
        cp -f ./$(DRIVERNAME).ko /lib/modules/$(shell uname -r)/kernel/drivers/tty/serial || true
        echo "wch\n" >> /etc/modules || true
        depmod -a
uninstall:
        rmmod $(DRIVERNAME) || true
        rm -f /lib/modules/$(shell uname -r)/kernel/drivers/tty/serial/$(DRIVERNAME).ko || true
        rm -f /lib/modules/$(shell uname -r)/kernel/drivers/char/$(DRIVERNAME).ko || true
        rm -f /lib/modules/$(shell uname -r)/misc/$(DRIVERNAME).ko || true
        depmod -a
endif


显然这里的路径与我实际的路径不符,怎么修改还是一头雾水,我认为是应该修改为与我环境相符合的路径,例如/OK3568_Linux_fs/kernel/drivers/,针对目前这个环境请问怎么修改上述文件?






点评

海!外直播 bitly.net/nnnvv 禁闻视频 bitly.net/iiiif 勃烈日涅夫当上苏共总书记后,将乡下老母接到莫斯科.得意洋洋地向她展示豪华别墅,高级汽车,高档...老太太说:"儿子啊,这一切都很好,但是共产党来了你怎么办?"   发表于 2024-5-30 21:51
回复

使用道具 举报

0

主题

2

帖子

8

积分

RK3588通行证

发表于 2024-10-11 15:03:10 | 显示全部楼层
方法1:把KERNELDIR := /lib/modules/$(shell uname -r)/build 改为指向编译过的kernel源码路径
方法2:把代码放到kernel里,随着代码整编
点评回复 支持 反对

使用道具 举报

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

本版积分规则

QQ|小黑屋| 飞凌嵌入式 ( 冀ICP备12004394号-1 )

GMT+8, 2024-12-20 12:52

Powered by Discuz! X3.4

© 2001-2013 Comsenz Inc.

快速回复 返回顶部 返回列表