mfastboot for Linux? - Moto X Q&A

Need mfastboot for Linux, since I don't have Winduhs. Yes I know about
https://dl.dropboxusercontent.com/u/7632904/Mfastboot-4.4.zip
and
https://drive.google.com/folderview...sharing&tid=0B5uAY0sZrRUib0JMZVJGOURzMkU#list
... but it doesn't work.
Code:
# ./fastboot devices
bash: ./fastboot: No such file or directory
{der}
Anyone know what I'm talking about?

As a bonus, SafeStrap does not work on Moto X. Black screen.
Now after trying to replace the boot logo I get a scarred-up logo... and "Safestrap Disabled" on boot. Hooray for me.

I'm guessing that you set permissions properly so that you can execute the file, and also verified that the file is in the current directory.

Yes to both. Notice it's not a permissions problem.
Code:
# ls -al fastboot
-rwxr-xr-x 1 root staff 541322 Feb 13 16:10 fastboot*
# strace ./fastboot
execve("./fastboot", ["./fastboot"], [/* 54 vars */]) = -1 ENOENT (No such file or directory)
dup(2) = 3
fcntl(3, F_GETFL) = 0x8002 (flags O_RDWR|O_LARGEFILE)
fstat(3, {st_mode=S_IFCHR|0600, st_rdev=makedev(136, 3), ...}) = 0
mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f105b38d000
lseek(3, 0, SEEK_CUR) = -1 ESPIPE (Illegal seek)
write(3, "strace: exec: No such file or di"..., 40strace: exec: No such file or directory
) = 40
close(3) = 0
munmap(0x7f105b38d000, 4096) = 0
exit_group(1) = ?

Looks like you have 64bit Linux. mfastboot is 32bit binary. You need to setup your system to be able to run 32 bit binaries.
Sent from my XT1053 using Tapatalk

Yes I'm 64bit. But it should throw an exception to that effect.
Maybe I'll research adding 32bit.

Architecture must not be it. Debian 64bit is supposed to natively run 64bit and 32bit code if booted in 64bit mode.
Following the multiarch wiki article I also
# dpkg --add-architecture i386
# apt-get update
# ldconfig
... and no change.
# ldd fastboot
not a dynamic executable
# ls -al
total 532
drwxr-xr-x 2 root root 8 Dec 3 14:35 ./
drwxr-xr-x 5 root root 24 Dec 3 14:35 ../
-rwxr-xr-x 1 root root 541322 Nov 1 10:47 fastboot
# ./fastboot devices
bash: ./fastboot: No such file or directory
Like I say, it will normally let you know that it's 32bit code in a 64bit system if that's the problem.

Quantumstate said:
Architecture must not be it. Debian 64bit is supposed to natively run 64bit and 32bit code if booted in 64bit mode.
Following the multiarch wiki article I also
# dpkg --add-architecture i386
# apt-get update
# ldconfig
... and no change.
# ldd fastboot
not a dynamic executable
# ls -al
total 532
drwxr-xr-x 2 root root 8 Dec 3 14:35 ./
drwxr-xr-x 5 root root 24 Dec 3 14:35 ../
-rwxr-xr-x 1 root root 541322 Nov 1 10:47 fastboot
# ./fastboot devices
bash: ./fastboot: No such file or directory
Like I say, it will normally let you know that it's 32bit code in a 64bit system if that's the problem.
Click to expand...
Click to collapse
Yes and your system is letting you know that with exactly this error message (message is stupid, but unfortunately that is how it works), believe me I was there...
Did you read carefully the article you linked. What you did with those commands is added i386 architecture to available packages to install, nothing more. You need to have installed 32bit versions of libc, libstdc++ and probably some more...
The fastboot binaries you linked in first post, are working perfectly on my 64bit Debian installation:
Code:
[email protected]:~/mfastboot_4.4/Linux$ uname -a
Linux rotfl 3.13-1-amd64 #1 SMP Debian 3.13.7-1 (2014-03-25) x86_64 GNU/Linux
[email protected]:~/mfastboot_4.4/Linux$ ldd fastboot
linux-gate.so.1 (0xf7736000)
librt.so.1 => /lib/i386-linux-gnu/librt.so.1 (0xf770a000)
libstdc++.so.6 => /usr/lib/i386-linux-gnu/libstdc++.so.6 (0xf7617000)
libm.so.6 => /lib/i386-linux-gnu/libm.so.6 (0xf75d1000)
libgcc_s.so.1 => /lib/i386-linux-gnu/libgcc_s.so.1 (0xf75b4000)
libc.so.6 => /lib/i386-linux-gnu/libc.so.6 (0xf7442000)
libpthread.so.0 => /lib/i386-linux-gnu/libpthread.so.0 (0xf7427000)
/lib/ld-linux.so.2 (0xf7737000)
I'm using Debian as my primary system for over 15 years, 64bit Debian installation will let you run 32bit binaries if you setup your system properly.
Run on your system dpkg --get-selections | grep i386 and see if you have anything installed. I have over 100 32bit packages installed just to run FoxitReader (which is 32bit).

