How to install Magisk in AVD Emulator? - Magisk

I tried to root android in AVD Emulator.
Google APIs 27 x86 Revision 8
MagiskManager 7.1.1
My attempt:
1. Make a boot.img with kernel and ramdisk.img in system-images:
Code:
mkbootimg --kernel kernel-ranchu --ramdisk ramdisk.img -o boot.img
2. Patch boot.img in MagiskManager;
3. Separate ramdisk.img from patched boot.img:
Code:
split_boot patched_boot.img
4. Replace the ramdisk.img.
But this won't work, the MagiskManager show Magisk is not installed.
I need to do what else?

@goddade
You can try this https://github.com/shakalaca/MagiskOnEmulator

HemanthJabalpuri said:
@goddade
You can try this https://github.com/shakalaca/MagiskOnEmulator
Click to expand...
Click to collapse
Thank you for your reply.

Related

mkbootimg in cygwin

Is there a way to run mkbootimg in cygwin.. I can extract the ramdisk from boot & recovery images but cannot rebuild.. each time it fails to /usr/bin/mkbootimg: /usr/bin/mkbootimg: cannot execute binary file
Thanks.

[HACK] compiled mkbootimg and unpack/repack linux scripts for boot.img

want to edit your boot.img?
included files in zip: mkbootimg (i compiled this file from android source), unpack-bootimg.pl, repack-bootimg.pl
i edited the repack script to compile the nexus s img correctly.
Code:
--base 0x30000000 --pagesize 4096
first dump original boot.img:
Code:
cat /dev/mtd/mtd2 > /sdcard/boot.img
then drag/drop to your linux box to edit file.
use unpack script:
Code:
./unpack-bootimg.pl boot.img
you will end up with 2 compressed files and 1 folder.
finished editing and want to repack boot.img, for example:
Code:
./repack-bootimg.pl <kernel> <ramdisk-directory> <outfile>
most info and scripts pulled from here: http://android-dls.com/wiki/index.php?title=HOWTO:_Unpack,_Edit,_and_Re-Pack_Boot_Images, thanks to the original author.
test your new boot.img:
Code:
fastboot boot boot.img
Two things:
1. if you have any bad blocks in your boot partition, this method will fail to extract the boot.img (you need to skip bad blocks, but cat will just get an error)
2. you can replace just the kernel (leaving the ramdisk and parameters intact) using:
Code:
% fastboot flash zimage zImage
The bootloader will read-modify-write the boot partition, replacing the kernel only.
how would you skip bad blocks? i never thought of a phone as having bad blocks.
k0mpresd said:
i never thought of a phone as having bad blocks.
Click to expand...
Click to collapse
All flash devices can have bad blocks. But it usually isn't something the end user would notice, unless there are so many and something is wrong that you're losing drive space.
edit: more info here if your curious http://en.wikipedia.org/wiki/Flash_memory
hmm, very strange thing happening to me. I've only gotten my boot.img to compile and boot successfully once with this method, but now I can't seem to get it to compile? I keep getting errors of the file name or file type. I'm using the correct usage.. If I compile manually with mkbootimg on the cmd line it'll compile but it won't boot. Just bootloops at the Google splash..
Jroid try my Matr1x kernel and see what happens
Sent from my Nexus S using XDA App
The problem seems to be compiling the boot with the perl scripts, not the kernel itself.
Try manually:
Once unpacked do the boot.img-ramdisk.cpio.gz with the following command (moved to the ramdisk folder):
Code:
#sudo find . | cpio -o -H newc | gzip > ../<your boot name>.img-ramdisk.cpio.gz
Then cd ../
And repack:
Code:
#./mkbootimg --kernel <your boot name>.img-kernel.gz --ramdisk <your boot name>.img-ramdisk.cpio.gz --base 0x30000000 --pagesize 4096 -o boot.img
you can replace just the kernel (leaving the ramdisk and parameters intact) using:
Code:
% fastboot flash zimage zImage
The bootloader will read-modify-write the boot partition, replacing the kernel only.
Click to expand...
Click to collapse
It won't work on the Nexus S.
python08 said:
It won't work on the Nexus S.
Click to expand...
Click to collapse
exactly, i'd love to be able to do this for some testing but it doesn't allow me.
EDIT: yes it does. Swetland is right
Chamb' said:
Try manually:
Once unpacked do the boot.img-ramdisk.cpio.gz with the following command (moved to the ramdisk folder):
Code:
#sudo find . | cpio -o -H newc | gzip > ../<your boot name>.img-ramdisk.cpio.gz
Then cd ../
And repack:
Code:
#./mkbootimg --kernel <your boot name>.img-kernel.gz --ramdisk <your boot name>.img-ramdisk.cpio.gz --base 0x30000000 --pagesize 4096 -o boot.img
Click to expand...
Click to collapse
I've tied compiling a boot both manually (with cmdline) and with the perl scripts and have used a simple kernel.gz and ramdisk.cpio.gz for my file names.. doesn't really matter what I name it as long as it has the correct file format in this .gz and .cpio.gz right? the manual compile goes fine with base 0x30000000 and pagesize 4096
however, it does not boot and will bootloop at the Google splash
Used boot.img extracted from (what ROM ?) cat /dev/mtd/mtd2 ?
Is the phone start with this boot.img (unchanged) if you flash it by typing "fastboot flash..." ?
After that, just try to unpack and repack the boot.img without changes on ramdisk or kernel, if it works that means your changes suck (^^).
These commands (or perl scripts) work perfectly for me.
Lol I will try doing that. The boot.img I used is from stock 2.3.4, edited the ramdisk (specifically init.rc & init.herring.rc)
Like I said, first time I used the perl scripts I edited my ramdisk, threw in a netarchy kernel, it compiled fine and booted. Now if I use the perl script to repack with an aosp kernel, it gives me an error about file name and/or extension being wrong. Or complains it can't find mkbootimg when its there and executable. I'll re run it again and post errors
Sent from my Nexus S
he guys where is the boot image located? not the animation, the google logo at the start of the booting!
Sent from my Nexus S using XDA Premium App
ok so when I used the repack-bootimg.pl script, it kept giving me this error:
Code:
boot.img-kernel.gz Not a directory at ./repack-bootimg.pl line 13.
So I ran mkbootimg manually, without a cmdline comment as stated above. It compiled
and booted beautifully all stock with no init.rc or init.herring.rc edits.
however when I compile a boot.img coupled with a stock kernel and a modified ramdisk, I get a non-booting boot.img. One came out at 2.9 mb and the other at 5.6 mb neither boots using the same cmd that compiled the working boot. Must be my edits.. I literally only changed about 1 line in init.rc and another line in init.herring.rc that causing it not to boot.
By the way, I got some info on a stock boot.img using the unpackbootimg binary (not the perl script) and here's what it outputs:
Code:
#BOARD_KERNEL_CMDLINE console=ttyFIQ0 no_console_suspend
BOARD_KERNEL_BASE 30000000
BOARD_PAGE_SIZE 00001000
I enter that pagesize and it says it's not a valid value when I compile boot.img's
Borky_16 said:
he guys where is the boot image located? not the animation, the google logo at the start of the booting!
Sent from my Nexus S using XDA Premium App
Click to expand...
Click to collapse
part of the kernel
to change-https://github.com/morfic/Samsung-logo
ogdobber said:
part of the kernel
to change-https://github.com/morfic/Samsung-logo
Click to expand...
Click to collapse
yeah i know thanks for the link a helping source though!
Sent from my Nexus S using XDA Premium App
Sorry for the Control C Control V of it, but I just found this topic now..
I`m facing this problem when I try to unpack boot.img..
I have done it 2 days ago but dunno why, now I can`t..
Follows what is happening..
Code:
[email protected]:~/NS-bootwork$ ./unpack-bootimg.pl boot.img
Found a secondary file after the ramdisk image.
According to the spec (mkbootimg.h) this file can exist,
but this script is not designed to deal with this scenario.
The Kernel is built, as a zImage and the WLAN as a bmc3429.ko..
Just repeating, I have built this Kernel 2 days ago in the same way, without any problems, but now I`m struggling on the message after inputting ./unpack-bootimg.pl boot.img..
Dunno what else to try, I re-downloaded the unpack-bootimg.pl from 2 different sources, and still the same error..
Any ideas?
Many thanks..
P.S.: Ubuntu 11.04 x64..
EDIT
Well, I already solve it!
That is what I did..
As unpack-bootimg.pl was not working (don`t know why) I used split_bootimg.pl script, splitting the boot.img and created new ramdisk img..
Code:
./split_bootimg.pl boot.img
mkdir ramdisk
cd ramdisk
gzip -dc ../boot.img-ramdisk.gz | cpio -i
find . | cpio -o -H newc | gzip > ../newramdisk.cpio.gz
Then after just compiled the Kernel with
Code:
./mkbootimg --kernel zImage --ramdisk newramdisk.cpio.gz --base 0x30000000 --pagesize 4096 --cmdline _console_suspend=1 console=bull's -o newtestboot.img'no
Witches includes " --cmdline _console_suspend=1 console=bull's" to not break BT functionality, in the case of Nexus S..
I found the tools here work well: http://glandium.org/blog/?p=2214
...if you then use the code originally posted above:
Code:
sudo find . | cpio -o -H newc | gzip > ../<your boot name>.img-ramdisk.cpio.gz
./mkbootimg --kernel <your boot name>.img-kernel.gz --ramdisk <your boot name>.img-ramdisk.cpio.gz --base 0x30000000 --pagesize 4096 -o boot.img

