RK3506移植FT6336U触摸驱动
最近使用万象奥科的RK3506G核心板开发一个小项目用到了蒲洋的一块触摸屏驱动芯片为FT6336U记录一下移植过程踩的坑kernel 板级配置文件kernel/device/rockchip/rk3506/rockchip_rk3506_g_evm_nand_defconfigkernel 默认配置文件/kernel-6.1/arch/arm/configs/vanxoak_hd_rk3506g_evm_nand_defconfig设备树文件/kernel-6.1/arch/arm/boot/dts/vanxoak-hd-rk3506g-evm-nand-v1.dts一、内核配置修改内核配置有2种方式图形化配置进入到kernel根目录通过命令make archarm vanxoak_hd_rk3506g_evm_nand_defconfig即可加载默认配置文件修改。修改配置文件在kernel/arch/arm/configs文件夹下找到vanxoak_hd_rk3506g_evm_nand_defconfig文件添加CONFIG_TOUCHSCREEN_FTSy即可。由于是刚接触对Linux SDK编译的原理不甚了解此处厂家提供SDK使用了分段配置RK_KERNEL_CFGvanxoak_hd_rk3506g_evm_nand_defconfigRK_KERNEL_CFG_FRAGMENTSrk3506-display.config rk3506-usb-otg.config在执行编译时后面的配置文件会覆盖上一段文件最后合并生成.config最终是使用.config来编译文件所以上述只改了一处配置文件在rk3506-display.config文件中有一条设置# CONFIG_TOUCHSCREEN_FT5726 is not set# CONFIG_TOUCHSCREEN_FTS is not set# CONFIG_TOUCHSCREEN_FUJITSU is not set需要将CONFIG_TOUCHSCREEN_FTS is not set删掉否则会覆盖前面的配置。二、修改设备树根据原理图在板级设备树文件中新增或修改I2C节点代码如下i2c2{statusokay;pinctrl-0rm_io4_i2c2_sclrm_io5_i2c2_sda;myts38{statusokay;compatiblefocaltech,fts;reg0x38;max-x480;max-y800;//interruptsRK_PB1 IRQ_TYPE_LEVEL_LOW;// 指定中断号和触发方式 focaltech,irq-gpiogpio0 RK_PB1 IRQ_TYPE_LEVEL_LOW;// 指定中断号和触发方式 focaltech,reset-gpiogpio1 RK_PD2 GPIO_ACTIVE_HIGH;focaltech,max-touch-number5;};其中compatible focaltech,fts;是与/kernel/drivers/input/touchscreen/focaltech_touch/focaltech_core.c中的匹配列表一致。static struct of_device_id fts_match_table[]{{.compatiblefocaltech,fts,},{},};三、内核编译SDK根目录下执行./build.sh kernel编译时会报错make[6]: ***[scripts/Makefile.build:250drivers/input/touchscreen/focaltech_touch/focaltech_core.o]错误1make[6]: *** 正在等待未完成的任务....drivers/input/touchscreen/focaltech_touch/focaltech_flash.c: 在函数‘fts_read_file’中: drivers/input/touchscreen/focaltech_touch/focaltech_flash.c:1076:5: 错误 未知的类型名‘mm_segment_t’1076|mm_segment_t old_fs;|^~~~~~~~~~~~ drivers/input/touchscreen/focaltech_touch/focaltech_flash.c:1106:14: 错误 implicit declaration offunction‘get_fs’;did you mean ‘sget_fc’?[-Werrorimplicit-function-declaration]1106|old_fsget_fs();|^~~~~~|sget_fc drivers/input/touchscreen/focaltech_touch/focaltech_flash.c:1107:5: 错误 implicit declaration offunction‘set_fs’;did you mean ‘sget_fc’?[-Werrorimplicit-function-declaration]1107|set_fs(KERNEL_DS);|^~~~~~|sget_fc drivers/input/touchscreen/focaltech_touch/focaltech_flash.c:1107:12: 错误 ‘KERNEL_DS’ undeclared(first useinthisfunction);did you mean ‘KERNFS_NS’?1107|set_fs(KERNEL_DS);|^~~~~~~~~|KERNFS_NS drivers/input/touchscreen/focaltech_touch/focaltech_flash.c:1107:12: 附注 每个未声明的标识符在其出现的函数内只报告一次 cc1所有的警告都被当作是错误 make[6]: ***[scripts/Makefile.build:250drivers/input/touchscreen/focaltech_touch/focaltech_flash.o]错误1make[5]: ***[scripts/Makefile.build:503drivers/input/touchscreen/focaltech_touch]错误2make[4]: ***[scripts/Makefile.build:503drivers/input/touchscreen]错误2make[3]: ***[scripts/Makefile.build:503drivers/input]错误2make[3]: *** 正在等待未完成的任务....make[2]: ***[scripts/Makefile.build:503drivers]错误2make[1]: ***[Makefile:2009.]错误2make: ***[arch/arm/Makefile:344: vanxoak-hd-rk3506g-evm-nand-v1.img]Error2make: Leaving directory/home/zts/rk3506_linux6.1_sdk_v1.2.0/kernel-6.1ERROR: Running /home/zts/rk3506_linux6.1_sdk_v1.2.0/device/rockchip/common/build-hooks/10-kernel.sh - run_command failed!ERROR:exitcode2from line36:$ERROR: call stack: build-helper: run_command(36)10-kernel.sh: do_build(79)10-kernel.sh: build_hook(438)build-helper: try_func(63)build-helper: try_hook(96)build-helper: source(165)10-kernel.sh: main(490)ERROR: Running /home/zts/rk3506_linux6.1_sdk_v1.2.0/device/rockchip/common/build-hooks/10-kernel.sh - try_func build_hook kernel failed!ERROR:exitcode2from line67: build_hook ERROR: call stack: build-helper: try_func(67)build-helper: try_hook(96)build-helper: source(165)10-kernel.sh: main(490)Deepseek给的解释是API 过时focaltech_flash.c使用了 Linux 6.x 中已移除的mm_segment_t、get_fs、set_fs、KERNEL_DS等内核接口。修改/kernel/drivers/input/touchscreen/focaltech_touch/makefile将focaltech_flash.o注释即可。obj-$(CONFIG_TOUCHSCREEN_FTS)focaltech-ts.o focaltech-ts-yfocaltech_core.o focaltech-ts-yfocaltech_ex_fun.o focaltech-ts-yfocaltech_ex_mode.o#focaltech-ts-y focaltech_flash.ofocaltech-ts-yfocaltech_gesture.o focaltech-ts-yfocaltech_esdcheck.o focaltech-ts-yfocaltech_i2c.o focaltech-ts-yfocaltech_point_report_check.o focaltech-ts-yfocaltech_upgrade_ft8201.o#focaltech-ts-y focaltech_test/另外还要将focaltech_test/注释否则也会报错ake[2]: ***[scripts/Makefile.vmlinux_o:61vmlinux.o]错误1make[1]: ***[Makefile:1231vmlinux_o]错误2make: ***[arch/arm/Makefile:344: vanxoak-hd-rk3506g-evm-nand-v1.img]Error2make: Leaving directory/home/zts/rk3506_linux6.1_sdk_v1.2.0/kernel-6.1ERROR: Running /home/zts/rk3506_linux6.1_sdk_v1.2.0/device/rockchip/common/build-hooks/10-kernel.sh - run_command failed!ERROR:exitcode2from line36:$ERROR: call stack: build-helper: run_command(36)10-kernel.sh: do_build(79)10-kernel.sh: build_hook(438)build-helper: try_func(63)build-helper: try_hook(96)build-helper: source(165)10-kernel.sh: main(490)ERROR: Running /home/zts/rk3506_linux6.1_sdk_v1.2.0/device/rockchip/common/build-hooks/10-kernel.sh - try_func build_hook kernel failed!ERROR:exitcode2from line67: build_hook ERROR: call stack: build-helper: try_func(67)build-helper: try_hook(96)build-helper: source(165)10-kernel.sh: main(490)大概意思是接器提示focaltech_test不是一个有效的对象文件。这通常意味着驱动目录下有一个名为focaltech_test的文件可能是编译生成的临时文件、空文件或残留的源文件导致Makefile将其作为对象文件包含进来但链接时发现它无效。四、烧录测试将编译生成的boot文件烧录至开发板移植完成。