OpenHarmony 内核鼠标调试 原创 精华

软通动力HOS
发布于 2023-4-3 15:46
浏览
4收藏

1、USB鼠标插入USB2不供电问题解决

1.1、增加IO控制驱动

解压IO控制驱动压缩包io_zhouke.tar.gz
复制压缩包的文件到drivers/char/目录下

tar zxvf io_zhouke.tar.gz
cp io_zhouke/* drivers/char/ -avf

注释:这些文件可以在3.1LTS版本中获取,复制完之后drivers/char目录结构如下:

-rw-rw-r--    1    1000    1000    13K    Dec    13    08:13    id_card.c    io:total 28K-rw-rw-r--       1       1000       1000       44       Jul       12       09:52       Makefile    -rw-rw-r--    1    1000    1000    138    Dec    13    08:02    built-in.a    -rw-rw-r--    1    1000    1000    0    Aug    17    06:41    modules.order    -rw-rw-r--    1    1000    1000    7.9K    Jul    12    09:52    io.c    -rw-rw-r--    1    1000    1000    2.6K    Jul    12    09:52    io.h    -rw-rw-r--    1    1000    1000    2.0K    Jul    12    09:52    io_external.c    -rw-rw-r--    1    1000    1000    4.0K    Jul    12    09:52    io_stub.c    
相应的修改Makefile文件,把驱动编译到内核中
drivers/char/Makefile
# SPDX-License-Identifier: GPL-2.0 #
# Makefile for the kernel character device drivers. #
obj-y  += jy.o
obj-y  += mcu.o
+ obj-y  += io/    //增加此行 obj-y    += mem.o random.o
obj-$(CONFIG_TTY_PRINTK)  += ttyprintk.o obj-y  += misc.o
obj-$(CONFIG_ATARI_DSP56K)  += dsp56k.o
obj-$(CONFIG_VIRTIO_CONSOLE)  += virtio_console.o obj-$(CONFIG_RAW_DRIVER)  += raw.o
obj-$(CONFIG_MSPEC)  += mspec.o
obj-$(CONFIG_UV_MMTIMER)  += uv_mmtimer.o obj-$(CONFIG_IBM_BSR)  += bsr.o
obj-$(CONFIG_PRINTER)  += lp.o
obj-$(CONFIG_APM_EMULATION)  += apm-emulation.o obj-$(CONFIG_DTLK)  += dtlk.o
obj-$(CONFIG_APPLICOM)  += applicom.o
obj-$(CONFIG_SONYPI)  += sonypi.o
obj-$(CONFIG_HPET)  += hpet.o
obj-$(CONFIG_XILINX_HWICAP)  += xilinx_hwicap/ obj-$(CONFIG_NVRAM)  += nvram.o
obj-$(CONFIG_TOSHIBA)  += toshiba.o
obj-$(CONFIG_DS1620)  += ds1620.o
obj-$(CONFIG_HW_RANDOM)  += hw_random/ obj-$(CONFIG_PPDEV)  += ppdev.o
obj-$(CONFIG_NWBUTTON)  += nwbutton.o
obj-$(CONFIG_NWFLASH)  += nwflash.o
obj-$(CONFIG_SCx200_GPIO)  += scx200_gpio.o obj-$(CONFIG_PC8736x_GPIO)  += pc8736x_gpio.o obj-$(CONFIG_NSC_GPIO)  += nsc_gpio.o
obj-$(CONFIG_GPIO_TB0219)  += tb0219.o
obj-$(CONFIG_TELCLOCK)  += tlclk.o
obj-$(CONFIG_MWAVE)  += mwave/
obj-y  += agp/
obj-$(CONFIG_PCMCIA)  += pcmcia/
obj-$(CONFIG_HANGCHECK_TIMER)  += hangcheck-timer.o obj-$(CONFIG_TCG_TPM)  += tpm/
obj-$(CONFIG_PS3_FLASH)  += ps3flash.o obj-$(CONFIG_XILLYBUS)  += xillybus/
obj-$(CONFIG_POWERNV_OP_PANEL) += powernv-op-panel.o obj-$(CONFIG_ADI)  += adi.o

1.2 、增加USB相关支持

修改 arch/arm64/configs/rockchip_linux_defconfig

CONFIG_USB_ACM=y CONFIG_USB_SERIAL_QT2=y

重新编译内核,此时USB可以正确识别鼠标生成对应的设备节点,但是鼠标还是不能正常工作。

2、内核崩溃问题解决

内核崩溃log如下:

[  61.187709] kernel BUG at kernel/sched/walt.h:108! [  61.188143] Internal error: Oops - BUG: 0 [#1] SMP [  61.188573] Modules linked in:
[  61.188866] CPU: 3 PID: 25 Comm: migration/3 Tainted: G  W  5.10.97 #6 [  61.189541] Hardware name: Rockchip RK3399 Excavator Board (Linux Opensource) (DT) [  61.190214] pstate: 80000085 (Nzcv daIf -PAN -UAO -TCO BTYPE=--)
[  61.190760] pc : dequeue_task_rt+0xf8/0xfc [  61.191131] lr : dequeue_task_rt+0x68/0xfc [  61.191497] sp : ffffffc011bd3ce0
[    61.191797]    x29:    ffffffc011bd3ce0    x28:    0000000000000000    [    61.192281]    x27:    0000000000000000    x26:    0000000000000001    [    61.192765]    x25:    ffffffc011854000    x24:    ffffff800245cb00    [    61.193247]    x23:    ffffff80f779e440    x22:    ffffff800c799180    [    61.193729]    x21:    0000000000000000    x20:    ffffff800c798f00    [    61.194211]    x19:    ffffff80f779e440    x18:    00000000ffff1020    [    61.194693]    x17:    0000000000000000    x16:    00000000000000e0    [    61.195176]    x15:    ffffffc010645160    x14:    000000000000006c    [    61.195658]    x13:    ffffffc0100a2f8c    x12:    0000000000000000    [    61.196140]    x11:    0000000000000001    x10:    ffffffc010f7be28    [    61.196622]    x9 :    0000000000000002    x8 :    ffffffffffffffd8    [    61.197104]    x7 :    6e6f636e69203a69    x6 :    ffffffc011908110    [    61.197586]    x5 :    0000000000000004    x4 :    0000000000000001    [    61.198067]    x3 :    0000000000000000    x2 :    0000000000000000    [    61.198550]    x1 :    0000000000000000    x0 :    ffffff80f779e800    [    61.199034]    Call    trace:    [    61.199264]    dequeue_task_rt+0xf8/0xfc    [    61.199608]    dequeue_task+0xbc/0x2c4    [    61.199935]    deactivate_task+0x28/0x34    [    61.200278]    rt_active_load_balance_cpu_stop+0x90/0x150    [    61.200749]    cpu_stopper_thread+0xac/0x154    [    61.201119]    smpboot_thread_fn+0x100/0x190    [    61.201491]    kthread+0x11c/0x174    [    61.201787]    ret_from_fork+0x10/0x30    [    61.202117]    Code: f9400bf7 a8c47bfd d50323bf d65f03c0 (d4210000)    [    61.202662]    ---[ end trace 72c26b1564636cfc ]---    [    61.203076]    Kernel panic - not syncing: Oops - BUG: Fatal exception    [    61.203639]    SMP: stopping secondary CPUs    [    62.370663]    SMP: failed to stop secondary CPUs 1,3-5    [    62.371105]    CRU:    [    62.371291]    00000000:    0000004b    00001301    80000000    00000108    00000007    00007f00    00000000    00000000    [    62.372052]    00000020:    0000004b    00001101    80000000    00000108    00000007    00007f00    00000000    00000000    [    62.372812]    00000040:    0000006b    00001301    8000031f    00000108    00000007    00007f00    00000000    00000000    [    62.373573]    00000060:    0000008b    00001604    8000031f    00000108    00000007    00007f00    00000000    00000000    
......

只需要修改 arch/arm64/configs/rockchip_linux_defconfig 文件,注释掉以下内容即可(此修改包含第二部分USB支持):

< CONFIG_PSI=y
---
>CONFIG_PSI=y 98c98
< CONFIG_SCHED_RUNNING_AVG=y
---
>CONFIG_SCHED_RUNNING_AVG=y 100c100
< CONFIG_SCHED_CORE_CTRL=y
---
>CONFIG_SCHED_CORE_CTRL=y 139c139
< #CONFIG_SCHED_EAS=y
---
>CONFIG_SCHED_EAS=y 4395c4395
< CONFIG_USB_ACM=y
---
># CONFIG_USB_ACM is not set 4433c4433
< #CONFIG_USB_DWC3_HOST=y
---
># CONFIG_USB_DWC3_HOST is not set 4511c4511
< CONFIG_USB_SERIAL_QT2=y
---
># CONFIG_USB_SERIAL_QT2 is not set

注释:红色内容为修改后的文件。解决上边崩溃问题只需要关闭 CONFIG_SCHED_EAS 一个配置即可。

1.CONFIG_PSI

PSI (Pressure Stall Information) 机制,其核心思想是:如果有进程因为等待某种资源而 stall 了,那说明这个时候资源成了一个限制条件(生产资料的短缺导致了生产力的损失),那就应该适当增加分配给这个进程的资源。

在部署业务时,如果过于保守地追求安全,那资源往往得不到充分的利用,造成浪费,在成本上丧失竞争力。而如果对资源进行过饱和使用(比如内存的 overcommit),又可能导致运行过程中的波动(spike),影响延迟敏感型的任务,甚至最终不得不走向 OOM。
所谓人尽其才,物尽其用,Linux 中 PSI 的目标就是让硬件资源的效能最大化。
2.CONFIG_SCHED_RUNNING_AVG
用于确定平均运行队列的调度程序接口
3.CONFIG_SCHED_CORE_CTRL
OpenHarmony CPU轻量级隔离特性介绍
基本概念
CPU轻量级隔离特性提供了根据系统负载和用户配置来选择合适的CPU进行动态隔离的能力。内核会将被隔离CPU上的任务和中断迁移到其他合适的CPU上执行,被隔离的CPU会进入ilde状态,以此来达到功耗优化的目标。同时提供用户的配置和查询接口来实现更好的系统调优。
配置指导
使能CPU轻量级隔离特性
打开相关配置项及依赖。启用CPU轻量级隔离,需要通过编译内核时打开相应的配置项及依赖,相关CONFIG如下:

4.CONFIG_SCHED_EAS
能量感知调度(EAS)使调度程序能够预测其决策对 CPU 消耗的电量的影响。EAS 依赖于 CPU的能量模型 (EM) 来为每个任务选择省电的 CPU,同时要求对执行任务的吞吐量的影响最小。
EAS 仅在异构 CPU 架构上(例如 Arm big.LITTLE)上运行,因为这是通过调度器节省电量的效果最大的地方。
3、多模子系统服务加载错误
错误日志log

[pid=1][Init][ERROR][init_signal_handler.c:42]
Child process multimodalinput(pid 1351) exit with signal : 11 [pid=1][Init][INFO][init_signal_handler.c:51]
SigHandler, SIGCHLD received, Service:multimodalinput pid:1351 uid:6696 status:11. [pid=1][Init][INFO][init_common_service.c:497]
Reap service multimodalinput, pid 1351. [pid=1][Init][ERROR][init_common_service.c:540]
Service name=multimodalinput, crash 4 times, no more start.
修改 foundation/multimodalinput/input/service/window_manager/src/input_windows_manager.cpp 文件
diff --git a/service/window_manager/src/input_windows_manager.cpp b/service/window_manager/src/i index 1be96f7..6146c01 100644
--- a/service/window_manager/src/input_windows_manager.cpp
+++ b/service/window_manager/src/input_windows_manager.cpp @@ -229,6 +229,7 @@
int32_t logicX = mouseLocation.physicalX + displayInfo->x; int32_t logicY = mouseLocation.physicalY + displayInfo->y; std::optional<WindowInfo> windowInfo;
+  CHKPV(lastPointerEvent_);
if (lastPointerEvent_->GetPointerAction() == PointerEvent::POINTER_ACTION_MOVE && lastPointerEvent_->GetPressedButtons().empty()) {
windowInfo = GetWindowInfo(logicX, logicY); @@ -396,6 +397,7 @@
{
CALL_INFO_TRACE;
std::optional<WindowInfo> windowInfo;
+  CHKPV(lastPointerEvent_);
if (lastPointerEvent_->GetPointerAction() == PointerEvent::POINTER_ACTION_MOVE && lastPointerEvent_->GetPressedButtons().empty()) {
windowInfo = GetWindowInfo(lastLogicX_, lastLogicY_);

总结:

经过以上修改之后,系统完全启动进入桌面之后,输入 power-shell setmode 602 命令,设置电源模式,防止系统重启,鼠标可正常工作。

©著作权归作者所有,如需转载,请注明出处,否则将追究法律责任
7
收藏 4
回复
举报
4条回复
按时间正序
/
按时间倒序
红叶亦知秋
红叶亦知秋

很详细的操作流程

回复
2023-4-4 10:16:11
liurick
liurick

鼠标驱动安装偶尔会出现失败问题


回复
2023-4-6 11:20:55
带带小老弟
带带小老弟

一般驱动加载不出来就直接重新插一次就好了

回复
2023-4-6 18:41:05
喝一大口可乐
喝一大口可乐

即使是鼠标的内核看来也不简单

回复
2023-4-7 15:36:38
回复
    相关推荐