Yes I read the whole wiki article. It only dictates the changes I made, and doesn't explain or say anything about additional libs so I was left to infer that adding the architecture would install the needed files, which is the only conclusion that makes sense out of the article. That's why I did an ldconfig.
Well I'll be damned. mfastboot now works. I installed libx32stdc++6, lib32stdc++6-4.7-dev, and all their dependencies.
Is there any way to get mfastboot from Motorola, or is it internal?

Quantumstate said:
Yes I read the whole wiki article. It only dictates the changes I made, and doesn't explain or say anything about additional libs so I was left to infer that adding the architecture would install the needed files, which is the only conclusion that makes sense out of the article. That's why I did an ldconfig.
Well I'll be damned. mfastboot now works. I installed libx32stdc++6, lib32stdc++6-4.7-dev, and all their dependencies.
Is there any way to get mfastboot from Motorola, or is it internal?
Click to expand...
Click to collapse
It's in GSM Dev Edition Moto X here: https://motorola-global-portal.custhelp.com/app/standalone/bootloader/recovery-images
At least it was when I downloaded 4.2.2 version image. It was not in Verizon one (some time ago I downloaded 4.2.2 GSM and Verizon Dev edition images and only in GSM one there were fastboot binaries, don't know why Motorola included it only in one image not all of them). Don't know about 4.4.2 images, never downloaded them. The 4.2.2 GSM Dev Edition image contained Win/Linux/Mac moto fastboot binaries.

Here is the fastboot binary for Linux from the 4.4.2 images that Moto posted. I also know that it works:
Code:
[email protected] ~ $ ls -l fastboot
-rwxr-xr-x 1 imnuts imnuts 541322 Dec 6 13:40 fastboot
[email protected] ~ $ ./fastboot
usage: fastboot [ <option> ] <command>
commands:
update <filename> reflash device from update.zip
flashall flash boot + recovery + system
flash <partition> [ <filename> ] write a file to a flash partition
erase <partition> erase a flash partition
format <partition> format a flash partition
getvar <variable> display a bootloader variable
boot <kernel> [ <ramdisk> ] download and boot kernel
flash:raw boot <kernel> [ <ramdisk> ] create bootimage and flash it
devices list all connected devices
continue continue with autoboot
reboot reboot device normally
reboot-bootloader reboot device into bootloader
help show this help message
options:
-w erase userdata and cache
-P enable parallel loading for multi-flash if
there is no enough memory on host to load
whole image
-s <serial number> specify device serial number
-p <product> specify product name
-c <cmdline> override kernel commandline
-i <vendor id> specify a custom USB vendor id
-b <base_addr> specify a custom kernel base address
-n <page size> specify the nand page size. default: 2048
-S <size>[K|M|G] automatically sparse files greater than
size. 0 to disable
[email protected] ~ $

Related

[BOOT SPLASH] collections AND how to flash in Linux

Just wanted to start a thread with the collections of the ThunderBolt's Splash Screen (Very first screen when you turn it on)
The manual way of flashing your Splash Screen (I have found to be faster and easier, In Linux anyways))
I have my adb and fastboot files in /bin on my root. This way it always acts as an internal command and can access it from anywhere.
If you have the adb, fastboot and adb_usb.ini files then you can, in root terminal use this command to move them over.
I just drag the files to the terminal instead of manually typing them in after I write in the 'mv' command.
Code:
# mv *where ever adb files are located* /bin
Now open up your terminal and copy the code after each one is finished.
Code:
# apt-get install ffmpeg
It should look similiar to this and the responses after each command
[email protected]:/home/ubuntu# apt-get install ffmpeg
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following NEW packages will be installed:
ffmpeg
0 upgraded, 1 newly installed, 0 to remove and 9 not upgraded.
Need to get 2,220 B of archives.
After this operation, 68.6 kB of additional disk space will be used.
Get:1 http://us.archive.ubuntu.com/ubuntu/ precise-updates/main ffmpeg all 4:0.8.4-0ubuntu0.12.04.1 [2,220 B]
Fetched 2,220 B in 0s (10.7 kB/s)
Selecting previously unselected package ffmpeg.
(Reading database ... 206414 files and directories currently installed.)
Unpacking ffmpeg (from .../ffmpeg_4%3a0.8.4-0ubuntu0.12.04.1_all.deb) ...
Setting up ffmpeg (4:0.8.4-0ubuntu0.12.04.1) ...
[email protected]:/home/ubuntu#
First make sure your image is 480 X 800 and in jpg format with 24 bits depth
Code:
$ ffmpeg -i PICTURE_LOCATION.jpg -f rawvideo -pix_fmt rgb565 SPLASH1.img
(This should put it in your Home Folder, move it to where ever you want)
Code:
$ adb devices
List of devices attached
HT********** device
Code:
$ adb reboot fastboot
[email protected]:/home/ubuntu#
Code:
$ fastboot flash splash1 LOCATION_OF_CUSTOM_SPLASH1.img
[email protected]:/home/ubuntu#
Code:
fastboot reboot
[email protected]:/home/ubuntu#
More Splash Screens
Remember to rename them to splash1.img before you flash the picture OR drag and drop them in place of the "splash1.img" location.
http://goo.gl/aFnRE
DeadMau5
http://goo.gl/d1CWV
Processor Chip
http://goo.gl/cx8eW
Plant Cable
http://goo.gl/IZYD9
Three Wise Androids
http://goo.gl/uqzq3
iphone killer
Thursday, February 21st
http://goo.gl/RC4kW
Hot Chick!
http://goo.gl/ZIjMa
SuperWoman
http://goo.gl/rDDfXg
Light Plug
http://goo.gl/nf5vp
SkellyMan
http://goo.gl/r1hU4
Sexy Country Chick
Batman (Image won't work right, flashes just fine)
http://goo.gl/lU2ZC

Is there a way of getting *Locked* bootloader via CMD?

Hey.
I'm currently working on a method to lock the ONE's bootloader compelitly via cmd.
I dont know if there is any fastboot command , but is it?
And is there any way to transfer revone to the phone and use the terminal on the computer instead of the one is the phone?
Tnx
TunneIVision said:
Hey.
I'm currently working on a method to lock the ONE's bootloader compelitly via cmd.
I dont know if there is any fastboot command , but is it?
And is there any way to transfer revone to the phone and use the terminal on the computer instead of the one is the phone?
Tnx
Click to expand...
Click to collapse
Umh, do you have a custom recovery?
If yes, use the guru zip.
However, you can use the revone from the cmd of pc
And you can also use the command for lock in recovery.
Guich said:
Umh, do you have a custom recovery?
If yes, use the guru zip.
However, you can use the revone from the cmd of pc
And you can also use the command for lock in recovery.
Click to expand...
Click to collapse
I dont have a custon recovery , and I'd like to hear how
" you can use the revone from the cmd of pc
And you can also use the command for lock in recovery "
TunneIVision said:
I dont have a custon recovery , and I'd like to hear how
" you can use the revone from the cmd of pc
And you can also use the command for lock in recovery "
Click to expand...
Click to collapse
Code:
adb push revone /data/local/tmp
Code:
adb shell
Code:
cd /data/local/tmp
Code:
chmod 755 revone
And after you can use the revone commands
Guich said:
Code:
adb push revone /data/local/tmp
Code:
adb shell
Code:
cd /data/local/tmp
Code:
chmod 755 revone
And after you can use the revone commands
Click to expand...
Click to collapse
So I should do the whole proccess in the computer? but how does the computer get into the tmp folder of the phone?
And is there a command in the (computer) CMD for factory reset?
Thanks
TunneIVision said:
So I should do the whole proccess in the computer? but how does the computer get into the tmp folder of the phone?
And is there a command in the (computer) CMD for factory reset?
Thanks
Click to expand...
Click to collapse
Yes, you can do the process with the pc.
When you use the adb shell code you're "into" you phone, so you will see all the folder/file of the phone...
Nope, as i know, there isn't any command for the factory reset from prompt.
Seems i'm using my One...
Guich said:
Yes, you can do the process with the pc.
When you use the adb shell code you're "into" you phone, so you will see all the folder/file of the phone...
Nope, as i know, there isn't any command for the factory reset from prompt.
Seems i'm using my One...
Click to expand...
Click to collapse
I found this in some site , and I lighted what seems to be a wiping command , but I cant really get it.
fastboot
usage: fastboot [ <option> ] <command>
commands:
update <filename> reflash device from update.zip
flashall flash boot + recovery + system
flash <partition> [ <filename> ] write a file to a flash partition
erase <partition> erase a flash partition
format <partition> format a flash partition
getvar <variable> display a bootloader variable
boot <kernel> [ <ramdisk> ] download and boot kernel
flash:raw boot <kernel> [ <ramdisk> ] create bootimage and flash it
devices list all connected devices
continue continue with autoboot
reboot reboot device normally
reboot-bootloader reboot device into bootloader
help show this help message
options:
-w erase userdata and cache (and format
if supported by partition type)
-u do not first erase partition before
formatting
-s <specific device> specify device serial number
or path to device port
-l with "devices", lists device paths
-p <product> specify product name
-c <cmdline> override kernel commandline
-i <vendor id> specify a custom USB vendor id
-b <base_addr> specify a custom kernel base address
-n <page size> specify the nand page size. default:
2048
-S <size>[K|M|G] automatically sparse files greater th
an
size. 0 to disable
TunneIVision said:
I found this in some site , and I lighted what seems to be a wiping command , but I cant really get it.
fastboot
usage: fastboot [ <option> ] <command>
commands:
update <filename> reflash device from update.zip
flashall flash boot + recovery + system
flash <partition> [ <filename> ] write a file to a flash partition
erase <partition> erase a flash partition
format <partition> format a flash partition
getvar <variable> display a bootloader variable
boot <kernel> [ <ramdisk> ] download and boot kernel
flash:raw boot <kernel> [ <ramdisk> ] create bootimage and flash it
devices list all connected devices
continue continue with autoboot
reboot reboot device normally
reboot-bootloader reboot device into bootloader
help show this help message
options:
-w erase userdata and cache (and format
if supported by partition type)
-u do not first erase partition before
formatting
-s <specific device> specify device serial number
or path to device port
-l with "devices", lists device paths
-p <product> specify product name
-c <cmdline> override kernel commandline
-i <vendor id> specify a custom USB vendor id
-b <base_addr> specify a custom kernel base address
-n <page size> specify the nand page size. default:
2048
-S <size>[K|M|G] automatically sparse files greater th
an
size. 0 to disable
Click to expand...
Click to collapse
Probably should work, but i never checked because for a factory reset i flashed the stock recovery and permformed it from bootloader
Or do a full wipe, that is the same, from recovery
Seems i'm using my One...

Froma newbiz : Mirek 7 is working !!!

My first post on xda about my first flashing ever. Mirek seems to work. Still need 9 more posts to be able to post on dev forum.
By the way, i plan to install debian on it. Either by replacing winshiiiiiii*, either by doing a install with a shared kernel (but not as chroot as seen in gnu root debian).
Still need to post 9 more posts before i can thank Mirek.
10.
that's 9
By the way it's a very stressing situation when you never flashed a rom.
I plan to remove the windows partitions in order to install the debian system on a separate partition but i first need to back up the partition table of the current installation in order to reinstall windows (in case something go wrong).
Use dd command to Bacup windows partition .
In the future I add that possibility in my flash tool .
7
Thank for your answer.
That's what i did. (In fact, it's the very first thing i did).
But i want to backup the partition table in order to reinstall as origin, even if this will probably never happen.
I want to remove all the msft partition in order to make room for debian root & home and make the data partition larger. I guess it is possible to do so by editing the .tbl file in the partition folder.
But do you know a tool to extract the current partition table ? Or do i have to make it manually ?
You have to make it manually .
If you want know how big is each partition - easy way install partition info ( in that program check advanced view )
Or use terminal ....
With my partitions you have partition editor .
Only diffrences will be on the last 4 petitions /cache / sytem /data and windows last partition .
Or if you install teclast windows then windows create 4 partitions for itself at the end partition tables .
PS I tried boot Debian ....and failed ... looks like in half of booting from usb just usb stoped working ( I have powered usb hub ) .
I finally figured it out for the partition editor. Thanks.
About debian, it's not the usb way i'm talking about but more something like that :
whiteboard.ping.se/Android/Debian
The article is a little old but...
It's less straithforward than usb but you keep the advantage of android (and the drivers) with the full fonctionnality of debian (no chroot).
Oh, i forgot.
The rom is a nice improvement of the system. The battery life lasts far longer.
I had a few bug (apps closing like xprivacy).
There is also semething else. I'm not able anymore to setenforce selinux in enforcing mode. I did it with the Selinuxmodechanger but the change to enforce mode prevented other apps as well selinuxmode changer & terminal emulator to restart.
I had to reboot the device.
Don't change to enforce mode because mods will stop works.
I have a question :
What is exactly efilinux-userdebug.efi ? It seems you flash it before any operation on the device.
This is EFI boot able partition ( small partition ) that allow to boot droidboot in ram disk .
Ok...
I have issue with your rom :
Some apps are crashing (privacy X).... I think there is an issue with permission system.
I had also to screen freezes. May be related to Gravity box or apex, may be both.
I removed animation of the dock swipe from apex settings and now it's ok.
But he selinux issue is a big issue for me, i don't feel it well. It like going outside with just a T-shirt in the middle of the winter.
And i want to try Remix. I will maybe come back to Mirek later.
In order to flash Remix from my debian pc, I adapted your batch script in bash. and your partition.tbl
your excel sheet was inspiring. I backed-up the current partition table with fdisk command for all partition. It give something equals to the excel sheet for the first partitions.
I upload the 2 necessary file (script & partition flash) in the hope you could take a look at it.
teclast_remix_partition.sh :
#!/bin/bash
#Flash osloader & boot from droidboot.img
fastboot flash osloader ROM/efilinux-userdebug.efi
fastboot boot ROM/droidboot.img
fastboot devices
sleep 30
#Wipe ESP
fastboot oem wipe ESP
echo "ESP wiped"
####Start partitionning####
echo "start partitioning"
fastboot oem start_partitioning
fastboot flash /tmp/partition.tbl ROM/partition.tbl
fastboot oem partition /tmp/partition.tbl
echo "start erasing..."
####Erase partitions####
fastboot erase system
echo "system erased"
fastboot erase cache
echo "cache erased"
fastboot erase config
echo "config erased"
fastboot erase data
echo "data erased"
fastboot erase logs
echo "logs erased"
fastboot erase factory
echo "factory erased"
fastboot oem stop_partitioning
#Flash partitions
fastboot flash ESP ROM/esp.img
echo "esp flashed"
fastboot flash fastboot ROM/droidboot.img
echo "droidboot flashed"
fastboot flash boot ROM/boot.img
echo "boot flashed"
fastboot flash recovery ROM/recovery.img
echo "recovery flashed"
fastboot flash system ROM/system.img
echo "system flashed"
fastboot continue
echo "All should be OK now"
sleep 10
Click to expand...
Click to collapse
partition.tbl :
partition_table=gpt
create -z /dev/block/mmcblk0
create /dev/block/mmcblk0
boot -p /dev/block/mmcblk0
reload /dev/block/mmcblk0
add -b 40 -s 131072 -t efi -u C12A7328-F81F-11D2-BA4B-00A0C93EC93B -l ESP -T 0 -P 0 /dev/block/mmcblk0
add -b 131112 -s 131072 -t data -u 80868086-8086-8086-8086-FFFFFFFFFFF0 -l reserved -T 0 -P 0 /dev/block/mmcblk0
add -b 262184 -s 32768 -t data -u 80868086-8086-8086-8086-000000000100 -l boot -T 3 -P 15 /dev/block/mmcblk0
add -b 294952 -s 32768 -t data -u 80868086-8086-8086-8086-000000000101 -l recovery -T 3 -P 14 /dev/block/mmcblk0
add -b 327720 -s 32768 -t data -u 80868086-8086-8086-8086-000000000102 -l fastboot -T 3 -P 13 /dev/block/mmcblk0
add -b 360488 -s 32768 -t data -u 80868086-8086-8086-8086-FFFFFFFFFFF1 -l reserved_1 -T 3 -P 0 /dev/block/mmcblk0
add -b 393256 -s 131072 -t data -u 80868086-8086-8086-8086-000000000104 -l test -T 3 -P 12 /dev/block/mmcblk0
add -b 524328 -s 65536 -t data -u 80868086-8086-8086-8086-000000000001 -l panic -T 0 -P 0 /dev/block/mmcblk0
add -b 589864 -s 32768 -t data -u 80868086-8086-8086-8086-000000000002 -l factory -T 0 -P 0 /dev/block/mmcblk0
add -b 622632 -s 32768 -t data -u 80868086-8086-8086-8086-000000000003 -l misc -T 0 -P 0 /dev/block/mmcblk0
add -b 655400 -s 32768 -t data -u 80868086-8086-8086-8086-000000000004 -l config -T 0 -P 0 /dev/block/mmcblk0
add -b 688168 -s 2097152 -t data -u 80868086-8086-8086-8086-000000000005 -l cache -T 0 -P 0 /dev/block/mmcblk0
add -b 2785320 -s 524288 -t data -u 80868086-8086-8086-8086-000000000006 -l logs -T 0 -P 0 /dev/block/mmcblk0
add -b 3309608 -s 4194304 -t data -u 80868086-8086-8086-8086-000000000007 -l system -T 0 -P 0 /dev/block/mmcblk0
add -b 7503912 -s 50331648 -t data -u 80868086-8086-8086-8086-000000000008 -l data -T 0 -P 0 /dev/block/mmcblk0
add -b 57835560 -s 31457280 -t data -u 80868086-8086-8086-8086-000000000009 -l debianroot -T 0 -P 0 /dev/block/mmcblk0
add -b 89292840 -s $calc($lba_end-16384) -t data -u 80868086-8086-8086-8086-000000000010 -l debianhome -T 0 -P 0 /dev/block/mmcblk0
reload /dev/block/mmcblk0
Click to expand...
Click to collapse
Is everything ok ?
PS : I don't understand the use of the xml and cmd files, since everything can be done from the batch files
Ok i get it. that's for the intel MFT.
get a huge connectivity problem with the rom : i couldn't g et internet anymore.
I had to make a factory reset.
Hi!
I install mirek190_rom_v7.0 - android Lollipop, I had a few bug (apps closing like facebook, word, powerpoint) and apps OLX are hang, and help only reboot by pressing on 10s power button.
Battery start show full capacity and take on all day after fully discharge and charge on power-off device
And after reboot or shut down when tablet on again, when pressing "last up" soft button i see app what working on last session, they likely didn't close.
In Titanium Backup i cant uninstall, integrate updates 'system' app like Youtube, Apex.. TB wrote "app dont find"
Also on my c9j8 don't work camera.
I can suggest you the remix os rom for x98 on jide website. But you will have to customise it with a kitchen in order to have root access.
You can even build it with malware in it and propose it on the forum, like the russian version proposed by allegator in the teclat-remix thread. (I cheked the adbd binary in the ramdisk with a hexadecimal editor ; at the end there is a fair number of call of external functions).
It seems android herited some of the bad common practices met in the windows world. Coming from the Linux world, Android looks like the Wild West in comparaison.
But the good part is the Android implementation is far more accessible for system programming and general understanding than the desktop versions of linux. It is possible to quickly make your own tweaks.
By the way, the official jide rom offers a great improvement in android gui like a task bar which allow you to switch easily from one app to another. Once you get used to it, you cannot come back to regular android gui.
But you will have to get your hands dirty if you want root access without having to flash dubious 'custom' rom.
If your interested i suggest you to look for kitchen in the search engine and tutorials about ramdisk and kernel. It can take a little time to get it all, but that's not rocket science.

