[INFO][DEV] Wildfire S (marvel) partition information/recovery commands - HTC Wildfire S

Hello all,
Upon porting sense 4 I needed to mount a certain partition via a command that needed the exact dev block, so I decided to find out using adb and post my results here for other devs to see:
Filesystem........................Size......Used........Available......Use%........Mounted on
tmpfs...........................209.0M......48.0K.........209.0M...........0%................/dev
/dev/block/mmcblk0p1....861.1M....739.5M.........121.6M.........86%............/sdcard <-- May vary
/dev/block/mtdblock4.......35.0M.......1.3M...........33.7M...........4%............./cache
/dev/block/mmcblk0p2..1003.6M....330.8M..........672.8M.........33%............/sd-ext <-- May vary
/dev/block/mtdblock3.....269.4M....165.0M..........104.4M.........61%.........../system
/dev/block/mtdblock5.....150.0M.......1.5M..........148.5M...........1%............../data
I hope somebody finds this helpful. I was going to post this is general, but since it is not a question and is directed for developers like myself (and this is where I would look for this info TBH) I posted it here.
Okay guys, have fun

Here is a list of commands you can use in recovery/installation scripts.
[ flash_lock mesg setserial
[[ flash_unlock mkdir setsid
adbd flashcp mkdosfs sh
adjtimex flock mke2fs sha1sum
arp fold mkfifo sha256sum
ash free mkfs.ext2 sha512sum
awk freeramdisk mkfs.vfat sleep
base64 fs mknod sort
basename fsync mkswap split
bbconfig ftpget mktemp stat
bbinstall.sh ftpput modinfo strings
blkid fuser modprobe stty
blockdev getopt more sum
brctl grep mount swapoff
bunzip2 groups mountpoint swapon
busybox gunzip mpstat sync
bzcat gzip mv sysctl
bzip2 halt nanddump tac
cal head nandwrite tail
cat hexdump nbd-client tar
catv htcbatt nc taskset
chattr htcdumlock netstat teamwin
chgrp id nice tee
chmod ifconfig nohup telnet
choice_fn insmod nslookup telnetd
chown install ntpd test
chroot iostat od tftp
clear ip offmode_charging tftpd
cmp kill parted time
comm killall patch timeout
cp killall5 pgrep top
cpio less pidof touch
crond libbmlutils.so pigz tr
crontab libc.so ping traceroute
cut libcutils.so pipe_progress true
date libdl.so pkill ttysize
dc libext2_blkid.so pmap tune2fs
dd libext2_com_err.so power_test ueventd
depmod libext2_e2p.so poweroff umount
detect_key libext2_profile.so printenv uname
devmem libext2_uuid.so printf uncompress
df libext2fs.so ps unexpand
diff libflashutils.so pstree uniq
dirname liblog.so pwd unix2dos
dmesg libm.so pwdx unlzma
dnsd libmmcutils.so rdev unlzop
dos2unix libstdc++.so readlink unpigz
du libstlport.so realpath unxz
dump_image libz.so reboot unzip
e2fsck linker recovery uptime
echo ln renice usleep
ed losetup reset uudecode
egrep ls resize uuencode
env lsattr rev vi
erase_image lsmod rm watch
expand lsof rmdir wc
expr lsusb rmmod wget
false lzcat route which
fbsplash lzma run-parts whoami
fdisk lzop rx xargs
fgrep lzopcat sdparted xz
find man sed xzcat
fix_permissions.sh md5check.sh seq yes
flash_image md5sum setconsole zcat

Related

Updated: expand initramfs ramdisc from zImage kernel, supports gzip, lzma, bzip2 (?)

If you are interested in building your own kernels (from the Samsung-released open-source code, or any other source), you may need to extract initramfs ramdiscs from existing kernels.
There is a well-known script to achieve that goal, but it only supports uncompressed and gzip'ed kernels, and it doesn't unpack the CPIO archive for further inspection of the actual initramfs "source code" (the output trace is also not easy to debug when working with "weird" zImages). The original script is explained in the XDA wiki: http://forum.xda-developers.com/wiki/index.php?title=Extract_initramfs_from_zImage.
For my personal convenience, I tweaked the original bash script so I thought I'd share it with the XDA devs. I added support for lzma-compressed initramfs ramdiscs (thanks to koxudaxi for reminding me of the lzma "magic string"), please let me know if you know the "magic string" for bzip2 archives (EDIT: "0x314159265359" 6 bytes "start of block", 4 bytes header at the beginning...experimental untested support is now available in the script below).
Note that the latest Samfirmware ROMs include encrypted boot.bin and Sbl.bin bootloaders, but I'm not sure how the zImage kernels are encoded...so this script may not work.
Also note that zImage files patched with z4mod require further decoding work, see the XDA wiki page mentioned above for instructions.
Code:
#!/bin/bash
zImage=$1
read -rp "Enter any text to skip extraction (assumes /tmp/kernel2.img already exists): " input
if [ ${input}" " = " " ]; then
echo "==> deleting /tmp/kernel1.img"
rm /tmp/kernel1.img
echo "==> deleting /tmp/kernel2.img"
rm /tmp/kernel2.img
echo "==> searching for gzip header in $zImage"
skip=`grep -P -a -b -m 1 --only-matching $'\x1F\x8B\x08' $zImage | cut -f 1 -d :`
echo "==> found gzip header at $skip"
echo "==> unzipping $zImage to /tmp/kernel1.img"
dd if=$zImage bs=1 skip=$skip | gunzip > /tmp/kernel1.img
echo "==> searching for gzip header in /tmp/kernel1.img"
poszip=`grep -P -a -b -m 1 --only-matching $'\x1F\x8B\x08' /tmp/kernel1.img | cut -f 1 -d :`
if [ ! $poszip = "" ]; then
echo "==> gzip header at $poszip in /tmp/kernel1.img"
echo "==> extracting /tmp/kernel2.img from /tmp/kernel1.img using gunzip"
dd if=/tmp/kernel1.img bs=1 skip=$poszip | gunzip > /tmp/kernel2.img
else
echo "==> no gzip header in /tmp/kernel1.img"
echo "==> searching for lzma header in /tmp/kernel1.img"
poslzma=`grep -P -a -b -m 1 --only-matching '\x{5D}\x{00}\x..\x{FF}\x{FF}\x{FF}\x{FF}\x{FF}\x{FF}' /tmp/kernel1.img | cut -f 1 -d :`
if [ ! $poslzma = "" ]; then
echo "==> lzma header at $poslzma in /tmp/kernel1.img"
echo "==> extracting /tmp/kernel2.img from /tmp/kernel1.img using lzma"
dd if=/tmp/kernel1.img bs=1 skip=$poslzma | unlzma > /tmp/kernel2.img
else
echo "==> no lzma header in /tmp/kernel1.img"
echo "==> searching for bzip2 header in /tmp/kernel1.img"
posbzip2=`grep -P -a -b -m 1 --only-matching $'\x{42}\x{5A}\x{68}\x{39}\x{31}\x{41}\x{59}\x{26}\ x{53}\x{59}' /tmp/kernel1.img | cut -f 1 -d :`
if [ ! $posbzip2 = "" ]; then
echo "==> bzip2 header at $posbzip2 in /tmp/kernel1.img"
posbzip2=$((posbzip2 - 4))
echo "==> adjusted bzip2 header with -4 bytes offset: $posbzip2"
echo "==> extracting /tmp/kernel2.img from /tmp/kernel1.img using bzip2"
dd if=/tmp/kernel1.img bs=1 skip=$posbzip2 | bunzip2 > /tmp/kernel2.img
else
echo "==> no bzip2 header in /tmp/kernel1.img"
echo "==> assuming no compression for /tmp/kernel1.img, copying to /tmp/kernel2.img"
cp /tmp/kernel1.img /tmp/kernel2.img
fi
fi
fi
fi
# '070701' == $'\x30\x37\x30' == '\x{30}\x{37}\x{30}'
echo "==> searching for cpio header in /tmp/kernel2.img"
start=`grep -a -b -m 1 --only-matching '070701' /tmp/kernel2.img | head -1 | cut -f 1 -d :`
echo "==> cpio header at $start in /tmp/kernel2.img"
echo "==> searching for cpio footer in /tmp/kernel2.img"
end=`grep -a -b -m 1 --only-matching 'TRAILER!!!' /tmp/kernel2.img | head -1 | cut -f 1 -d :`
echo "==> cpio footer at $end in /tmp/kernel2.img"
# 14 bytes = length of "TRAILER!!!" (zero-terminated string) + padding => fixes premature end of file warning in CPIO
end=$((end + 14))
echo "==> adjusted cpio footer with 14 bytes offset: $end"
count=$((end - start))
echo "==> cpio size is $count bytes ($end - $start)"
if (($count < 0)); then
echo "==> error in cpio positions, aborting"
exit
fi
cpio_file="initramfs.cpio"
cpio_dir=`echo "${cpio_file}.expanded"`
cpio_ls=`echo "${cpio_file}.ls"`
echo "==> deleting ${zImage}_${cpio_file}"
rm ${zImage}_${cpio_file}
echo "==> deleting ${zImage}_${cpio_dir}"
rm -r ${zImage}_${cpio_dir}
echo "==> deleting ${zImage}_${cpio_ls}"
rm -r ${zImage}_${cpio_ls}
echo "==> extracting initramfs ramdisc from /tmp/kernel2.img to ${zImage}_${cpio_file}"
dd if=/tmp/kernel2.img bs=1 skip=$start count=$count > ${zImage}_${cpio_file}
echo "==> expanding ${zImage}_${cpio_file} into ${zImage}_${cpio_dir} directory"
mkdir ${zImage}_${cpio_dir}
curdir=`pwd`
(cd ${zImage}_${cpio_dir} && cpio --quiet -id --no-absolute-filenames < ${curdir}/${zImage}_${cpio_file})
echo "==> generating ls-like file list in ${zImage}_${cpio_ls}"
cpio --quiet -tvnF ${zImage}_${cpio_file} > ${zImage}_${cpio_ls}
echo "==> DONE."
- heads-up - nice rewrite/cleanup by Mistadman:
https://github.com/mistadman/Extract-Kernel-Initramfs/

[Q] Stagefright help

I'm running the latest CM7 nightly and I added all of the necessary steps to get the boot audio working. The problem is that I have a 2 second audio file that I would like to repeat until the boot is complete. I know stagefright has the capability to repeat files but I cannot actual make it do it.
These are the listed options from the help
-h(elp)
-a(udio)
-n repetitions
-l(ist) components
-m max-number-of-frames-to-decode in each pass
-b bug to reproduce
-p(rofiles) dump decoder profiles supported
-t(humbnail) extract video thumbnail or album art
-s(oftware) prefer software codec
-o playback audio
-w(rite) filename (write to .mp4 file)
-k seek test
Here are the options that I have tried. If anyone knows how to do this I am sure it is simple.
#stagefright -a -o -n 9 /system/media/android_audio.mp3
#stagefright -a -o -9 /system/media/android_audio.mp3
unknown option -- 9usage: t
#stagefright -a -o -n9 /system/media/android_audio.mp3#
# stagefright -a -o n=9 /system/media/android_audio.mp3
Unable to create data source.
#stagefright -a -o -n=9 /system/media/android_audio.mp3
#stagefright -a -o -n = 9 /system/media/android_audio.mp3
Unable to create data source.
#stagefright -a -o -n='9' /system/media/android_audio.mp3
#stagefright -a -o -n="9" /system/media/android_audio.mp3
# stagefright -h
usage: stagefright
#stagefright -a -o -n-9 /system/media/android_audio.mp3
After a little more playing aorund with it I think I am able to get the file to repeat but not when it actually plays audio.
# stagefright -o -n 6 /system/media/android_audio.mp3
No suitable video track found. The '-a' option will target audio tracks only, the default is to target video tracks only.
# stagefright -a -n 6 /system/media/android_audio.mp3
..$..$..$..$..$..$
avg. 2323.33 KB/sec
decoded a total of 207360 bytes
# stagefright -a -n -o /system/media/android_audio.mp3
..$
avg. 1811.30 KB/sec
decoded a total of 34560 bytes
if you compare the output from the -n being placed in front of the -o options it will display the ..$ which I do not understand what that means but with a number of repetitions it will repeat the ..$ however many times. The only problem is that it will not play the audio when it displays the ..$

[Q] Odexing MIUIv4 or other ICS ROM

hello i trying to ODEX my MIUIv4 (ICS 4.0.4) but i had some troubles:
there is my script for odexing:
Code:
#/sbin/sh
D=/data
E=/sddata
S=/system
SD=/sdcard
bbcmd="busybox"
bbcat="$bbcmd cat"
bbgrep="$bbcmd grep"
bbsed="$bbcmd sed"
SYSTARGET="/system"
OPTTEMP="/tmp"
$bbcmd chmod 777 $OPTTEMP/{busybox,dexopt_wrapper,zip,zipalign}
mount -o rw /system
mount -o rw /data
mount -o rw /cache
local zip="$OPTTEMP/zip"
local zipalign="$OPTTEMP/zipalign"
local dexopt_wrapper="$OPTTEMP/dexopt_wrapper"
local bootclpath="/system/framework/core.jar:/system/framework/core-junit.jar:/system/framework/bouncycastle.jar:/system/framework/ext.jar:/system/framework/framework.jar:/system/framework/android.policy.jar:/system/framework/services.jar:/system/framework/apache-xml.jar:/system/framework/filterfw.jar"
# change to system/framework and process EVERY jar IN ORDER OF BOOTCLASSPATH!
cd /system/framework
indir=$(pwd)
for filename in \
core.jar core-junit.jar miui-framework.jar bouncycastle.jar ext.jar framework.jar android.policy.jar services.jar apache-xml.jar filterfw.jar \
am.jar ime.jar android.test.runner.jar input.jar javax.obex.jar monkey.jar pm.jar svc.jar bmgr.jar com.android.location.provider.jar com.android.future.usb.accessory.jar com.google.android.maps.jar com.google.android.media.effects.jar com.google.widevine.software.drm.jar
do
name=${filename%.jar}
$bbcmd cp -f $filename $OPTTEMP/$filename
$dexopt_wrapper $filename $name.odex $bootclpath > /dev/null 2>&1
if [ $? -eq 0 ]
then
$zip -d $filename classes.dex > /dev/null 2>&1
$bbcmd cp -f $name.odex $OPTTEMP/$name.odex
echo "$filename - done."
else
$bbcmd rm *.odex
$bbcmd cp -f $OPTTEMP/*.jar $indir/
echo "Framework file $filename failled. Cannot Complete."
echo "System has been restored."
return 1;
fi
done
$zipalign 4 framework-res.apk framework-res.apk.align > /dev/null 2>&1
$bbcmd mv -f framework-res.apk.align framework-res.apk
$zipalign 4 framework-miui-res.apk framework-miui-res.align > /dev/null 2>&1
$bbcmd mv -f framework-miui-res.align framework-miui-res.apk
cd /system/app
indir=$(pwd)
# Process apks from system/app that are normally odexed
for filename in *.apk
do
name=${filename%.apk}
$dexopt_wrapper $filename $name.odex $bootclpath > /dev/null 2>&1
if [ $? -eq 0 ]
then
$zip -d $filename classes.dex > /dev/null 2>&1
$zipalign 4 $filename $filename.align > /dev/null 2>&1
$bbcmd mv -f $filename.align $filename
echo "$filename - done."
fi
done
$bbcmd find /system/framework -type f -exec chmod 644 {} \;
$bbcmd find /system/app -type f -exec chmod 644 {} \;
[ -d /cache/dalvik-cache ] && $bbcmd rm -rf /cache/dalvik-cache/*
[ -d /data/dalvik-cache ] && $bbcmd rm -rf /data/dalvik-cache/*
return 0;
and i had errors in android.policy, framework, services .odex files

[SCRIPT][BACKUP][TOOL]Preserve addon , dpi , Xposed app_process /system files

Hi,
i flash many roms and sometimes after new rom flashed , i see dpi preserved my change before flash, even some rom preserve xposed framework still activated...maybe you have experience with some other backup/restore /system files during flash, maybe have you another idea to preserve some stuff.
For my part, i make a new backuptool.sh and backuptool.functions scripts compiled with some i find over roms i tried....
We have:
save dpi
save xposed framework
save addond
i think in red are the line you can personalize, i hope you know what to do with.
backuptool.sh
Code:
#!/sbin/sh
#
# Backup and restore addon /system files
#
export C=/tmp/backup
export S=/system
[COLOR="Red"]export V=what you want[/COLOR]
persist_props="ro.sf.lcd_density"
sysroot="/system"
saveroot="/tmp/save"
# Preserve DPI
save_props()
{
rm -f "$saveroot/prop"
for prop in $persist_props; do
echo "save_props: $prop"
grep "^$prop=" "$sysroot/build.prop" >> "$saveroot/prop"
done
}
# Restore DPI
restore_props()
{
local sedargs
sedargs="-i"
for prop in $(cat $saveroot/prop); do
echo "restore_props: $prop"
k=$(echo $prop | cut -d'=' -f1)
sedargs="$sedargs s/^$k=.*/$prop/"
done
sed $sedargs "$sysroot/build.prop"
}
# Backup Xposed Framework (bin/app_process)
xposed_backup()
{
if [ -f /system/bin/app_process.orig ]
then
cp /system/bin/app_process /tmp/backup/
fi
}
# Restore Xposed Framework (bin/app_process)
xposed_restore()
{
if [ -f /tmp/backup/app_process ]
then
mv /system/bin/app_process /system/bin/app_process.orig
cp /tmp/backup/app_process /system/bin/
fi
}
# Preserve /system/addon.d in /tmp/addon.d
preserve_addon_d() {
mkdir -p /tmp/addon.d/
cp -a /system/addon.d/* /tmp/addon.d/
chmod 755 /tmp/addon.d/*.sh
}
# Restore /system/addon.d in /tmp/addon.d
restore_addon_d() {
cp -a /tmp/addon.d/* /system/addon.d/
rm -rf /tmp/addon.d/
}
[COLOR="Red"]# Proceed only if /system is the expected major and minor version
check_prereq() {
if ( ! grep -q "^ro.cm.version=$V.*" /system/build.prop ); then
echo "Not backing up files from incompatible version: $V"
return 0
fi
return 1
}[/COLOR]
check_blacklist() {
if [ -f /system/addon.d/blacklist ];then
## Discard any known bad backup scripts
cd /$1/addon.d/
for f in *sh; do
s=$(md5sum $f | awk {'print $1'})
grep -q $s /system/addon.d/blacklist && rm -f $f
done
fi
}
check_whitelist() {
found=0
if [ -f /system/addon.d/whitelist ];then
## forcefully keep any version-independent stuff
cd /$1/addon.d/
for f in *sh; do
s=$(md5sum $f | awk {'print $1'})
grep -q $s /system/addon.d/whitelist
if [ $? -eq 0 ]; then
found=1
else
rm -f $f
fi
done
fi
return $found
}
mkdir -p $saveroot
# Execute /system/addon.d/*.sh scripts with $1 parameter
run_stage() {
for script in $(find /tmp/addon.d/ -name '*.sh' |sort -n); do
$script $1
done
}
case "$1" in
backup)
save_props
mkdir -p $C
[COLOR="Red"]# if check_prereq; then[/COLOR]
if check_whitelist system; then
exit 127
fi
[COLOR="Red"]# fi[/COLOR]
check_blacklist system
xposed_backup
preserve_addon_d
run_stage pre-backup
run_stage backup
run_stage post-backup
;;
restore)
restore_props
[COLOR="Red"]# if check_prereq; then[/COLOR]
if check_whitelist tmp; then
exit 127
fi
[COLOR="Red"]# fi[/COLOR]
check_blacklist tmp
xposed_restore
run_stage pre-restore
run_stage restore
run_stage post-restore
restore_addon_d
rm -rf $C
rm -rf /data/data/android.pacstats
sync
;;
*)
echo "Usage: $0 {backup|restore}"
exit 1
esac
exit 0
backuptool.functions
Code:
#!/sbin/sh
#
# Functions for backuptool.sh
#
export C=/tmp/backup
export S=/system
export V=what you want
backup_file() {
if [ -e "$1" ]; then
local F=`basename "$1"`
local D=`dirname "$1"`
# dont backup any apps that have odex files, they are useless
if ( echo "$F" | grep -q "\.apk$" ) && [ -e `echo "$1" | sed -e 's/\.apk$/\.odex/'` ]; then
echo "Skipping odexed apk $1";
else
mkdir -p "$C/$D"
cp -p $1 "$C/$D/$F"
fi
fi
}
restore_file() {
local FILE=`basename "$1"`
local DIR=`dirname "$1"`
if [ -e "$C/$DIR/$FILE" ]; then
if [ ! -d "$DIR" ]; then
mkdir -p "$DIR";
fi
cp -p "$C/$DIR/$FILE" "$1";
if [ -n "$2" ]; then
echo "Deleting obsolete file $2"
rm "$2";
fi
fi
}
the files in attachments. just remove ".txt' at end to use them as well.
thanks.

Fix DNS issue (internet access) on NSTV Pro 2019 [Magisk]

Hello my friends!
*** You should have ROOT access ***
*** This steps is not contains details so is not for newbies ***
1- Install AFWall (https://github.com/ukanth/afwall)
2- Install dnscrypt-proxy for Android (https://github.com/adit/dnscrypt-proxy)
3- Install NTP & GPS Clock [ROOT] (https://play.google.com/store/apps/details?id=jp.xrea.poca.clocksync&hl=en&gl=US)
4- Run AfWall and:
write thiscustom script:
HTML:
iptables -t nat -A OUTPUT -p tcp ! -d 8.8.8.8 --dport 53 -j DNAT --to-destination 127.0.0.1:5354
iptables -t nat -A OUTPUT -p udp ! -d 8.8.8.8 --dport 53 -j DNAT --to-destination 127.0.0.1:5354
iptables -t nat -A OUTPUT -p tcp ! -d 8.8.8.8 --dport 853 -j DNAT --to-destination 127.0.0.1:5354
iptables -t nat -A OUTPUT -p udp ! -d 8.8.8.8 --dport 853 -j DNAT --to-destination 127.0.0.1:5354
and this shutdown script
HTML:
iptables -t nat -D OUTPUT -p tcp ! -d 8.8.8.8 --dport 53 -j DNAT --to-destination 127.0.0.1:5354
iptables -t nat -D OUTPUT -p udp ! -d 8.8.8.8 --dport 53 -j DNAT --to-destination 127.0.0.1:5354
iptables -t nat -D OUTPUT -p tcp ! -d 8.8.8.8 --dport 853 -j DNAT --to-destination 127.0.0.1:5354
iptables -t nat -D OUTPUT -p udp ! -d 8.8.8.8 --dport 853 -j DNAT --to-destination 127.0.0.1:5354
5- Run AFWall and make sure all apps has access to Internet and start Firewall.
6- Turn Off Automatic Date&Time from settings.
7- Run "NTP & GPS Clock" app Sync device Date&Time. (try ntp-server: 132.163.97.5 or 132.163.96.5 or 129.6.15.32)
HTML:
#dcp stop
#dcp disable
#dcp start
8- Done! all DNS request redirect to dnscrypt-proxy (Magisk-Module)
Note: You can play around more with AfWall and dnscrypt to gain much more security.

Categories

Resources