[经验分享] OpenHarmony系统修改cfg文件权限方法-使用瑞芯微RK3568开发板

cjzn-1234 显示全部楼层 发表于 2024-9-24 14:48:47

一、查看文件路径

首先init.rkxxx.cfg文件在系统路径 <span>/vendor/etc/</span>,如下图所示:

C:\Users\industio>hdc shell
# cd vendor/etc/
# ls
audio                fstab.rk3568         iqfil.json  soc_perf
battery              hdfconfig            iqfiles     thermal_config
cgroup_sched         init                 ons
distributedhardware  init.rk3568.cfg      param
firmware             init.rk3568.usb.cfg  ressched"

二、文件传至本地

将需要需要修改的cfg文件从文件系统中拉下来放在本地目录,命令是:<span>hdc file recv '系统路径' '本地文件路径'</span>,如下图所示:



C:\Users\industio>hdc file recv /vendor/etc/init.rk3568.cfg D:\
[I][2024-07-25 10:49:35] HdcFile::TransferSummary success
FileTransfer finish, Size:3581, File count = 1, time:127ms rate:28.20kB/s

三、修改文件

在cfg文件中增加权限,注意在对文件修改不要使用TAB键,复制前一行代码后再修改防止出错

{
    "import" : [
            "init.${ohos.boot.hardware}.usb.cfg"
    ],
    "jobs" : [{
            "name" : "pre-init",
            "cmds" : [
                "write /proc/sys/vm/min_free_kbytes 10240",
                "mount debugfs /sys/kernel/debug /sys/kernel/debug mode=755",
                "write /sys/kernel/debug/hisi_inno_phy/role peripheral"
            ]
        }, {
            "name" : "init",
            "cmds" : [
                "write /proc/1/oom_score_adj -1000",
                "chown system system /sys/kernel/hungtask/userlist",
                "symlink /dev/block/platform/fe310000.sdhci/by-name /dev/block/by-name"
            ]
        }, {
            "name" : "boot",          //在此位置添加设备权限
            "cmds" : [
                "write /sys/block/zram0/disksize 1024M",
                "mkswap /dev/block/zram0",
                "swapon /dev/block/zram0",
                "chmod 777 /dev/ttyAMA2",
+               "chmod 666 /dev/bus/usb/005/001"
+               "chmod 666 /dev/bus/usb/005/002"
                "chmod 775 /sys/class/rfkill/rfkill0/state",   
            ]
        }, {
            "name" : "post-fs-data",
            "cmds" : [
                "restorecon",
                "restorecon /data/updater"
            ]
        }
    ],
    "services" : [{
            "name" : "ispserver",
            "path" : ["/vendor/bin/ispserver"],
            "once" : 1,
            "secon" : "u:r:ispserver:s0",
            "uid": "ispserver",
            "gid": [ "ispserver", "camera_host" ]
        }
    ]
}

四、文件推送

当修改完成后将文件推送回去,命令如下:

hdc shell mount -o remount,rw /vendor      //重新挂载设备,将设备改为可读可写
hdc file send “本地路径” “/vendor/etc/init.rkxxx.cfg”    //将修改好的文件覆盖到系统当中
hdc shell reboot        //将文件推送回去,系统重启

©著作权归作者所有,转载或内容合作请联系作者

您尚未登录,无法参与评论,登录后可以:
参与开源共建问题交流
认同或收藏高质量问答
获取积分成为开源共建先驱

精彩评论1

Hazel

沙发 发表于 2024-11-7 14:46:01
如何在cfg文件中执行脚本,我用exec和start都失败

Copyright   ©2023  OpenHarmony开发者论坛  京ICP备2020036654号-3 |技术支持 Discuz!

返回顶部