How To Burn your own kernel on SM-G900H:

Preliminary requirements:
1. Phone rooted.
2. CWM recovery installed.
3. Full backup created using CWM.
Actions:
1. Download the mkbootimg tools.
2. Get the current boot.img by using:
adb pull sdcard/clockworkmod/backup/xxx/boot.img
if sdcard symlink does not exist grab it from: /data/media/0/clockworkmod/backup/xxx/boot.img
3. use umkbootimg to extract boot.img:
./umkbootimg boot.img
you suppose to get two files:
1. zImage - kernel
2. initramfs.cpio.gz - ramdisk filesystem
4. build samsung kernel with dtb support:
4.1. Download kernel version from samsung website.
4.2 Do make exynos5422-k3g_00_defconfig
4.3 manually edit the .config created by adding the following lines:
CONFIG_BUILD_ARM_APPENDED_DTB_IMAGE=y
CONFIG_BUILD_ARM_APPENDED_DTB_IMAGE_NAMES="exynos5422-k3g_eur_open_10"
CONFIG_ARM_APPENDED_DTB=y
CONFIG_ARM_ATAG_DTB_COMPAT=y
CONFIG_ARM_ATAG_DTB_COMPAT_CMDLINE_FROM_BOOTLOADER=y
4.4 run: make -j8
5. Take the build product from:
arch/arm/boot/zImage-dtb and copy it to the folder where you extracted the boot.img
6. Run the following to create a new boot.img:
./mkbootimg --kernel zImage-dtb --ramdisk initramfs.cpio.gz -o new_boot.img
7. Push the new_boot.img to the sdcard:
adb push new_boot.img sdcard/
8. Get into adb shell and run from there:
su -c dd if=/sdcard/new_boot.img of=/dev/block/platform/12200000.dwmmc0/by-name/BOOT
9. Get out of adb shell, and run adb reboot.
10. Wait for the phone to upload.. And you've get your own kenrel running on Samsung galaxy s5 sm-g900h!!

