首先执行job,如果开发者的进程在启动之前需要首先执行一些操作(例如创建文件夹),可以把操作放到pre-init中先执行。一般pre-init阶段主要是为后面启动服务做准备的,比如挂载目录,设置权限,启动uevent、watchdog等,uevent主要是有些服务需要响应插拔事件才会被拉起。
执行job介绍:
job名
说明
pre-init
最先执行的job,如果开发者的进程在启动之前需要首先执行一些操作(例如创建文件夹),可以把操作放到pre-init中先执行。
init
中间执行的job,例如服务启动。
post-init
最后被执行的job,如果开发者的进程在启动完成之后需要有一些处理(如驱动初始化后再挂载设备),可以把这类操作放到该job执行。单个job最多支持30条命令(当前仅支持start/mkdir/chmod/chown/mount/loadcfg),命令名称和后面的参数(参数长度≤128字节)之间有且只能有一个空格。
pre-init,init,post-init 除了/etc/init.cfg 里定义的jobs外,也包括其他服务配置的jobs。也就是说其他服务进程也可以配置pre-init,init,post-init。
执行流程:
图为一次执行的顺序是pre-init,init,启动所有boot服务,post-init,所有Normal 服务。
主要是启动ueventd,watch_dog, 其他的就是设置权限,挂载/data 和 硬件相关的挂载目录。具体看下面注释:
{
"name" : "pre\-init",
"cmds" : \[
"write /proc/sys/kernel/sysrq 0",
\#\#1、 写为0表示 关闭sysrq,1表示启动。 sysrq 是系统请求,在键盘上对应PrintScreen键。
\#\# 这里是关闭了所有的请求。
"mkdir /acct/uid",
"chown root system /dev/memcg/memory\.pressure\_level",
"chmod 0040 /dev/memcg/memory\.pressure\_level",
"mkdir /dev/memcg/apps/ 0755 system system",
"mkdir /dev/memcg/system 0550 system system",
\#\#2、 设置内存压力相关的权限配置。
"start ueventd", \#\#3、 启动ueventd 服务
"start watchdog\_service", \#\#4、 启动看门狗
"mkdir /data",
"mount\_fstab /vendor/etc/fstab\.$\{ohos\.boot\.hardware\}", \#\#5、 挂载vendor分区,跟硬件产品相关
"chown system system /data", \#\# 6、 为userdata 分区 会挂载在/data 目录做准备
"chmod 0771 /data", \#\# 可读可写可执行,其他用户只读
"mkdir /data/service 0711 root root",
"mkdir /data/service/el0 0711 root root",
"load\_persist\_params ", \#\#7、 加载常驻参数,类似 persist\.sys\.usb\.config=hdc
"chown access\_token access\_token /dev/access\_token\_id", \#\#8、 token id
"chmod 0666 /dev/access\_token\_id"
\]
}
init 是触发所有配置文件中的init字段的命令的。
在init.cfg加载了"/etc/init.usb.cfg", "/etc/init.usb.configfs.cfg", /vendor/etc/init.${ohos.boot.hardware}.cfg"这几个config,会把它们的信息全部整合进来。
可以看出,在 init.cfg 中,主要是做了如下事情:
创建相关的目录,修改各设备节点的权限,配置一些参数。 启动 lo 回环网卡,配置hostname为localhost, domainname为localdomain。
{
"import" : [
"/etc/init\.usb\.cfg",
"/etc/init\.usb\.configfs\.cfg",
"/vendor/etc/init\.$\{ohos\.boot\.hardware\}\.cfg"
],
],
"jobs" : [ {
"name" : "init",
"cmds" : \[
"copy /proc/cmdline /dev/urandom",
"copy /system/etc/prop\.default /dev/urandom",
"symlink /proc/self/fd/0 /dev/stdin",
"symlink /proc/self/fd/1 /dev/stdout",
"symlink /proc/self/fd/2 /dev/stderr",
"symlink /system/bin /bin",
"symlink /system/etc /etc",
"symlink /sys/kernel/debug /d",
"symlink /system/vendor /vendor",
"mkdir /dev/stune/foreground",
"mkdir /dev/stune/background",
"mkdir /dev/stune/top\-app",
"mkdir /dev/stune/rt",
"chown system system /dev/stune",
"chown system system /dev/stune/foreground",
"chown system system /dev/stune/background",
"chown system system /dev/stune/top\-app",
"chown system system /dev/stune/rt",
"chown system system /dev/stune/tasks",
"chown system system /dev/stune/foreground/tasks",
"chown system system /dev/stune/background/tasks",
"chown system system /dev/stune/top\-app/tasks",
"chown system system /dev/stune/rt/tasks",
"chmod 0664 /dev/stune/tasks",
"chmod 0664 /dev/stune/foreground/tasks",
"chmod 0664 /dev/stune/background/tasks",
"chmod 0664 /dev/stune/top\-app/tasks",
"chmod 0664 /dev/stune/rt/tasks",
"mkdir /dev/blkio/background",
"chown system system /dev/blkio",
"chown system system /dev/blkio/background",
"chown system system /dev/blkio/tasks",
"chown system system /dev/blkio/background/tasks",
"chmod 0664 /dev/blkio/tasks",
"chmod 0664 /dev/blkio/background/tasks",
"write /dev/blkio/blkio\.weight 1000",
"write /dev/blkio/background/blkio\.weight 500",
"write /dev/blkio/blkio\.group\_idle 0",
"write /dev/blkio/background/blkio\.group\_idle 0",
"mount configfs none /config nodev noexec nosuid",
"chmod 0770 /config/sdcardfs",
"chown system package\_info /config/sdcardfs",
"mkdir /mnt/secure 0700 root root",
"mkdir /mnt/secure/asec 0700 root root",
"mkdir /mnt/asec 0755 root system",
"mkdir /mnt/obb 0755 root system",
"mkdir /mnt/media\_rw 0750 root media\_rw",
"mkdir /mnt/user 0755 root root",
"mkdir /mnt/user/0 0755 root root",
"mkdir /mnt/expand 0771 system system",
"mkdir /mnt/appfuse 0711 root root",
"mkdir /mnt/runtime 0700 root root",
"mkdir /mnt/runtime/default 0755 root root",
"mkdir /mnt/runtime/default/self 0755 root root",
"mkdir /mnt/runtime/read 0755 root root",
"mkdir /mnt/runtime/read/self 0755 root root",
"mkdir /mnt/runtime/write 0755 root root",
"mkdir /mnt/runtime/write/self 0755 root root",
"mkdir /mnt/runtime/full 0755 root root",
"mkdir /mnt/runtime/full/self 0755 root root",
"symlink /storage/self/primary /sdcard",
"symlink /storage/self/primary /mnt/sdcard",
"symlink /mnt/user/0/primary /mnt/runtime/default/self/primary",
"write /proc/sys/kernel/panic\_on\_oops 1",
"write /proc/sys/kernel/hung\_task\_timeout\_secs 0",
"write /proc/cpu/alignment 4",
"write /proc/sys/kernel/sched\_tunable\_scaling 0",
"write /proc/sys/kernel/sched\_latency\_ns 10000000",
"write /proc/sys/kernel/sched\_wakeup\_granularity\_ns 2000000",
"write /proc/sys/kernel/sched\_child\_runs\_first 0",
"write /proc/sys/kernel/randomize\_va\_space 2",
"write /proc/sys/vm/mmap\_min\_addr 32768",
"write /proc/sys/net/ipv4/ping\_group\_range 0 2147483647",
"write /proc/sys/net/unix/max\_dgram\_qlen 600",
"write /proc/sys/kernel/sched\_rt\_runtime\_us 950000",
"write /proc/sys/kernel/sched\_rt\_period\_us 1000000",
"write /proc/sys/net/core/rmem\_max 262144",
"write /proc/sys/net/core/wmem\_max 262144",
"write /proc/sys/net/ipv4/fwmark\_reflect 1",
"write /proc/sys/net/ipv6/fwmark\_reflect 1",
"write /proc/sys/net/ipv4/tcp\_fwmark\_accept 1",
"write /proc/sys/net/ipv4/conf/all/accept\_redirects 0",
"write /proc/sys/net/ipv6/conf/all/accept\_redirects 0",
"chmod 0400 /proc/net/fib\_trie",
"chown system system /dev/cpuctl",
"chown system system /dev/cpuctl/tasks",
"chmod 0666 /dev/cpuctl/tasks",
"write /dev/cpuctl/cpu\.rt\_period\_us 1000000",
"write /dev/cpuctl/cpu\.rt\_runtime\_us 950000",
"mkdir /dev/cpuset/foreground",
"copy /dev/cpuset/cpus /dev/cpuset/foreground/cpus",
"copy /dev/cpuset/mems /dev/cpuset/foreground/mems",
"mkdir /dev/cpuset/background",
"copy /dev/cpuset/cpus /dev/cpuset/background/cpus",
"copy /dev/cpuset/mems /dev/cpuset/background/mems",
"mkdir /dev/cpuset/system\-background",
"copy /dev/cpuset/cpus /dev/cpuset/system\-background/cpus",
"copy /dev/cpuset/mems /dev/cpuset/system\-background/mems",
"mkdir /dev/cpuset/restricted",
"copy /dev/cpuset/cpus /dev/cpuset/restricted/cpus",
"copy /dev/cpuset/mems /dev/cpuset/restricted/mems",
"mkdir /dev/cpuset/top\-app",
"copy /dev/cpuset/cpus /dev/cpuset/top\-app/cpus",
"copy /dev/cpuset/mems /dev/cpuset/top\-app/mems",
"chown system system /dev/cpuset",
"chown system system /dev/cpuset/foreground",
"chown system system /dev/cpuset/background",
"chown system system /dev/cpuset/system\-background",
"chown system system /dev/cpuset/top\-app",
"chown system system /dev/cpuset/restricted",
"chown system system /dev/cpuset/tasks",
"chown system system /dev/cpuset/foreground/tasks",
"chown system system /dev/cpuset/background/tasks",
"chown system system /dev/cpuset/system\-background/tasks",
"chown system system /dev/cpuset/top\-app/tasks",
"chown system system /dev/cpuset/restricted/tasks",
"chmod 0775 /dev/cpuset/system\-background",
"chmod 0664 /dev/cpuset/foreground/tasks",
"chmod 0664 /dev/cpuset/background/tasks",
"chmod 0664 /dev/cpuset/system\-background/tasks",
"chmod 0664 /dev/cpuset/top\-app/tasks",
"chmod 0664 /dev/cpuset/restricted/tasks",
"chmod 0664 /dev/cpuset/tasks",
"chown system system /proc/pressure/memory",
"chmod 0664 /proc/pressure/memory",
"chown root net\_bw\_acct /proc/net/xt\_qtaguid/ctrl",
"chown root net\_bw\_stats /proc/net/xt\_qtaguid/stats",
"chmod 0644 /dev/xt\_qtaguid",
"chown root root /dev/cg2\_bpf",
"chmod 0600 /dev/cg2\_bpf",
"mount bpf bpf /sys/fs/bpf nodev noexec nosuid",
"mkdir /dev/fscklogs 0770 root system",
"mount pstore pstore /sys/fs/pstore nodev noexec nosuid",
"chown system log /sys/fs/pstore",
"chmod 0550 /sys/fs/pstore",
"chown system log /sys/fs/pstore/console\-ramoops",
"chmod 0440 /sys/fs/pstore/console\-ramoops",
"chown system log /sys/fs/pstore/console\-ramoops\-0",
"chmod 0440 /sys/fs/pstore/console\-ramoops\-0",
"chown system log /sys/fs/pstore/pmsg\-ramoops\-0",
"chmod 0440 /sys/fs/pstore/pmsg\-ramoops\-0",
"write /proc/sys/abi/swp 1",
"symlink /proc/self/fd /dev/fd",
"export DOWNLOAD\_CACHE /data/cache",
"setrlimit RLIMIT\_NICE 40 40",
"setrlimit RLIMIT\_NOFILE 32768 32768",
"write /sys/class/leds/vibrator/trigger transient",
"write /dev/cpu\_variant:$\{ro\.bionic\.arch\} $\{ro\.bionic\.cpu\_variant\}",
"chmod 0444 /dev/cpu\_variant:$\{ro\.bionic\.arch\}",
"write /dev/cpu\_variant:$\{ro\.bionic\.2nd\_arch\} $\{ro\.bionic\.2nd\_cpu\_variant\}",
"chmod 0444 /dev/cpu\_variant:$\{ro\.bionic\.2nd\_arch\}",
"chown system system /sys/power/state",
"chown system system /sys/power/wakeup\_count",
"chmod 0660 /sys/power/state",
"ifup lo",
"hostname localhost",
"domainname localdomain"
\]
\}
主要是跟硬件产品相关的配置,这里看hi3516dv300, 可见主要是挂载了debugfs(调试子系统),修改设备角色为 peripheral,即设备。
{
"import" : [
"init\.$\{ro\.hardware\}\.usb\.cfg"
],
"jobs" : [ {
"name" : "init",
"cmds" : \[
"mount debugfs /sys/kernel/debug /sys/kernel/debug mode=755",
"write /sys/kernel/debug/hisi\_inno\_phy/role peripheral"
\]
\}
]
}
挂载cgroup到/dev/memcg主要做了如下事情:
挂载 cgroup 的memory、cpuset、cpu、freezer这几个到 /dev/memcg 目录下 cgroups子系统: Linux CGroup全称Linux Control Group, 是Linux内核的一个功能,用来限制,控制与分离一个进程组群的资源(如CPU、内存、磁盘输入输出等),其最早的名称为进程容器(process containers)。
cgroups可控制的子系统主要如下: cpu 子系统,主要限制进程的 cpu 使用率。 cpuacct 子系统,可以统计 cgroups 中的进程的 cpu 使用报告。 cpuset 子系统,可以为 cgroups 中的进程分配单独的 cpu 节点或者内存节点。 memory 子系统,可以限制进程的 memory 使用量。 blkio 子系统,可以限制进程的块设备 io。 devices 子系统,可以控制进程能够访问某些设备。 net_cls 子系统,可以标记 cgroups 中进程的网络数据包,然后可以使用 tc 模块(traffic control)对数据包进行控制。 net_prio — 这个子系统用来设计网络流量的优先级 freezer 子系统,可以挂起或者恢复 cgroups 中的进程。 ns 子系统,可以使不同 cgroups 下面的进程使用不同的 namespace hugetlb — 这个子系统主要针对于HugeTLB系统进行限制,这是一个大页文件系统。
{
"jobs" : [{
"name" : "init",
"cmds" : \[
"mkdir /dev/memcg",
"mount cgroup none /dev/memcg memory",
"chown system system /dev/memcg",
"chown system system /dev/memcg/tasks",
"chown system system /dev/memcg/memory\.oom\_control",
"chown system system /dev/memcg/cgroup\.event\_control",
"chown system system /dev/memcg/memory\.pressure\_level",
"chmod 0755 /dev/memcg",
"chmod 0755 /dev/memcg/tasks",
"chmod 0755 /dev/memcg/memory\.oom\_control",
"chmod 0755 /dev/memcg/cgroup\.event\_control",
"chmod 0755 /dev/memcg/memory\.pressure\_level",
"mkdir /dev/cpuset",
"mount cgroup none /dev/cpuset cpuset",
"mkdir /dev/cpuset/background",
"chown system system /dev/cpuset",
"chown system system /dev/cpuset/tasks",
"chown system system /dev/cpuset/background",
"chown system system /dev/cpuset/background/tasks",
"chmod 0755 /dev/cpuset",
"chmod 0755 /dev/cpuset/tasks",
"chmod 0755 /dev/cpuset/background",
"chmod 0755 /dev/cpuset/background/tasks",
"write /dev/cpuset/background/cpuset\.cpus 0",
"mkdir /dev/cpuctl",
"mount cgroup none /dev/cpuctl cpu",
"mkdir /dev/cpuctl/background",
"chown system system /dev/cpuctl",
"chown system system /dev/cpuctl/tasks",
"chown system system /dev/cpuctl/background",
"chown system system /dev/cpuctl/background/tasks",
"chmod 0755 /dev/cpuctl",
"chmod 0755 /dev/cpuctl/tasks",
"chmod 0755 /dev/cpuctl/background",
"chmod 0755 /dev/cpuctl/background/tasks",
"write /dev/cpuctl/background/cpu\.shares 512",
"mkdir /dev/freezer",
"mount cgroup none /dev/freezer freezer",
"mkdir /dev/freezer/frozen",
"mkdir /dev/freezer/thawed",
"chown system system /dev/freezer",
"chown system system /dev/freezer/frozen",
"chown system system /dev/freezer/frozen/tasks",
"chown system system /dev/freezer/thawed",
"chown system system /dev/freezer/thawed/tasks",
"chmod 0755 /dev/freezer",
"chmod 0755 /dev/freezer/frozen",
"chmod 0755 /dev/freezer/frozen/tasks",
"chmod 0755 /dev/freezer/thawed",
"chmod 0755 /dev/freezer/thawed/tasks",
"write /dev/freezer/frozen/freezer\.state FROZEN",
"write /dev/freezer/thawed/freezer\.state THAWED"
\]
\}, \{
"name" : "boot",
"cmds" : \[
"chown radio system /sys/power/wake\_lock",
"chown radio system /sys/power/wake\_unlock",
"chmod 0664 /sys/power/wakeup\_count",
"start foundation"
\]
\}
],
"services" : [{
"name" : "foundation",
"path" : \["/system/bin/sa\_main", "/system/profile/foundation\.xml"\],
"importance" : \-20,
"uid" : "system",
"gid" : \["system"\],
"caps" : \["SYS\_PTRACE", "KILL"\]
\}
]
}
主要是挂载调试子系统,启动用户程序框架子系统samgr
{
"jobs" : [{
"name" : "init",
"cmds" : \[
"mkdir /data/sadata\_de",
"chmod 755 /data/sadata\_de",
"chown system system /data/sadata\_de",
"mkdir /data/sadata\_de/samgr",
"chmod 755 /data/sadata\_de/samgr",
"chown system system /data/sadata\_de/samgr",
\#\# 可见,samgr 在init阶段提前启动了。
"start samgr"
\]
\}
],
"services" : [{
"name" : "samgr",
"path" : \["/system/bin/samgr"\],
"uid" : "system",
"gid" : \["system"\]
\}
]
}
post-init 作用是处理系统服务进程启动之后的行为。他会触发启动所有cfg文件中post-init 字段的命令。
{
"name" : "post-init",
"cmds" : \[
"trigger early\-fs", // 触发\`early\-fs\` 阶段的命令
"trigger fs", // 触发\`fs\` 阶段的命令
"trigger post\-fs", // 触发\`post\-fs\` 阶段的命令
"trigger late\-fs", // 触发\`late\-fs\` 阶段的命令
"trigger post\-fs\-data", // 触发\`post\-fs\-data\` 阶段的命令
"trigger load\_persist\_props\_action", // 触发\`load\_persist\_props\_action\` 阶段的命令
"trigger firmware\_mounts\_complete", // 触发\`firmware\_mounts\_complete\` 阶段的命令
"trigger early\-boot", // 触发\`early\-boot\` 阶段的命令
"trigger boot" // 触发\`boot\` 阶段的命令
\]
}
主要是初始化trace框架并使能trace功能。内核调试跟踪模块。
{
"jobs" : [{
"name" : "post\-init",
"cmds" : \[
"write /proc/sys/kernel/sched\_schedstats 1",
"write /sys/kernel/debug/tracing/tracing\_on 0",
"chmod 0666 /sys/kernel/debug/tracing/buffer\_size\_kb",
"chmod 0666 /sys/kernel/debug/tracing/saved\_cmdlines\_size",
"chmod 0666 /sys/kernel/debug/tracing/trace",
"chmod 0666 /sys/kernel/debug/tracing/trace\_clock",
"chmod 0222 /sys/kernel/debug/tracing/trace\_marker",
"chmod 0666 /sys/kernel/debug/tracing/tracing\_on",
"chmod 0666 /sys/kernel/debug/tracing/events/binder/binder\_lock/enable",
"chmod 0666 /sys/kernel/debug/tracing/events/binder/binder\_locked/enable",
"chmod 0666 /sys/kernel/debug/tracing/events/binder/binder\_unlock/enable",
"chmod 0666 /sys/kernel/debug/tracing/events/binder/binder\_transaction/enable",
"chmod 0666 /sys/kernel/debug/tracing/events/binder/binder\_transaction\_received/enable",
"chmod 0666 /sys/kernel/debug/tracing/events/binder/binder\_transaction\_alloc\_buf/enable",
"chmod 0666 /sys/kernel/debug/tracing/events/cgroup/enable",
"chmod 0666 /sys/kernel/debug/tracing/events/cpufreq\_interactive/enable",
"chmod 0666 /sys/kernel/debug/tracing/events/dma\_fence/enable",
"chmod 0666 /sys/kernel/debug/tracing/events/fence/enable",
"chmod 0666 /sys/kernel/debug/tracing/events/i2c/enable",
"chmod 0666 /sys/kernel/debug/tracing/events/i2c/i2c\_read/enable",
"chmod 0666 /sys/kernel/debug/tracing/events/i2c/i2c\_write/enable",
"chmod 0666 /sys/kernel/debug/tracing/events/i2c/i2c\_result/enable",
"chmod 0666 /sys/kernel/debug/tracing/events/i2c/i2c\_reply/enable",
"chmod 0666 /sys/kernel/debug/tracing/events/i2c/smbus\_read/enable",
"chmod 0666 /sys/kernel/debug/tracing/events/i2c/smbus\_write/enable",
"chmod 0666 /sys/kernel/debug/tracing/events/i2c/smbus\_result/enable",
"chmod 0666 /sys/kernel/debug/tracing/events/i2c/smbus\_reply/enable",
"chmod 0666 /sys/kernel/debug/tracing/events/kmem/rss\_stat/enable",
"chmod 0666 /sys/kernel/debug/tracing/events/kmem/ion\_heap\_grow/enable",
"chmod 0666 /sys/kernel/debug/tracing/events/kmem/ion\_heap\_shrink/enable",
"chmod 0666 /sys/kernel/debug/tracing/events/lowmemorykiller/enable",
"chmod 0666 /sys/kernel/debug/tracing/events/lowmemorykiller/lowmemory\_kill/enable",
"chmod 0666 /sys/kernel/debug/tracing/events/mm\_event/mm\_event\_record/enable",
"chmod 0666 /sys/kernel/debug/tracing/events/oom/oom\_score\_adj\_update/enable",
"chmod 0666 /sys/kernel/debug/tracing/events/power/cpu\_frequency/enable",
"chmod 0666 /sys/kernel/debug/tracing/events/power/cpu\_idle/enable",
"chmod 0666 /sys/kernel/debug/tracing/events/power/clock\_set\_rate/enable",
"chmod 0666 /sys/kernel/debug/tracing/events/power/cpu\_frequency\_limits/enable",
"chmod 0666 /sys/kernel/debug/tracing/events/power/gpu\_frequency/enable",
"chmod 0666 /sys/kernel/debug/tracing/events/sched/sched\_switch/enable",
"chmod 0666 /sys/kernel/debug/tracing/events/sched/sched\_wakeup/enable",
"chmod 0666 /sys/kernel/debug/tracing/events/sched/sched\_blocked\_reason/enable",
"chmod 0666 /sys/kernel/debug/tracing/events/sched/sched\_cpu\_hotplug/enable",
"chmod 0666 /sys/kernel/debug/tracing/events/sched/sched\_pi\_setprio/enable",
"chmod 0666 /sys/kernel/debug/tracing/events/sched/sched\_process\_exit/enable",
"chmod 0666 /sys/kernel/debug/tracing/events/sched/sched\_waking/enable",
"chmod 0666 /sys/kernel/debug/tracing/events/signal/signal\_generate/enable",
"chmod 0666 /sys/kernel/debug/tracing/events/signal/signal\_deliver/enable",
"chmod 0666 /sys/kernel/debug/tracing/events/sync/enable",
"chmod 0666 /sys/kernel/debug/tracing/events/task/task\_rename/enable",
"chmod 0666 /sys/kernel/debug/tracing/events/task/task\_newtask/enable",
"chmod 0666 /sys/kernel/debug/tracing/events/vmscan/mm\_vmscan\_direct\_reclaim\_begin/enable",
"chmod 0666 /sys/kernel/debug/tracing/events/vmscan/mm\_vmscan\_direct\_reclaim\_end/enable",
"chmod 0666 /sys/kernel/debug/tracing/events/vmscan/mm\_vmscan\_kswapd\_wake/enable",
"chmod 0666 /sys/kernel/debug/tracing/events/vmscan/mm\_vmscan\_kswapd\_sleep/enable",
"chmod 0666 /sys/kernel/debug/tracing/events/block/block\_rq\_issue/enable",
"chmod 0666 /sys/kernel/debug/tracing/events/block/block\_rq\_complete/enable",
"chmod 0666 /sys/kernel/debug/tracing/events/ext4/ext4\_da\_write\_begin/enable",
"chmod 0666 /sys/kernel/debug/tracing/events/ext4/ext4\_da\_write\_end/enable",
"chmod 0666 /sys/kernel/debug/tracing/events/ext4/ext4\_es\_lookup\_extent\_enter/enable",
"chmod 0666 /sys/kernel/debug/tracing/events/ext4/ext4\_es\_lookup\_extent\_exit/enable",
"chmod 0666 /sys/kernel/debug/tracing/events/ext4/ext4\_load\_inode/enable",
"chmod 0666 /sys/kernel/debug/tracing/events/ext4/ext4\_sync\_file\_enter/enable",
"chmod 0666 /sys/kernel/debug/tracing/events/ext4/ext4\_sync\_file\_exit/enable",
"chmod 0666 /sys/kernel/debug/tracing/events/f2fs/f2fs\_get\_data\_block/enable",
"chmod 0666 /sys/kernel/debug/tracing/events/f2fs/f2fs\_iget/enable",
"chmod 0666 /sys/kernel/debug/tracing/events/f2fs/f2fs\_sync\_file\_enter/enable",
"chmod 0666 /sys/kernel/debug/tracing/events/f2fs/f2fs\_sync\_file\_exit/enable",
"chmod 0666 /sys/kernel/debug/tracing/events/f2fs/f2fs\_write\_begin/enable",
"chmod 0666 /sys/kernel/debug/tracing/events/f2fs/f2fs\_write\_end/enable",
"chmod 0666 /sys/kernel/debug/tracing/events/filemap/mm\_filemap\_add\_to\_page\_cache/enable",
"chmod 0666 /sys/kernel/debug/tracing/events/filemap/mm\_filemap\_delete\_from\_page\_cache/enable",
"chmod 0666 /sys/kernel/debug/tracing/options/overwrite",
"chmod 0666 /sys/kernel/debug/tracing/options/print\-tgid",
"chmod 0666 /sys/kernel/debug/tracing/options/record\-tgid",
"chmod 0666 /sys/kernel/debug/tracing/per\_cpu/cpu0/trace",
"chmod 0666 /sys/kernel/debug/tracing/per\_cpu/cpu1/trace",
"chmod 0666 /sys/kernel/debug/tracing/per\_cpu/cpu2/trace",
"chmod 0666 /sys/kernel/debug/tracing/per\_cpu/cpu3/trace",
"chmod 0666 /sys/kernel/debug/tracing/per\_cpu/cpu4/trace",
"chmod 0666 /sys/kernel/debug/tracing/per\_cpu/cpu5/trace",
"chmod 0666 /sys/kernel/debug/tracing/per\_cpu/cpu6/trace",
"chmod 0666 /sys/kernel/debug/tracing/per\_cpu/cpu7/trace",
"chmod 0666 /sys/kernel/debug/tracing/per\_cpu/cpu8/trace",
"chmod 0666 /sys/kernel/debug/tracing/per\_cpu/cpu9/trace",
"chmod 0666 /sys/kernel/debug/tracing/per\_cpu/cpu10/trace",
"chmod 0666 /sys/kernel/debug/tracing/per\_cpu/cpu11/trace",
"chmod 0666 /sys/kernel/debug/tracing/per\_cpu/cpu12/trace",
"chmod 0666 /sys/kernel/debug/tracing/per\_cpu/cpu13/trace",
"chmod 0666 /sys/kernel/debug/tracing/per\_cpu/cpu14/trace",
"chmod 0666 /sys/kernel/debug/tracing/per\_cpu/cpu15/trace"
\}
启动vold服务 volume daemon
Vold 就是负责挂载SD卡的,vold 的全称是volume daemon。 实际上是负责完成系统的CDROM,USB 大容量存储,MMC 卡等扩展存储的挂载任务自动完成的守护进程。 它提供的主要特点是支持这些存储外设的热插拔。
# base/startup/init_lite/services/etc/init.cfg
"jobs" : \[\{
"name" : "early\-fs",
"cmds" : \[
"start vold"
\]
\}
insmod加载内核驱动模块
跟具体的硬件相关,这里以hi3516为例,/etc/init.Hi3516DV300.cfg
{
"name" : "fs",
"cmds" : \[
"insmod /vendor/modules/hi\_securec\.ko",
"insmod /vendor/modules/hi\_osal\.ko anony=1 mmz\_allocator=hisi mmz=anonymous,0,0xA8000000,384M || report\_error",
"insmod /vendor/modules/hi\_irq\.ko",
"insmod /vendor/modules/hi\_proc\.ko",
"insmod /vendor/modules/sys\_config\.ko chip=hi3516dv300 sensors=sns0=imx335,sns1=NULL,g\_cmos\_yuv\_flag=0",
"insmod /vendor/modules/hi3516cv500\_base\.ko",
"insmod /vendor/modules/hi3516cv500\_sys\.ko",
"insmod /vendor/modules/hi3516cv500\_tde\.ko",
"insmod /vendor/modules/hi3516cv500\_vo\_dev\.ko",
"insmod /vendor/modules/hifb\.ko video=\"hifb:vram0\_size:16200\"",
"insmod /vendor/modules/hi3516cv500\_hdmi\.ko",
"insmod /vendor/modules/hi\_mipi\_rx\.ko",
"insmod /vendor/modules/hi3516cv500\_wdt\.ko"
\]
\}
挂载 rootfs文件系统到根目录,启动udevd_service监听并处理内核udev事件
主要是挂载rootfs 到根目录。
{
"name" : "post\-fs",
"cmds" : \[
"mount rootfs rootfs / remount bind ro nodev",
"chown root log /proc/vmallocinfo",
"chmod 0440 /proc/vmallocinfo",
"chown root log /proc/slabinfo",
"chmod 0440 /proc/slabinfo",
"chown root system /proc/kmsg",
"chmod 0440 /proc/kmsg",
"chmod 0444 /sys/fs/selinux/policy"
\]
\}
启动分布式权限管理、应用孵化器组件、用户程序管理等服务;
修改tracing节点权限为755
{
"name" : "late\-fs",
"cmds" : \[
"chmod 0755 /sys/kernel/debug/tracing"
\]
\}
启动驱动子系统、系统帐号组件、鸿蒙通用密钥库系统 huks、设备认证模块、日志文件系统(hilog)、布式软总线组件(dsoftbus)、无线局域网组件、蓝牙、音频组件、分布式任务调度模块等服务;
初始化/data 下目录,并赋予权限
{
"name" : "post\-fs\-data",
"cmds" : \[
"chown system system /data",
"chmod 0771 /data",
"mkdir /data/bootchart 0755 shell shell",
"mkdir /data/app\-staging 0750 system system",
"copy /data/system/entropy\.dat /dev/urandom",
"mkdir /data/misc 01771 system misc",
"mkdir /data/misc/recovery 0770 system log",
"copy /data/misc/recovery/ro\.build\.fingerprint /data/misc/recovery/ro\.build\.fingerprint\.1",
"chmod 0440 /data/misc/recovery/ro\.build\.fingerprint\.1",
"chown system log /data/misc/recovery/ro\.build\.fingerprint\.1",
"write /data/misc/recovery/ro\.build\.fingerprint $\{ro\.build\.fingerprint\}",
"chmod 0440 /data/misc/recovery/ro\.build\.fingerprint",
"chown system log /data/misc/recovery/ro\.build\.fingerprint",
"mkdir /data/misc/recovery/proc 0770 system log",
"copy /data/misc/recovery/proc/version /data/misc/recovery/proc/version\.1",
"chmod 0440 /data/misc/recovery/proc/version\.1",
"chown system log /data/misc/recovery/proc/version\.1",
"copy /proc/version /data/misc/recovery/proc/version",
"chmod 0440 /data/misc/recovery/proc/version",
"chown system log /data/misc/recovery/proc/version",
"mkdir /data/misc/bluedroid 02770 bluetooth bluetooth",
"chmod 0660 /data/misc/bluedroid/bt\_config\.conf",
"chown bluetooth bluetooth /data/misc/bluedroid/bt\_config\.conf",
"mkdir /data/misc/bluetooth 0770 bluetooth bluetooth",
"mkdir /data/misc/bluetooth/logs 0770 bluetooth bluetooth",
"mkdir /data/misc/keystore 0700 keystore keystore",
"mkdir /data/misc/gatekeeper 0700 system system",
"mkdir /data/misc/keychain 0771 system system",
"mkdir /data/misc/net 0750 root shell",
"mkdir /data/misc/radio 0770 system radio",
"mkdir /data/misc/sms 0770 system radio",
"mkdir /data/misc/carrierid 0770 system radio",
"mkdir /data/misc/apns 0770 system radio",
"mkdir /data/misc/zoneinfo 0775 system system",
"mkdir /data/misc/network\_watchlist 0774 system system",
"mkdir /data/misc/textclassifier 0771 system system",
"mkdir /data/misc/vpn 0770 system vpn",
"mkdir /data/misc/shared\_relro 0771 shared\_relro shared\_relro",
"mkdir /data/misc/systemkeys 0700 system system",
"mkdir /data/misc/wifi 0770 wifi wifi",
"mkdir /data/misc/wifi/sockets 0770 wifi wifi",
"mkdir /data/misc/wifi/wpa\_supplicant 0770 wifi wifi",
"mkdir /data/misc/ethernet 0770 system system",
"mkdir /data/misc/dhcp 0770 dhcp dhcp",
"mkdir /data/misc/user 0771 root root",
"mkdir /data/misc/perfprofd 0775 root root",
"chmod 0660 /data/misc/wifi/wpa\_supplicant\.conf",
"mkdir /data/local 0751 root root",
"mkdir /data/misc/media 0700 media media",
"mkdir /data/misc/audioserver 0700 audioserver audioserver",
"mkdir /data/misc/cameraserver 0700 cameraserver cameraserver",
"mkdir /data/misc/vold 0700 root root",
"mkdir /data/misc/boottrace 0771 system shell",
"mkdir /data/misc/update\_engine 0700 root root",
"mkdir /data/misc/update\_engine\_log 02750 root log",
"mkdir /data/misc/trace 0700 root root",
"mkdir /data/misc/wmtrace 0700 system system",
"mkdir /data/misc/profiles 0771 system system",
"mkdir /data/misc/profiles/cur 0771 system system",
"mkdir /data/misc/profiles/ref 0771 system system",
"mkdir /data/misc/profman 0770 system shell",
"mkdir /data/misc/gcov 0770 root root",
"mkdir /data/preloads 0775 system system",
"mkdir /data/vendor 0771 root root",
"mkdir /data/vendor\_ce 0771 root root",
"mkdir /data/vendor\_de 0771 root root",
"mkdir /data/vendor/hardware 0771 root root",
"mkdir /data/local/tmp 0771 shell shell",
"mkdir /data/local/traces 0777 shell shell",
"mkdir /data/data 0771 system system",
"mkdir /data/app\-private 0771 system system",
"mkdir /data/app\-ephemeral 0771 system system",
"mkdir /data/app\-asec 0700 root root",
"mkdir /data/app\-lib 0771 system system",
"mkdir /data/app 0771 system system",
"mkdir /data/ota 0771 root root",
"mkdir /data/ota\_package 0770 system cache",
"mkdir /data/resource\-cache 0771 system system",
"chown system system /data/resource\-cache",
"chmod 0771 /data/resource\-cache",
"mkdir /data/lost\+found 0770 root root",
"mkdir /data/drm 0770 drm drm",
"mkdir /data/mediadrm 0770 mediadrm mediadrm",
"mkdir /data/nfc 0770 nfc nfc",
"mkdir /data/nfc/param 0770 nfc nfc",
"mkdir /data/backup 0700 system system",
"mkdir /data/ss 0700 system system",
"mkdir /data/system 0775 system system",
"mkdir /data/system/dropbox 0700 system system",
"mkdir /data/system/heapdump 0700 system system",
"mkdir /data/system/users 0775 system system",
"mkdir /data/system\_de 0770 system system",
"mkdir /data/system\_ce 0770 system system",
"mkdir /data/misc\_de 01771 system misc",
"mkdir /data/misc\_ce 01771 system misc",
"mkdir /data/user 0711 system system",
"mkdir /data/user\_de 0711 system system",
"symlink /data/data /data/user/0",
"mkdir /data/media 0770 media\_rw media\_rw",
"mkdir /data/media/obb 0770 media\_rw media\_rw",
"mkdir /data/cache 0770 system cache",
"mkdir /data/cache/recovery 0770 system cache",
"mkdir /data/cache/backup\_stage 0700 system system",
"mkdir /data/cache/backup 0700 system system",
"setparam sys\.use\_memfd false",
"chown root system /dev/fscklogs/log",
"chmod 0770 /dev/fscklogs/log"
\]
\}
将hdf input,dsoftbus,sendor,audio 等所有者改为system
{
"jobs" : [{
"name" : "post\-fs\-data",
"cmds" : \[
"chown system system /dev/hdf\_disp",
"chown system system /dev/hdf\_input\_host",
"chown system system /dev/hdf\_input\_event1",
"chown system system /dev/hdf\_input\_event2",
"chown system system /dev/hdf\_input\_event3",
"chown system system /dev/hdf\_input\_event4",
"chown system system /dev/hdf\_input\_event5",
"chown system system /dev/hdf\_input\_event6",
"chown system system /dev/hdf\_sensor\_manager\_ap",
"chown system system /dev/hdf\_misc\_vibrator",
"chown system system /dev/hdf\_audio\_render",
"chown system system /dev/hdf\_audio\_capture",
"chown system system /dev/hdf\_audio\_control",
"chown system system /dev/hdf\_audio\_codec\_dev0",
"chown system system /dev/hdf\_audio\_smartpa\_dev0",
"chown system system /dev/hdf\_dsoftbus"
\]\}\]
}
启动hdf 驱动子系统服务
{
"jobs" : [{
"name" : "post\-fs\-data",
"cmds" : \[
"start hdf\_devmgr"
\]\}\],
"services" : [{
"name" : "hdf\_devmgr",
"path" : \["/system/bin/hdf\_devmgr"\],
"uid" : "root",
"gid" : \["system"\]
\}\]
启动hdf host 系统子服务
{
"jobs" : [{
"name" : "post\-fs\-data",
"cmds" : \[
"start hdf\_devhost"
\]
\}
],
"services" : [
\{
"name" : "blue\_host",
"dynamic" : true,
"path" : \["/vendor/bin/hdf\_devhost"\],
"uid" : "root",
"gid" : \["system"\],
"caps" : \["DAC\_OVERRIDE", "DAC\_READ\_SEARCH"\]
\},
\{
"name" : "sample\_host",
"dynamic" : true,
"path" : \["/vendor/bin/hdf\_devhost"\],
"uid" : "sample\_host",
"gid" : \["sample\_host"\],
"caps" : \["DAC\_OVERRIDE", "DAC\_READ\_SEARCH"\]
\},
\{
"name" : "usb\_host",
"dynamic" : true,
"path" : \["/vendor/bin/hdf\_devhost"\],
"uid" : "usb\_host",
"gid" : \["usb\_host"\],
"caps" : \["DAC\_OVERRIDE", "DAC\_READ\_SEARCH"\]
\},
\{
"name" : "usbfnMaster\_host",
"dynamic" : true,
"path" : \["/vendor/bin/hdf\_devhost"\],
"uid" : "usbfnMaster\_host",
"gid" : \["usbfnMaster\_host"\],
"caps" : \["DAC\_OVERRIDE", "DAC\_READ\_SEARCH"\]
\},
\{
"name" : "power\_host",
"dynamic" : true,
"path" : \["/vendor/bin/hdf\_devhost"\],
"uid" : "system",
"gid" : \["system"\],
"caps" : \["DAC\_OVERRIDE", "DAC\_READ\_SEARCH"\]
\},
\{
"name" : "wifi\_host",
"dynamic" : true,
"path" : \["/vendor/bin/hdf\_devhost"\],
"uid" : "wifi\_host",
"gid" : \["wifi\_host"\],
"caps" : \["DAC\_OVERRIDE", "DAC\_READ\_SEARCH"\]
\},
\{
"name" : "audio\_hdi\_server\_host",
"dynamic" : true,
"path" : \["/vendor/bin/hdf\_devhost"\],
"uid" : "audio\_hdi\_server\_host",
"gid" : \["audio\_hdi\_server\_host"\],
"caps" : \["DAC\_OVERRIDE", "DAC\_READ\_SEARCH"\]
\},
\{
"name" : "camera\_mpp\_host",
"dynamic" : true,
"path" : \["/vendor/bin/hdf\_devhost"\],
"uid" : "root",
"gid" : \["system"\]
\},
\{
"name" : "camera\_host",
"dynamic" : true,
"path" : \["/vendor/bin/hdf\_devhost"\],
"uid" : "camera\_host",
"gid" : \["camera\_host"\],
"caps" : \["DAC\_OVERRIDE", "DAC\_READ\_SEARCH"\]
\},
\{
"name" : "input\_user\_host",
"dynamic" : true,
"path" : \["/vendor/bin/hdf\_devhost"\],
"uid" : "input\_user\_host",
"gid" : \["input\_user\_host"\],
"caps" : \["DAC\_OVERRIDE", "DAC\_READ\_SEARCH"\]
\},
\{
"name" : "display\_gralloc\_host",
"dynamic" : true,
"path" : \["/vendor/bin/hdf\_devhost"\],
"uid" : "display\_gralloc\_host",
"gid" : \["display\_gralloc\_host"\],
"caps" : \["DAC\_OVERRIDE", "DAC\_READ\_SEARCH"\]
\},
\{
"name" : "codec\_host",
"dynamic" : true,
"path" : \["/vendor/bin/hdf\_devhost"\],
"uid" : "codec\_host",
"gid" : \["codec\_host"\],
"caps" : \["DAC\_OVERRIDE", "DAC\_READ\_SEARCH"\]
\},
\{
"name" : "riladapter\_host",
"dynamic" : true,
"path" : \["/vendor/bin/hdf\_devhost"\],
"uid" : "riladapter\_host",
"gid" : \["riladapter\_host"\],
"caps" : \["DAC\_OVERRIDE", "DAC\_READ\_SEARCH"\]
\},
\{
"name" : "sensor\_dal\_host",
"dynamic" : true,
"path" : \["/vendor/bin/hdf\_devhost"\],
"uid" : "sensor\_dal\_host",
"gid" : \["sensor\_dal\_host"\],
"caps" : \["DAC\_OVERRIDE", "DAC\_READ\_SEARCH"\]
\},
\{
"name" : "vibrator\_dal\_host",
"dynamic" : true,
"path" : \["/vendor/bin/hdf\_devhost"\],
"uid" : "vibrator\_dal\_host",
"gid" : \["vibrator\_dal\_host"\],
"caps" : \["DAC\_OVERRIDE", "DAC\_READ\_SEARCH"\]
\},
\{
"name" : "light\_dal\_host",
"dynamic" : true,
"path" : \["/vendor/bin/hdf\_devhost"\],
"uid" : "light\_dal\_host",
"gid" : \["light\_dal\_host"\],
"caps" : \["DAC\_OVERRIDE", "DAC\_READ\_SEARCH"\]
\},
\{
"name" : "wifi\_c\_host",
"dynamic" : true,
"path" : \["/vendor/bin/hdf\_devhost"\],
"uid" : "wifi\_c\_host",
"gid" : \["wifi\_c\_host"\],
"caps" : \["DAC\_OVERRIDE", "DAC\_READ\_SEARCH"\]
\},
\{
"name" : "disp\_gralloc\_host",
"dynamic" : true,
"path" : \["/vendor/bin/hdf\_devhost"\],
"uid" : "disp\_gralloc\_host",
"gid" : \["disp\_gralloc\_host"\],
"caps" : \["DAC\_OVERRIDE", "DAC\_READ\_SEARCH"\]
\},
\{
"name" : "dcamera\_host",
"dynamic" : true,
"path" : \["/vendor/bin/hdf\_devhost"\],
"uid" : "dcamera\_host",
"gid" : \["dcamera\_host"\],
"caps" : \["DAC\_OVERRIDE", "DAC\_READ\_SEARCH"\]
\},
\{
"name" : "hwc\_host",
"dynamic" : true,
"path" : \["/vendor/bin/hdf\_devhost"\],
"uid" : "hwc\_host",
"gid" : \["hwc\_host"\],
"caps" : \["DAC\_OVERRIDE", "DAC\_READ\_SEARCH"\]
\},
\{
"name" : "gralloc\_host",
"dynamic" : true,
"path" : \["/vendor/bin/hdf\_devhost"\],
"uid" : "gralloc\_host",
"gid" : \["gralloc\_host"\],
"caps" : \["DAC\_OVERRIDE", "DAC\_READ\_SEARCH"\]
\},
\{
"name" : "sensor\_host",
"dynamic" : true,
"path" : \["/vendor/bin/hdf\_devhost"\],
"uid" : "sensor\_host",
"gid" : \["sensor\_host"\],
"caps" : \["DAC\_OVERRIDE", "DAC\_READ\_SEARCH"\]
\},
\{
"name" : "nfc\_host",
"dynamic" : true,
"path" : \["/vendor/bin/hdf\_devhost"\],
"uid" : "nfc\_host",
"gid" : \["nfc\_host"\],
"caps" : \["DAC\_OVERRIDE", "DAC\_READ\_SEARCH"\]
\},
\{
"name" : "a2dp\_host",
"dynamic" : true,
"path" : \["/vendor/bin/hdf\_devhost"\],
"uid" : "root",
"gid" : \["system"\],
"caps" : \["DAC\_OVERRIDE", "DAC\_READ\_SEARCH"\]
\}
]
}
初始化USB驱动、启动电话、时间、输入法、升级服务引擎、hdcd、媒体库组件、相机组件、媒体组件、分布式数据等服务;
# base/startup/init_lite/services/etc/init.cfg
{
"name" : "boot",
"cmds" : \[
"write /proc/sys/net/core/xfrm\_acq\_expires 3600",
"write /proc/sys/vm/overcommit\_memory 1",
"write /proc/sys/vm/min\_free\_order\_shift 4",
"chown root system /sys/module/lowmemorykiller/parameters/adj",
"chmod 0664 /sys/module/lowmemorykiller/parameters/adj",
"chown root system /sys/module/lowmemorykiller/parameters/minfree",
"chmod 0664 /sys/module/lowmemorykiller/parameters/minfree",
"chown root system /sys/block/zram0/idle",
"chmod 0664 /sys/block/zram0/idle",
"chown root system /sys/block/zram0/writeback",
"chmod 0664 /sys/block/zram0/writeback",
"write /proc/sys/vm/dirty\_expire\_centisecs 200",
"write /proc/sys/vm/dirty\_background\_ratio 5",
"write /sys/fs/f2fs/$\{dev\.mnt\.blk\.data\}/cp\_interval 200",
"chown radio system /sys/android\_power/state",
"chown radio system /sys/android\_power/request\_state",
"chown radio system /sys/android\_power/acquire\_full\_wake\_lock",
"chown radio system /sys/android\_power/acquire\_partial\_wake\_lock",
"chown radio system /sys/android\_power/release\_wake\_lock",
"chown system system /sys/power/autosleep",
"chown radio wakelock /sys/power/wake\_lock",
"chown radio wakelock /sys/power/wake\_unlock",
"chmod 0660 /sys/power/wake\_lock",
"chmod 0660 /sys/power/wake\_unlock",
"chown system system /sys/devices/system/cpu/cpufreq/interactive/timer\_rate",
"chmod 0660 /sys/devices/system/cpu/cpufreq/interactive/timer\_rate",
"chown system system /sys/devices/system/cpu/cpufreq/interactive/timer\_slack",
"chmod 0660 /sys/devices/system/cpu/cpufreq/interactive/timer\_slack",
"chown system system /sys/devices/system/cpu/cpufreq/interactive/min\_sample\_time",
"chmod 0660 /sys/devices/system/cpu/cpufreq/interactive/min\_sample\_time",
"chown system system /sys/devices/system/cpu/cpufreq/interactive/hispeed\_freq",
"chmod 0660 /sys/devices/system/cpu/cpufreq/interactive/hispeed\_freq",
"chown system system /sys/devices/system/cpu/cpufreq/interactive/target\_loads",
"chmod 0660 /sys/devices/system/cpu/cpufreq/interactive/target\_loads",
"chown system system /sys/devices/system/cpu/cpufreq/interactive/go\_hispeed\_load",
"chmod 0660 /sys/devices/system/cpu/cpufreq/interactive/go\_hispeed\_load",
"chown system system /sys/devices/system/cpu/cpufreq/interactive/above\_hispeed\_delay",
"chmod 0660 /sys/devices/system/cpu/cpufreq/interactive/above\_hispeed\_delay",
"chown system system /sys/devices/system/cpu/cpufreq/interactive/boost",
"chmod 0660 /sys/devices/system/cpu/cpufreq/interactive/boost",
"chown system system /sys/devices/system/cpu/cpufreq/interactive/boostpulse",
"chown system system /sys/devices/system/cpu/cpufreq/interactive/input\_boost",
"chmod 0660 /sys/devices/system/cpu/cpufreq/interactive/input\_boost",
"chown system system /sys/devices/system/cpu/cpufreq/interactive/boostpulse\_duration",
"chmod 0660 /sys/devices/system/cpu/cpufreq/interactive/boostpulse\_duration",
"chown system system /sys/devices/system/cpu/cpufreq/interactive/io\_is\_busy",
"chmod 0660 /sys/devices/system/cpu/cpufreq/interactive/io\_is\_busy",
"chown system system /sys/devices/system/cpu/cpu0/cpufreq/scaling\_max\_freq",
"chmod 0660 /sys/devices/system/cpu/cpu0/cpufreq/scaling\_max\_freq",
"chown system system /sys/class/leds/vibrator/trigger",
"chown system system /sys/class/leds/vibrator/activate",
"chown system system /sys/class/leds/vibrator/brightness",
"chown system system /sys/class/leds/vibrator/duration",
"chown system system /sys/class/leds/vibrator/state",
"chown system system /sys/class/timed\_output/vibrator/enable",
"chown system system /sys/class/leds/keyboard\-backlight/brightness",
"chown system system /sys/class/leds/lcd\-backlight/brightness",
"chown system system /sys/class/leds/button\-backlight/brightness",
"chown system system /sys/class/leds/jogball\-backlight/brightness",
"chown system system /sys/class/leds/red/brightness",
"chown system system /sys/class/leds/green/brightness",
"chown system system /sys/class/leds/blue/brightness",
"chown system system /sys/class/leds/red/device/grpfreq",
"chown system system /sys/class/leds/red/device/grppwm",
"chown system system /sys/class/leds/red/device/blink",
"chown system system /sys/module/sco/parameters/disable\_esco",
"chown system system /sys/kernel/ipv4/tcp\_wmem\_min",
"chown system system /sys/kernel/ipv4/tcp\_wmem\_def",
"chown system system /sys/kernel/ipv4/tcp\_wmem\_max",
"chown system system /sys/kernel/ipv4/tcp\_rmem\_min",
"chown system system /sys/kernel/ipv4/tcp\_rmem\_def",
"chown system system /sys/kernel/ipv4/tcp\_rmem\_max",
"chown root radio /proc/cmdline",
"setparam net\.tcp\.default\_init\_rwnd 60"
\]
}
初始化graphics图形相关节点权限
{
"name" : "boot",
"cmds" : \[
"chmod 777 /dev/ttyAMA2",
"chmod 775 /sys/class/rfkill/rfkill0/state",
"chmod 777 /dev/rtkbt\_dev",
"chmod 0440 /proc/interrupts",
"chmod 0440 /proc/stat",
"chmod 0640 /dev/xt\_qtaguid",
"chmod 0660 /proc/net/xt\_qtaguid/ctrl",
"chmod 0440 /proc/net/xt\_qtaguid/stats",
"chmod 666 /dev/mali0",
"chown system graphics /dev/mali0",
"chown system graphics /dev/graphics/fb0",
"chmod 666 /dev/ion",
"chown system system /dev/ion"
\]
\}
挂载configfs 文件系统,挂载usb驱动到/dev/usb-ffs/hdc
# device/hisilicon/hi3516dv300/build/rootfs/init.Hi3516DV300.usb.cfg
{
"jobs" : [{
"name" : "boot",
"cmds" : \[
"mkdir /dev/usb\-ffs 0770 shell shell",
"mkdir /dev/usb\-ffs/hdc 0770 shell shell",
"mount configfs none /config", // 挂载configfs文件系统
"mkdir /config/usb\_gadget/g1 0770 shell shell", // 初始化 usb\_gadget 相关信息,如pid、vid等
"write /config/usb\_gadget/g1/idVendor 0x12D1",
"write /config/usb\_gadget/g1/idProduct 0x5000",
"write /config/usb\_gadget/g1/os\_desc/use 1",
"write /config/usb\_gadget/g1/bcdDevice 0x0223",
"write /config/usb\_gadget/g1/bcdUSB 0x0200",
"mkdir /config/usb\_gadget/g1/strings/0x409 0770",
"copy /sys/block/mmcblk0/device/cid /config/usb\_gadget/g1/strings/0x409/serialnumber",
"write /config/usb\_gadget/g1/strings/0x409/manufacturer HISILICON",
"write /config/usb\_gadget/g1/strings/0x409/product \"HDC Device\"",
"mkdir /config/usb\_gadget/g1/functions/ffs\.hdc",
"mkdir /config/usb\_gadget/g1/configs/b\.1 0770 shell shell",
"mkdir /config/usb\_gadget/g1/configs/b\.1/strings/0x409 0770 shell shell",
"write /config/usb\_gadget/g1/os\_desc/b\_vendor\_code 0x1",
"write /config/usb\_gadget/g1/os\_desc/qw\_sign MSFT100",
"write /config/usb\_gadget/g1/configs/b\.1/MaxPower 500",
"symlink /config/usb\_gadget/g1/configs/b\.1 /config/usb\_gadget/g1/os\_desc/b\.1",
"mount functionfs hdc /dev/usb\-ffs/hdc uid=2000,gid=2000", // 挂载\`usb\` 相关驱动到\`/dev/usb\-ffs/hdc\`
"setparam sys\.usb\.configfs 1",
"setparam sys\.usb\.controller 100e0000\.hidwc3\_0"
\]\}, \{
"name" : "param:sys\.usb\.config=none && param:sys\.usb\.configfs=1",
"condition" : "sys\.usb\.config=none && sys\.usb\.configfs=1",
"cmds" : \[
"write /config/usb\_gadget/g1/os\_desc/use 0",
"setparam sys\.usb\.ffs\.ready 0"
\]\}, \{
"name" : "param:init\.svc\.hdcd=stopped",
"condition" : "init\.svc\.hdcd=stopped",
"cmds" : \[
"setparam sys\.usb\.ffs\.ready 0"
\] \}, \{
"name" : "param:sys\.usb\.config=hdc && param:sys\.usb\.configfs=1",
"condition" : "sys\.usb\.config=hdc && sys\.usb\.configfs=1",
"cmds" : \[
"write /config/usb\_gadget/g1/idProduct 0x5000",
"write /config/usb\_gadget/g1/os\_desc/use 1"
\] \} \]\}
电话服务
{
"jobs" : [{
"name" : "boot",
"cmds" : \[
"exec /system/bin/sleep 4",
"start telephony\_sa"
\]\} \],
"services" : [{
"name" : "telephony\_sa",
"path" : \["/system/bin/sa\_main", "/system/profile/telephony\.xml"\],
"uid" : "system",
"gid" : \["system", "shell"\]
\} \]\}
启动时间服务
# base/miscservices/time/etc/init/timeservice.cfg
{
"jobs" : [{
"name" : "boot",
"cmds" : \[
"start time\_service"
\]\}\],
"services" : [{
"name" : "time\_service",
"path" : \["/system/bin/sa\_main", "/system/profile/time\_service\.xml"\],
"uid" : "system",
"gid" : \["system", "shell"\],
"caps" : \["SYS\_TIME", "WAKE\_ALARM"\]
\}
\]
}
升级服务
{
"jobs" : [{
"name" : "boot",
"cmds" : \[
"start updater\_sa"
\]\}\],
"services" : [{
"name" : "updater\_sa",
"path" : \["/system/bin/sa\_main", "/system/profile/updater\_sa\.xml"\],
"uid" : "system",
"gid" : \["system", "shell"\]
\}\]\}
输入法服务
# base/miscservices/time/etc/init/timeservice.cfg
{
"jobs" : [{
"name" : "boot",
"cmds" : \[
"start time\_service"
\]\}\],
"services" : [{
"name" : "time\_service",
"path" : \["/system/bin/sa\_main", "/system/profile/time\_service\.xml"\],
"uid" : "system",
"gid" : \["system", "shell"\],
"caps" : \["SYS\_TIME", "WAKE\_ALARM"\]
\}
启动hdcd 服务,用于调试
# base/startup/init_lite/services/etc/init.usb.cfg
{
"jobs" : [{
"name" : "boot",
"cmds" : \[
"setparam sys\.usb\.configfs 0"
\]
\}, \{
"name" : "boot && param:persist\.sys\.usb\.config=\*",
"condition" : "boot && persist\.sys\.usb\.config=\*",
"cmds" : \[
"setparam sys\.usb\.config $\{persist\.sys\.usb\.config\}"
\]
\}, \{
"name" : "param:sys\.usb\.config=none && param:sys\.usb\.configfs=0",
"condition" : "sys\.usb\.config=none && sys\.usb\.configfs=0",
"cmds" : \[
"stop hdcd"
\]
\}, \{
"name" : "param:sys\.usb\.config=hdc && param:sys\.usb\.configfs=0",
"condition" : "sys\.usb\.config=hdc && sys\.usb\.configfs=0",
"cmds" : \[
"start hdcd"
\] \}\],
"services" : [{
"name" : "hdcd",
"path" : \["/system/bin/hdcd"\],
"socket" : \[
"hdcd seqpacket 660 system system false"
\],
"disabled" : 1
\}\]\}
基础应用框架
# foundation/appexecfwk/standard/sa_profile/foundation.cfg
{
"jobs" : [{
"name" : "boot",
"cmds" : \[
"chown radio system /sys/power/wake\_lock",
"chown radio system /sys/power/wake\_unlock",
"chmod 0664 /sys/power/wakeup\_count",
"start foundation"
\]\}\],
"services" : [{
"name" : "foundation",
"path" : \["/system/bin/sa\_main", "/system/profile/foundation\.xml"\],
"importance" : \-20,
"uid" : "system",
"gid" : \["system"\],
"caps" : \["SYS\_PTRACE", "KILL"\]
\}
更多回帖