This repository contains a Magisk module designed to enable automatic booting of your Android device when it's connected to a charger or USB.
Before you can use this Magisk module, you need to ensure that:
Important :
boot.img
to restore in case of issues.After installation, your Android will boot automatically on cable connected.
This module adds autoboot.init.rc
and autoboot.sh
to the boot image. The patching process can be viewed in scripts/boot_patch.sh
. The scripts
folder is obtained from the installed Magisk on Android in the /data/adb/magisk
folder. Only some necessary code is imported and then modified for patching boot.img
.
In the autoboot.sh
file, MIN_CAPACITY=5
is set as the minimum battery percentage threshold before Android boots automatically. If your battery percentage is below 5, the device will wait until it reaches this threshold before booting automatically. If you need to adjust this threshold, change the MIN_CAPACITY
value in the autoboot.sh
file and reflash this module.
In case of any errors, your current boot image is backed up under /data/adb/modules/magisk-autoboot/
. If something happens, you can safely restore them.
If you encounter any issues while using this module, follow these steps:
Check if your current boot image is backed up under /data/adb/modules/magisk-autoboot/
. If it is, try restoring it.
Confirm successful installation by checking the presence of the autoboot.sh
file in the directory outputted by the magisk --path
command, usually /debug_ramdisk
or /sbin
.
If you continue to experience issues, please raise an issue in the repository with a detailed description of the problem, steps to reproduce it, and any error messages you are seeing.
If you're an advanced user and want go trough hard way, follow this:
Prepare your boot image by following these steps:
On TWRP, go to Advanced > Terminal and run the following commands:
mkdir /sdcard/autboot
.dd if=/dev/block/bootdevice/by-name/boot of=/sdcard/autoboot/boot.img
for dump boot.img.Boot into TWRP recovery and connect your device to your computer, connect to ADB shell and run the following commands:
mkdir /sdcard/autoboot
dd if=/dev/block/bootdevice/by-name/boot of=/sdcard/autoboot/boot.img
On TWRP, go to Backup and select Boot. Then, swipe to backup.
Your boot image will be backed up to /sdcard/TWRP/BACKUPS/<device_serial_number>/<name_of_backup>/boot.emmc.win
.
Just copy and place it in a folder /sdcard/autoboot/
on your device, then rename it to boot.img
.
Create a file named autoboot.init.rc
in the same folder as boot.img
with the following contents:
on charger
setprop ro.bootmode "normal"
setprop sys.powerctl "reboot"
Execute the following commands:
/data/adb/magisk/magiskboot unpack boot.img
/data/adb/magisk/magiskboot cpio ramdisk.cpio \
"mkdir 0700 overlay.d" \
"add 0700 overlay.d/autoboot.init.rc autoboot.init.rc"
/data/adb/magisk/magiskboot repack boot.img boot_patched_autoboot.img
/data/adb/magisk/magiskboot cleanup
You can flash the patched boot image using the following methods:
On TWRP, go to Advanced > Terminal and run the following commands:
dd if=/sdcard/autoboot/boot_patched_autoboot.img of=/dev/block/bootdevice/by-name/boot
Boot into TWRP recovery and connect your device to your computer, connect to ADB shell and run the following commands:
dd if=/sdcard/autoboot/boot_patched_autoboot.img of=/dev/block/bootdevice/by-name/boot
On TWRP, go to Install and select the patched boot image. Then, swipe to flash.
Power off your device and connect it to a charger or USB. Your device should boot automatically.
This module is provided "as is" without warranty of any kind, either express or implied, including without limitation any warranties of merchantability, fitness for a particular purpose, and non-infringement. The entire risk as to the quality and performance of the module is with you. Should the module prove defective, you assume the cost of all necessary servicing, repair, or correction.
The method has been successfully tested on the following devices:
OEM Specific device may not work, need to research which rc value should trigger autoboot script !!
Here are some useful links for further reading:
futility
binaryThis project is licensed under the MIT License.