1#
2# Copyright 2014 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.shamu.usb.rc
18import init.shamu.power.rc
19import init.shamu.diag.rc
20
21on early-init
22    mkdir /firmware 0771 system system
23    symlink /data/tombstones /tombstones
24    mount debugfs debugfs /sys/kernel/debug
25    chown system system /sys/kernel/debug/kgsl/proc
26
27on init
28    # See storage config details at http://source.android.com/tech/storage/
29    mkdir /mnt/shell/emulated 0700 shell shell
30    mkdir /storage/emulated 0555 root root
31
32    mkdir /oem 0550 root root
33
34    # Set permissions for persist partition
35    mkdir /persist 0771 system system
36
37    export EXTERNAL_STORAGE /storage/emulated/legacy
38    export EMULATED_STORAGE_SOURCE /mnt/shell/emulated
39    export EMULATED_STORAGE_TARGET /storage/emulated
40
41    # Support legacy paths
42    symlink /storage/emulated/legacy /sdcard
43    symlink /storage/emulated/legacy /mnt/sdcard
44    symlink /storage/emulated/legacy /storage/sdcard0
45    symlink /mnt/shell/emulated/0 /storage/emulated/legacy
46
47on fs
48    mount_all fstab.shamu
49    setprop ro.crypto.fuse_sdcard true
50
51    # Keeping following partitions outside fstab file. As user may not have
52    # these partition flashed on the device. Failure to mount any partition in fstab file
53    # results in failure to launch late-start class.
54    wait /dev/block/platform/msm_sdcc.1/by-name/oem
55    mount ext4 /dev/block/platform/msm_sdcc.1/by-name/oem /oem ro nosuid nodev context=u:object_r:oemfs:s0
56
57    mkdir /fsg 0755 root root
58    mount ext4 /dev/block/platform/msm_sdcc.1/by-name/mdm1m9kefs3 /fsg ro nosuid nodev barrier=0 context=u:object_r:fsg_file:s0
59
60    restorecon_recursive /persist
61    mkdir /persist/data 0700 system system
62    mkdir /persist/data/sfs 0700 system system
63    mkdir /persist/data/tz 0700 system system
64    mkdir /persist/public 0755 system radio
65    mkdir /persist/public/hiddenmenu 0775 system radio
66    mkdir /persist/public/hiddenmenu/data 0775 system radio
67
68    # Enable rmnet data and aggregation
69    setprop persist.rmnet.mux enabled
70    setprop persist.rmnet.data.enable true
71    setprop persist.data.wda.enable true
72    setprop persist.data.df.agg.dl_pkt 10
73    setprop persist.data.df.agg.dl_size 4096
74
75on post-fs-data
76    mkdir /data/tombstones 0771 system system
77    mkdir /tombstones/modem 0771 system system
78    mkdir /tombstones/lpass 0771 system system
79    mkdir /tombstones/wcnss 0771 system system
80    mkdir /tombstones/dsps 0771 system system
81
82    # SENSORS
83    #Create directory used by sensor subsystem(dsps)
84    mkdir /data/system/sensors
85    chmod 0775 /data/system/sensors
86
87    # AKM setting data
88    mkdir /data/misc/sensors
89    chmod 0775 /data/misc/sensors
90
91    mkdir /persist/sensors
92    chmod 0775 /persist/sensors
93
94    mkdir /persist/mdm 0770 radio radio
95
96    #Subsystem RAM-dumps
97    mkdir /data/ss-ram-dumps 0750 radio log
98    mkdir /data/ss-ram-dumps/bp-dumps 0750 radio log
99
100    # rild files
101    mkdir /data/misc/audio_cutback 0770 radio audio
102
103on early-boot
104    # set RLIMIT_MEMLOCK to 64MB
105    setrlimit 8 67108864 67108864
106
107    # Allow subsystem (modem etc) debugging
108    # write /sys/module/subsystem_restart/parameters/enable_debug ${persist.sys.ssr.enable_debug}
109
110    write /sys/kernel/boot_adsp/boot 1
111
112    # Subsytem Restart
113    #venus
114    write /sys/bus/msm_subsys/devices/subsys0/restart_level "related"
115    write /sys/bus/msm_subsys/devices/subsys0/recovery_policy "skip_restart"
116    #adsp
117    write /sys/bus/msm_subsys/devices/subsys1/restart_level "related"
118    write /sys/bus/msm_subsys/devices/subsys1/recovery_policy "skip_restart"
119    #vpu
120    write /sys/bus/msm_subsys/devices/subsys2/restart_level "related"
121    write /sys/bus/msm_subsys/devices/subsys2/recovery_policy "skip_restart"
122    #esoc0 (mdm)
123    write /sys/bus/msm_subsys/devices/subsys3/restart_level "related"
124    write /sys/bus/msm_subsys/devices/subsys3/recovery_policy "skip_restart"
125
126on boot
127    insmod /system/lib/modules/adsprpc.ko
128    insmod /system/lib/modules/mhi.ko
129    chown bluetooth net_bt_stack /sys/module/bluetooth_power/parameters/power
130    chown bluetooth net_bt_stack /sys/class/rfkill/rfkill0/type
131    chown bluetooth net_bt_stack /sys/class/rfkill/rfkill0/state
132    chown bluetooth net_bt_stack /proc/bluetooth/sleep/proto
133    chown bluetooth net_bt_stack /proc/bluetooth/sleep/lpm
134    chown bluetooth net_bt_stack /proc/bluetooth/sleep/btwrite
135    chown bluetooth net_bt_stack /sys/module/hci_uart/parameters/ath_lpm
136    chown bluetooth net_bt_stack /sys/module/hci_uart/parameters/ath_btwrite
137    chown system system /sys/module/sco/parameters/disable_esco
138    chown bluetooth net_bt_stack /sys/module/hci_smd/parameters/hcismd_set
139    chmod 0660 /sys/module/bluetooth_power/parameters/power
140    chmod 0660 /sys/module/hci_smd/parameters/hcismd_set
141    chmod 0660 /sys/class/rfkill/rfkill0/state
142    chmod 0660 /proc/bluetooth/sleep/proto
143    chown bluetooth net_bt_stack /dev/ttyHS0
144    chmod 0660 /sys/module/hci_uart/parameters/ath_lpm
145    chmod 0660 /sys/module/hci_uart/parameters/ath_btwrite
146    chmod 0660 /dev/ttyHS0
147    chown bluetooth net_bt_stack /sys/devices/platform/msm_serial_hs.0/clock
148    chmod 0660 /sys/devices/platform/msm_serial_hs.0/clock
149
150    chmod 0660 /dev/ttyHS2
151    chown bluetooth net_bt_stack /dev/ttyHS2
152
153    #Create QMUX deamon socket area
154    mkdir /dev/socket/qmux_radio 0770 radio radio
155    chmod 2770 /dev/socket/qmux_radio
156    mkdir /dev/socket/qmux_audio 0770 media audio
157    chmod 2770 /dev/socket/qmux_audio
158    mkdir /dev/socket/qmux_bluetooth 0770 bluetooth bluetooth
159    chmod 2770 /dev/socket/qmux_bluetooth
160    mkdir /dev/socket/qmux_gps 0770 gps gps
161    chmod 2770 /dev/socket/qmux_gps
162
163    mkdir /dev/socket/mpdecision 2775 root system
164    chmod 2775 /dev/socket/mpdecision
165
166    setprop wifi.interface wlan0
167
168    #readable symlinks for video nodes
169    mkdir /dev/video
170    symlink /dev/video32 /dev/video/venus_dec
171    symlink /dev/video33 /dev/video/venus_enc
172
173    setprop ro.telephony.call_ring.multiple false
174
175    chown system system /sys/bus/i2c/devices/1-004a/tsp
176
177    chmod 0444 /sys/devices/platform/msm_hsusb/gadget/usb_state
178
179    # Allow QMUX daemon to assign port open wait time
180    chown radio radio /sys/devices/virtual/hsicctl/hsicctl0/modem_wait
181
182    #port-bridge
183    chmod 0660 /dev/smd0
184    chown system system /dev/smd0
185
186    #BT DUN port-bridge
187    chmod 0660 /dev/smd7
188    chown bluetooth net_bt_stack /dev/smd7
189
190    #For bridgemgr daemon to inform the USB driver of the correct transport
191    chown radio radio /sys/class/android_usb/f_rmnet_smd_sdio/transport
192
193#   Assign TCP buffer thresholds to be ceiling value of technology maximums
194#   Increased technology maximums should be reflected here.
195    write /proc/sys/net/core/rmem_max  8388608
196    write /proc/sys/net/core/wmem_max  8388608
197
198    #To allow interfaces to get v6 address when tethering is enabled
199    write /proc/sys/net/ipv6/conf/rmnet0/accept_ra 2
200    write /proc/sys/net/ipv6/conf/rmnet1/accept_ra 2
201    write /proc/sys/net/ipv6/conf/rmnet2/accept_ra 2
202    write /proc/sys/net/ipv6/conf/rmnet3/accept_ra 2
203    write /proc/sys/net/ipv6/conf/rmnet4/accept_ra 2
204    write /proc/sys/net/ipv6/conf/rmnet5/accept_ra 2
205    write /proc/sys/net/ipv6/conf/rmnet6/accept_ra 2
206    write /proc/sys/net/ipv6/conf/rmnet7/accept_ra 2
207    write /proc/sys/net/ipv6/conf/rmnet_sdio0/accept_ra 2
208    write /proc/sys/net/ipv6/conf/rmnet_sdio1/accept_ra 2
209    write /proc/sys/net/ipv6/conf/rmnet_sdio2/accept_ra 2
210    write /proc/sys/net/ipv6/conf/rmnet_sdio3/accept_ra 2
211    write /proc/sys/net/ipv6/conf/rmnet_sdio4/accept_ra 2
212    write /proc/sys/net/ipv6/conf/rmnet_sdio5/accept_ra 2
213    write /proc/sys/net/ipv6/conf/rmnet_sdio6/accept_ra 2
214    write /proc/sys/net/ipv6/conf/rmnet_sdio7/accept_ra 2
215    write /proc/sys/net/ipv6/conf/rmnet_usb0/accept_ra 2
216    write /proc/sys/net/ipv6/conf/rmnet_usb1/accept_ra 2
217    write /proc/sys/net/ipv6/conf/rmnet_usb2/accept_ra 2
218    write /proc/sys/net/ipv6/conf/rmnet_usb3/accept_ra 2
219
220    # To prevent out of order acknowledgements from making
221    # connection tracking to treat them as not belonging to
222    # the connection they belong to.
223    # Otherwise, a weird issue happens in which some long
224    # connections on high-throughput links get dropped when
225    # an ack packet comes out of order
226    write /proc/sys/net/netfilter/nf_conntrack_tcp_be_liberal 1
227
228    # Set the console loglevel to < KERN_INFO
229    # Set the default message loglevel to KERN_INFO
230    # write /proc/sys/kernel/printk "6 6 1 7"
231
232    write /sys/bus/platform/drivers/xhci_msm_hsic/unbind msm_hsic_host
233    write /sys/module/rmnet_usb/parameters/mux_enabled 1
234    write /sys/module/rmnet_usb/parameters/no_fwd_rmnet_links 8
235    write /sys/module/rmnet_usb/parameters/no_rmnet_insts_per_dev 17
236    write /sys/module/rmnet_usb/parameters/rmnet_data_init 1
237    chown radio radio /sys/devices/virtual/hsicctl/hsicctl0/modem_wait
238
239    # Audio DSP permissions
240    chown media media /dev/ttyHS3
241    chown media media /sys/devices/c55_ctrl/gpio_ap_int/edge
242    chown media media /sys/devices/c55_ctrl/gpio_ap_int/value
243    chown media media /sys/devices/c55_ctrl/gpio_c55_int/value
244    chown media media /sys/devices/c55_ctrl/gpio_core/value
245    chown media media /sys/devices/c55_ctrl/gpio_reset/value
246
247# subsystem ramdump collection
248on property:persist.sys.qc.sub.rdump.on=*
249    write /sys/module/subsystem_restart/parameters/enable_ramdumps ${persist.sys.qc.sub.rdump.on}
250
251# permissions for CapSense firmware update
252    chown radio radio /sys/devices/cycapsense_prog.1/cycapsense_fw
253    chmod 0220 /sys/devices/cycapsense_prog.1/cycapsense_fw
254
255# msm specific files that need to be created on /data
256on post-fs-data
257    # we will remap this as /mnt/sdcard with the sdcard fuse tool
258    mkdir /data/media 0770 media_rw media_rw
259    chown media_rw media_rw /data/media
260
261    mkdir /data/misc/bluetooth 0770 bluetooth bluetooth
262
263    # Create the directories used by the Wireless subsystem
264    mkdir /data/misc/wifi 0770 wifi wifi
265    mkdir /data/misc/wifi/sockets 0770 wifi wifi
266    mkdir /data/misc/wifi/wpa_supplicant 0770 wifi wifi
267    mkdir /data/misc/dhcp 0770 dhcp dhcp
268    chown dhcp dhcp /data/misc/dhcp
269
270    # Create the directories used by CnE subsystem
271    mkdir /data/connectivity 0771 system system
272    chown system system /data/connectivity
273
274    mkdir /data/connectivity/nsrm 0771 system system
275    chown system system /data/connectivity/nsrm
276
277    # Create directory used by audio subsystem
278    mkdir /data/misc/audio 0770 audio audio
279
280    # Mounting of persist is moved to 'on emmc-fs' and 'on fs' sections
281    # We chown/chmod /persist again so because mount is run as root + defaults
282    chown system system /persist
283    chmod 0771 /persist
284    chmod 0664 /sys/devices/platform/msm_sdcc.1/polling
285    chmod 0664 /sys/devices/platform/msm_sdcc.2/polling
286    chmod 0664 /sys/devices/platform/msm_sdcc.3/polling
287    chmod 0664 /sys/devices/platform/msm_sdcc.4/polling
288
289    # Chown polling nodes as needed from UI running on system server
290    chown system system /sys/devices/platform/msm_sdcc.1/polling
291    chown system system /sys/devices/platform/msm_sdcc.2/polling
292    chown system system /sys/devices/platform/msm_sdcc.3/polling
293    chown system system /sys/devices/platform/msm_sdcc.4/polling
294
295    #Create the symlink to qcn wpa_supplicant folder for ar6000 wpa_supplicant
296    mkdir /data/system 0775 system system
297    #symlink /data/misc/wifi/wpa_supplicant /data/system/wpa_supplicant
298
299    #Create directories for gpsone_daemon services
300    mkdir /data/misc/gpsone_d 0770 system gps
301
302    #Create directories for QuIPS
303    mkdir /data/misc/quipc 0770 gps system
304
305    #Create directories for Location services
306    mkdir /data/misc/location 0770 gps gps
307    mkdir /data/misc/location/mq 0770 gps gps
308    mkdir /data/misc/location/xtwifi 0770 gps gps
309
310    #Create directory from IMS services
311    mkdir /data/shared 0755
312    chown system system /data/shared
313
314    #Create directory for FOTA
315    mkdir /data/fota 0771
316    chown system system /data/fota
317
318    #Create directory for hostapd
319    mkdir /data/hostapd 0770 system wifi
320
321    # Create /data/time folder for time-services
322    mkdir /data/time/ 0700 system system
323
324    mkdir /data/audio/ 0770 media audio
325
326    setprop vold.post_fs_data_done 1
327
328    #Create a folder for SRS to be able to create a usercfg file
329    mkdir /data/data/media 0770 media media
330
331    # NFC local data and nfcee xml storage
332    mkdir /data/nfc 0770 nfc nfc
333    mkdir /data/nfc/param 0770 nfc nfc
334
335    # Audio DSP permissions
336    mkdir /data/adspd 0770 media media
337    mkdir /data/adspd/1 0770 media media
338
339on property:init.svc.wpa_supplicant=stopped
340    stop dhcpcd
341
342on property:bluetooth.isEnabled=true
343    start btwlancoex
344    write /sys/class/bluetooth/hci0/idle_timeout 7000
345
346on property:ro.bluetooth.ftm_enabled=true
347    start ftmd
348
349on property:persist.env.fastdorm.enabled=true
350    setprop persist.radio.data_no_toggle 1
351
352service irsc_util /system/bin/irsc_util "/etc/sec_config"
353    class main
354    user root
355    oneshot
356
357service mdm_helper /system/bin/mdm_helper
358    user root
359    group root system radio
360    class core
361    onrestart setprop ro.service.mdm_helper_restarted "true"
362
363service tcmd /system/bin/tcmd_mini
364    class core
365    user radio
366    group radio net_raw net_admin
367    disabled
368
369service bridgemgrd /system/bin/bridgemgrd
370    class late_start
371    user radio
372    group radio
373
374# QMUX must be in multiple groups to support external process connections
375service qmuxd /system/bin/qmuxd
376    class main
377    user root
378    group radio audio bluetooth gps
379
380service netmgrd /system/bin/netmgrd
381    class main
382    group radio
383
384service sensors /system/bin/sensors.qcom
385    class core
386    user root
387    group root
388
389on property:ro.use_data_netmgrd=false
390    # netmgr not supported on specific target
391    stop netmgrd
392
393# Adjust socket buffer to enlarge TCP receive window for high bandwidth
394# but only if ro.data.large_tcp_window_size property is set.
395on property:ro.data.large_tcp_window_size=true
396    write /proc/sys/net/ipv4/tcp_adv_win_scale  2
397
398service p2p_supplicant /system/bin/wpa_supplicant \
399    -iwlan0 -Dnl80211 -c/data/misc/wifi/wpa_supplicant.conf \
400    -I/system/etc/wifi/p2p_supplicant_overlay.conf  \
401    -puse_p2p_group_interface=1p2p_device=1 \
402    -m/data/misc/wifi/p2p_supplicant.conf \
403    -e/data/misc/wifi/entropy.bin -g@android:wpa_wlan0
404#   we will start as root and wpa_supplicant will switch to user wifi
405#   after setting up the capabilities required for WEXT
406#   user wifi
407#   group wifi inet keystore
408    class main
409    socket wpa_wlan0 dgram 660 wifi wifi
410    disabled
411    oneshot
412
413service wpa_supplicant /system/bin/wpa_supplicant \
414    -iwlan0 -Dnl80211 -c/data/misc/wifi/wpa_supplicant.conf \
415    -I/system/etc/wifi/wpa_supplicant_overlay.conf \
416    -e/data/misc/wifi/entropy.bin -g@android:wpa_wlan0
417    #   we will start as root and wpa_supplicant will switch to user wifi
418    #   after setting up the capabilities required for WEXT
419    #   user wifi
420    #   group wifi inet keystore
421    class main
422    socket wpa_wlan0 dgram 660 wifi wifi
423    disabled
424    oneshot
425
426service dhcpcd_wlan0 /system/bin/dhcpcd -ABKLG
427    class late_start
428    disabled
429    oneshot
430
431service dhcpcd_p2p /system/bin/dhcpcd -ABKLG
432    class late_start
433    disabled
434    oneshot
435
436service iprenew_wlan0 /system/bin/dhcpcd -n
437    class late_start
438    disabled
439    oneshot
440
441service iprenew_p2p /system/bin/dhcpcd -n
442    class late_start
443    disabled
444    oneshot
445
446service dhcpcd_bt-pan /system/bin/dhcpcd -BKLG
447    class late_start
448    disabled
449    oneshot
450
451service iprenew_bt-pan /system/bin/dhcpcd -n
452    class late_start
453    disabled
454    oneshot
455
456service dhcpcd_bnep0 /system/bin/dhcpcd -BKLG
457    disabled
458    oneshot
459
460service dhcpcd_bnep1 /system/bin/dhcpcd -BKLG
461    disabled
462    oneshot
463
464service dhcpcd_bnep2 /system/bin/dhcpcd -BKLG
465    disabled
466    oneshot
467
468service dhcpcd_bnep3 /system/bin/dhcpcd -BKLG
469    disabled
470    oneshot
471
472service dhcpcd_bnep4 /system/bin/dhcpcd -BKLG
473    disabled
474    oneshot
475
476service dhcpcd_eth0 /system/bin/dhcpcd -aABDKL
477    class late_start
478    disabled
479    oneshot
480
481service iprenew_eth0 /system/bin/dhcpcd -n
482    class late_start
483    disabled
484    oneshot
485
486service adspd /system/bin/adspd /dev/ttyHS3
487   class late_start
488   socket adspdsock stream 0660 media media
489   user media
490   group media input
491
492on property:sys.boot_completed=1
493    start qcom-post-boot
494
495on property:ro.debuggable=1
496    start ss_ramdump
497
498on property:ro.data.large_tcp_window_size=true
499    # Adjust socket buffer to enlarge TCP receive window for high bandwidth (e.g. DO-RevB)
500    write /proc/sys/net/ipv4/tcp_adv_win_scale  2
501
502# virtual sdcard daemon running as media_rw (1023)
503service sdcard /system/bin/sdcard -u 1023 -g 1023 -l /data/media /mnt/shell/emulated
504    class late_start
505
506on charger
507    write /sys/class/leds/lcd-backlight/brightness 100
508    mount ext4 /dev/block/platform/msm_sdcc.1/by-name/system /system ro barrier=1
509    start thermal-engine
510
511service charger /charger
512    class charger
513    group log
514    seclabel u:r:healthd:s0
515
516# Allow usb charging to be disabled peristently
517on property:persist.usb.chgdisabled=1
518    write /sys/class/power_supply/battery/charging_enabled 0
519
520on property:persist.usb.chgdisabled=0
521    write /sys/class/power_supply/battery/charging_enabled 1
522
523service qseecomd /system/bin/qseecomd
524   class core
525   user root
526   group root
527
528service mpdecision /system/bin/mpdecision --avg_comp
529   class main
530   user root
531
532service ss_ramdump /system/bin/subsystem_ramdump
533    class main
534    user root
535    group root
536    disabled
537
538service thermal-engine /system/bin/thermal-engine
539   class main
540   user root
541   group root
542
543service time_daemon /system/bin/time_daemon
544   class late_start
545   user root
546   group root
547
548on property:init.svc.bootanim=stopped
549    start usf-post-boot
550
551service qcamerasvr /system/bin/mm-qcamera-daemon
552    class late_start
553    user camera
554    group camera system inet input graphics
555
556service bdAddrLoader /system/bin/bdAddrLoader -p ro.boot.btmacaddr -s -x
557    class main
558    user bluetooth
559    group system bluetooth
560    oneshot
561
562on property:vold.decrypt=trigger_reset_main
563    stop gnss-svcd
564
565# When QCA1530 is known not to present
566on property:persist.qca1530=no
567   stop gnss-svcd
568   stop gnss-detect
569   write /sys/kernel/qca1530/chip_state 0
570
571on property:init.svc.surfaceflinger=stopped
572    stop ppd
573
574service mmi-touch-sh /system/bin/sh /init.mmi.touch.sh atmel
575    class main
576    user root
577    oneshot
578
579# bugreport is triggered by holding down volume down, volume up and power
580service bugreport /system/bin/dumpstate -d -p -B \
581        -o /data/data/com.android.shell/files/bugreports/bugreport
582    class main
583    disabled
584    oneshot
585    keycodes 114 115 116
586
587service mdm_helper_proxy /system/bin/mdm_helper_proxy
588    class core
589    user system
590    group system
591    disabled
592
593# Stop mdm_helper_proxy in case of shutdown
594on property:sys.shutdown.requested=*
595    stop mdm_helper_proxy
596
597# Start mdm_helper_proxy after RIL.
598on property:ro.mdm_helper_proxy_req=true
599    start mdm_helper_proxy
600
601on property:init.svc.ril-daemon=running
602    setprop ro.mdm_helper_proxy_req true
603
604service atfwd /system/bin/ATFWD-daemon
605    class late_start
606    user system
607    group system radio
608