[HELP][Q] How to properly repack ramdisk in order to avoid boot stuck?

Hello mates!
I've been playing with XT1097's boot.img and need some help as my boot.img fails to boot if I repack ramdisk.
Using abootimg
Extracting boot.img contents:
Code:
abootimg -x boot.img ==> produces bootimg.cfg, initrd.img and zImage files in the current directory
Updating boot.img contents without touching ramdisk (using the one extracted in the previous step):
Code:
abootimg -u boot.img -r initrd.img
If I extract initrd.img and try to repack it, then system fails at boot:
Extracting ramdisk (initrd.img) contents:
Code:
abootimg-unpack-initrd ==> produces a ramdisk subdir
Repacking without modyfing ramdisk folder contents:
Code:
abootimg-pack-initrd newramdisk.img
Updating boot.img with newramdisk.img
Code:
abootimg -u boot.img -r newramdisk.img
Even though the generated boot.img's size matches the original one - 10444800 bytes - system gets stuck at boot logo.
The same issue happens if I use these tools combined:
mkbootimg, unmkbootimg, gzip and cpio
Any ideas are welcome

Question S21 Ultra 5G stuck after flashing customized boot.img

I am trying to do some customization on S21 Ultra 5G SM-G998B
The source code is obtained from Samsung open source (SM-G998B_RR_Opensource.zip - G998BXXS2AUBB)
Firmware G998BXXS2AUBB_G998BOXM2AUBB_.zip is downloaded from sammobile
Step 1) Extract boot.img from firmware
The boot.img is extracted from the firmware's AP_G998BXXS2AUBB_CL20701476_QB38432109_REV01_user_low_ship_MULTI_CERT_meta_OS11.tar (using 7-zip and unpack with lz4)
The boot.img is then unpacked as follows:
$ ./unpack_bootimg.py --boot_img ./sambootimg/boot.img --out ./out
boot_magic: ANDROID!
kernel_size: 28807680
ramdisk size: 697174
os version: 11.0.0
os patch level: 2021-03
boot image header version: 3
command line args: androidboot.selinux=permissive
This step will output the following files: kernel, ramdisk and mkbootimg_args.json
Step 2) Building kernel
After building the samsung open source kernel (no changes have been made to Kernel code), the Image is obtained at arch/arm64/boot
I understand that Android 11 is based on ver 3 header. The boot.img only consists of Kernel and ramdisk
Step 3) Make boot.img
This kernel image (Image) together with ramdisk is created as follows:
$ ./mkbootimg.py --kernel ./myBootimg/Image --ramdisk ./out/ramdisk --header_version 3 --os_version 11.0.0 --os_patch_level 2021-03 --cmdline androidboot.selinux=permissive --out ./myBootimg/boot.img
$ tar -cvf boot.img.tar boot.img
This created boot.img.tar
Step 4) Magisk patch
After tar, this boot.img.tar is patched according to the magisk procedure which gives magisk_patched-22006_CjCUM.tar
The patched download to phone via the Odin utility successfully
After phone restart, it hang at Samsung screen (with the Android robot)
May I checked if I missed out any other steps?
mhc009 said:
I am trying to do some customization on S21 Ultra 5G SM-G998B
The source code is obtained from Samsung open source (SM-G998B_RR_Opensource.zip - G998BXXS2AUBB)
Firmware G998BXXS2AUBB_G998BOXM2AUBB_.zip is downloaded from sammobile
Step 1) Extract boot.img from firmware
The boot.img is extracted from the firmware's AP_G998BXXS2AUBB_CL20701476_QB38432109_REV01_user_low_ship_MULTI_CERT_meta_OS11.tar (using 7-zip and unpack with lz4)
The boot.img is then unpacked as follows:
$ ./unpack_bootimg.py --boot_img ./sambootimg/boot.img --out ./out
boot_magic: ANDROID!
kernel_size: 28807680
ramdisk size: 697174
os version: 11.0.0
os patch level: 2021-03
boot image header version: 3
command line args: androidboot.selinux=permissive
This step will output the following files: kernel, ramdisk and mkbootimg_args.json
Step 2) Building kernel
After building the samsung open source kernel (no changes have been made to Kernel code), the Image is obtained at arch/arm64/boot
I understand that Android 11 is based on ver 3 header. The boot.img only consists of Kernel and ramdisk
Step 3) Make boot.img
This kernel image (Image) together with ramdisk is created as follows:
$ ./mkbootimg.py --kernel ./myBootimg/Image --ramdisk ./out/ramdisk --header_version 3 --os_version 11.0.0 --os_patch_level 2021-03 --cmdline androidboot.selinux=permissive --out ./myBootimg/boot.img
$ tar -cvf boot.img.tar boot.img
This created boot.img.tar
Step 4) Magisk patch
After tar, this boot.img.tar is patched according to the magisk procedure which gives magisk_patched-22006_CjCUM.tar
The patched download to phone via the Odin utility successfully
After phone restart, it hang at Samsung screen (with the Android robot)
May I checked if I missed out any other steps?
Click to expand...
Click to collapse
Hmm... Maybe you have to do a factory reset / wipe data in recovery.
Just guessing ...

Categories

Resources