Colin Cross | f510f06 | 2012-08-08 13:06:26 -0700 | [diff] [blame] | 1 | import /init.recovery.${ro.hardware}.rc |
| 2 | |
Colin Cross | dd6a041 | 2010-05-14 13:42:20 -0700 | [diff] [blame] | 3 | on early-init |
Alex Deymo | 6bcc8af | 2016-03-02 14:21:02 -0800 | [diff] [blame] | 4 | # Set the security context of /postinstall if present. |
| 5 | restorecon /postinstall |
| 6 | |
Kiyoung Kim | ea2b683 | 2019-12-17 15:05:54 +0900 | [diff] [blame] | 7 | # Copy prebuilt ld.config.txt into linkerconfig directory |
| 8 | copy /system/etc/ld.config.txt /linkerconfig/ld.config.txt |
Kiyoung Kim | 3a88a17 | 2019-12-09 19:27:57 +0900 | [diff] [blame] | 9 | chmod 444 /linkerconfig/ld.config.txt |
| 10 | |
Colin Cross | dd6a041 | 2010-05-14 13:42:20 -0700 | [diff] [blame] | 11 | start ueventd |
The Android Open Source Project | c24a8e6 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 12 | |
Hridya Valsaraju | 20c81b3 | 2018-07-27 22:09:12 -0700 | [diff] [blame] | 13 | setprop sys.usb.configfs 0 |
| 14 | |
The Android Open Source Project | c24a8e6 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 15 | on init |
The Android Open Source Project | c24a8e6 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 16 | export ANDROID_ROOT /system |
| 17 | export ANDROID_DATA /data |
| 18 | export EXTERNAL_STORAGE /sdcard |
| 19 | |
Elliott Hughes | a4495b5 | 2018-08-23 08:31:59 -0700 | [diff] [blame] | 20 | symlink /proc/self/fd/0 /dev/stdin |
| 21 | symlink /proc/self/fd/1 /dev/stdout |
| 22 | symlink /proc/self/fd/2 /dev/stderr |
| 23 | |
Elliott Hughes | 4dca6f1 | 2017-12-06 08:41:50 -0800 | [diff] [blame] | 24 | symlink /system/bin /bin |
The Android Open Source Project | c24a8e6 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 25 | symlink /system/etc /etc |
| 26 | |
| 27 | mkdir /sdcard |
| 28 | mkdir /system |
| 29 | mkdir /data |
| 30 | mkdir /cache |
Doug Zongker | 075ad80 | 2014-06-26 15:35:51 -0700 | [diff] [blame] | 31 | mkdir /sideload |
Jiyong Park | 8b7af4c | 2018-06-01 11:58:54 +0900 | [diff] [blame] | 32 | mkdir /mnt/system |
Doug Zongker | 075ef32 | 2014-01-14 09:50:35 -0800 | [diff] [blame] | 33 | mount tmpfs tmpfs /tmp |
The Android Open Source Project | c24a8e6 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 34 | |
Doug Zongker | 703ed15 | 2012-03-19 15:52:03 -0700 | [diff] [blame] | 35 | chown root shell /tmp |
| 36 | chmod 0775 /tmp |
| 37 | |
Colin Cross | 22bcf97 | 2014-06-24 13:43:39 -0700 | [diff] [blame] | 38 | write /proc/sys/kernel/panic_on_oops 1 |
Jesse Zhao | 5bf74b2 | 2015-01-08 15:59:23 -0800 | [diff] [blame] | 39 | write /proc/sys/vm/max_map_count 1000000 |
Colin Cross | 22bcf97 | 2014-06-24 13:43:39 -0700 | [diff] [blame] | 40 | |
Yifan Hong | cb22b13 | 2021-11-12 20:27:15 -0800 | [diff] [blame] | 41 | # Mount binderfs |
| 42 | mkdir /dev/binderfs |
| 43 | mount binder binder /dev/binderfs stats=global |
| 44 | chmod 0755 /dev/binderfs |
| 45 | |
| 46 | symlink /dev/binderfs/binder /dev/binder |
| 47 | chmod 0666 /dev/binderfs/binder |
| 48 | |
Yifan Hong | 8798099 | 2021-11-12 20:04:14 -0800 | [diff] [blame] | 49 | # Start essential services |
| 50 | start servicemanager |
| 51 | |
The Android Open Source Project | c24a8e6 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 52 | on boot |
The Android Open Source Project | c24a8e6 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 53 | ifup lo |
| 54 | hostname localhost |
| 55 | domainname localdomain |
| 56 | |
| 57 | class_start default |
Yifan Hong | 0fa1707 | 2021-11-13 01:34:16 -0800 | [diff] [blame] | 58 | class_start hal |
The Android Open Source Project | c24a8e6 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 59 | |
JP Abgrall | 9eb8c8b | 2014-10-20 20:02:57 -0700 | [diff] [blame] | 60 | on firmware_mounts_complete |
| 61 | rm /dev/.booting |
| 62 | |
Riley Andrews | e739d7e | 2014-06-24 16:29:16 -0700 | [diff] [blame] | 63 | # Mount filesystems and start core system services. |
| 64 | on late-init |
| 65 | trigger early-fs |
| 66 | trigger fs |
| 67 | trigger post-fs |
| 68 | trigger post-fs-data |
| 69 | |
JP Abgrall | 9eb8c8b | 2014-10-20 20:02:57 -0700 | [diff] [blame] | 70 | # Remove a file to wake up anything waiting for firmware |
| 71 | trigger firmware_mounts_complete |
| 72 | |
Riley Andrews | e739d7e | 2014-06-24 16:29:16 -0700 | [diff] [blame] | 73 | trigger early-boot |
| 74 | trigger boot |
| 75 | |
Tom Cherry | b2fd168 | 2018-07-24 15:58:29 -0700 | [diff] [blame] | 76 | service ueventd /system/bin/ueventd |
Colin Cross | dd6a041 | 2010-05-14 13:42:20 -0700 | [diff] [blame] | 77 | critical |
Stephen Smalley | 2c9d5b2 | 2014-01-13 09:44:42 -0500 | [diff] [blame] | 78 | seclabel u:r:ueventd:s0 |
The Android Open Source Project | c24a8e6 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 79 | |
Tao Bao | a89c21c | 2018-09-11 14:50:02 -0700 | [diff] [blame] | 80 | service charger /system/bin/charger |
Todd Poynor | 2f2c988 | 2013-06-04 13:11:44 -0700 | [diff] [blame] | 81 | critical |
Sandeep Patil | c4b381c | 2016-11-01 08:49:51 -0700 | [diff] [blame] | 82 | seclabel u:r:charger:s0 |
Todd Poynor | 2f2c988 | 2013-06-04 13:11:44 -0700 | [diff] [blame] | 83 | |
Hridya Valsaraju | cfb3c92 | 2018-07-26 13:04:06 -0700 | [diff] [blame] | 84 | service recovery /system/bin/recovery |
Hridya Valsaraju | 20c81b3 | 2018-07-27 22:09:12 -0700 | [diff] [blame] | 85 | socket recovery stream 422 system system |
Stephen Smalley | 2c9d5b2 | 2014-01-13 09:44:42 -0500 | [diff] [blame] | 86 | seclabel u:r:recovery:s0 |
The Android Open Source Project | c24a8e6 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 87 | |
Jiyong Park | 8b7af4c | 2018-06-01 11:58:54 +0900 | [diff] [blame] | 88 | service adbd /system/bin/adbd --root_seclabel=u:r:su:s0 --device_banner=recovery |
Kenny Root | ecc76ba | 2010-06-28 09:01:22 -0700 | [diff] [blame] | 89 | disabled |
Doug Zongker | cc2958f | 2013-09-11 13:24:32 -0700 | [diff] [blame] | 90 | socket adbd stream 660 system system |
Stephen Smalley | 2c9d5b2 | 2014-01-13 09:44:42 -0500 | [diff] [blame] | 91 | seclabel u:r:adbd:s0 |
The Android Open Source Project | c24a8e6 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 92 | |
Hridya Valsaraju | 20c81b3 | 2018-07-27 22:09:12 -0700 | [diff] [blame] | 93 | service fastbootd /system/bin/fastbootd |
| 94 | disabled |
| 95 | group system |
| 96 | seclabel u:r:fastbootd:s0 |
The Android Open Source Project | c24a8e6 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 97 | |
Mike Lockwood | 718a2f7 | 2011-06-29 10:22:04 -0400 | [diff] [blame] | 98 | # Restart adbd so it can run as root |
Doug Zongker | fb04b87 | 2011-06-23 15:30:34 -0700 | [diff] [blame] | 99 | on property:service.adb.root=1 |
Doug Zongker | fb04b87 | 2011-06-23 15:30:34 -0700 | [diff] [blame] | 100 | restart adbd |
Hridya Valsaraju | 20c81b3 | 2018-07-27 22:09:12 -0700 | [diff] [blame] | 101 | |
Hridya Valsaraju | 20c81b3 | 2018-07-27 22:09:12 -0700 | [diff] [blame] | 102 | on fs && property:sys.usb.configfs=1 |
| 103 | mount configfs none /config |
| 104 | mkdir /config/usb_gadget/g1 0770 shell shell |
Josh Gao | c40208c | 2022-08-17 12:57:17 -0700 | [diff] [blame^] | 105 | write /config/usb_gadget/g1/idVendor 0x${ro.recovery.usb.vid} |
Hridya Valsaraju | 20c81b3 | 2018-07-27 22:09:12 -0700 | [diff] [blame] | 106 | mkdir /config/usb_gadget/g1/strings/0x409 0770 |
| 107 | write /config/usb_gadget/g1/strings/0x409/serialnumber ${ro.serialno} |
| 108 | write /config/usb_gadget/g1/strings/0x409/manufacturer ${ro.product.manufacturer} |
| 109 | write /config/usb_gadget/g1/strings/0x409/product ${ro.product.model} |
| 110 | mkdir /config/usb_gadget/g1/functions/ffs.adb |
| 111 | mkdir /config/usb_gadget/g1/functions/ffs.fastboot |
| 112 | mkdir /config/usb_gadget/g1/configs/b.1 0777 shell shell |
| 113 | mkdir /config/usb_gadget/g1/configs/b.1/strings/0x409 0770 shell shell |
| 114 | |
| 115 | on fs && property:sys.usb.configfs=0 |
| 116 | write /sys/class/android_usb/android0/f_ffs/aliases adb,fastboot |
Josh Gao | c40208c | 2022-08-17 12:57:17 -0700 | [diff] [blame^] | 117 | write /sys/class/android_usb/android0/idVendor ${ro.recovery.usb.vid} |
Hridya Valsaraju | 20c81b3 | 2018-07-27 22:09:12 -0700 | [diff] [blame] | 118 | write /sys/class/android_usb/android0/iManufacturer ${ro.product.manufacturer} |
| 119 | write /sys/class/android_usb/android0/iProduct ${ro.product.model} |
| 120 | write /sys/class/android_usb/android0/iSerial ${ro.serialno} |
| 121 | |
| 122 | on fs |
| 123 | mkdir /dev/usb-ffs 0775 shell shell |
| 124 | mkdir /dev/usb-ffs/adb 0770 shell shell |
| 125 | mount functionfs adb /dev/usb-ffs/adb uid=2000,gid=2000 |
| 126 | mkdir /dev/usb-ffs/fastboot 0770 system system |
| 127 | mount functionfs fastboot /dev/usb-ffs/fastboot rmode=0770,fmode=0660,uid=1000,gid=1000 |
| 128 | |
| 129 | on property:sys.usb.config=adb |
| 130 | start adbd |
| 131 | |
| 132 | on property:sys.usb.config=fastboot |
| 133 | start fastbootd |
| 134 | |
Hridya Valsaraju | 20c81b3 | 2018-07-27 22:09:12 -0700 | [diff] [blame] | 135 | on property:sys.usb.config=none && property:sys.usb.configfs=0 |
Hridya Valsaraju | e4ef453 | 2018-08-31 11:57:51 -0700 | [diff] [blame] | 136 | stop adbd |
Dmytro Prokopchuk | df35405 | 2019-11-13 13:30:17 +0200 | [diff] [blame] | 137 | stop fastbootd |
Hridya Valsaraju | 20c81b3 | 2018-07-27 22:09:12 -0700 | [diff] [blame] | 138 | write /sys/class/android_usb/android0/enable 0 |
| 139 | setprop sys.usb.state ${sys.usb.config} |
| 140 | |
| 141 | on property:sys.usb.config=adb && property:sys.usb.configfs=0 |
Josh Gao | c40208c | 2022-08-17 12:57:17 -0700 | [diff] [blame^] | 142 | write /sys/class/android_usb/android0/idProduct ${ro.recovery.usb.adb.pid} |
Hridya Valsaraju | 20c81b3 | 2018-07-27 22:09:12 -0700 | [diff] [blame] | 143 | write /sys/class/android_usb/android0/functions adb |
Doug Zongker | fb04b87 | 2011-06-23 15:30:34 -0700 | [diff] [blame] | 144 | write /sys/class/android_usb/android0/enable 1 |
Hridya Valsaraju | 20c81b3 | 2018-07-27 22:09:12 -0700 | [diff] [blame] | 145 | setprop sys.usb.state ${sys.usb.config} |
| 146 | |
Hridya Valsaraju | e4ef453 | 2018-08-31 11:57:51 -0700 | [diff] [blame] | 147 | on property:sys.usb.config=sideload && property:sys.usb.configfs=0 |
Josh Gao | c40208c | 2022-08-17 12:57:17 -0700 | [diff] [blame^] | 148 | write /sys/class/android_usb/android0/idProduct ${ro.recovery.usb.adb.pid} |
Hridya Valsaraju | e4ef453 | 2018-08-31 11:57:51 -0700 | [diff] [blame] | 149 | write /sys/class/android_usb/android0/functions adb |
| 150 | write /sys/class/android_usb/android0/enable 1 |
| 151 | setprop sys.usb.state ${sys.usb.config} |
| 152 | |
Hridya Valsaraju | 20c81b3 | 2018-07-27 22:09:12 -0700 | [diff] [blame] | 153 | on property:sys.usb.config=fastboot && property:sys.usb.configfs=0 |
Josh Gao | c40208c | 2022-08-17 12:57:17 -0700 | [diff] [blame^] | 154 | write /sys/class/android_usb/android0/idProduct ${ro.recovery.usb.fastboot.pid} |
Hridya Valsaraju | 20c81b3 | 2018-07-27 22:09:12 -0700 | [diff] [blame] | 155 | write /sys/class/android_usb/android0/functions fastboot |
| 156 | write /sys/class/android_usb/android0/enable 1 |
| 157 | setprop sys.usb.state ${sys.usb.config} |
| 158 | |
| 159 | # Configfs triggers |
| 160 | on property:sys.usb.config=none && property:sys.usb.configfs=1 |
| 161 | write /config/usb_gadget/g1/UDC "none" |
Hridya Valsaraju | e4ef453 | 2018-08-31 11:57:51 -0700 | [diff] [blame] | 162 | stop adbd |
| 163 | stop fastbootd |
Hridya Valsaraju | 20c81b3 | 2018-07-27 22:09:12 -0700 | [diff] [blame] | 164 | setprop sys.usb.ffs.ready 0 |
| 165 | rm /config/usb_gadget/g1/configs/b.1/f1 |
| 166 | setprop sys.usb.state ${sys.usb.config} |
| 167 | |
Hridya Valsaraju | e4ef453 | 2018-08-31 11:57:51 -0700 | [diff] [blame] | 168 | on property:sys.usb.config=sideload && property:sys.usb.ffs.ready=1 && property:sys.usb.configfs=1 |
Josh Gao | c40208c | 2022-08-17 12:57:17 -0700 | [diff] [blame^] | 169 | write /config/usb_gadget/g1/idProduct 0x${ro.recovery.usb.adb.pid} |
Hridya Valsaraju | e4ef453 | 2018-08-31 11:57:51 -0700 | [diff] [blame] | 170 | write /config/usb_gadget/g1/configs/b.1/strings/0x409/configuration "adb" |
| 171 | symlink /config/usb_gadget/g1/functions/ffs.adb /config/usb_gadget/g1/configs/b.1/f1 |
| 172 | write /config/usb_gadget/g1/UDC ${sys.usb.controller} |
| 173 | setprop sys.usb.state ${sys.usb.config} |
| 174 | |
Hridya Valsaraju | 20c81b3 | 2018-07-27 22:09:12 -0700 | [diff] [blame] | 175 | on property:sys.usb.config=adb && property:sys.usb.ffs.ready=1 && property:sys.usb.configfs=1 |
Josh Gao | c40208c | 2022-08-17 12:57:17 -0700 | [diff] [blame^] | 176 | write /config/usb_gadget/g1/idProduct 0x${ro.recovery.usb.adb.pid} |
Hridya Valsaraju | 20c81b3 | 2018-07-27 22:09:12 -0700 | [diff] [blame] | 177 | write /config/usb_gadget/g1/configs/b.1/strings/0x409/configuration "adb" |
| 178 | symlink /config/usb_gadget/g1/functions/ffs.adb /config/usb_gadget/g1/configs/b.1/f1 |
| 179 | write /config/usb_gadget/g1/UDC ${sys.usb.controller} |
| 180 | setprop sys.usb.state ${sys.usb.config} |
| 181 | |
| 182 | on property:sys.usb.config=fastboot && property:sys.usb.ffs.ready=1 && property:sys.usb.configfs=1 |
Josh Gao | c40208c | 2022-08-17 12:57:17 -0700 | [diff] [blame^] | 183 | write /config/usb_gadget/g1/idProduct 0x${ro.recovery.usb.fastboot.pid} |
Hridya Valsaraju | 20c81b3 | 2018-07-27 22:09:12 -0700 | [diff] [blame] | 184 | write /config/usb_gadget/g1/configs/b.1/strings/0x409/configuration "fastboot" |
| 185 | symlink /config/usb_gadget/g1/functions/ffs.fastboot /config/usb_gadget/g1/configs/b.1/f1 |
| 186 | write /config/usb_gadget/g1/UDC ${sys.usb.controller} |
| 187 | setprop sys.usb.state ${sys.usb.config} |