OpenHarmony恢复启动子系统init进程之服务启动
首先执行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 服务。
pre-init
主要是启动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字段的命令的。
- /etc/init.cfg
在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"
]
}
- /vendor/etc/init.${ohos.boot.hardware}.cfg
主要是跟硬件产品相关的配置,这里看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"
]
}
]
}
- foundation.cfg 用户程序框架子系统
挂载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.cfg
主要是挂载调试子系统,启动用户程序框架子系统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
post-init 作用是处理系统服务进程启动之后的行为。他会触发启动所有cfg文件中post-init 字段的命令。
- /etc/init.cfg
{
"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` 阶段的命令
]
}
- /system/etc/init/bytrace.cfg
主要是初始化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"
}
early-fs 阶段
启动vold服务 volume daemon
- /etc/init.cfg early-fs
Vold 就是负责挂载SD卡的,vold 的全称是volume daemon。 实际上是负责完成系统的CDROM,USB 大容量存储,MMC 卡等扩展存储的挂载任务自动完成的守护进程。 它提供的主要特点是支持这些存储外设的热插拔。
# base/startup/init_lite/services/etc/init.cfg
"jobs" : [{
"name" : "early-fs",
"cmds" : [
"start vold"
]
}
fs 阶段
insmod加载内核驱动模块
- /etc/init.${ohos.boot.hardware}.cfg fs 段
跟具体的硬件相关,这里以hi3516为例,/etc/init.Hi3516DV300.cfg
- 加载 hi_securec.ko 安全模块
- 加载 mmz模块驱动 hi_osal.ko 在海思平台上将内存分为两个部分:os内存和mmz内存。 os内存指:由linux操作系统管理的内存; mmz内存:由mmz驱动模块进行管理供媒体业务单独使用的内存,在驱动加载时可以指定该模块管理内存的大小。
- 加载中断模块驱动 hi_irq.ko
- 加载 proc 虚拟文件系统模块驱动 hi_proc.ko
- 加载Hi3516DV300芯片的linux内核驱动模块驱动 sys_config.ko
{
"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"
]
}
post-fs段
挂载 rootfs文件系统到根目录,启动udevd_service监听并处理内核udev事件
- /etc/init.cfg post-fs 段
主要是挂载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"
]
}
late-fs 阶段
启动分布式权限管理、应用孵化器组件、用户程序管理等服务;
- /etc/init.cfg late-fs 段
修改tracing节点权限为755
{
"name" : "late-fs",
"cmds" : [
"chmod 0755 /sys/kernel/debug/tracing"
]
}
post-fs-data 阶段
启动驱动子系统、系统帐号组件、鸿蒙通用密钥库系统 huks、设备认证模块、日志文件系统(hilog)、布式软总线组件(dsoftbus)、无线局域网组件、蓝牙、音频组件、分布式任务调度模块等服务;
- /etc/init.cfg
初始化/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"
]
}
- /vendor/etc/init/hdf_peripheral.cfg post-fs-data段
将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"
]}]
}
- /vendor/etc/init/hdf_devmgr.cfg post-fs-data段
启动hdf 驱动子系统服务
{
"jobs" : [{
"name" : "post-fs-data",
"cmds" : [
"start hdf_devmgr"
]}],
"services" : [{
"name" : "hdf_devmgr",
"path" : ["/system/bin/hdf_devmgr"],
"uid" : "root",
"gid" : ["system"]
}]
- /vendor/etc/init/hdf_devhostmusl.cfg post-fs-data 段
启动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"]
}
]
}
boot 段
初始化USB驱动、启动电话、时间、输入法、升级服务引擎、hdcd、媒体库组件、相机组件、媒体组件、分布式数据等服务;
- /etc/init.cfg
# 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"
]
}
- /vendor/etc/init.${ohos.boot.hardware}.cfg
初始化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"
]
}
- /vendor/etc/init.${ohos.boot.hardware}.usb.cfg
挂载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"
] } ]}
- telephony.cfg
电话服务
{
"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"]
} ]}
- timeservice.cfg
启动时间服务
# 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"]
}
]
}
- updater_sa.cfg
升级服务
{
"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"]
}]}
- inputmethodservice.cfg
输入法服务
# 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"]
}
- init.usb.cfg
启动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.cfg
基础应用框架
# 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"]
}