Created
December 13, 2013 14:41
-
-
Save alvinhochun/7945270 to your computer and use it in GitHub Desktop.
Simple (sample) shell script to perform kexec hardboot for Xperia M/M Dual.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/boot/busybox sh | |
set -x | |
echo "About to kexec new kernel..." | |
if [ -x "/cache/kexec" ] && [ -f "/cache/stock_kernel" ] && [ -f "/cache/ramdisk" ]; then | |
# Builds the new cmdline | |
# The portion starting from "androidboot.emmc=true" is added by | |
# the bootloader, therefore we extract it and append it to the | |
# cmdline for the new kernel | |
CUR_CMDLINE=`/boot/busybox sed 's/^.*\( androidboot.emmc.*\)/\1/' /proc/cmdline` | |
# warmboot=0x77665501 stands for normal reboot | |
# Don't let warmboot=0x77665502 (recovery) slip through | |
CUR_CMDLINE=`echo "$CUR_CMDLINE" | /boot/busybox sed 's/\(warmboot=0x\)[0-9a-fA-F]*/\177665501/'` | |
if [ "$CUR_CMDLINE" = "" ]; then | |
echo "Extracted cmdline is empty. Is this Xperia M/M Dual?" | |
else | |
NEW_CMDLINE="panic=3 console=ttyHSL0,115200,n8 androidboot.hardware=qcom user_debug=31 msm_rtb.filter=0x3F ehci-hcd.park=3$CUR_CMDLINE" | |
echo "Newformed cmdline is:" | |
echo "$NEW_CMDLINE" | |
/boot/busybox sync | |
/boot/busybox mount -o remount,ro /system | |
/boot/busybox mount -o remount,ro /data | |
/boot/busybox mount -o remount,ro /cache | |
/boot/busybox sync | |
/cache/kexec --load-hardboot /cache/stock_kernel --initrd=/cache/ramdisk --mem-min=0x85000000 --mem-max=0x87ffffff --command-line="$NEW_CMDLINE" | |
/boot/busybox sync | |
/cache/kexec -e | |
echo "It appears that kexec has failed..." | |
fi | |
else | |
echo "kexec, kernel or ramdisk missing!" | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment