Addon.d script for Xposed NOUGAT to survive dirty flashes - Xposed General

The script has been adapted for CM13: https://forum.xda-developers.com/xposed/addon-d-script-xposed-to-survive-cm13-t3268520
Since many things have been changed to get Xposed working on Nougat I guess this script has to be adapted again.
Please share if you find something
Thank you.

I second this. The addon.d script was a godsend in the good 'ol days

Something as this?:
Code:
#!/sbin/sh
#
#
# /system/addon.d/81-Xposed.sh
# During a LineageOS 14.1 upgrade, this script backs up Xposed framework files.
# /system is formatted and reinstalled, then the files are restored.
# Based on Xposed "flash-script.sh" script and https://forum.xda-developers.com/xposed/addon-d-script-xposed-to-survive-cm13-t3268520
export C=/sdcard/xposed_backupdir-1234
backup_file() {
if [ -e "$1" ]; then
if [ ! -L "$1" ]; then
local F="${1##*/}"
local D="${1%/*}"
mkdir -p "$C/$D"
cp -dp "$1" "$C/$D/$F"
else
ui_print "Skipping symbolic link $1"
fi
else
ui_print "NE: $1"
fi
}
restore_file() {
local FILE="${1##*/}"
local DIR="${1%/*}"
if [ -e "$C/$DIR/$FILE" ]; then
if [ "$FILE" == "xposed.prop" ] || [ "$FILE" == "XposedBridge.jar" ]; then
restore_nobackup "/$DIR/$FILE" 0 0 0644
elif [ "$FILE" == "app_process64_xposed" ] || [ "$FILE" == "app_process32_xposed" ]; then
restore_and_link "/$DIR/${FILE%_xposed}" 0 2000 0755 u:object_r:zygote_exec:s0
elif [ "$FILE" == "dex2oat" ] || [ "$FILE" == "patchoat" ]; then
restore_overwrite "/$DIR/$FILE" 0 2000 0755 u:object_r:dex2oat_exec:s0
elif [ "$FILE" == "oatdump" ]; then
restore_overwrite "/$DIR/$FILE" 0 2000 0755
else
restore_overwrite "/$DIR/$FILE" 0 0 0644
fi
else
ui_print "NE: $C/$DIR/$FILE"
fi
}
cp_perm() {
cp -f "$1" "$2" || exit 1
set_perm "$2" $3 $4 $5 $6
}
set_perm() {
chown $2:$3 "$1" || exit 1
chmod $4 "$1" || exit 1
if [ "$5" ]; then
chcon $5 "$1" 2>/dev/null
else
chcon 'u:object_r:system_file:s0' "$1" 2>/dev/null
fi
}
restore_nobackup() {
cp_perm "$C/$1" "$1" $2 $3 $4 $5
}
restore_and_link() {
TARGET="${1}"
XPOSED="${1}_xposed"
BACKUP="${1}_original"
if [ ! -f "$C/$XPOSED" ]; then
return
fi
cp_perm "$C/$XPOSED" "$XPOSED" $2 $3 $4 $5
if [ ! -f "$BACKUP" ]; then
mv "$TARGET" "$BACKUP" || exit 1
ln -s "$XPOSED" "$TARGET" || exit 1
chcon -h 'u:object_r:system_file:s0' "$TARGET" 2>/dev/null
fi
}
restore_overwrite() {
TARGET=$1
BACKUP="${1}.orig"
NO_ORIG="${1}.no_orig"
if [ ! -f "$TARGET" ]; then
touch "$NO_ORIG" || exit 1
set_perm "$NO_ORIG" 0 0 600
elif [ -f "$BACKUP" ]; then
rm -f "$TARGET"
gzip "$BACKUP" || exit 1
set_perm "${BACKUP}.gz" 0 0 600
elif [ ! -f "${BACKUP}.gz" ] && [ ! -f "$NO_ORIG" ]; then
mv "$TARGET" "$BACKUP" || exit 1
gzip "$BACKUP" || exit 1
set_perm "${BACKUP}.gz" 0 0 600
fi
cp_perm "$C/$TARGET" "$TARGET" $2 $3 $4 $5
}
ui_print() {
echo -n -e "ui_print $1\n" >> /proc/self/fd/$OUTFD
echo -n -e "ui_print\n" >> /proc/self/fd/$OUTFD
}
list_files() {
cat <<EOF
/system/xposed.prop
/system/framework/XposedBridge.jar
# For 32bits
/system/bin/app_process32_xposed
/system/bin/dex2oat
/system/bin/oatdump
/system/bin/patchoat
/system/lib/libart.so
/system/lib/libart-compiler.so
/system/lib/libart-disassembler.so
/system/lib/libsigchain.so
/system/lib/libxposed_art.so
# For 64bits
/system/bin/app_process64_xposed 64bit
/system/lib64/libart.so 64bit
/system/lib64/libart-compiler.so 64bit
/system/lib64/libart-disassembler.so 64bit
/system/lib64/libsigchain.so 64bit
/system/lib64/libxposed_art.so 64bit
EOF
}
OSA="32bit"
OUTFD=`ps | grep -v grep | grep -oE "update(.*)" | cut -d" " -f3`
API=$(sed -n "s/^ro.build.version.sdk=//p" /system/build.prop | head -n 1)
ABILONG=$(sed -n "s/^ro.product.cpu.abi=//p" /system/build.prop | head -n 1)
if [ "$API" -ge "21" ]; then
if [ "$ABILONG" = "arm64-v8a" ] || [ "$ABILONG" = "x86_64" ]; then OSA="64bit"; fi;
fi
case "$1" in
backup)
ui_print "Starting to backup Xposed"
list_files | while read FILE ARCH; do
echo $FILE | grep -q '^#'
if [ $? -ne 0 ]; then
if [ $ARCH ] && [ "$ARCH" != "$OSA" ]; then continue; fi;
backup_file "$FILE"
fi
done
ui_print "Ending to backup Xposed"
;;
restore)
ui_print "Starting to restore Xposed"
list_files | while read FILE ARCH; do
echo $FILE | grep -q '^#'
if [ $? -ne 0 ]; then
if [ $ARCH ] && [ "$ARCH" != "$OSA" ]; then continue; fi;
restore_file "$FILE"
fi
done
if [ "$API" -ge "22" ]; then
find /system /vendor -type f -name '*.odex.gz' 2>/dev/null | while read f; do mv "$f" "$f.xposed"; done
fi
rm -rf "${C:?}/"
ui_print "Ending to restore Xposed"
;;
pre-backup)
# Stub
;;
post-backup)
# Stub
;;
pre-restore)
# Stub
;;
post-restore)
# Stub
;;
esac

MariferC said:
Something as this?:
Code:
#!/sbin/sh
#
#
# /system/addon.d/81-Xposed.sh
# During a LineageOS 14.1 upgrade, this script backs up Xposed framework files.
# /system is formatted and reinstalled, then the files are restored.
# Based on Xposed "flash-script.sh" script and https://forum.xda-developers.com/xposed/addon-d-script-xposed-to-survive-cm13-t3268520
export C=/sdcard/xposed_backupdir-1234
backup_file() {
if [ -e "$1" ]; then
if [ ! -L "$1" ]; then
local F="${1##*/}"
local D="${1%/*}"
mkdir -p "$C/$D"
cp -dp "$1" "$C/$D/$F"
else
ui_print "Skipping symbolic link $1"
fi
else
ui_print "NE: $1"
fi
}
restore_file() {
local FILE="${1##*/}"
local DIR="${1%/*}"
if [ -e "$C/$DIR/$FILE" ]; then
if [ "$FILE" == "xposed.prop" ] || [ "$FILE" == "XposedBridge.jar" ]; then
restore_nobackup "/$DIR/$FILE" 0 0 0644
elif [ "$FILE" == "app_process64_xposed" ] || [ "$FILE" == "app_process32_xposed" ]; then
restore_and_link "/$DIR/${FILE%_xposed}" 0 2000 0755 u:object_r:zygote_exec:s0
elif [ "$FILE" == "dex2oat" ] || [ "$FILE" == "patchoat" ]; then
restore_overwrite "/$DIR/$FILE" 0 2000 0755 u:object_r:dex2oat_exec:s0
elif [ "$FILE" == "oatdump" ]; then
restore_overwrite "/$DIR/$FILE" 0 2000 0755
else
restore_overwrite "/$DIR/$FILE" 0 0 0644
fi
else
ui_print "NE: $C/$DIR/$FILE"
fi
}
cp_perm() {
cp -f "$1" "$2" || exit 1
set_perm "$2" $3 $4 $5 $6
}
set_perm() {
chown $2:$3 "$1" || exit 1
chmod $4 "$1" || exit 1
if [ "$5" ]; then
chcon $5 "$1" 2>/dev/null
else
chcon 'u:object_r:system_file:s0' "$1" 2>/dev/null
fi
}
restore_nobackup() {
cp_perm "$C/$1" "$1" $2 $3 $4 $5
}
restore_and_link() {
TARGET="${1}"
XPOSED="${1}_xposed"
BACKUP="${1}_original"
if [ ! -f "$C/$XPOSED" ]; then
return
fi
cp_perm "$C/$XPOSED" "$XPOSED" $2 $3 $4 $5
if [ ! -f "$BACKUP" ]; then
mv "$TARGET" "$BACKUP" || exit 1
ln -s "$XPOSED" "$TARGET" || exit 1
chcon -h 'u:object_r:system_file:s0' "$TARGET" 2>/dev/null
fi
}
restore_overwrite() {
TARGET=$1
BACKUP="${1}.orig"
NO_ORIG="${1}.no_orig"
if [ ! -f "$TARGET" ]; then
touch "$NO_ORIG" || exit 1
set_perm "$NO_ORIG" 0 0 600
elif [ -f "$BACKUP" ]; then
rm -f "$TARGET"
gzip "$BACKUP" || exit 1
set_perm "${BACKUP}.gz" 0 0 600
elif [ ! -f "${BACKUP}.gz" ] && [ ! -f "$NO_ORIG" ]; then
mv "$TARGET" "$BACKUP" || exit 1
gzip "$BACKUP" || exit 1
set_perm "${BACKUP}.gz" 0 0 600
fi
cp_perm "$C/$TARGET" "$TARGET" $2 $3 $4 $5
}
ui_print() {
echo -n -e "ui_print $1\n" >> /proc/self/fd/$OUTFD
echo -n -e "ui_print\n" >> /proc/self/fd/$OUTFD
}
list_files() {
cat <<EOF
/system/xposed.prop
/system/framework/XposedBridge.jar
# For 32bits
/system/bin/app_process32_xposed
/system/bin/dex2oat
/system/bin/oatdump
/system/bin/patchoat
/system/lib/libart.so
/system/lib/libart-compiler.so
/system/lib/libart-disassembler.so
/system/lib/libsigchain.so
/system/lib/libxposed_art.so
# For 64bits
/system/bin/app_process64_xposed 64bit
/system/lib64/libart.so 64bit
/system/lib64/libart-compiler.so 64bit
/system/lib64/libart-disassembler.so 64bit
/system/lib64/libsigchain.so 64bit
/system/lib64/libxposed_art.so 64bit
EOF
}
OSA="32bit"
OUTFD=`ps | grep -v grep | grep -oE "update(.*)" | cut -d" " -f3`
API=$(sed -n "s/^ro.build.version.sdk=//p" /system/build.prop | head -n 1)
ABILONG=$(sed -n "s/^ro.product.cpu.abi=//p" /system/build.prop | head -n 1)
if [ "$API" -ge "21" ]; then
if [ "$ABILONG" = "arm64-v8a" ] || [ "$ABILONG" = "x86_64" ]; then OSA="64bit"; fi;
fi
case "$1" in
backup)
ui_print "Starting to backup Xposed"
list_files | while read FILE ARCH; do
echo $FILE | grep -q '^#'
if [ $? -ne 0 ]; then
if [ $ARCH ] && [ "$ARCH" != "$OSA" ]; then continue; fi;
backup_file "$FILE"
fi
done
ui_print "Ending to backup Xposed"
;;
restore)
ui_print "Starting to restore Xposed"
list_files | while read FILE ARCH; do
echo $FILE | grep -q '^#'
if [ $? -ne 0 ]; then
if [ $ARCH ] && [ "$ARCH" != "$OSA" ]; then continue; fi;
restore_file "$FILE"
fi
done
if [ "$API" -ge "22" ]; then
find /system /vendor -type f -name '*.odex.gz' 2>/dev/null | while read f; do mv "$f" "$f.xposed"; done
fi
rm -rf "${C:?}/"
ui_print "Ending to restore Xposed"
;;
pre-backup)
# Stub
;;
post-backup)
# Stub
;;
pre-restore)
# Stub
;;
post-restore)
# Stub
;;
esac
Click to expand...
Click to collapse
Did you create it? Did you try it on Nougat?
Anyway my custom ROM is no longer updated for Nougat. Hopefully it will work on Oreo.

OSheden said:
Did you create it? Did you try it on Nougat?
Anyway my custom ROM is no longer updated for Nougat. Hopefully it will work on Oreo.
Click to expand...
Click to collapse
Yes I've created it.
Yes I've tested on Nougat (LineageOS 14.1) on a Xiaomi Mi4 and a Moto G 2014, and it works.

Related

Bricked TP revival tip, SEE POST 2

Is anyone aware if there's anybody that will repair a bricked TP?
jlc0312 said:
Did you have the questionmark of death(QOD)? I had QOD before it died completely and jcsullins walkthrough fixed it. jcsullins is a boss dog, he has been walking people through unbricking their touchpads for over a month, and today came out with a do it yourself guide.
http://rootzwiki.com/topic/38786-tpdebrick-v004/
best of luck
Click to expand...
Click to collapse
I did this yesterday and successfully revived my brothers completely dead touchpad. Wanted to post a link but found you already posted. Anyway here is what I learnt and I hope it helps others.
Steps from jsullins procedure:
1) download a ubuntu i386 iso, burn it to a usb drive using pendrivelinux (a windows tool). Make sure you set atleast 1GB for the reusable R/W filesystem (casper filesystem). Note: a virtual instance of ubuntu will NOT work.
2) boot into ubuntu, change your bios settings to allow usb booting if needed
3) follow the guide. the simple steps are
a) download the webosdoctor jar file
b) download the tpdebrick004 zip
c) extract tpdebrick004
d) connect your tochpad via usb and hold the power+home+vol down buttons for 20-30 seconds
e) run the tpdebrick script with the storage size as parameter.
ex: sudo tpdebrick 32
note: if you use a version of ubuntu other than 12.04 you will need to edit ("sudo gedit tpdebrick")the tpdebrick script and change the version check code to look for that version instead of 12.04. i.e change 12.04 to 12.10 or 13.04 (as applicable)
f) the script installs fastboot, dfu-util and other components and then proceeds with the de-bricking process. wait till you see "ALL DONE". If it asks for a root password just keep pressing enter.
4) charge your touchpad for 5-10 hours on the 2A charger. You should see the home button blinking at this point.
Thanks, I will try this when I get the chance.
I've changed the thread title
Would this work if the battery is completely dead. I believe mine is. I get absolutely no response from the touchpad. Tried all the button combinations with two different original chargers and tried trickle charging it. If my battery went below the safe threshold would I have to replace it?
zaq123 said:
Would this work if the battery is completely dead. I believe mine is. I get absolutely no response from the touchpad. Tried all the button combinations with two different original chargers and tried trickle charging it. If my battery went below the safe threshold would I have to replace it?
Click to expand...
Click to collapse
You would need to fully charge using the charging block. If you elect to charge through a PC/Laptop USB it should charge for several days. Using the block only needs 5-6 hours to accomplish the steps. Then a full charge would need to be accomplished using the block.
TonyStark said:
You would need to fully charge using the charging block. If you elect to charge through a PC/Laptop USB it should charge for several days. Using the block only needs 5-6 hours to accomplish the steps. Then a full charge would need to be accomplished using the block.
Click to expand...
Click to collapse
Left it on the charging block for 30 hours still no response and the tpdebrick does not find the device. Is it gone? I read on some posts that if the voltage drops below a certain threshold it wont charge anymore.
zaq123 said:
Left it on the charging block for 30 hours still no response and the tpdebrick does not find the device. Is it gone? I read on some posts that if the voltage drops below a certain threshold it wont charge anymore.
Click to expand...
Click to collapse
Hadn't read that, however I needed to replace my block and usb (new OE). I realized mine wasn't up to par.
zaq123 said:
Left it on the charging block for 30 hours still no response and the tpdebrick does not find the device. Is it gone? I read on some posts that if the voltage drops below a certain threshold it wont charge anymore.
Click to expand...
Click to collapse
Does anything happen if:
1: You hold power and volume up
2: power and home buttons for at least 30 seconds preferably a minute.
3 if you connect to your PC does anything show in device manager or when you right click on the safely remove icon.
sstar said:
Does anything happen if:
1: You hold power and volume up
2: power and home buttons for at least 30 seconds preferably a minute.
3 if you connect to your PC does anything show in device manager or when you right click on the safely remove icon.
Click to expand...
Click to collapse
I get no response doing any of those or any other button combination that has been suggested on different forums. I know the charger is good since i have another touchpad that I use it with. It is an original hp. I ordered a touchstone since some people have has success getting the touchstone to charge it when the regular would not.
Any other suggestions would be appreciated. Thanks
zaq123 said:
Would this work if the battery is completely dead.
Click to expand...
Click to collapse
Yup that's what I wrote
britoso said:
Yup that's what I wrote
Click to expand...
Click to collapse
It doesnt work I get no response. lipo batteries wont charge if they go below a certain voltage for safety reasons. On this battery it is 3.6/37 volts. Unless you use a lipo charger which are dangerous since you can end up with a fire.
Anyways I get no response at all pressing any combination of buttons.
When tpdebrick says to press power + home + vol-down it gives no response.
Any ideas?
zaq123 said:
It doesnt work I get no response. lipo batteries wont charge if they go below a certain voltage for safety reasons. On this battery it is 3.6/37 volts. Unless you use a lipo charger which are dangerous since you can end up with a fire.
Anyways I get no response at all pressing any combination of buttons.
When tpdebrick says to press power + home + vol-down it gives no response.
Any ideas?
Click to expand...
Click to collapse
I'm on the same boat, I did get the "all done" message after running the tpdebrick, im on hour 3 of charging, nothing yet, will post soon, fingers crossed, TP dead for over 3 months now
zaq123 said:
It doesnt work I get no response. lipo batteries wont charge if they go below a certain voltage for safety reasons. On this battery it is 3.6/37 volts. Unless you use a lipo charger which are dangerous since you can end up with a fire.
Anyways I get no response at all pressing any combination of buttons.
When tpdebrick says to press power + home + vol-down it gives no response.
Any ideas?
Click to expand...
Click to collapse
You are plugged in to a usb port and holding the 3 buttons for 20+ seconds right? Maybe you can leave it on the charger for a day first.
The one I fixed was dead for almost a year. the script failed to read the battery level.
britoso said:
You are plugged in to a usb port and holding the 3 buttons for 20+ seconds right? Maybe you can leave it on the charger for a day first.
The one I fixed was dead for almost a year. the script failed to read the battery level.
Click to expand...
Click to collapse
I tried that left it plugged in for almost two days. tried both the hp charger and a trickle charge. Right now I have it on a touchstone maybe that will work.
Tried all the button combinations still hoping.
miroxlava said:
I'm on the same boat, I did get the "all done" message after running the tpdebrick, im on hour 3 of charging, nothing yet, will post soon, fingers crossed, TP dead for over 3 months now
Click to expand...
Click to collapse
#!/bin/sh
###################################
### TPDebrick v004 by jcsullins ###
###################################
check_pgms()
{
local have_other=1
local ok_install=0
local lsb_rel
local lsb_id
local SP
if ! `which perl >/dev/null 2>&1`;
then
echo "perl not found"
echo "Aborting."
exit 1
fi
lsb_rel=`lsb_release --short --release`
lsb_id=`lsb_release --short --id`
if [ -n "$lsb_rel" -a -n "${lsb_id}" -a "${lsb_id}" = "Ubuntu" ];
then
if [ "${lsb_rel}" = "11.04" -o "${lsb_rel}" = "11.10" -o "${lsb_rel}" = "12.04" ];
then
ok_install=1
fi
fi
if ! `which dfu-util >/dev/null 2>&1`;
then
echo "dfu-util not installed"
have_other=0
fi
if ! `which fastboot >/dev/null 2>&1`;
then
echo "fastboot not installed"
have_other=0
fi
if [ $have_other -eq 1 ];
then
return;
fi
if [ $ok_install -eq 0 ];
then
echo "Aborted."
exit 1
fi
if `which software-properties-kde >/dev/null 2>&1`;
then
SP=software-properties-kde
else
SP=software-properties-gtk
fi
echo "Installing dfu-util/fastboot ..."
$SP --enable-component universe
if [ $? -ne 0 ];
then
echo "Enable universe failed."
echo "Aborted."
exit 1
fi
add-apt-repository --yes ppa:nilarimogard/webupd8
if [ $? -ne 0 ];
then
echo "add-apt-repository failed"
echo "Aborted."
exit 1
fi
apt-get update
if [ $? -ne 0 ];
then
echo "apt-get update failed"
echo "Aborted."
exit 1
fi
apt-get --yes install dfu-util
if [ $? -ne 0 ];
then
echo "install dfu-util failed"
echo "Aborted."
exit 1
fi
apt-get --yes install android-tools-fastboot
if [ $? -ne 0 ];
then
echo "install fastboot failed"
echo "Aborted."
exit 1
fi
}
check_files()
{
local chk_list
local need_files=0
local doc_fn
local doc_fn_wifi="webosdoctorp305hstnhwifi.jar"
local doc_fn_3g="webosdoctorp305hstnhatt.jar"
echo "checking doc files ..."
chk_list="sbl1.mbn sbl2.mbn sbl3.mbn rpm.mbn tz.mbn"
chk_list="${chk_list} emmc_appsboot.mbn"
chk_list="${chk_list} bootie-topaz305.bin"
chk_list="${chk_list} PmA6Updater"
chk_list="${chk_list} a6_firmware.txt.00"
for fn in $chk_list
do
if [ ! -r ${fn} ];
then
need_files=1
fi
done
if [ $need_files -eq 0 ];
then
return
fi
if [ -r ../${doc_fn_wifi} ];
then
doc_fn=../${doc_fn_wifi}
fi
if [ -r ../${doc_fn_3g} ];
then
doc_fn=../${doc_fn_3g}
fi
if [ -z "${doc_fn}" ];
then
echo "could not find ../${doc_fn_wifi} or ../${doc_fn_3g}"
echo "Aborted."
exit 1
fi
echo "extracting doc files ..."
unzip -p "${doc_fn}" resources/webOS.tar \
| tar -xOf - ./nova-cust-image-topaz.rootfs.tar.gz \
| tar -xzOf - ./boot/boot-genesis.tar.gz \
| tar -xzf -
if [ $? -ne 0 ];
then
echo "failed to extract core bootloaders"
echo "Aborted."
exit 1
fi
unzip -p "${doc_fn}" resources/webOS.tar | \
tar -xOf - ./boot-topaz.bin \
>bootie-topaz305-raw.bin
if [ $? -ne 0 ];
then
echo "failed to extract boot.bin"
echo "Aborted."
exit 1
fi
PRINTF=`which printf 2>/dev/null`
if [ $? -ne 0 ];
then
echo "printf not found."
echo "Aborting."
exit 1
fi
$PRINTF "\x1C\xC3\x01\x00\x00\x00\x80\x40" >bootie-topaz305.bin
cat bootie-topaz305-raw.bin >>bootie-topaz305.bin
$PRINTF "\x18\xDA\x06\x15" >>bootie-topaz305.bin
unzip -p "${doc_fn}" resources/webOS.tar \
| tar -xOf - ./nova-cust-image-topaz.rootfs.tar.gz \
| tar -xzOf - ./usr/bin/PmA6Updater \
>PmA6Updater
if [ $? -ne 0 ];
then
echo "failed to extract PmA6Updater"
echo "Aborted."
exit 1
fi
chmod 755 PmA6Updater
unzip -p "${doc_fn}" resources/webOS.tar | tar -xOf - ./nova-cust-image-topaz.rootfs.tar.gz | tar -xzOf - ./lib/firmware/a6_firmware.txt.00 >a6_firmware.txt.00
if [ $? -ne 0 ];
then
echo "failed to extract a6_firmware.txt.00"
echo "Aborted."
exit 1
fi
}
check_config_files()
{
local cfgf=$1
echo -n "Checking that config/files are valid... "
if [ \! -r ${cfgf} ];
then
echo "FAILED"
echo "Cannot read config file ${cfgf}"
echo "Aborted."
exit 1
fi
while read fname pos md5
do
if [ "${fname}" = '#' ];
then
continue
fi
if [ \! -r "${fname}" ];
then
echo "FAILED"
echo "Cannot read file ${fname}"
echo "Aborted."
exit 1
fi
if [ "${md5}" = "nocheck" ];
then
continue;
fi
CHK_MD5=`md5sum ${fname} | cut -d' ' -f1`
if [ "${CHK_MD5}" != "${md5}" ];
then
echo "FAILED"
echo "File ${fname} failed check."
echo "Aborted."
exit 1
fi
done <${cfgf}
echo "OK"
}
load_files()
{
local cfgf=$1
while read fname pos md5
do
if [ "${fname}" = '#' ];
then
continue;
fi
echo "Writing file ${fname} ... "
addr=$(($pos * 512))
perl qdload.pl --laddr ${addr} --lfile ${fname}
if [ $? -ne 0 ];
then
echo "Cannot write file ${fname}"
echo "Aborted."
exit 1
fi
done <${cfgf}
echo "Done writing files."
}
check_usbdevs()
{
local tmout="$1"
shift
local dev_ids="$*"
local check_flag=1
while [ $check_flag -eq 1 ];
do
for dev_id in $dev_ids
do
dev_count=`lsusb | cut -d' ' -f6 | grep "^${dev_id}" | wc -l`
if [ $dev_count -gt 0 ];
then
return 0
fi
done
if [ $tmout -le 0 ];
then
check_flag=0
else
sleep 1
tmout=$((tmout - 1))
fi
done
return 1
}
get_usbdev_info()
{
local devid=$1
local field=$2
local filter=$3
if [ $field -eq 1 ];
then
lsusb -vv -d $devid |
while read a b c
do
if [ "x${a}" = "x${filter}" ];
then
echo "${b}"
return
fi
done
else
lsusb -vv -d $devid |
while read a b c
do
if [ "x${a}" = "x${filter}" ];
then
echo "${c}"
return
fi
done
fi
}
check_qdlmode()
{
local devid_qdl="05c6:9008"
local imanfac1="`get_usbdev_info $devid_qdl 1 iManufacturer`"
local imanfac2="`get_usbdev_info $devid_qdl 2 iManufacturer`"
local iprod1="`get_usbdev_info $devid_qdl 1 iProduct`"
local iprod2="`get_usbdev_info $devid_qdl 2 iProduct`"
if [ -z "${imanfac1}" -o -z "${iprod1}" ];
then
return 1
fi
if [ -z "${imanfac2}" -o -z "${iprod2}" ];
then
return 1
fi
if [ "${imanfac1}" != "3" ];
then
return 1
fi
if [ "${imanfac2}" != "Qualcomm, Incorporated" ];
then
return 1
fi
if [ "${iprod1}" != "2" ];
then
return 1
fi
if [ "${iprod2}" != "Qualcomm CDMA Technologies MSM" ];
then
return 1
fi
return 0
}
check_qdlmode2()
{
local devid_qdl="05c6:9008"
local imanfac1="`get_usbdev_info $devid_qdl 1 iManufacturer`"
local imanfac2="`get_usbdev_info $devid_qdl 2 iManufacturer`"
local iprod1="`get_usbdev_info $devid_qdl 1 iProduct`"
local iprod2="`get_usbdev_info $devid_qdl 2 iProduct`"
if [ -z "${imanfac1}" -o -z "${iprod1}" ];
then
return 1
fi
if [ -z "${imanfac2}" -o -z "${iprod2}" ];
then
return 1
fi
if [ "${imanfac1}" != "1" ];
then
return 1
fi
if [ "${imanfac2}" != "Qualcomm CDMA Technologies MSM" ];
then
return 1
fi
if [ "${iprod1}" != "2" ];
then
return 1
fi
if [ "${iprod2}" != "QHSUSB_DLOAD" ];
then
return 1
fi
return 0
}
#####
##### MAIN
#####
devid_qdl="05c6:9008"
if [ $# -ne 1 ];
then
echo "Usage: ${0} 16|32|64"
exit 1
fi
if [ "$1" != "16" -a "$1" != "32" -a "$1" != "64" ];
then
echo "Usage: ${0} 16|32|64"
exit 1
fi
tptype="$1"
if [ `id -u` -ne 0 ];
then
echo "Must run as superuser (i.e. sudo ...)"
echo "Aborting"
exit 1
fi
check_pgms
check_files
devid_qdl="05c6:9008"
devid_dfu="0830:8070"
devid_fastboot="18d1:d00d"
devid_netchip="0525:a4aa"
if `check_usbdevs 0 $devid_qdl`;
then
if ! `check_qdlmode2`;
then
echo "Incorrect QDL mode found."
echo "Please hold Power+Home+VolumeDown for 20-30 secs, then retry."
echo "Aborted."
exit 1
fi
else
echo "Connect Touchpad then hold Power+Home+VolumeDown for 30 seconds ..."
if ! `check_usbdevs 120 $devid_qdl`
then
echo "QDL mode not found"
echo "Aborting."
exit 1
else
echo "Release buttons now"
sleep 5
fi
fi
perl qdload.pl --pfile emmcbld.bin
if [ $? -ne 0 ];
then
echo "load of emmcbld.bin failed"
echo "Aborting."
exit 1
fi
sleep 3
echo "Checking QDL mode..."
if ! `check_qdlmode`;
then
echo "QDL second stage mode not found"
echo "Aborting"
exit 1
fi
load_files tp${tptype}nobootie.cfg
echo "Reseting device..."
perl qdload.pl --lreset
echo "Waiting for fastboot mode..."
if ! `check_usbdevs 60 ${devid_fastboot}`
then
echo "fastboot mode not found"
echo "Aborted."
exit 1
fi
echo "Loading TPToolbox-Headless ..."
fastboot flash bootmem TPToolbox-Headless-v004
if [ $? -ne 0 ];
then
echo "TPToolbox-Headless load failed"
echo "Aborted."
exit 1
fi
echo "Waiting for netchip mode... (may take 3+ mins)"
if ! `check_usbdevs 200 ${devid_netchip}`
then
echo "netchip mode not found"
echo "Aborted."
exit 1
fi
echo "Waiting for ping check... (may take 1-2 mins)"
ccnt=120
ping_ok=0
while [ $ccnt -gt 0 ];
do
ping -c 1 -W 1 192.168.7.7 >/dev/null 2>&1
if [ $? -eq 0 ];
then
ccnt=0
ping_ok=1
fi
ccnt=$(($ccnt - 1))
done
if [ $ping_ok -eq 0 ];
then
echo "ping check failed"
echo "check firewall/networking setup"
echo "access to the 192.68.7.7 host (Touchpad) failed"
echo "Aborted."
exit 1
fi
echo "Checking/updating known_hosts..."
need_khosts=0
if [ ! -r ~root/.ssh/known_hosts ];
then
need_khosts=1
else
chk1=`ssh-keygen -F 192.168.7.7 -f ~root/.ssh/known_hosts | wc -l`
if [ $? -ne 0 ];
then
echo "Failed to check known_hosts"
echo "Aborted."
exit 1
fi
if [ $chk1 -eq 0 ];
then
need_khosts=1
fi
fi
if [ $need_khosts -eq 1 ];
then
mkdir -p ~root/.ssh
cat khosts >>~root/.ssh/known_hosts
fi
echo "Copying A6 files..."
scp -i ssh-key a6_firmware.txt.00 PmA6Updater [email protected]:/tmp
if [ $? -ne 0 ];
then
echo "A6 files copy failed."
echo "Aborted."
exit 1
fi
echo "Copying bootloader files..."
scp -i ssh-key bootie-topaz305.bin emmc_appsboot.mbn [email protected]:/tmp
if [ $? -ne 0 ];
then
echo "bootloader files copy failed."
echo "Aborted."
exit 1
fi
echo ""
echo "Checking A6 firmware..."
ssh -i ssh-key [email protected] /tmp/PmA6Updater -x -d 0 /tmp/a6_firmware.txt.00
## if [ $? -ne 0 ];
## then
## echo "A6 firmware check failed."
## echo "Aborted."
## exit 1
## fi
echo ""
echo "Updating A6 firmware..."
ssh -i ssh-key [email protected] /tmp/PmA6Updater -f -d 0 /tmp/a6_firmware.txt.00
if [ $? -ne 0 ];
then
echo "A6 firmware update failed."
echo "Aborted."
exit 1
fi
echo ""
echo "Capturing DMESG..."
ssh -i ssh-key [email protected] dmesg
if [ $? -ne 0 ];
then
echo "dmesg capture failed"
echo "Aborted."
exit 1
fi
echo ""
echo "Updating bootloader emmc_appsboot..."
ssh -i ssh-key [email protected] dd if=/tmp/emmc_appsboot.mbn of=/dev/mmcblk0p7
if [ $? -ne 0 ];
then
echo "update bootloader emmc_appsboot failed."
echo "Aborted."
exit 1
fi
echo ""
echo "Updating bootloader bootie..."
ssh -i ssh-key [email protected] dd if=/tmp/bootie-topaz305.bin of=/dev/mmcblk0p8
if [ $? -ne 0 ];
then
echo "update bootloader bootie failed."
echo "Aborted."
exit 1
fi
echo ""
echo "Checking battery voltage/percent... "
bvolt=`ssh -i ssh-key [email protected] cat /sys/devices/i2c-3/3-0031/getvoltage`
if [ $? -ne 0 ];
then
echo "getvoltage failed"
echo "Aborted."
exit 1
fi
bperc=`ssh -i ssh-key [email protected] cat /sys/devices/i2c-3/3-0031/getpercent`
if [ $? -ne 0 ];
then
echo "getpercent failed"
echo "Aborted."
exit 1
fi
echo "Battery Voltage=${bvolt} Percent=${bperc}"
if [ $bperc -gt 5 ];
then
echo "Rebooting Touchpad ..."
ssh -i ssh-key [email protected] "(sleep 1;/sbin/reboot -f) &"
echo "ALL DONE."
exit 0
fi
if [ $bperc -gt 0 ];
then
echo "Rebooting Touchpad ..."
ssh -i ssh-key [email protected] "(sleep 1;/sbin/reboot -f) &"
echo "Connect touchpad to stock HP AC charger to allow to charge"
echo "ALL DONE."
exit 0
fi
echo ""
echo "Waiting 1 min before checking voltage/percent again (1/2) ..."
sleep 60
bvolt=`ssh -i ssh-key [email protected] cat /sys/devices/i2c-3/3-0031/getvoltage`
if [ $? -ne 0 ];
then
echo "getvoltage failed"
echo "Aborted."
exit 1
fi
bperc=`ssh -i ssh-key [email protected] cat /sys/devices/i2c-3/3-0031/getpercent`
if [ $? -ne 0 ];
then
echo "getpercent failed"
echo "Aborted."
exit 1
fi
echo "Battery Voltage=${bvolt} Percent=${bperc}"
echo ""
echo "Waiting 1 min before checking voltage/percent again (2/2) ..."
sleep 60
bvolt=`ssh -i ssh-key [email protected] cat /sys/devices/i2c-3/3-0031/getvoltage`
if [ $? -ne 0 ];
then
echo "getvoltage failed"
echo "Aborted."
exit 1
fi
bperc=`ssh -i ssh-key [email protected] cat /sys/devices/i2c-3/3-0031/getpercent`
if [ $? -ne 0 ];
then
echo "getpercent failed"
echo "Aborted."
exit 1
fi
echo "Battery Voltage=${bvolt} Percent=${bperc}"
echo "Rebooting Touchpad ..."
ssh -i ssh-key [email protected] "(sleep 1;/sbin/reboot -f) &"
echo "Connect Touchpad to stock HP AC charger now"
echo "and allow it to charge for several hours"
echo "ALL DONE."
not working, im running 12.10 and the only way it works is if I gedit tpdebrick 12.10... but how should i type it? sudo gedit tpdebrick 12.10 ./tpdebrick 32 ???
Please wrap [ hide ] and [/ hide ] (with no spacing between hide and brackets) so your post look like this
,,,,,,,,,
{
"lightbox_close": "Close",
"lightbox_next": "Next",
"lightbox_previous": "Previous",
"lightbox_error": "The requested content cannot be loaded. Please try again later.",
"lightbox_start_slideshow": "Start slideshow",
"lightbox_stop_slideshow": "Stop slideshow",
"lightbox_full_screen": "Full screen",
"lightbox_thumbnails": "Thumbnails",
"lightbox_download": "Download",
"lightbox_share": "Share",
"lightbox_zoom": "Zoom",
"lightbox_new_window": "New window",
"lightbox_toggle_sidebar": "Toggle sidebar"
}
###################################
### TPDebrick v004 by jcsullins ###
###################################
check_pgms()
{
local have_other=1
local ok_install=0
local lsb_rel
local lsb_id
local SP
if ! `which perl >/dev/null 2>&1`;
then
echo "perl not found"
echo "Aborting."
exit 1
fi
lsb_rel=`lsb_release --short --release`
lsb_id=`lsb_release --short --id`
if [ -n "$lsb_rel" -a -n "${lsb_id}" -a "${lsb_id}" = "Ubuntu" ];
then
if [ "${lsb_rel}" = "11.04" -o "${lsb_rel}" = "11.10" -o "${lsb_rel}" = "12.04" ];
then
ok_install=1
fi
fi
if ! `which dfu-util >/dev/null 2>&1`;
then
echo "dfu-util not installed"
have_other=0
fi
if ! `which fastboot >/dev/null 2>&1`;
then
echo "fastboot not installed"
have_other=0
fi
if [ $have_other -eq 1 ];
then
return;
fi
if [ $ok_install -eq 0 ];
then
echo "Aborted."
exit 1
fi
if `which software-properties-kde >/dev/null 2>&1`;
then
SP=software-properties-kde
else
SP=software-properties-gtk
fi
echo "Installing dfu-util/fastboot ..."
$SP --enable-component universe
if [ $? -ne 0 ];
then
echo "Enable universe failed."
echo "Aborted."
exit 1
fi
add-apt-repository --yes ppa:nilarimogard/webupd8
if [ $? -ne 0 ];
then
echo "add-apt-repository failed"
echo "Aborted."
exit 1
fi
apt-get update
if [ $? -ne 0 ];
then
echo "apt-get update failed"
echo "Aborted."
exit 1
fi
apt-get --yes install dfu-util
if [ $? -ne 0 ];
then
echo "install dfu-util failed"
echo "Aborted."
exit 1
fi
apt-get --yes install android-tools-fastboot
if [ $? -ne 0 ];
then
echo "install fastboot failed"
echo "Aborted."
exit 1
fi
}
check_files()
{
local chk_list
local need_files=0
local doc_fn
local doc_fn_wifi="webosdoctorp305hstnhwifi.jar"
local doc_fn_3g="webosdoctorp305hstnhatt.jar"
echo "checking doc files ..."
chk_list="sbl1.mbn sbl2.mbn sbl3.mbn rpm.mbn tz.mbn"
chk_list="${chk_list} emmc_appsboot.mbn"
chk_list="${chk_list} bootie-topaz305.bin"
chk_list="${chk_list} PmA6Updater"
chk_list="${chk_list} a6_firmware.txt.00"
for fn in $chk_list
do
if [ ! -r ${fn} ];
then
need_files=1
fi
done
if [ $need_files -eq 0 ];
then
return
fi
if [ -r ../${doc_fn_wifi} ];
then
doc_fn=../${doc_fn_wifi}
fi
if [ -r ../${doc_fn_3g} ];
then
doc_fn=../${doc_fn_3g}
fi
if [ -z "${doc_fn}" ];
then
echo "could not find ../${doc_fn_wifi} or ../${doc_fn_3g}"
echo "Aborted."
exit 1
fi
echo "extracting doc files ..."
unzip -p "${doc_fn}" resources/webOS.tar \
| tar -xOf - ./nova-cust-image-topaz.rootfs.tar.gz \
| tar -xzOf - ./boot/boot-genesis.tar.gz \
| tar -xzf -
if [ $? -ne 0 ];
then
echo "failed to extract core bootloaders"
echo "Aborted."
exit 1
fi
unzip -p "${doc_fn}" resources/webOS.tar | \
tar -xOf - ./boot-topaz.bin \
>bootie-topaz305-raw.bin
if [ $? -ne 0 ];
then
echo "failed to extract boot.bin"
echo "Aborted."
exit 1
fi
PRINTF=`which printf 2>/dev/null`
if [ $? -ne 0 ];
then
echo "printf not found."
echo "Aborting."
exit 1
fi
$PRINTF "\x1C\xC3\x01\x00\x00\x00\x80\x40" >bootie-topaz305.bin
cat bootie-topaz305-raw.bin >>bootie-topaz305.bin
$PRINTF "\x18\xDA\x06\x15" >>bootie-topaz305.bin
unzip -p "${doc_fn}" resources/webOS.tar \
| tar -xOf - ./nova-cust-image-topaz.rootfs.tar.gz \
| tar -xzOf - ./usr/bin/PmA6Updater \
>PmA6Updater
if [ $? -ne 0 ];
then
echo "failed to extract PmA6Updater"
echo "Aborted."
exit 1
fi
chmod 755 PmA6Updater
unzip -p "${doc_fn}" resources/webOS.tar | tar -xOf - ./nova-cust-image-topaz.rootfs.tar.gz | tar -xzOf - ./lib/firmware/a6_firmware.txt.00 >a6_firmware.txt.00
if [ $? -ne 0 ];
then
echo "failed to extract a6_firmware.txt.00"
echo "Aborted."
exit 1
fi
}
check_config_files()
{
local cfgf=$1
echo -n "Checking that config/files are valid... "
if [ \! -r ${cfgf} ];
then
echo "FAILED"
echo "Cannot read config file ${cfgf}"
echo "Aborted."
exit 1
fi
while read fname pos md5
do
if [ "${fname}" = '#' ];
then
continue
fi
if [ \! -r "${fname}" ];
then
echo "FAILED"
echo "Cannot read file ${fname}"
echo "Aborted."
exit 1
fi
if [ "${md5}" = "nocheck" ];
then
continue;
fi
CHK_MD5=`md5sum ${fname} | cut -d' ' -f1`
if [ "${CHK_MD5}" != "${md5}" ];
then
echo "FAILED"
echo "File ${fname} failed check."
echo "Aborted."
exit 1
fi
done <${cfgf}
echo "OK"
}
load_files()
{
local cfgf=$1
while read fname pos md5
do
if [ "${fname}" = '#' ];
then
continue;
fi
echo "Writing file ${fname} ... "
addr=$(($pos * 512))
perl qdload.pl --laddr ${addr} --lfile ${fname}
if [ $? -ne 0 ];
then
echo "Cannot write file ${fname}"
echo "Aborted."
exit 1
fi
done <${cfgf}
echo "Done writing files."
}
check_usbdevs()
{
local tmout="$1"
shift
local dev_ids="$*"
local check_flag=1
while [ $check_flag -eq 1 ];
do
for dev_id in $dev_ids
do
dev_count=`lsusb | cut -d' ' -f6 | grep "^${dev_id}" | wc -l`
if [ $dev_count -gt 0 ];
then
return 0
fi
done
if [ $tmout -le 0 ];
then
check_flag=0
else
sleep 1
tmout=$((tmout - 1))
fi
done
return 1
}
get_usbdev_info()
{
local devid=$1
local field=$2
local filter=$3
if [ $field -eq 1 ];
then
lsusb -vv -d $devid |
while read a b c
do
if [ "x${a}" = "x${filter}" ];
then
echo "${b}"
return
fi
done
else
lsusb -vv -d $devid |
while read a b c
do
if [ "x${a}" = "x${filter}" ];
then
echo "${c}"
return
fi
done
fi
}
check_qdlmode()
{
local devid_qdl="05c6:9008"
local imanfac1="`get_usbdev_info $devid_qdl 1 iManufacturer`"
local imanfac2="`get_usbdev_info $devid_qdl 2 iManufacturer`"
local iprod1="`get_usbdev_info $devid_qdl 1 iProduct`"
local iprod2="`get_usbdev_info $devid_qdl 2 iProduct`"
if [ -z "${imanfac1}" -o -z "${iprod1}" ];
then
return 1
fi
if [ -z "${imanfac2}" -o -z "${iprod2}" ];
then
return 1
fi
if [ "${imanfac1}" != "3" ];
then
return 1
fi
if [ "${imanfac2}" != "Qualcomm, Incorporated" ];
then
return 1
fi
if [ "${iprod1}" != "2" ];
then
return 1
fi
if [ "${iprod2}" != "Qualcomm CDMA Technologies MSM" ];
then
return 1
fi
return 0
}
check_qdlmode2()
{
local devid_qdl="05c6:9008"
local imanfac1="`get_usbdev_info $devid_qdl 1 iManufacturer`"
local imanfac2="`get_usbdev_info $devid_qdl 2 iManufacturer`"
local iprod1="`get_usbdev_info $devid_qdl 1 iProduct`"
local iprod2="`get_usbdev_info $devid_qdl 2 iProduct`"
if [ -z "${imanfac1}" -o -z "${iprod1}" ];
then
return 1
fi
if [ -z "${imanfac2}" -o -z "${iprod2}" ];
then
return 1
fi
if [ "${imanfac1}" != "1" ];
then
return 1
fi
if [ "${imanfac2}" != "Qualcomm CDMA Technologies MSM" ];
then
return 1
fi
if [ "${iprod1}" != "2" ];
then
return 1
fi
if [ "${iprod2}" != "QHSUSB_DLOAD" ];
then
return 1
fi
return 0
}
#####
##### MAIN
#####
devid_qdl="05c6:9008"
if [ $# -ne 1 ];
then
echo "Usage: ${0} 16|32|64"
exit 1
fi
if [ "$1" != "16" -a "$1" != "32" -a "$1" != "64" ];
then
echo "Usage: ${0} 16|32|64"
exit 1
fi
tptype="$1"
if [ `id -u` -ne 0 ];
then
echo "Must run as superuser (i.e. sudo ...)"
echo "Aborting"
exit 1
fi
check_pgms
check_files
devid_qdl="05c6:9008"
devid_dfu="0830:8070"
devid_fastboot="18d1:d00d"
devid_netchip="0525:a4aa"
if `check_usbdevs 0 $devid_qdl`;
then
if ! `check_qdlmode2`;
then
echo "Incorrect QDL mode found."
echo "Please hold Power+Home+VolumeDown for 20-30 secs, then retry."
echo "Aborted."
exit 1
fi
else
echo "Connect Touchpad then hold Power+Home+VolumeDown for 30 seconds ..."
if ! `check_usbdevs 120 $devid_qdl`
then
echo "QDL mode not found"
echo "Aborting."
exit 1
else
echo "Release buttons now"
sleep 5
fi
fi
perl qdload.pl --pfile emmcbld.bin
if [ $? -ne 0 ];
then
echo "load of emmcbld.bin failed"
echo "Aborting."
exit 1
fi
sleep 3
echo "Checking QDL mode..."
if ! `check_qdlmode`;
then
echo "QDL second stage mode not found"
echo "Aborting"
exit 1
fi
load_files tp${tptype}nobootie.cfg
echo "Reseting device..."
perl qdload.pl --lreset
echo "Waiting for fastboot mode..."
if ! `check_usbdevs 60 ${devid_fastboot}`
then
echo "fastboot mode not found"
echo "Aborted."
exit 1
fi
echo "Loading TPToolbox-Headless ..."
fastboot flash bootmem TPToolbox-Headless-v004
if [ $? -ne 0 ];
then
echo "TPToolbox-Headless load failed"
echo "Aborted."
exit 1
fi
echo "Waiting for netchip mode... (may take 3+ mins)"
if ! `check_usbdevs 200 ${devid_netchip}`
then
echo "netchip mode not found"
echo "Aborted."
exit 1
fi
echo "Waiting for ping check... (may take 1-2 mins)"
ccnt=120
ping_ok=0
while [ $ccnt -gt 0 ];
do
ping -c 1 -W 1 192.168.7.7 >/dev/null 2>&1
if [ $? -eq 0 ];
then
ccnt=0
ping_ok=1
fi
ccnt=$(($ccnt - 1))
done
if [ $ping_ok -eq 0 ];
then
echo "ping check failed"
echo "check firewall/networking setup"
echo "access to the 192.68.7.7 host (Touchpad) failed"
echo "Aborted."
exit 1
fi
echo "Checking/updating known_hosts..."
need_khosts=0
if [ ! -r ~root/.ssh/known_hosts ];
then
need_khosts=1
else
chk1=`ssh-keygen -F 192.168.7.7 -f ~root/.ssh/known_hosts | wc -l`
if [ $? -ne 0 ];
then
echo "Failed to check known_hosts"
echo "Aborted."
exit 1
fi
if [ $chk1 -eq 0 ];
then
need_khosts=1
fi
fi
if [ $need_khosts -eq 1 ];
then
mkdir -p ~root/.ssh
cat khosts >>~root/.ssh/known_hosts
fi
echo "Copying A6 files..."
scp -i ssh-key a6_firmware.txt.00 PmA6Updater [email protected]:/tmp
if [ $? -ne 0 ];
then
echo "A6 files copy failed."
echo "Aborted."
exit 1
fi
echo "Copying bootloader files..."
scp -i ssh-key bootie-topaz305.bin emmc_appsboot.mbn [email protected]:/tmp
if [ $? -ne 0 ];
then
echo "bootloader files copy failed."
echo "Aborted."
exit 1
fi
echo ""
echo "Checking A6 firmware..."
ssh -i ssh-key [email protected] /tmp/PmA6Updater -x -d 0 /tmp/a6_firmware.txt.00
## if [ $? -ne 0 ];
## then
## echo "A6 firmware check failed."
## echo "Aborted."
## exit 1
## fi
echo ""
echo "Updating A6 firmware..."
ssh -i ssh-key [email protected] /tmp/PmA6Updater -f -d 0 /tmp/a6_firmware.txt.00
if [ $? -ne 0 ];
then
echo "A6 firmware update failed."
echo "Aborted."
exit 1
fi
echo ""
echo "Capturing DMESG..."
ssh -i ssh-key [email protected] dmesg
if [ $? -ne 0 ];
then
echo "dmesg capture failed"
echo "Aborted."
exit 1
fi
echo ""
echo "Updating bootloader emmc_appsboot..."
ssh -i ssh-key [email protected] dd if=/tmp/emmc_appsboot.mbn of=/dev/mmcblk0p7
if [ $? -ne 0 ];
then
echo "update bootloader emmc_appsboot failed."
echo "Aborted."
exit 1
fi
echo ""
echo "Updating bootloader bootie..."
ssh -i ssh-key [email protected] dd if=/tmp/bootie-topaz305.bin of=/dev/mmcblk0p8
if [ $? -ne 0 ];
then
echo "update bootloader bootie failed."
echo "Aborted."
exit 1
fi
echo ""
echo "Checking battery voltage/percent... "
bvolt=`ssh -i ssh-key [email protected] cat /sys/devices/i2c-3/3-0031/getvoltage`
if [ $? -ne 0 ];
then
echo "getvoltage failed"
echo "Aborted."
exit 1
fi
bperc=`ssh -i ssh-key [email protected] cat /sys/devices/i2c-3/3-0031/getpercent`
if [ $? -ne 0 ];
then
echo "getpercent failed"
echo "Aborted."
exit 1
fi
echo "Battery Voltage=${bvolt} Percent=${bperc}"
if [ $bperc -gt 5 ];
then
echo "Rebooting Touchpad ..."
ssh -i ssh-key [email protected] "(sleep 1;/sbin/reboot -f) &"
echo "ALL DONE."
exit 0
fi
if [ $bperc -gt 0 ];
then
echo "Rebooting Touchpad ..."
ssh -i ssh-key [email protected] "(sleep 1;/sbin/reboot -f) &"
echo "Connect touchpad to stock HP AC charger to allow to charge"
echo "ALL DONE."
exit 0
fi
echo ""
echo "Waiting 1 min before checking voltage/percent again (1/2) ..."
sleep 60
bvolt=`ssh -i ssh-key [email protected] cat /sys/devices/i2c-3/3-0031/getvoltage`
if [ $? -ne 0 ];
then
echo "getvoltage failed"
echo "Aborted."
exit 1
fi
bperc=`ssh -i ssh-key [email protected] cat /sys/devices/i2c-3/3-0031/getpercent`
if [ $? -ne 0 ];
then
echo "getpercent failed"
echo "Aborted."
exit 1
fi
echo "Battery Voltage=${bvolt} Percent=${bperc}"
echo ""
echo "Waiting 1 min before checking voltage/percent again (2/2) ..."
sleep 60
bvolt=`ssh -i ssh-key [email protected] cat /sys/devices/i2c-3/3-0031/getvoltage`
if [ $? -ne 0 ];
then
echo "getvoltage failed"
echo "Aborted."
exit 1
fi
bperc=`ssh -i ssh-key [email protected] cat /sys/devices/i2c-3/3-0031/getpercent`
if [ $? -ne 0 ];
then
echo "getpercent failed"
echo "Aborted."
exit 1
fi
echo "Battery Voltage=${bvolt} Percent=${bperc}"
echo "Rebooting Touchpad ..."
ssh -i ssh-key [email protected] "(sleep 1;/sbin/reboot -f) &"
echo "Connect Touchpad to stock HP AC charger now"
echo "and allow it to charge for several hours"
echo "ALL DONE."
not working, im running 12.10 and the only way it works is if I gedit tpdebrick 12.10... but how should i type it? sudo gedit tpdebrick 12.10 ./tpdebrick 32 ???
Thank you.
signs of life !!!!!!!!!!!
miroxlava said:
#!/bin/sh
###################################
### TPDebrick v004 by jcsullins ###
###################################
check_pgms()
{
local have_other=1
local ok_install=0
local lsb_rel
local lsb_id
local SP
if ! `which perl >/dev/null 2>&1`;
then
echo "perl not found"
echo "Aborting."
exit 1
fi
lsb_rel=`lsb_release --short --release`
lsb_id=`lsb_release --short --id`
if [ -n "$lsb_rel" -a -n "${lsb_id}" -a "${lsb_id}" = "Ubuntu" ];
then
if [ "${lsb_rel}" = "11.04" -o "${lsb_rel}" = "11.10" -o "${lsb_rel}" = "12.04" ];
then
ok_install=1
fi
fi
if ! `which dfu-util >/dev/null 2>&1`;
then
echo "dfu-util not installed"
have_other=0
fi
if ! `which fastboot >/dev/null 2>&1`;
then
echo "fastboot not installed"
have_other=0
fi
if [ $have_other -eq 1 ];
then
return;
fi
if [ $ok_install -eq 0 ];
then
echo "Aborted."
exit 1
fi
if `which software-properties-kde >/dev/null 2>&1`;
then
SP=software-properties-kde
else
SP=software-properties-gtk
fi
echo "Installing dfu-util/fastboot ..."
$SP --enable-component universe
if [ $? -ne 0 ];
then
echo "Enable universe failed."
echo "Aborted."
exit 1
fi
add-apt-repository --yes ppa:nilarimogard/webupd8
if [ $? -ne 0 ];
then
echo "add-apt-repository failed"
echo "Aborted."
exit 1
fi
apt-get update
if [ $? -ne 0 ];
then
echo "apt-get update failed"
echo "Aborted."
exit 1
fi
apt-get --yes install dfu-util
if [ $? -ne 0 ];
then
echo "install dfu-util failed"
echo "Aborted."
exit 1
fi
apt-get --yes install android-tools-fastboot
if [ $? -ne 0 ];
then
echo "install fastboot failed"
echo "Aborted."
exit 1
fi
}
check_files()
{
local chk_list
local need_files=0
local doc_fn
local doc_fn_wifi="webosdoctorp305hstnhwifi.jar"
local doc_fn_3g="webosdoctorp305hstnhatt.jar"
echo "checking doc files ..."
chk_list="sbl1.mbn sbl2.mbn sbl3.mbn rpm.mbn tz.mbn"
chk_list="${chk_list} emmc_appsboot.mbn"
chk_list="${chk_list} bootie-topaz305.bin"
chk_list="${chk_list} PmA6Updater"
chk_list="${chk_list} a6_firmware.txt.00"
for fn in $chk_list
do
if [ ! -r ${fn} ];
then
need_files=1
fi
done
if [ $need_files -eq 0 ];
then
return
fi
if [ -r ../${doc_fn_wifi} ];
then
doc_fn=../${doc_fn_wifi}
fi
if [ -r ../${doc_fn_3g} ];
then
doc_fn=../${doc_fn_3g}
fi
if [ -z "${doc_fn}" ];
then
echo "could not find ../${doc_fn_wifi} or ../${doc_fn_3g}"
echo "Aborted."
exit 1
fi
echo "extracting doc files ..."
unzip -p "${doc_fn}" resources/webOS.tar \
| tar -xOf - ./nova-cust-image-topaz.rootfs.tar.gz \
| tar -xzOf - ./boot/boot-genesis.tar.gz \
| tar -xzf -
if [ $? -ne 0 ];
then
echo "failed to extract core bootloaders"
echo "Aborted."
exit 1
fi
unzip -p "${doc_fn}" resources/webOS.tar | \
tar -xOf - ./boot-topaz.bin \
>bootie-topaz305-raw.bin
if [ $? -ne 0 ];
then
echo "failed to extract boot.bin"
echo "Aborted."
exit 1
fi
PRINTF=`which printf 2>/dev/null`
if [ $? -ne 0 ];
then
echo "printf not found."
echo "Aborting."
exit 1
fi
$PRINTF "\x1C\xC3\x01\x00\x00\x00\x80\x40" >bootie-topaz305.bin
cat bootie-topaz305-raw.bin >>bootie-topaz305.bin
$PRINTF "\x18\xDA\x06\x15" >>bootie-topaz305.bin
unzip -p "${doc_fn}" resources/webOS.tar \
| tar -xOf - ./nova-cust-image-topaz.rootfs.tar.gz \
| tar -xzOf - ./usr/bin/PmA6Updater \
>PmA6Updater
if [ $? -ne 0 ];
then
echo "failed to extract PmA6Updater"
echo "Aborted."
exit 1
fi
chmod 755 PmA6Updater
unzip -p "${doc_fn}" resources/webOS.tar | tar -xOf - ./nova-cust-image-topaz.rootfs.tar.gz | tar -xzOf - ./lib/firmware/a6_firmware.txt.00 >a6_firmware.txt.00
if [ $? -ne 0 ];
then
echo "failed to extract a6_firmware.txt.00"
echo "Aborted."
exit 1
fi
}
check_config_files()
{
local cfgf=$1
echo -n "Checking that config/files are valid... "
if [ \! -r ${cfgf} ];
then
echo "FAILED"
echo "Cannot read config file ${cfgf}"
echo "Aborted."
exit 1
fi
while read fname pos md5
do
if [ "${fname}" = '#' ];
then
continue
fi
if [ \! -r "${fname}" ];
then
echo "FAILED"
echo "Cannot read file ${fname}"
echo "Aborted."
exit 1
fi
if [ "${md5}" = "nocheck" ];
then
continue;
fi
CHK_MD5=`md5sum ${fname} | cut -d' ' -f1`
if [ "${CHK_MD5}" != "${md5}" ];
then
echo "FAILED"
echo "File ${fname} failed check."
echo "Aborted."
exit 1
fi
done <${cfgf}
echo "OK"
}
load_files()
{
local cfgf=$1
while read fname pos md5
do
if [ "${fname}" = '#' ];
then
continue;
fi
echo "Writing file ${fname} ... "
addr=$(($pos * 512))
perl qdload.pl --laddr ${addr} --lfile ${fname}
if [ $? -ne 0 ];
then
echo "Cannot write file ${fname}"
echo "Aborted."
exit 1
fi
done <${cfgf}
echo "Done writing files."
}
check_usbdevs()
{
local tmout="$1"
shift
local dev_ids="$*"
local check_flag=1
while [ $check_flag -eq 1 ];
do
for dev_id in $dev_ids
do
dev_count=`lsusb | cut -d' ' -f6 | grep "^${dev_id}" | wc -l`
if [ $dev_count -gt 0 ];
then
return 0
fi
done
if [ $tmout -le 0 ];
then
check_flag=0
else
sleep 1
tmout=$((tmout - 1))
fi
done
return 1
}
get_usbdev_info()
{
local devid=$1
local field=$2
local filter=$3
if [ $field -eq 1 ];
then
lsusb -vv -d $devid |
while read a b c
do
if [ "x${a}" = "x${filter}" ];
then
echo "${b}"
return
fi
done
else
lsusb -vv -d $devid |
while read a b c
do
if [ "x${a}" = "x${filter}" ];
then
echo "${c}"
return
fi
done
fi
}
check_qdlmode()
{
local devid_qdl="05c6:9008"
local imanfac1="`get_usbdev_info $devid_qdl 1 iManufacturer`"
local imanfac2="`get_usbdev_info $devid_qdl 2 iManufacturer`"
local iprod1="`get_usbdev_info $devid_qdl 1 iProduct`"
local iprod2="`get_usbdev_info $devid_qdl 2 iProduct`"
if [ -z "${imanfac1}" -o -z "${iprod1}" ];
then
return 1
fi
if [ -z "${imanfac2}" -o -z "${iprod2}" ];
then
return 1
fi
if [ "${imanfac1}" != "3" ];
then
return 1
fi
if [ "${imanfac2}" != "Qualcomm, Incorporated" ];
then
return 1
fi
if [ "${iprod1}" != "2" ];
then
return 1
fi
if [ "${iprod2}" != "Qualcomm CDMA Technologies MSM" ];
then
return 1
fi
return 0
}
check_qdlmode2()
{
local devid_qdl="05c6:9008"
local imanfac1="`get_usbdev_info $devid_qdl 1 iManufacturer`"
local imanfac2="`get_usbdev_info $devid_qdl 2 iManufacturer`"
local iprod1="`get_usbdev_info $devid_qdl 1 iProduct`"
local iprod2="`get_usbdev_info $devid_qdl 2 iProduct`"
if [ -z "${imanfac1}" -o -z "${iprod1}" ];
then
return 1
fi
if [ -z "${imanfac2}" -o -z "${iprod2}" ];
then
return 1
fi
if [ "${imanfac1}" != "1" ];
then
return 1
fi
if [ "${imanfac2}" != "Qualcomm CDMA Technologies MSM" ];
then
return 1
fi
if [ "${iprod1}" != "2" ];
then
return 1
fi
if [ "${iprod2}" != "QHSUSB_DLOAD" ];
then
return 1
fi
return 0
}
#####
##### MAIN
#####
devid_qdl="05c6:9008"
if [ $# -ne 1 ];
then
echo "Usage: ${0} 16|32|64"
exit 1
fi
if [ "$1" != "16" -a "$1" != "32" -a "$1" != "64" ];
then
echo "Usage: ${0} 16|32|64"
exit 1
fi
tptype="$1"
if [ `id -u` -ne 0 ];
then
echo "Must run as superuser (i.e. sudo ...)"
echo "Aborting"
exit 1
fi
check_pgms
check_files
devid_qdl="05c6:9008"
devid_dfu="0830:8070"
devid_fastboot="18d1:d00d"
devid_netchip="0525:a4aa"
if `check_usbdevs 0 $devid_qdl`;
then
if ! `check_qdlmode2`;
then
echo "Incorrect QDL mode found."
echo "Please hold Power+Home+VolumeDown for 20-30 secs, then retry."
echo "Aborted."
exit 1
fi
else
echo "Connect Touchpad then hold Power+Home+VolumeDown for 30 seconds ..."
if ! `check_usbdevs 120 $devid_qdl`
then
echo "QDL mode not found"
echo "Aborting."
exit 1
else
echo "Release buttons now"
sleep 5
fi
fi
perl qdload.pl --pfile emmcbld.bin
if [ $? -ne 0 ];
then
echo "load of emmcbld.bin failed"
echo "Aborting."
exit 1
fi
sleep 3
echo "Checking QDL mode..."
if ! `check_qdlmode`;
then
echo "QDL second stage mode not found"
echo "Aborting"
exit 1
fi
load_files tp${tptype}nobootie.cfg
echo "Reseting device..."
perl qdload.pl --lreset
echo "Waiting for fastboot mode..."
if ! `check_usbdevs 60 ${devid_fastboot}`
then
echo "fastboot mode not found"
echo "Aborted."
exit 1
fi
echo "Loading TPToolbox-Headless ..."
fastboot flash bootmem TPToolbox-Headless-v004
if [ $? -ne 0 ];
then
echo "TPToolbox-Headless load failed"
echo "Aborted."
exit 1
fi
echo "Waiting for netchip mode... (may take 3+ mins)"
if ! `check_usbdevs 200 ${devid_netchip}`
then
echo "netchip mode not found"
echo "Aborted."
exit 1
fi
echo "Waiting for ping check... (may take 1-2 mins)"
ccnt=120
ping_ok=0
while [ $ccnt -gt 0 ];
do
ping -c 1 -W 1 192.168.7.7 >/dev/null 2>&1
if [ $? -eq 0 ];
then
ccnt=0
ping_ok=1
fi
ccnt=$(($ccnt - 1))
done
if [ $ping_ok -eq 0 ];
then
echo "ping check failed"
echo "check firewall/networking setup"
echo "access to the 192.68.7.7 host (Touchpad) failed"
echo "Aborted."
exit 1
fi
echo "Checking/updating known_hosts..."
need_khosts=0
if [ ! -r ~root/.ssh/known_hosts ];
then
need_khosts=1
else
chk1=`ssh-keygen -F 192.168.7.7 -f ~root/.ssh/known_hosts | wc -l`
if [ $? -ne 0 ];
then
echo "Failed to check known_hosts"
echo "Aborted."
exit 1
fi
if [ $chk1 -eq 0 ];
then
need_khosts=1
fi
fi
if [ $need_khosts -eq 1 ];
then
mkdir -p ~root/.ssh
cat khosts >>~root/.ssh/known_hosts
fi
echo "Copying A6 files..."
scp -i ssh-key a6_firmware.txt.00 PmA6Updater [email protected]:/tmp
if [ $? -ne 0 ];
then
echo "A6 files copy failed."
echo "Aborted."
exit 1
fi
echo "Copying bootloader files..."
scp -i ssh-key bootie-topaz305.bin emmc_appsboot.mbn [email protected]:/tmp
if [ $? -ne 0 ];
then
echo "bootloader files copy failed."
echo "Aborted."
exit 1
fi
echo ""
echo "Checking A6 firmware..."
ssh -i ssh-key [email protected] /tmp/PmA6Updater -x -d 0 /tmp/a6_firmware.txt.00
## if [ $? -ne 0 ];
## then
## echo "A6 firmware check failed."
## echo "Aborted."
## exit 1
## fi
echo ""
echo "Updating A6 firmware..."
ssh -i ssh-key [email protected] /tmp/PmA6Updater -f -d 0 /tmp/a6_firmware.txt.00
if [ $? -ne 0 ];
then
echo "A6 firmware update failed."
echo "Aborted."
exit 1
fi
echo ""
echo "Capturing DMESG..."
ssh -i ssh-key [email protected] dmesg
if [ $? -ne 0 ];
then
echo "dmesg capture failed"
echo "Aborted."
exit 1
fi
echo ""
echo "Updating bootloader emmc_appsboot..."
ssh -i ssh-key [email protected] dd if=/tmp/emmc_appsboot.mbn of=/dev/mmcblk0p7
if [ $? -ne 0 ];
then
echo "update bootloader emmc_appsboot failed."
echo "Aborted."
exit 1
fi
echo ""
echo "Updating bootloader bootie..."
ssh -i ssh-key [email protected] dd if=/tmp/bootie-topaz305.bin of=/dev/mmcblk0p8
if [ $? -ne 0 ];
then
echo "update bootloader bootie failed."
echo "Aborted."
exit 1
fi
echo ""
echo "Checking battery voltage/percent... "
bvolt=`ssh -i ssh-key [email protected] cat /sys/devices/i2c-3/3-0031/getvoltage`
if [ $? -ne 0 ];
then
echo "getvoltage failed"
echo "Aborted."
exit 1
fi
bperc=`ssh -i ssh-key [email protected] cat /sys/devices/i2c-3/3-0031/getpercent`
if [ $? -ne 0 ];
then
echo "getpercent failed"
echo "Aborted."
exit 1
fi
echo "Battery Voltage=${bvolt} Percent=${bperc}"
if [ $bperc -gt 5 ];
then
echo "Rebooting Touchpad ..."
ssh -i ssh-key [email protected] "(sleep 1;/sbin/reboot -f) &"
echo "ALL DONE."
exit 0
fi
if [ $bperc -gt 0 ];
then
echo "Rebooting Touchpad ..."
ssh -i ssh-key [email protected] "(sleep 1;/sbin/reboot -f) &"
echo "Connect touchpad to stock HP AC charger to allow to charge"
echo "ALL DONE."
exit 0
fi
echo ""
echo "Waiting 1 min before checking voltage/percent again (1/2) ..."
sleep 60
bvolt=`ssh -i ssh-key [email protected] cat /sys/devices/i2c-3/3-0031/getvoltage`
if [ $? -ne 0 ];
then
echo "getvoltage failed"
echo "Aborted."
exit 1
fi
bperc=`ssh -i ssh-key [email protected] cat /sys/devices/i2c-3/3-0031/getpercent`
if [ $? -ne 0 ];
then
echo "getpercent failed"
echo "Aborted."
exit 1
fi
echo "Battery Voltage=${bvolt} Percent=${bperc}"
echo ""
echo "Waiting 1 min before checking voltage/percent again (2/2) ..."
sleep 60
bvolt=`ssh -i ssh-key [email protected] cat /sys/devices/i2c-3/3-0031/getvoltage`
if [ $? -ne 0 ];
then
echo "getvoltage failed"
echo "Aborted."
exit 1
fi
bperc=`ssh -i ssh-key [email protected] cat /sys/devices/i2c-3/3-0031/getpercent`
if [ $? -ne 0 ];
then
echo "getpercent failed"
echo "Aborted."
exit 1
fi
echo "Battery Voltage=${bvolt} Percent=${bperc}"
echo "Rebooting Touchpad ..."
ssh -i ssh-key [email protected] "(sleep 1;/sbin/reboot -f) &"
echo "Connect Touchpad to stock HP AC charger now"
echo "and allow it to charge for several hours"
echo "ALL DONE."
not working, im running 12.10 and the only way it works is if I gedit tpdebrick 12.10... but how should i type it? sudo gedit tpdebrick 12.10 ./tpdebrick 32 ???
Click to expand...
Click to collapse
booted into ubuntu 12.04 cd, script worked, home button lit up, now on charger, will post results tomorrow.... im happy again (i think):laugh:
It's aliiiivvvveeeee!!!!!!
miroxlava said:
booted into ubuntu 12.04 cd, script worked, home button lit up, now on charger, will post results tomorrow.... im happy again (i think):laugh:
Click to expand...
Click to collapse
i couldnt get it to work with ubuntu 12.10 usb, but with one try on 12.04 CD.... my TP was up and running this morning, I felt like a kid on Xmas!!!
ThanX JC!!!!!!:good:
britoso said:
You are plugged in to a usb port and holding the 3 buttons for 20+ seconds right? Maybe you can leave it on the charger for a day first.
The one I fixed was dead for almost a year. the script failed to read the battery level.
Click to expand...
Click to collapse
Question: Where does the script read the battery level?
hi-phile said:
Question: Where does the script read the battery level?
Click to expand...
Click to collapse
will have to check the script for that.

[Q] boot.img

how to assemble and disassemble boot.img on this phone?
Stock jb 4.1 uses kernel.bin.md5, cm uses boot.img
I tried many times but never managed (there's a script somewhere in this section but didn't work either for me)
Why do you want to unpack it?
Sent from Italy using Tapatalk
Toni5830 said:
Stock jb 4.1 uses kernel.bin.md5, cm uses boot.img
I tried many times but never managed (there's a script somewhere in this section but didn't work either for me)
Why do you want to unpack it?
Sent from Italy using Tapatalk
Click to expand...
Click to collapse
I want to insert a file init.rc service service
Code:
shelld /system/xbin/shelld
class main
I fear you need to compile kernel from sources..(I can compile stock kernel but don't know how to compile cm one )
Sent from Italy using Tapatalk
Toni5830 said:
I fear you need to compile kernel from sources..(I can compile stock kernel but don't know how to compile cm one )
Sent from Italy using Tapatalk
Click to expand...
Click to collapse
no I do not need to be collected from source
lolo696 said:
no I do not need to be collected from source
Click to expand...
Click to collapse
It depends how it is compiled. I think Frapeti told that some later versions will have possibiliti to be decompiled. I am not into kernels, not sure how and does this version now can be decompiled. And boot.img is only on CM - on stock we have kernel.bin.md5.
Actually kernel.bin.md5 is the zImage renamed with an md5 checksum. There is boot.img in stock too. Boot.img usually contains the zImage and the ramdisk. But in our device the ramdisk is packed in the zImage, this makes the boot.img un-unpackable. So kernel.bin.md5 (the zImage) can be renamed to boot.img because it's the same. I hope you understood this. I tried to explain in the simplest way
and you can follow any responses to add service init.rc ?
Sent from my GT-I9070 using xda app-developers app
Look at post #5, there's an attached file to unpack kernel, but never worked for me..some say it works
http://forum.xda-developers.com/showthread.php?t=2115337
Sent from Italy using Tapatalk
But in our device the ramdisk is packed in the zImage, this makes the boot.img un-unpackable.
Click to expand...
Click to collapse
Read this from KINGbabasula post.
I'm quite sure I can read -.-
Quoting Cocafe:
#!/bin/bash
# This is an update version of the script found at
# http://forum.xda-developers.com/wiki/index.php?title=Extract_initramfs_from_zImage
#
# The problem with that script is that the gzip magic number occasionally occur
# naturally, meaning that some non-compressed files get uncompressed.
DEBUG=
TEMP_DIR=/tmp
KERNEL_FILE=kernel
KERNEL_GZIP_FILE=kernel.gz
INITRAMFS_FILE=initramfs.cpio
INITRAMFS_DIR=initramfs_root
# DO NOT MODIFY BELOW THIS LINE
[ -z $1 ] && exit 1 || zImage=$1
[ ! -e $1 ] && exit 1
#GET CURRENT DIR
CURRENT_DIR=`pwd`
function pre_clean()
{
[ -z $DEBUG ] || echo "-D- Function: pre_clean()"
[ -e $INITRAMFS_FILE ] && ( [ -z $DEBUG ] || echo "-D- Deleting $INITRAMFS_FILE"; rm -f $INITRAMFS_FILE )
[ -e $INITRAMFS_DIR ] && ( [ -z $DEBUG ] || echo "-D- Deleting $INITRAMFS_DIR"; rm -rf $INITRAMFS_DIR )
[ -z $DEBUG ] || echo
}
function ungzip_kernel()
{
#========================================================
# find start of gziped kernel object in the zImage file:
#========================================================
[ -z $DEBUG ] || echo "-D- Function: ungzip_kernel()"
pos=`grep -P -a -b -m 1 --only-matching '\x1F\x8B\x08' $zImage | cut -f 1 -d :`
echo "-I- Extracting gzip'd kernel image from file: $zImage (start = $pos)"
if [ ! -z $pos ]; then
dd if=$zImage of=$TEMP_DIR/$KERNEL_GZIP_FILE bs=1 skip=$pos 2>/dev/null >/dev/null
gunzip -qf $TEMP_DIR/$KERNEL_GZIP_FILE
else
echo "-E- Compressed kernel image not found"; exit 1
fi
[ -z $DEBUG ] || echo
}
function search_cpio()
{
#========================================================
# Determine cpio compression type:
#========================================================
[ -z $DEBUG ] || echo "-D- Function: search_cpio()"
for x in gzip bzip lzma none; do
case $x in
bzip)
csig='\x{31}\x{41}\x{59}\x{26}\x{53}\x{59}'
ucmd='bunzip2 -q'
fext='.bz2'
;;
gzip)
csig='\x1F\x8B\x08'
ucmd='gunzip -q'
fext='.gz'
;;
lzma)
csig='\x{5D}\x{00}\x..\x{FF}\x{FF}\x{FF}\x{FF}\x{FF}\x{FF}'
ucmd='unlzma -q'
fext='.lzma'
;;
none)
csig='070701'
ucmd=
fext=
;;
esac
#========================================================================
# Search for compressed cpio archive
#========================================================================
search=`grep -P -a -b -m 1 --only-matching $csig $TEMP_DIR/$KERNEL_FILE | cut -f 1 -d : | head -1`
pos=${search:-0}
if [ ${pos} -gt 0 ]; then
if [ ${pos} -le ${cpio_compressed_start:-0} ] || [ -z $cpio_compressed_start ];then
cpio_compressed_start=$pos
compression_name=$x
compression_signature=$csig
uncompress_cmd=$ucmd
file_ext=$fext
[ -z $DEBUG ] || echo "-D- Checking for compression type: $compression_name | signature: $compression_signature | in file: $TEMP_DIR/$KERNEL_FILE | offset = $pos"
fi
fi
done
[ $compression_name = "bzip" ] && cpio_compressed_start=$((cpio_compressed_start - 4))
echo "-I- CPIO compression type detected = $compression_name | offset = $cpio_compressed_start"
[ -z $DEBUG ] || echo
}
function extract_cpio()
{
[ -z $DEBUG ] || echo "-D- Function: extract_cpio()"
if [ ! $compression_name = "none" ]; then
echo "-I- Extracting $compression_name'd compressed CPIO image from kernel image (offset = $cpio_compressed_start)"
[ -z $DEBUG ] || echo "-D- dd if=$TEMP_DIR/$KERNEL_FILE of=$TEMP_DIR/$INITRAMFS_FILE$file_ext bs=1 skip=$cpio_compressed_start; $uncompress_cmd $TEMP_DIR/$INITRAMFS_FILE$file_ext"
dd if=$TEMP_DIR/$KERNEL_FILE of=$TEMP_DIR/$INITRAMFS_FILE$file_ext bs=1 skip=$cpio_compressed_start 2>/dev/null >/dev/null
$uncompress_cmd -q $TEMP_DIR/$INITRAMFS_FILE$file_ext
else
echo "-I- Extracting non-compressed CPIO image from kernel image (offset = $cpio_compressed_start)"
[ -z $DEBUG ] || echo "-D- dd if=$TEMP_DIR/$KERNEL_FILE of=$TEMP_DIR/${INITRAMFS_FILE}${file_ext} bs=1 skip=$cpio_compressed_start 2>/dev/null >/dev/null"
dd if=$TEMP_DIR/$KERNEL_FILE of=$TEMP_DIR/${INITRAMFS_FILE}${file_ext} bs=1 skip=$cpio_compressed_start 2>/dev/null >/dev/null
fi
[ -z $DEBUG ] || echo
}
function uncompress_cpio()
{
#==========================================================================
# find start and end of the "cpio" initramfs image inside the kernel object:
# ASCII cpio header starts with '070701'
# The end of the cpio archive is marked with an empty file named TRAILER!!!
#==========================================================================
[ -z $DEBUG ] || echo "-D- Function: uncompress_cpio()"
if [ ! $compress_type = "none" ]; then
start=`grep -a -b -m 1 --only-matching '070701' $TEMP_DIR/$INITRAMFS_FILE | head -1 | cut -f 1 -d :`
end=`grep -a -b -m 1 --only-matching 'TRAILER!!!' $TEMP_DIR/$INITRAMFS_FILE | head -1 | cut -f 1 -d :`
if [ ! -z $start ] || [ ! -z $end ]; then
#11 bytes = length of TRAILER!!! zero terminated string, fixes premature end of file warning in CPIO
end=$((end + 14))
[ -z $DEBUG ] || echo "-D- Kernel start = $start"
[ -z $DEBUG ] || echo "-D- Kernel end = $end"
count=$((end - start))
if (($count < 0)); then
echo "-E- Couldn't match start/end of the initramfs image."
exit 1
fi
echo "-I- Extracting initramfs image from file: $inputfile (start = $start, end = $end)"
dd if=$TEMP_DIR/$INITRAMFS_FILE of=$CURRENT_DIR/$INITRAMFS_FILE bs=1 skip=$start count=$count 2>/dev/null >/dev/null
INITRAMFS_FILE=$CURRENT_DIR/$INITRAMFS_FILE
else
echo "-E- No CPIO image found in $inputfile."
fi
else
echo "-I- CPIO already uncompressed."
fi
[ -z $DEBUG ] || echo
}
function expand_cpio_archive()
{
[ -z $DEBUG ] || echo "-D- Function: expand_cpio_archive()"
echo "-I- Expanding CPIO archive: $INITRAMFS_FILE to $INITRAMFS_DIR."
if [ -e $TEMP_DIR/$INITRAMFS_FILE ]; then
mkdir $INITRAMFS_DIR
cd $INITRAMFS_DIR
cpio --quiet -i --make-directories --preserve-modification-time --no-absolute-filenames -F $TEMP_DIR/$INITRAMFS_FILE 2>/dev/null
fi
[ -z $DEBUG ] || echo
}
function clean_up()
{
[ -z $DEBUG ] || echo "-D- Deleting $TEMP_DIR/$KERNEL_FILE"; rm -f $TEMP_DIR/$KERNEL_FILE
[ -z $DEBUG ] || echo "-D- Deleting $TEMP_DIR/$INITRAMFS_FILE"; rm -f $TEMP_DIR/$INITRAMFS_FILE
[ -z $DEBUG ] || echo "-D- Deleting $TEMP_DIR/$INITRAMFS_FILE$file_ext"; rm -f $TEMP_DIR/$INITRAMFS_FILE$file_ext
}
reset
pre_clean
ungzip_kernel
search_cpio
extract_cpio
uncompress_cpio
expand_cpio_archive
clean_up
Click to expand...
Click to collapse
Save this QUOTE as a file name unpack_initramfs.sh
Use:
./unpack_initramfs.sh kernel.bin.md5
Click to expand...
Click to collapse
-I- Extracting gzip'd kernel image from file: kernel.bin.md5 (start = 18528)
-I- CPIO compression type detected = none | offset = 219120
-I- Extracting non-compressed CPIO image from kernel image (offset = 219120)
-I- CPIO already uncompressed.
-I- Expanding CPIO archive: initramfs.cpio to initramfs_root.
Click to expand...
Click to collapse
Then you should have stock ramdisk
Click to expand...
Click to collapse
Worked for Cocafe but never worked for me:/ maybe because Cocore-e's compression is now set to lzo
Last 2 things then I'll leave:
1) Frapeti said next cm kernel will be possible to unpack (check dual boot thread)
2) I don't know how to repack it
Sent from Italy using Tapatalk
Toni5830 said:
I'm quite sure I can read -.-
Quoting Cocafe:
Worked for Cocafe but never worked for me:/ maybe because Cocore-e's compression is now set to lzo
Last 2 things then I'll leave:
1) Frapeti said next cm kernel will be possible to unpack (check dual boot thread)
2) I don't know how to repack it
Sent from Italy using Tapatalk
Click to expand...
Click to collapse
I never saw before that script
Here you can find how to unpack and repack a "normal" boot.img with tools for cygwin too https://github.com/KINGbabasula/boot.img-tools

Xposed's latest version is not active

Hello I'm on oxygenOS 2.1.1 (one plus 2) with a custom kernel and today I woke up and noticed Xposed wasn't active.. I didn't change any setting from the setup I had with Xposed working, and even after rebooting; reflashing rom+Xposed; flashing the Uninstaller and then reflashing Xposed would not make it work again.
Xposed reports "Xposed's latest version is not active. Have you installed the framework and rebooted? "
Here's a screenshot
{
"lightbox_close": "Close",
"lightbox_next": "Next",
"lightbox_previous": "Previous",
"lightbox_error": "The requested content cannot be loaded. Please try again later.",
"lightbox_start_slideshow": "Start slideshow",
"lightbox_stop_slideshow": "Stop slideshow",
"lightbox_full_screen": "Full screen",
"lightbox_thumbnails": "Thumbnails",
"lightbox_download": "Download",
"lightbox_share": "Share",
"lightbox_zoom": "Zoom",
"lightbox_new_window": "New window",
"lightbox_toggle_sidebar": "Toggle sidebar"
}
Next time I'll better do a search. Installing busybox from playstore solved the problem
kal eh said:
Next time I'll better do a search. Installing busybox from playstore solved the problem
Click to expand...
Click to collapse
Thanks for coming back and posting the solution, even though it does not pertain to me
banderos101 said:
Thanks for coming back and posting the solution, even though it does not pertain to me
Click to expand...
Click to collapse
Have you tried a /system and both cache wipe? Then install rom (supersu) gapps xposed??
edit: lol misundersoo d
Hello!
I have the same problem:
I installed the framework manually (ASUS MemoPad 7 (ME572CL) has currently no means to unlock the bootloader, so there is no custom recovery). Also I installed the Xposed Installer alpha 4 apk.
Then I restarted the MemoPad 7, but the Xposed Installer app told me the the latest version (v75) is installed but not active. So I installed Busybox as mentioned and restarted. But there is no change and Xposed framework remains inactive.
Any idea what's going wrong here?
klausstoertebeker said:
Hello!
I have the same problem:
I installed the framework manually (ASUS MemoPad 7 (ME572CL) has currently no means to unlock the bootloader, so there is no custom recovery). Also I installed the Xposed Installer alpha 4 apk.
Then I restarted the MemoPad 7, but the Xposed Installer app told me the the latest version (v75) is installed but not active. So I installed Busybox as mentioned and restarted. But there is no change and Xposed framework remains inactive.
Any idea what's going wrong here?
Click to expand...
Click to collapse
Without a custom recovery, you won't be able to install the Xposed framework properly. A custom recovery is mandatory.
So you want to tell me that everybody who cannot unlock the bootloader of his/her device won't be able to use Xposed framework? I don't believe that because there are posts concerning successful installations on those devices. So there must be a way...
kal eh said:
Have you tried a /system and both cache wipe? Then install rom (supersu) gapps xposed??
Click to expand...
Click to collapse
Sorry, probably should have phrased that better............i dont have this problem, i was just commenting that its nice to see someone post the solution to their issue instead of not, if/when they find it, as it might end up helping someone else down the line someday
Hello again!
I was able to install Xposed framework on my ASUS MemoPad 7 (ME572CL) without unlocked bootloader and therefore without custom recovery.
And for everybody interested in I'll tell in the following how I made it
Prerequisites:
- a rooted device
- a terminal emulator able to run in root mode (I used that from ROM Toolbox Pro)
- the xposed ZIP file compatible with your devices architecture and Android version (can be downloades here)
Now find out the architecture of your device. For this you have to open the file "/system/build.prop" and search for one of these strings:
"ro.product.cpu.abilist32" or
"ro.product.cpu.abilist64"
One of these entries is NOT empty and contains data describing the architecture (in my case it was the first entry which wasn't empty and looked like:
"ro.product.cpu.abilist32=x86,armeabi-v7a,armeabi" - so I have a 32 Bit X86-architecture)
Next find out the sdk version which was used for building your Android system. Again search the file "/system/build.prop", but this time for the string:
"ro.build.version.sdk" (in my case it looked like: "ro.build.version.sdk=21" - so they have used sdk version 21 to build my Android system)
Now you know which file to download (for me it was xposed-v75-sdk21-x86.zip)
After download unzip the file to where you want Now open the terminal emulator, apply the "SU"-command and change to the directory "META-INF" found in the unzipped xposed folder. Then apply the command "touch flash-script.sh" to generate an alternatve install script. Open this file with a text editor and fill in the following code:
Code:
##########################################################################################
#
# Xposed framework installer zip.
#
# This script installs the Xposed framework files to the system partition.
# The Xposed Installer app is needed as well to manage the installed modules.
#
##########################################################################################
cp_perm() {
cp -f $1 $2 || exit 1
set_perm $2 $3 $4 $5 $6
}
set_perm() {
chown $2:$3 $1 || exit 1
chmod $4 $1 || exit 1
if [ "$5" ]; then
chcon $5 $1 2>/dev/null
else
chcon 'u:object_r:system_file:s0' $1 2>/dev/null
fi
}
install_nobackup() {
cp_perm ..$1 $1 $2 $3 $4 $5
}
install_and_link() {
TARGET=$1
XPOSED="${1}_xposed"
BACKUP="${1}_original"
if [ ! -f ..$XPOSED ]; then
return
fi
cp_perm ..$XPOSED $XPOSED $2 $3 $4 $5
if [ ! -f $BACKUP ]; then
mv $TARGET $BACKUP || exit 1
ln -s $XPOSED $TARGET || exit 1
chcon -h 'u:object_r:system_file:s0' $TARGET 2>/dev/null
fi
}
install_overwrite() {
TARGET=$1
if [ ! -f ..$TARGET ]; then
return
fi
BACKUP="${1}.orig"
NO_ORIG="${1}.no_orig"
if [ ! -f $TARGET ]; then
touch $NO_ORIG || exit 1
set_perm $NO_ORIG 0 0 600
elif [ -f $BACKUP ]; then
rm -f $TARGET
gzip $BACKUP || exit 1
set_perm "${BACKUP}.gz" 0 0 600
elif [ ! -f "${BACKUP}.gz" -a ! -f $NO_ORIG ]; then
mv $TARGET $BACKUP || exit 1
gzip $BACKUP || exit 1
set_perm "${BACKUP}.gz" 0 0 600
fi
cp_perm ..$TARGET $TARGET $2 $3 $4 $5
}
##########################################################################################
echo "******************************"
echo "Xposed framework installer zip"
echo "******************************"
echo "- Mounting /system and /vendor read-write"
mount /system >/dev/null 2>&1
mount /vendor >/dev/null 2>&1
mount -o remount,rw /system
mount -o remount,rw /vendor >/dev/null 2>&1
if [ ! -f '/system/build.prop' ]; then
echo "! Failed: /system could not be mounted!"
exit 1
fi
echo "- Placing files"
install_nobackup /system/xposed.prop 0 0 0644
install_nobackup /system/framework/XposedBridge.jar 0 0 0644
install_and_link /system/bin/app_process32 0 2000 0755 u:object_r:zygote_exec:s0
install_overwrite /system/bin/dex2oat 0 2000 0755 u:object_r:dex2oat_exec:s0
install_overwrite /system/bin/oatdump 0 2000 0755
install_overwrite /system/bin/patchoat 0 2000 0755 u:object_r:dex2oat_exec:s0
install_overwrite /system/lib/libart.so 0 0 0644
install_overwrite /system/lib/libart-compiler.so 0 0 0644
install_overwrite /system/lib/libart-disassembler.so 0 0 0644
install_overwrite /system/lib/libsigchain.so 0 0 0644
install_overwrite /system/lib/libxposed_art.so 0 0 0644
echo "- Done"
exit 0
PLEASE BE AWARE THAT THIS SCRIPT ONLY WORKS WITH 32 BIT VERSIONS. FOR 64 BIT VERSIONS IT HAS TO BE ADOPTED! BECAUSE I DON'T HAVE A 64 BIT SYSTEM I WASN'T ABLE TO DO THIS!
After saving the changes run this script by applying the command "sh flash-script.sh". This should install the framework as intended by rovo89. I got some linker error messages (something like not found) concerning "libsigchain.so" - I ignored them, but it worked.
And don't forget to install the "XposedInstaller_3.0_alpha4.apk"
klausstoertebeker said:
Hello again!
I was able to install Xposed framework on my ASUS MemoPad 7 (ME572CL) without unlocked bootloader and therefore without custom recovery.
And for everybody interested in I'll tell in the following how I made it
Prerequisites:
- a rooted device
- a terminal emulator able to run in root mode (I used that from ROM Toolbox Pro)
- the xposed ZIP file compatible with your devices architecture and Android version (can be downloades here)
Now find out the architecture of your device. For this you have to open the file "/system/build.prop" and search for one of these strings:
"ro.product.cpu.abilist32" or
"ro.product.cpu.abilist64"
One of these entries is NOT empty and contains data describing the architecture (in my case it was the first entry which wasn't empty and looked like:
"ro.product.cpu.abilist32=x86,armeabi-v7a,armeabi" - so I have a 32 Bit X86-architecture)
Next find out the sdk version which was used for building your Android system. Again search the file "/system/build.prop", but this time for the string:
"ro.build.version.sdk" (in my case it looked like: "ro.build.version.sdk=21" - so they have used sdk version 21 to build my Android system)
Now you know which file to download (for me it was xposed-v75-sdk21-x86.zip)
After download unzip the file to where you want Now open the terminal emulator, apply the "SU"-command and change to the directory "META-INF" found in the unzipped xposed folder. Then apply the command "touch flash-script.sh" to generate an alternatve install script. Open this file with a text editor and fill in the following code:
Code:
##########################################################################################
#
# Xposed framework installer zip.
#
# This script installs the Xposed framework files to the system partition.
# The Xposed Installer app is needed as well to manage the installed modules.
#
##########################################################################################
cp_perm() {
cp -f $1 $2 || exit 1
set_perm $2 $3 $4 $5 $6
}
set_perm() {
chown $2:$3 $1 || exit 1
chmod $4 $1 || exit 1
if [ "$5" ]; then
chcon $5 $1 2>/dev/null
else
chcon 'u:object_r:system_file:s0' $1 2>/dev/null
fi
}
install_nobackup() {
cp_perm ..$1 $1 $2 $3 $4 $5
}
install_and_link() {
TARGET=$1
XPOSED="${1}_xposed"
BACKUP="${1}_original"
if [ ! -f ..$XPOSED ]; then
return
fi
cp_perm ..$XPOSED $XPOSED $2 $3 $4 $5
if [ ! -f $BACKUP ]; then
mv $TARGET $BACKUP || exit 1
ln -s $XPOSED $TARGET || exit 1
chcon -h 'u:object_r:system_file:s0' $TARGET 2>/dev/null
fi
}
install_overwrite() {
TARGET=$1
if [ ! -f ..$TARGET ]; then
return
fi
BACKUP="${1}.orig"
NO_ORIG="${1}.no_orig"
if [ ! -f $TARGET ]; then
touch $NO_ORIG || exit 1
set_perm $NO_ORIG 0 0 600
elif [ -f $BACKUP ]; then
rm -f $TARGET
gzip $BACKUP || exit 1
set_perm "${BACKUP}.gz" 0 0 600
elif [ ! -f "${BACKUP}.gz" -a ! -f $NO_ORIG ]; then
mv $TARGET $BACKUP || exit 1
gzip $BACKUP || exit 1
set_perm "${BACKUP}.gz" 0 0 600
fi
cp_perm ..$TARGET $TARGET $2 $3 $4 $5
}
##########################################################################################
echo "******************************"
echo "Xposed framework installer zip"
echo "******************************"
echo "- Mounting /system and /vendor read-write"
mount /system >/dev/null 2>&1
mount /vendor >/dev/null 2>&1
mount -o remount,rw /system
mount -o remount,rw /vendor >/dev/null 2>&1
if [ ! -f '/system/build.prop' ]; then
echo "! Failed: /system could not be mounted!"
exit 1
fi
echo "- Placing files"
install_nobackup /system/xposed.prop 0 0 0644
install_nobackup /system/framework/XposedBridge.jar 0 0 0644
install_and_link /system/bin/app_process32 0 2000 0755 u:object_r:zygote_exec:s0
install_overwrite /system/bin/dex2oat 0 2000 0755 u:object_r:dex2oat_exec:s0
install_overwrite /system/bin/oatdump 0 2000 0755
install_overwrite /system/bin/patchoat 0 2000 0755 u:object_r:dex2oat_exec:s0
install_overwrite /system/lib/libart.so 0 0 0644
install_overwrite /system/lib/libart-compiler.so 0 0 0644
install_overwrite /system/lib/libart-disassembler.so 0 0 0644
install_overwrite /system/lib/libsigchain.so 0 0 0644
install_overwrite /system/lib/libxposed_art.so 0 0 0644
echo "- Done"
exit 0
PLEASE BE AWARE THAT THIS SCRIPT ONLY WORKS WITH 32 BIT VERSIONS. FOR 64 BIT VERSIONS IT HAS TO BE ADOPTED! BECAUSE I DON'T HAVE A 64 BIT SYSTEM I WASN'T ABLE TO DO THIS!
After saving the changes run this script by applying the command "sh flash-script.sh". This should install the framework as intended by rovo89. I got some linker error messages (something like not found) concerning "libsigchain.so" - I ignored them, but it worked.
And don't forget to install the "XposedInstaller_3.0_alpha4.apk"
Click to expand...
Click to collapse
It seems I have to withdraw my statement about the mandatory custom recovery. You should open a separate thread for this guide in the Xposed sub-forum or at least ask the moderator of the unofficial Xposed for Lollipop FAQ (danarama) to include it in his FAQ. This is really helpful for people running a device for which a custom recovery is not available.
Use light theme and flash framework again.
Sent from my GT-I9505 using Tapatalk
klausstoertebeker said:
So you want to tell me that everybody who cannot unlock the bootloader of his/her device won't be able to use Xposed framework? I don't believe that because there are posts concerning successful installations on those devices. So there must be a way...
Click to expand...
Click to collapse
There is an all in one root tool that can unlock bootloaders for you or you can use ADB to do the work for you.

[Marshmallow] Xposed addon.d script

Can somebody please provide a script to keep xposed between rom updates?
Thanks in advance
From xposed installer the only thing I see different is the install_and_link /system/bin/app_process32 0 2000 0755 ubject_r:zygote_exec:s0
Script I'm using:
Code:
#!/sbin/sh
#
# Backkup xposed after a dirty flash
# Script by /r/FG3
#
. /tmp/backuptool.functions
list_files() {
cat <<EOF
bin/app_process32_xposed
bin/dex2oat
bin/oatdump
bin/patchoat
framework/XposedBridge.jar
lib/libart-compiler.so
lib/libart-disassembler.so
lib/libart.so
lib/libsigchain.so
lib/libxposed_art.so
xposed.prop
EOF
}
case "$1" in
backup)
list_files | while read FILE DUMMY; do
backup_file $S/"$FILE"
done
;;
restore)
list_files | while read FILE REPLACEMENT; do
R=""
[ -n "$REPLACEMENT" ] && R="$S/$REPLACEMENT"
[ -f "$C/$S/$FILE" ] && restore_file $S/"$FILE" "$R"
done
;;
pre-backup)
# Stub
;;
post-backup)
# Stub
;;
pre-restore)
# Stub
;;
post-restore)
;;
esac

/system/su.d

Hello. I found same questions in other topics, but couldn't find answer.
I would like run script from /system/su.d folder:
Code:
#!/system/bin/sh
echo 0 > /sys/fs/selinux/enforce
or
Code:
#!/system/bin/sh
setenforce 0
and I even tried to run test script:
Code:
#!/system/bin/sh
touch /data/local/tmp/test.txt
echo "test" >> /data/local/tmp/test.txt
But no one of them works. I tried different names for files, gave different chmod (644,700,755). Nothing helps me to run script.
Mb somebody can give me advice what's problem can be?
Phone: Xperia Z3c, MM, systemless SuperSU
On other phone (Xperia M5) this all works fine.
I have a the same problem with a different file in /system/su.d,
Code:
#!/system/bin/sh
logfile0=/data/local/tmp/exfat_mount.log
#logfile=$logfile0
logfile=/dev/null
if [ -e $logfile0 ]; then
logfile=$logfile0
fi
echo '******' $(date) '******' >> $logfile
echo 'id: ' $(id) >> $logfile 2>&1
if [ x$SECONDARY_STORAGE == x ]; then
SECONDARY_STORAGE=/storage/sdcard1
fi
device=/dev/block/mmcblk1p1
echo "Starting for $device" >> $logfile
while read line; do
words=($line)
if [ ${words[0]} == $device ]; then
echo "Error: $device already mounted:" >> $logfile
echo "$line" >> $logfile
exit 1
fi
if [ ${words[1]} == $SECONDARY_STORAGE ]; then
echo "Error: SECONDARY_STORAGE already in use:" >> $logfile
echo "$line" >> $logfile
exit 1
fi
done < /proc/mounts
binpath=/system/xbin
probe=$binpath/probe
if [ ! -e $probe ]; then
echo "Error: $probe not found!" >> $logfile
exit 1
fi
FS=($($probe $device))
echo "$device file system:" ${FS[0]} >> $logfile
# ***** Setup tools for different file systems:
if [ ${FS[0]} == "exFAT" ]; then
echo "$device is exFAT" >> $logfile
mount=$binpath/mount.exfat
if [ -f $mount ]; then
links=( "mkfs.exfat" "fsck.exfat" "dumpexfat" "exfatfsck" "exfatlabel" "mkexfatfs" "mount.exfat-fuse" )
for l in "${links[@]}"
do
if [ ! -e $binpath/$l ]; then
mount -o remount,rw /
ln -s $mount $binpath/$l
echo "Created symlink $binpath/$l" >> $logfile
fi
done
fi
fsck=$binpath/exfatfsck
fsck_ops=
elif [ ${FS[0]} == "NTFS" ]; then
echo "$device is NTFS" >> $logfile
mount=$binpath/ntfs-3g
fsck=$binpath/ntfsfix
fsck_ops='-n'
else
echo "Error: $device is not supported!" >> $logfile
exit 1
fi
# ***** Check if we have required tools.
if [ ! -e $mount ]; then
echo "Error: $mount not found!" >> $logfile
exit 1
fi
if [ ! -e $fsck ]; then
echo "Error: $fsck not found!" >> $logfile
exit 1
fi
# ***** Mount for rw only if the file system is not damaged.
options_ro="ro,uid=1023,gid=1023,umask=0000"
options_rw="rw,uid=1023,gid=1023,umask=0000,noatime"
mnt_cmd="$mount -o $options_rw $device /mnt/media_rw/sdcard1"
$fsck $fsck_ops $device >> $logfile 2>&1
if [ $? != 0 ]; then
mnt_cmd="$mount -o $options_ro $device /mnt/media_rw/sdcard1"
fi
echo "$mnt_cmd" >> $logfile
if [ -e /sys/fs/selinux/enforce ]; then
if [ -e /system/xbin/supolicy ]; then
# ***** Set permissions for fuse. Instead, our mounts would be RO for others.
echo "Using supolicy to provide permissions to fuse." >> $logfile
/system/xbin/supolicy --live "allow sdcardd unlabeled dir { append create execute write relabelfrom link unlink ioctl getattr setattr read rename lock mounton quotaon swapon rmdir audit_access remove_name add_name reparent execmod search open }"
/system/xbin/supolicy --live "allow sdcardd unlabeled file { append create write relabelfrom link unlink ioctl getattr setattr read rename lock mounton quotaon swapon audit_access open }"
/system/xbin/supolicy --live "allow unlabeled unlabeled filesystem associate"
/system/xbin/supolicy --live "allow sdcardd unlabeled filesystem { getattr mount remount unmount }"
/system/xbin/supolicy --live "allow vold unlabeled filesystem { getattr mount remount unmount }"
/system/xbin/supolicy --live "allow init unlabeled filesystem { getattr mount remount unmount }"
else
# ***** Turn SELinux to Permissive. Instead, our mounts would be RO for others.
echo "Using setenforce 0 to provide permissions to fuse." >> $logfile
setenforce 0
fi
fi
# ***** Try to mount:
if [ 0 != 0 ]; then
$mount -o $options_rw $device $SECONDARY_STORAGE
echo "Mounted directly" >> $logfile
else
mount -o remount,rw /system
rm -f /system/bin/debuggerd.mine
echo '#!/system/bin/sh' > /system/bin/debuggerd.mine
echo "$mnt_cmd" >> /system/bin/debuggerd.mine
echo 'start fuse_sdcard1' >> /system/bin/debuggerd.mine
chmod 777 /system/bin/debuggerd.mine
stop debuggerd
mv /system/bin/debuggerd /system/bin/debuggerd.its
mv /system/bin/debuggerd.mine /system/bin/debuggerd
start debuggerd
sleep 2
stop debuggerd
mv /system/bin/debuggerd /system/bin/debuggerd.mine
mv /system/bin/debuggerd.its /system/bin/debuggerd
start debuggerd
mount -o remount,ro /system
vdc volume mount $SECONDARY_STORAGE
echo "Mounted via debuggerd" >> $logfile
fi
The file is called 00mountsd and is used to give access to exfat microsd on stock android 5.1 running on a Chuwi Hi10pro tablet with cherry trail z8350 cpu. I used this on a previous version of the tablet and it worked fine although that tablet came with RemixOS.
The file runs without errors when run manually and succeeds at it task
ls -lZ returns this -rwxr-xr-x root root u: object_r:system_file:s0 00mountsd
I'm running SuperSU Free v2.79 everything else works fine.
Any ideas?

Categories

Resources