How To Guide How to use the Hardware Test App from ASUS on a Zenfone running a CustomROM

How to use the Hardware Test App from ASUS on a Zenfone running a CustomROM
The Hardware Test App from ASUS for the Zenfone 8 can also be used on a ASUS Zenfone 8 running a CustomROM.
But to get the App working on a CustomROM some efforts are neccessary.
The ASUS Hardware Test App needs the permission to modify system settings. To get this permission the app must be signed with the platform certificate used for the running Android OS.
And because these certificates are not available for the public for all public available CustomROMs (for some very good reasons ...) you must compile your own CustomROM for using the ASUS Hardware Test App on a CustomROM.
So -- for those who still want to continue: Here are the steps neccessary to run the Hardware Test App from ASUS for the Zenfone 8 on a phone running a CustomROM :
First copy the apk with the ASUS Hardware Test App from a Zenfone 8 running the original Android 12 from ASUS to your PC.
This is the file
/system/apps/SMMI_TEST/SMMI_TEST.apk
on the phone running the ASUS Android OS.
Now it's neccessary to sign the App with the platform key from your CustomROM:
In the OmniROM (and I assume that's also true for other AOSP based CustomROMs) the neccessary files, platform.pk8 and platform.x509.pem, are in the directory
Code:
./build/make/target/product/security
in your build tree for the CustomROM, e.g.
Code:
[[email protected] /data/develop/android/OmniROM]$ ls -l ./build/make/target/product/security/platform.*
-rw-------. 1 xtrnaw7 xtrnaw7 1219 Jun 25 09:39 ./build/make/target/product/security/platform.pk8
-rw-rw-r--. 1 xtrnaw7 xtrnaw7 1460 Jun 25 09:39 ./build/make/target/product/security/platform.x509.pem
[[email protected] /data/develop/android/OmniROM]$
Now re-sign the apk file using these commands:
Code:
# remove the current certificate files from the apk (probably not neccessary -- but shouldn't harm)
#
zip -d SMMI_TEST.apk META-INF/CERT.SF META-INF/CERT.RSA
# do a zip align for the apk and write the output to SMMI_TEST1.apk
#
# (zipalign is part of the OTA tools)
#
/data/develop/android/otatools/bin/zipalign 4 SMMI_TEST.apk SMMI_TEST1.apk
# test the result (there should be NO output from this command)
#
/data/develop/android/otatools/bin/zipalign -c 4 SMMI_TEST1.ap
# and now sign the apk with the platform key from the development tree for your self compiled CustomROM
# (apksigner.jar is part of the Sdk from Google for Android)
#
java -jar ./Android/Sdk/build-tools/33.0.0/lib/apksigner.jar sign --key platform.pk8 --cert platform.x509.pem SMMI_TEST1.apk
That's it . The re-signed apk file SMMI_TEST1.apk should work on your CustomROM
To test it:
To test the signed apk do:
Copy the signed apk to the phone running your self compiled CustomROM and issue
Code:
ls -l /sdcard/Download/SMMI_TEST1.apk
# 25733396 in the next command is the size of the file /sdcard/Download/SMMI_TEST1.apk in byte
#
cat /sdcard/Download/SMMI_TEST1.apk | pm install -S 25733396
If you get an error like this
Code:
130|ASUS_I006D:/ # ls -l /sdcard/Download/SMMI_TEST1.apk
-rw-rw---- 1 u0_a111 media_rw 25733396 2022-08-04 19:02 /sdcard/Download/SMMI_TEST1.apk
ASUS_I006D:/ #
ASUS_I006D:/ # cat /sdcard/Download/SMMI_TEST1.apk | pm install -S 25733396
Failure [INSTALL_FAILED_SHARED_USER_INCOMPATIBLE: Reconciliation failed...: Reconcile failed: Package com.asus.atd.smmitest has no signatures that match those in shared user android.uid.system; ignoring!]
1|ASUS_I006D:/ #
something went wrong signing the apk. Just do it again.
To install the apk do:
If not already done:
Compile your own CustomROM (using the certificates used to sign the ASUS Hardware Test App!) and install it on the ASUS Zenfone 8. (see How to compile the OmniROM for the ASUS Zenfone 8 for how to compile the OmniROM)
Install Magisk on your phone running the self compiled CustomROM
Simulate a Magisk Module using these commands:
Code:
adb shell su - -c mkdir -p /data/adb/modules/SMMI_TEST/system/app/SMMI_TEST
adb push SMMI_TEST1.apk /sdcard/Download/
adb shell su - -c cp /sdcard/Download/SMMI_TEST1.apk /data/adb/modules/SMMI_TEST/system/app/SMMI_TEST/SMMI_TEST1.apk
adb shell su - -c chmod o+r /data/adb/modules/SMMI_TEST/system/app/SMMI_TEST/SMMI_TEST1.apk
and reboot the phone
Code:
adb reboot
After the reboot the ASUS Hardware Test App should be visible in the directory /system/app, e.g.
Code:
130|ASUS_I006D:/ # find /system/app/SMMI_TEST/
/system/app/SMMI_TEST/
/system/app/SMMI_TEST/SMMI_TEST1.apk
ASUS_I006D:/ #
To execute the ASUS Hardware Test App do
Code:
# open a shell on the ASUS Zenfone 8 (either local or via "adb shell"), become root user
su -
and execute
Code:
# switch SELinux to permissive mode (I currently do not know the neccessary SELinux policies to avoid this step ...)
#
setenforce 0
# and start the ASUS Hardware Test App from within the shell
#
am start -n com.asus.atd.smmitest/com.asus.atd.smmitest.main.MAIN
Do not forget to enable SELinux enforcing mode after the tests are done (or reboot the phone ...)
Code:
# switch SELinux to permissive mode (I currenlty do not know the neccessary SELinux policies to avoid this step ...)
#
setenforce 1
Sample Script to start the ASUS Hardware Test App
Code:
# simple script to start the ASUS Hardware App
CUR_SELINUX_STATUS="$( getenforce )"
CUR_USERID=$( id -u -n )
RESTORE_SELINUX_STATE="false"
if [ "${CUR_SELINUX_STATUS}"x != "Permissive"x ] ; then
if [ "${CUR_USERID}"x != "root"x ] ; then
echo "Either start this script as user \"root\" or set the SELinux mode to \"permissive\" using the command \"setenforce 0\" before starting this script"
exit 1
fi
echo "Setting the SELinux mode to \"Permissive\" ..."
setenforce 0
RESTORE_SELINUX_STATE="true"
else
echo "The SELinux mode is already \"Permissive}\" "
fi
am start -n com.asus.atd.smmitest/com.asus.atd.smmitest.main.MAIN 2>&1 | tee /sdcard/Download/test.out
if [ ${RESTORE_SELINUX_STATE} = true ] ; then
echo "Press return when done with the tests .."
read USER_INPUT
echo "Setting the SElinux mode back to \"Enforcing\" ...."
setenforce 1
else
echo "Do not forget to set the SELinxu mode back to \"Enforcing\" using the command \"setenforce 1\" "
fi
Trouble Shooting
If the boot process of the phone hangs after adding the pseudo Magisk Module for the ASUS Hardware Test App do:
Code:
# connect to the phone via adb (that should work!)
#
adb shell
# become root user
#
su -
# delete the file with the AUS Hardware Test App
#
rm /data/adb/modules/SMMI_TEST/system/app/SMMI_TEST/SMMI_TEST1.apk
# and reboot the phone
#
reboot
Most probably something went wrong signing the app or you did not do the zip align (there should be some messages visible in logcat to find the reason for the boot loop; check the output of logcat before rebooting the phone)
A useful test to find reason for the boot loop is :
Code:
# try to install the apk as root user
#
su -
# and then
#
setenforce 0
pm install /sdcard/Download/SMMI_TEST.apk
If booting the phone works but the App does not start make sure that the SELinux status is permissive.
Update 26.06.2022
The adb commands to create the "simulated" Magisk Module must be executed by the user root - fixed.
Added a sample script to start the ASUS Hardware Test Tool
Update 04.08.2022
Added instructions to to test if signing the apk was successfull
Thank you so much for your guides! This is very detailled documentation with good explanations!

How To Guide How to Install TWRP into the boot partition again after the installation of an OS update

After installing an operating system update on a phone with the Android operating system and A/B slots, Magisk can be installed in the boot partition of the inactive slot with the new operating system version using the "Install to inactive slot" installation option in the Magisk App.
Unfortunately this option is not available for TWRP.
Therefor I wrote a litlle script to install TWRP into the boot partition of the inactive slot with the new operating system version after an OS upgrade.
The method works on my ASUS Zenfone 8 and should in principle also work on other phones with the same architecture (Qualcomm CPU, A/B slots, and boot partitions with ram disks)
Looking at the source code for TWRP (https://github.com/TeamWin/android_bootable_recovery/blob/android-12.1/twrpRepacker.cpp) it can be seen that the installation of TWRP is in principle only the installation of a new ramdisk:
Spoiler: TWRP source code excerpt
C++:
bool twrpRepacker::Flash_Current_Twrp() {
if (!TWFunc::Path_Exists("/ramdisk-files.txt")) {
LOGERR("can not find ramdisk-files.txt");
return false;
}
PartitionManager.Unlock_Block_Partitions();
Repack_Options_struct Repack_Options;
Repack_Options.Disable_Verity = false;
Repack_Options.Disable_Force_Encrypt = false;
Repack_Options.Type = REPLACE_RAMDISK_UNPACKED;
Repack_Options.Backup_First = DataManager::GetIntValue("tw_repack_backup_first") != 0;
std::string verifyfiles = "cd / && sha256sum --status -c ramdisk-files.sha256sum";
if (TWFunc::Exec_Cmd(verifyfiles) != 0) {
gui_msg(Msg(msg::kError, "modified_ramdisk_error=ramdisk files have been modified, unable to create ramdisk to flash, fastboot boot twrp and try this option again or use the Install Recovery Ramdisk option."));
return false;
}
std::string command = "cd / && /system/bin/cpio -H newc -o < ramdisk-files.txt > /tmp/currentramdisk.cpio && /system/bin/gzip -f /tmp/currentramdisk.cpio";
if (TWFunc::Exec_Cmd(command) != 0) {
gui_msg(Msg(msg::kError, "create_ramdisk_error=failed to create ramdisk to flash."));
return false;
}
if (!Repack_Image_And_Flash("/tmp/currentramdisk.cpio.gz", Repack_Options))
return false;
else
return true;
}
Therefor to install TWRP via script after an OS version update two steps are neccessary:
Step one
First we must create the ramdisk with TWRP; this step must only be done once for each TWRP version.
Boot the phone from the TWRP image (NOT from a TWRP installed in the recovery!), e.g:
Bash:
adb rebboot bootloader
sudo fastboot boot /data/backup/ASUS_ZENFONE8/twrp/twrp-3.7.0_12-0-I006D-enhanced.img
Then open an adb session to the running TWRP on the phone and execute:
Bash:
# create the RAM disk
#
cd / && sha256sum --status -c ramdisk-files.sha256sum
if [ $? -eq 0 ] ; then
cd / && /system/bin/cpio -H newc -o < ramdisk-files.txt > /tmp/ramdisk_with_twrp.cpio && /system/bin/gzip -f /tmp/ramdisk_with_twrp.cpio
fi
# copy the RAM disk and magiskboot to a directory on the internal storage that supports the execution permission bit (not /sdcard/<something>)
#
mkdir -p /data/develop/twrp
cp /tmp/ramdisk_with_twrp.cpio.gz /data/develop/twrp/ramdisk_with_twrp.cpio
cp /bin/magiskboot /data/develop/twrp/
Notes:
It is recommended to store the files ramdisk_with_twrp.cpio and magiskboot also on the PC.
The executable magiskboot is only required if Magisk is not installed on the phone.
Now copy the script install_twrp_ramdisk.sh.sh to the phone; this script can be copied to any filesystem with write access on the phone.
That's it .
Step two
The next time an OS update should be done using these steps:
1. install the new OS version either manually or via OTA but do NOT reboot afterwards.
2. execute the script install_twrp_ramdisk.sh.sh to install TWRP into the boot partition for the inactive slot either in an shell on the phone or in an adb shell, e.g. (sh is only necessary if the script is on a filesystem that does not support the execution permission)
Bash:
sh /sdcard/Download/install_twrp_ramdisk.sh
Note that the script needs root access to read and write the boot partition
3. optional: Install Magisk into the new boot partition using the install option "Install to inactive slot" in the Magisk App
4. reboot the phone to activate the new OS version
Test Environment
ASUS Zenfone 8
OmniROM 13
Magisk v25.2
TWRP 3.7.0
Notes
Set the environment variable WORK_DIR before executing the script to use another directory with the image
Set the environment variable TWRP_RAMDISK_NAME before executing the script to use another filename for the ram disk image.
see How to add additional files to an TWRP image for how to add additional files to the TWRP image
see How to install TWRP via script for how to install TWRP with a script running on the PC
Usage for the script install_twrp_ramdisk.sh:
Spoiler: ./install_twrp_ramdisk.sh -H
Code:
./install_twrp_ramdisk.sh -H
Usage:
install_twrp_ramdisk.sh [-h|-H]
This script must run in a shell on the phone (or in an adb shell) after an OS update was installed (either manual or via OTA) but before rebooting the phone.
The script will then install TWRP into the inactive slot.
The script must be executed by the user "root"; if it's executed by a non-root user it will restart itself using "su - -c scriptname"
Supported environment variables
WORK_DIR
directory with the ram disk image and probably the executable magiskboot
TWRP_RAMDISK_NAME
name of the file with the ram disk image (without path)
Prerequisites
The script requires these files:
/data/develop/twrp/ramdisk_with_twrp.cpio
- the ram disk with TWRP
/data/develop/twrp/magiskboot or /data/adb/magisk/magiskboot
- the magiskboot executable
To create the ram disk with TWRP do:
Boot the phone from the TWRP image (NOT from a TWRP installed in the recovery!),
open an adb session to the running TWRP on the phone and execute:
cd / && sha256sum --status -c ramdisk-files.sha256sum
if [ $? -eq 0 ] ; then
cd / && /system/bin/cpio -H newc -o < ramdisk-files.txt > /tmp/ramdisk_with_twrp.cpio && /system/bin/gzip -f /tmp/ramdisk_with_twrp.cpio
fi
mkdir -p /data/develop/twrp
cp /tmp/ramdisk_with_twrp.cpio.gz /data/develop/twrp/ramdisk_with_twrp.cpio
cp /bin/magiskboot /data/develop/twrp/
Note:
It is recommended to store the files ramdisk_with_twrp.cpio and magiskboot also on the PC.
The file magiskboot is only required if Magisk is not installed on the phone.
The directory used for the files can be any directory on the phone on a filesystem supporting the execute permission bit.
But do not forget to change the directory used in the script below (variable WORK_DIR) also.
Update 04.06.2023:
see https://github.com/Magisk-Modules-Repo/twrp-keep for a Magisk module with a script to reinstall TWRP into the inactive boot partition after an OS Udate
Update 11.06.2023:
I successfully tested the Magisk Module twrp-keep on an ASUS Zenfone 8 with OmniROM 13, TRWP 3.7.0_12, and Magisk v26.2.
ToDo:
Create an App with GUI to execute the script

Categories

Resources