1#
2# Copyright 2013 The Android Open Source Project
3#
4# Licensed under the Apache License, Version 2.0 (the "License");
5# you may not use this file except in compliance with the License.
6# You may obtain a copy of the License at
7#
8#      http://www.apache.org/licenses/LICENSE-2.0
9#
10# Unless required by applicable law or agreed to in writing, software
11# distributed under the License is distributed on an "AS IS" BASIS,
12# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13# See the License for the specific language governing permissions and
14# limitations under the License.
15#
16
17import init.hammerhead.usb.rc
18import init.hammerhead_svelte.rc
19import init.hammerhead.diag.rc
20
21on early-init
22    mount debugfs debugfs /sys/kernel/debug
23    chown system system /sys/kernel/debug/kgsl/proc
24
25on init
26    # See storage config details at http://source.android.com/tech/storage/
27    mkdir /mnt/shell/emulated 0700 shell shell
28    mkdir /storage/emulated 0555 root root
29
30    # Set permissions for persist partition
31    mkdir /persist 0771 system system
32    mkdir /firmware 0771 system system
33
34    export EXTERNAL_STORAGE /storage/emulated/legacy
35    export EMULATED_STORAGE_SOURCE /mnt/shell/emulated
36    export EMULATED_STORAGE_TARGET /storage/emulated
37
38    # Support legacy paths
39    symlink /storage/emulated/legacy /sdcard
40    symlink /storage/emulated/legacy /mnt/sdcard
41    symlink /storage/emulated/legacy /storage/sdcard0
42    symlink /mnt/shell/emulated/0 /storage/emulated/legacy
43
44on fs
45    mount_all ./fstab.hammerhead
46    restorecon_recursive /persist
47    setprop ro.crypto.fuse_sdcard true
48
49on early-boot
50    # set RLIMIT_MEMLOCK to 64MB
51    setrlimit 8 67108864 67108864
52
53on boot
54    # Enable DEBUG_SUSPEND, DEBUG_EXIT_SUSPEND, and DEBUG_WAKEUP
55    write /sys/module/wakelock/parameters/debug_mask 7
56
57    # bluetooth
58    chown bluetooth net_bt_stack /sys/class/rfkill/rfkill0/type
59    chown bluetooth net_bt_stack /sys/class/rfkill/rfkill0/state
60    chmod 0660 /sys/class/rfkill/rfkill0/state
61
62    # bluetooth LPM
63    chown bluetooth net_bt_stack /proc/bluetooth/sleep/lpm
64    chown bluetooth net_bt_stack /proc/bluetooth/sleep/btwrite
65
66    #bluetooth UART dev
67    chown bluetooth net_bt_stack /sys/devices/platform/msm_serial_hs.0/clock
68    chmod 0660 /sys/devices/platform/msm_serial_hs.0/clock
69
70    #Create QMUX deamon socket area
71    mkdir /dev/socket/qmux_radio 0770 radio radio
72    chmod 2770 /dev/socket/qmux_radio
73    mkdir /dev/socket/qmux_audio 0770 media audio
74    chmod 2770 /dev/socket/qmux_audio
75    mkdir /dev/socket/qmux_bluetooth 0770 bluetooth bluetooth
76    chmod 2770 /dev/socket/qmux_bluetooth
77    mkdir /dev/socket/qmux_gps 0770 gps gps
78    chmod 2770 /dev/socket/qmux_gps
79
80    # Camera Recording
81    mkdir /dev/video
82    symlink /dev/video32 /dev/video/venus_dec
83    symlink /dev/video33 /dev/video/venus_enc
84
85    # Allow QMUX daemon to assign port open wait time
86    chown radio radio /sys/devices/virtual/hsicctl/hsicctl0/modem_wait
87
88    #For bridgemgr daemon to inform the USB driver of the correct transport
89    chown radio radio /sys/class/android_usb/f_rmnet_smd_sdio/transport
90
91    # Assign TCP buffer thresholds to be ceiling value of technology maximums
92    # Increased technology maximums should be reflected here.
93    write /proc/sys/net/core/rmem_max  2097152
94    write /proc/sys/net/core/wmem_max  2097152
95
96    # create symlink for fb1 as HDMI
97    symlink /dev/graphics/fb1 /dev/graphics/hdmi
98
99    # setup permissions for fb1 related nodes
100    chown system graphics /sys/class/graphics/fb1/hpd
101    chown system graphics /sys/class/graphics/fb1/vendor_name
102    chown system graphics /sys/class/graphics/fb1/product_description
103    chmod 0664 /sys/devices/virtual/graphics/fb1/hpd
104    chmod 0664 /sys/devices/virtual/graphics/fb1/vendor_name
105    chmod 0664 /sys/devices/virtual/graphics/fb1/product_description
106
107    # To allow interfaces to get v6 address when tethering is enabled
108    write /proc/sys/net/ipv6/conf/rmnet0/accept_ra 2
109    write /proc/sys/net/ipv6/conf/rmnet1/accept_ra 2
110    write /proc/sys/net/ipv6/conf/rmnet2/accept_ra 2
111    write /proc/sys/net/ipv6/conf/rmnet3/accept_ra 2
112    write /proc/sys/net/ipv6/conf/rmnet4/accept_ra 2
113    write /proc/sys/net/ipv6/conf/rmnet5/accept_ra 2
114    write /proc/sys/net/ipv6/conf/rmnet6/accept_ra 2
115    write /proc/sys/net/ipv6/conf/rmnet7/accept_ra 2
116
117    # Subsytem Restart
118    #adsp
119    write /sys/bus/msm_subsys/devices/subsys0/restart_level "related"
120    #modem
121    write /sys/bus/msm_subsys/devices/subsys1/restart_level "related"
122    #venus
123    write /sys/bus/msm_subsys/devices/subsys2/restart_level "related"
124
125    # Subsytem Ramdump collection
126    mkdir /data/tombstones 0777 system system
127    mkdir /data/tombstones/ramdump 0777 system system
128    restorecon_recursive /data/tombstones
129    write /sys/module/subsystem_restart/parameters/enable_ramdumps 1
130
131    # leds
132    chown system system /sys/class/leds/red/on_off_ms
133    chown system system /sys/class/leds/green/on_off_ms
134    chown system system /sys/class/leds/blue/on_off_ms
135    chown system system /sys/class/leds/red/rgb_start
136    chmod 664 /sys/class/leds/lcd-backlight/brightness
137
138on post-fs-data
139    write /sys/kernel/boot_adsp/boot 1
140
141    mkdir /data/media 0770 media_rw media_rw
142
143    # NFC: create data/nfc for nv storage
144    mkdir /data/nfc 0770 nfc nfc
145    mkdir /data/nfc/param 0770 nfc nfc
146
147    # wifi
148    chown wifi system /persist/wifi
149
150    #  bluetooth
151    mkdir /data/misc/bluetooth 0770 bluetooth bluetooth
152
153    # Create directory used by audio subsystem
154    mkdir /data/misc/audio 0770 audio audio
155
156    # Create directory used by sensor subsystem
157    mkdir /data/system 0755 system system
158    mkdir /data/system/sensors
159    chmod 755 /data/system/sensors
160
161    # AKM setting data
162    mkdir /data/misc/sensors
163    chmod 775 /data/misc/sensors
164
165    # Sensor
166    mkdir /persist/sensors
167    chmod 775 /persist/sensors
168    write /persist/sensors/sensors_settings 1
169    chmod 660 /persist/sensors/sensors_settings
170
171    # communicate with mpdecision and thermald
172    mkdir /dev/socket/mpdecision 2770 root system
173
174    # save rtc time offsets
175    mkdir /data/system/time 0700 system system
176
177    # Ecc_Handler qcril.db
178    mkdir /data/misc/radio 0770 radio radio
179    symlink /system/etc/qcril.db /data/misc/radio/qcril.db
180
181    setprop vold.post_fs_data_done 1
182
183    # Set the CPU Freq Sampling rates
184    write /sys/module/msm_thermal/core_control/enabled 0
185    write /sys/devices/system/cpu/cpu1/online 1
186    write /sys/devices/system/cpu/cpu2/online 1
187    write /sys/devices/system/cpu/cpu3/online 1
188    write /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor "ondemand"
189    write /sys/devices/system/cpu/cpu1/cpufreq/scaling_governor "ondemand"
190    write /sys/devices/system/cpu/cpu2/cpufreq/scaling_governor "ondemand"
191    write /sys/devices/system/cpu/cpu3/cpufreq/scaling_governor "ondemand"
192    write /sys/devices/system/cpu/cpufreq/ondemand/up_threshold 90
193    write /sys/devices/system/cpu/cpufreq/ondemand/sampling_rate 50000
194    write /sys/devices/system/cpu/cpufreq/ondemand/io_is_busy 1
195    write /sys/devices/system/cpu/cpufreq/ondemand/sampling_down_factor 4
196    write /sys/devices/system/cpu/cpufreq/ondemand/down_differential 10
197    write /sys/devices/system/cpu/cpufreq/ondemand/up_threshold_multi_core 70
198    write /sys/devices/system/cpu/cpufreq/ondemand/down_differential_multi_core 3
199    write /sys/devices/system/cpu/cpufreq/ondemand/optimal_freq 960000
200    write /sys/devices/system/cpu/cpufreq/ondemand/sync_freq 960000
201    write /sys/devices/system/cpu/cpufreq/ondemand/up_threshold_any_cpu_load 80
202    write /sys/devices/system/cpu/cpu0/cpufreq/scaling_min_freq 300000
203    write /sys/devices/system/cpu/cpu1/cpufreq/scaling_min_freq 300000
204    write /sys/devices/system/cpu/cpu2/cpufreq/scaling_min_freq 300000
205    write /sys/devices/system/cpu/cpu3/cpufreq/scaling_min_freq 300000
206    write /sys/module/msm_thermal/core_control/enabled 1
207    chown root.system /sys/devices/system/cpu/mfreq
208    chmod 220 /sys/devices/system/cpu/mfreq
209    chown root.system /sys/devices/system/cpu/cpu1/online
210    chown root.system /sys/devices/system/cpu/cpu2/online
211    chown root.system /sys/devices/system/cpu/cpu3/online
212    chmod 664 /sys/devices/system/cpu/cpu1/online
213    chmod 664 /sys/devices/system/cpu/cpu2/online
214    chmod 664 /sys/devices/system/cpu/cpu3/online
215    write /dev/cpuctl/apps/cpu.notify_on_migrate 1
216
217on charger
218    # Booting modem
219    wait /dev/block/platform/msm_sdcc.1/by-name/modem
220    mount vfat /dev/block/platform/msm_sdcc.1/by-name/modem /firmware ro shortname=lower,uid=1000,gid=1000,dmask=227,fmask=337,context=u:object_r:firmware_file:s0
221    wait /dev/block/platform/msm_sdcc.1/by-name/system
222    mount ext4 /dev/block/platform/msm_sdcc.1/by-name/system /system ro barrier=1
223    start rmt_storage
224    start irsc_util
225
226    # Enable Power modes and set the CPU Freq Sampling rates
227    write /sys/module/lpm_resources/enable_low_power/l2 2
228    write /sys/module/lpm_resources/enable_low_power/pxo 1
229    write /sys/module/lpm_resources/enable_low_power/vdd_dig 1
230    write /sys/module/lpm_resources/enable_low_power/vdd_mem 1
231    write /sys/module/pm_8x60/modes/cpu0/power_collapse/suspend_enabled 1
232    write /sys/module/pm_8x60/modes/cpu1/power_collapse/suspend_enabled 1
233    write /sys/module/pm_8x60/modes/cpu2/power_collapse/suspend_enabled 1
234    write /sys/module/pm_8x60/modes/cpu3/power_collapse/suspend_enabled 1
235    write /sys/module/pm_8x60/modes/cpu0/power_collapse/idle_enabled 1
236    write /sys/module/msm_thermal/core_control/enabled 0
237    write /sys/devices/system/cpu/cpu1/online 1
238    write /sys/devices/system/cpu/cpu2/online 1
239    write /sys/devices/system/cpu/cpu3/online 1
240    write /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor "powersave"
241    write /sys/devices/system/cpu/cpu1/cpufreq/scaling_governor "powersave"
242    write /sys/devices/system/cpu/cpu2/cpufreq/scaling_governor "powersave"
243    write /sys/devices/system/cpu/cpu3/cpufreq/scaling_governor "powersave"
244    write /sys/devices/system/cpu/cpu0/cpufreq/scaling_min_freq 300000
245    write /sys/devices/system/cpu/cpu1/cpufreq/scaling_min_freq 300000
246    write /sys/devices/system/cpu/cpu2/cpufreq/scaling_min_freq 300000
247    write /sys/devices/system/cpu/cpu3/cpufreq/scaling_min_freq 300000
248    write /sys/module/msm_thermal/core_control/enabled 1
249    write /sys/devices/system/cpu/cpu1/online 0
250    write /sys/devices/system/cpu/cpu2/online 0
251    write /sys/devices/system/cpu/cpu3/online 0
252    start mpdecision
253
254on property:init.svc.wpa_supplicant=stopped
255    stop dhcpcd
256
257on property:sys.boot_completed=1
258    # Enable Power modes
259    write /sys/module/lpm_resources/enable_low_power/l2 2
260    write /sys/module/lpm_resources/enable_low_power/pxo 1
261    write /sys/module/lpm_resources/enable_low_power/vdd_dig 1
262    write /sys/module/lpm_resources/enable_low_power/vdd_mem 1
263    write /sys/module/pm_8x60/modes/cpu0/power_collapse/suspend_enabled 1
264    write /sys/module/pm_8x60/modes/cpu1/power_collapse/suspend_enabled 1
265    write /sys/module/pm_8x60/modes/cpu2/power_collapse/suspend_enabled 1
266    write /sys/module/pm_8x60/modes/cpu3/power_collapse/suspend_enabled 1
267    write /sys/module/pm_8x60/modes/cpu0/power_collapse/idle_enabled 1
268    write /sys/module/pm_8x60/modes/cpu0/standalone_power_collapse/suspend_enabled 1
269    write /sys/module/pm_8x60/modes/cpu1/standalone_power_collapse/suspend_enabled 1
270    write /sys/module/pm_8x60/modes/cpu2/standalone_power_collapse/suspend_enabled 1
271    write /sys/module/pm_8x60/modes/cpu3/standalone_power_collapse/suspend_enabled 1
272    write /sys/module/pm_8x60/modes/cpu0/standalone_power_collapse/idle_enabled 1
273    write /sys/module/pm_8x60/modes/cpu1/standalone_power_collapse/idle_enabled 1
274    write /sys/module/pm_8x60/modes/cpu2/standalone_power_collapse/idle_enabled 1
275    write /sys/module/pm_8x60/modes/cpu3/standalone_power_collapse/idle_enabled 1
276    write /sys/module/pm_8x60/modes/cpu0/retention/idle_enabled 1
277    write /sys/module/pm_8x60/modes/cpu1/retention/idle_enabled 1
278    write /sys/module/pm_8x60/modes/cpu2/retention/idle_enabled 1
279    write /sys/module/pm_8x60/modes/cpu3/retention/idle_enabled 1
280    start mpdecision
281
282    # enable slimport detection
283    write /sys/module/slimport/parameters/enable_irq 1
284
285    # enable logging of wake up reasons to kernel logs
286    write /sys/module/msm_show_resume_irq/parameters/debug_mask 1
287
288on property:ro.debuggable=1
289    start ssr_ramdump
290
291service rmt_storage /system/bin/rmt_storage
292    class core
293    user root
294    group system
295
296service bridgemgrd /system/bin/bridgemgrd
297    class main
298    user radio
299    group radio
300
301# QMUX must be in multiple groups to support external process connections
302service qmuxd /system/bin/qmuxd
303    class main
304    user radio
305    group radio audio bluetooth gps
306
307service netmgrd /system/bin/netmgrd
308    class main
309    group radio
310
311# QCOM sensor
312service sensors /system/bin/sensors.qcom
313    class main
314    user root
315    group root
316
317service irsc_util /system/bin/irsc_util "/etc/sec_config"
318    class main
319    user root
320    oneshot
321
322service p2p_supplicant /system/bin/wpa_supplicant \
323    -iwlan0 -Dnl80211 -c/data/misc/wifi/wpa_supplicant.conf \
324    -I/system/etc/wifi/wpa_supplicant_overlay.conf -N \
325    -ip2p0 -Dnl80211 -c/data/misc/wifi/p2p_supplicant.conf \
326    -I/system/etc/wifi/p2p_supplicant_overlay.conf \
327    -puse_p2p_group_interface=1 -e/data/misc/wifi/entropy.bin \
328    -g@android:wpa_wlan0
329    #   we will start as root and wpa_supplicant will switch to user wifi
330    #   after setting up the capabilities required for WEXT
331    #   user wifi
332    #   group wifi inet keystore
333    class main
334    socket wpa_wlan0 dgram 660 wifi wifi
335    disabled
336    oneshot
337
338service wpa_supplicant /system/bin/wpa_supplicant \
339    -iwlan0 -Dnl80211 -c/data/misc/wifi/wpa_supplicant.conf \
340    -I/system/etc/wifi/wpa_supplicant_overlay.conf \
341    -e/data/misc/wifi/entropy.bin -g@android:wpa_wlan0
342    #   we will start as root and wpa_supplicant will switch to user wifi
343    #   after setting up the capabilities required for WEXT
344    #   user wifi
345    #   group wifi inet keystore
346    class main
347    socket wpa_wlan0 dgram 660 wifi wifi
348    disabled
349    oneshot
350
351service dhcpcd_wlan0 /system/bin/dhcpcd -aABDKL
352    class late_start
353    disabled
354    oneshot
355
356service dhcpcd_p2p /system/bin/dhcpcd -aABKL
357    class late_start
358    disabled
359    oneshot
360
361service iprenew_wlan0 /system/bin/dhcpcd -n
362    class late_start
363    disabled
364    oneshot
365
366service iprenew_p2p /system/bin/dhcpcd -n
367    class late_start
368    disabled
369    oneshot
370
371service dhcpcd_eth0 /system/bin/dhcpcd -aABDKL
372    class late_start
373    disabled
374    oneshot
375
376service iprenew_eth0 /system/bin/dhcpcd -n
377    class late_start
378    disabled
379    oneshot
380
381service dhcpcd_bnep0 /system/bin/dhcpcd -BKLG
382    disabled
383    oneshot
384
385service dhcpcd_bnep1 /system/bin/dhcpcd -BKLG
386    disabled
387    oneshot
388
389service dhcpcd_bnep2 /system/bin/dhcpcd -BKLG
390    disabled
391    oneshot
392
393service dhcpcd_bnep3 /system/bin/dhcpcd -BKLG
394    disabled
395    oneshot
396
397service dhcpcd_bnep4 /system/bin/dhcpcd -BKLG
398    disabled
399    oneshot
400
401service dhcpcd_bt-pan /system/bin/dhcpcd -BKLG
402    disabled
403    oneshot
404
405service iprenew_bt-pan /system/bin/dhcpcd -n
406    disabled
407    oneshot
408
409service qseecomd /system/bin/qseecomd
410    class core
411    user root
412    group root
413
414# virtual sdcard daemon running as media_rw (1023)
415service sdcard /system/bin/sdcard -u 1023 -g 1023 -l /data/media /mnt/shell/emulated
416    class late_start
417
418service charger /sbin/healthd -c
419    class charger
420    critical
421    seclabel u:r:healthd:s0
422
423service qcamerasvr /system/bin/mm-qcamera-daemon
424    class late_start
425    user camera
426    group camera system inet input
427
428service bdAddrLoader /system/bin/bdAddrLoader -f /persist/bluetooth/.bdaddr -h -x
429    class main
430    user bluetooth
431    group system bluetooth
432    oneshot
433
434# bugreport is triggered by holding down volume down, volume up and power
435service bugreport /system/bin/dumpstate -d -p -B \
436        -o /data/data/com.android.shell/files/bugreports/bugreport
437    class main
438    disabled
439    oneshot
440    keycodes 114 115 116
441
442service mpdecision /system/bin/mpdecision --no_sleep --avg_comp
443   class main
444   user root
445   group root system
446   disabled
447
448service ssr_ramdump /system/bin/subsystem_ramdump -m -t emmc
449    class main
450    user root
451    group root
452    disabled
453
454service thermal-engine /system/bin/thermal-engine-hh
455   class main
456   user root
457   group radio system
458
459service vss_init /vendor/bin/vss_init
460    class late_start
461    user root
462    group root
463    disabled
464
465service time_daemon /system/bin/time_daemon
466    class late_start
467    user root
468    group root
469