xlinkbox 发表于 2024-5-29 17:04:34

OK3568添加PCIE驱动

硬件环境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/,针对目前这个环境请问怎么修改上述文件?






feiyun 发表于 2024-10-11 15:03:10

方法1:把KERNELDIR := /lib/modules/$(shell uname -r)/build 改为指向编译过的kernel源码路径
方法2:把代码放到kernel里,随着代码整编
页: [1]
查看完整版本: OK3568添加PCIE驱动