Repack Stock Firmware with Android 10 for Odin - Samsung Galaxy S10+ ROMs, Kernels, Recoveries, & O

I am trying to de-bload/modify the original stock firmware and flash it to my phone using odin without installing TWRP. I have already successfully flashed Magisks this way. However, all the guides I found on modifying the system.img seem to be outdated and do not work anymore.
Here is my current workflow (all on Debian 10)
Code:
tar xvf AP_*.tar.md5 #from original stock rom package or magisk_patched_*.tar) into sub-directory
lz4 -d system.img.lz4
simg2img system.img system.raw.img #either the Debian version or fresh compile from https://github.com/anestisb/android-simg2img
mkdir sys
sudo mount -t ext4 -o loop system.raw.img sys/
# Do a bunch of changes in the mounted image e.g. delete Samsung bloatware
sudo umount sys/
img2simg system.raw.img system.img
lz4 -B6 --content-size system.img system.img.lz4
tar --owner=1000 --group=1000 -H ustar -cvf AP_modified.tar *
md5sum -t AP_modified.tar >> AP_modified.tar
mv AP_modified.tar AP_modified.tar.md5
Unfortunately, the resulting file does not work because odin hangs or odin finishes and the phone is stuck in a boot loop. Anybody knows what I am missing here. Bootloader is unlocked, as I said, I could successfully flash the modified AP_* from magisk.

Related

NT: Build root filesystem

Extracting the N2 root filesystem and adding rc.local
These instructions assume using a linux console.
The root filesystem lives in a u-boot/PPCboot ramdisk. These instructions tell you how to extract it.
Boot your nt with the "rooted forever" sdcard while connected with usb.
Make a copy of the boot partition. After this you may reboot your nt normally.
$ tar -cf boot.tar boot/
$ tar xvf boot.tar
$ cd boot
Extract the uRamdisk file. first 64 bytes is the u-boot header, we need to skip it.
$ dd if=URamdisk bs=64 skip=1 of=ramdisk.gz
ramdisk.gz now contains the root file system.
Copy ramdisk.gz to a work directory, then extract it:
gunzip -v ramdisk.gz
cpio -iv < ramdisk
The root file system will populate your work dir. Delete the ramdisk file. You can now make changes to the root file system.
The change I'm going to make is a simple one: adding the ability to run an rc.local file at boot.
edit the init.rc file in your work directory, adding at the bottom:
Code:
service rclocal /etc/rc.local
enabled
user root
oneshot
rebuilding the uRamdisk file is simple, once you know how (thanks to JesusFreke for pointing me in the right direction). cd into your working directory, issue these commands:
Code:
find . -regex "./.*"| cpio -ov -H newc | gzip > ../ramdisk.gz
mkimage -A ARM -T RAMDisk -n Image -d ../ramdisk.gz ../uRamdisk
A script with the the commands above is attached. Also attached is a rooted uRamdisk with the rc.local ability already build in. To replace the uRamdisk file, boot with your "Rooted Forever" sdcard, and copy the uRamdisk file to the nook's boot directory.
What's this good for? That's up to you. I'm using it to automatically start dropbear so I can ssh in my Nooks and also use rsync to keep them synced with my ebook library. This is also one of the steps in building a kernel for the Nook ST.
jocala said:
Extracting the N2 root filesystem and adding rc.local
These instructions assume using a linux console.
The root filesystem lives in a u-boot/PPCboot ramdisk. These instructions tell you how to extract it.
Boot your nt with the "rooted forever" sdcard while connected with usb.
Make a copy of the boot partition. After this you may reboot your nt normally.
$ tar -cf boot.tar boot/
$ tar xvf boot.tar
$ cd boot
Extract the uRamdisk file. first 64 bytes is the u-boot header, we need to skip it.
$ dd if=URamdisk bs=64 skip=1 of=ramdisk.gz
ramdisk.gz now contains the root file system.
Copy ramdisk.gz to a work directory, then extract it:
gunzip -v ramdisk.gz
cpio -iv < ramdisk
The root file system will populate your work dir. Delete the ramdisk file. You can now make changes to the root file system.
The change I'm going to make is a simple one: adding the ability to run an rc.local file at boot.
edit the init.rc file in your work directory, adding at the bottom:
Code:
service rclocal /etc/rc.local
enabled
user root
oneshot
rebuilding the uRamdisk file is simple, once you know how (thanks to JesusFreke for pointing me in the right direction). cd into your working directory, issue these commands:
Code:
find . -regex "./.*"| cpio -ov -H newc | gzip > ../ramdisk.gz
mkimage -A ARM -T RAMDisk -n Image -d ../ramdisk.gz ../uRamdisk
A script with the the commands above is attached. Also attached is a rooted uRamdisk with the rc.local ability already build in. To replace the uRamdisk file, boot with your "Rooted Forever" sdcard, and copy the uRamdisk file to the nook's boot directory.
What's this good for? That's up to you. I'm using it to automatically start dropbear so I can ssh in my Nooks and also use rsync to keep them synced with my ebook library. This is also one of the steps in building a kernel for the Nook ST.
Click to expand...
Click to collapse
dd if=URamdisk bs=64 skip=1 of=ramdisk.gz
Click to expand...
Click to collapse
"uRamdisk" instead of "URamdisk"
Thanks again.

[Download] system.img was extracted to a 7z file (Prerooted)

It's a 7z file. It was extracted from system.img
link: http://minus.com/lJ9OQT5ktY7Vr
I used the below command to get the system.img. Root is required. Image size is 1Gb.
Code:
dd if=/dev/block/mmcblk0p15 of=/sdcard/system.img
adb pull /sdcard/system.img
To mount:
Code:
mkdir sys
sudo mount -o loop system.img sys
Is this Gingerbread or ICS? What version?
popfan said:
Is this Gingerbread or ICS? What version?
Click to expand...
Click to collapse
LT28H 4.0.4
ganeshbiyer said:
I used the below command to get the system.img. Root is required. Image size is 1Gb.
Code:
dd if=/dev/block/mmcblk0p15 of=/sdcard/system.img
adb pull /sdcard/system.img
To mount:
Code:
mkdir sys
sudo mount -o loop system.img sys
Click to expand...
Click to collapse
Now we need a usable cwm

[Q] [SOLVED] Failed to create my own system.img

Hi all,
I'm trying to create my own system.img for the Nexus 7 2013 Wifi from the stock system.img from https://developers.google.com/android/nexus/images 5.0.2 LRX22G. Basically I did it the common way using the android repack tools http://forum.xda-developers.com/showthread.php?t=2600364 and I'm also using branch android-5.0.2_r1 from the git repo.
I'm flashing with the simple:
Code:
fastboot flash system mysystem.img
The problem I'm having is, even with an unmodified tree from system.img, the image I created always get the device stuck at the boot Google logo screen. If I flash the original system.img, then it is fine, so I think my flashing part is working.
The command line I used to create the image is:
Code:
./mkuser.img.sh -s /path/to/loop_mounted_system/ mysystem.img ext4 system 880803840
which will run:
Code:
make_ext4fs -s -T -1 -l 880803840 -a system mysystem.img /path/to/loop_mounted_system/
Has anyone here actually managed to create a working system.img?
Any suggestions would be much appreciated, thanks!
UPDATE: Using ext2simg instead of mkuserimg.sh/make_ext4fs fixes the problem!

Repack system.img with simg2img/mkuserimg

Has anyone been able to repack system.img using these tools? I've tried a couple variations of of parameters for mkuserimg, but everytime it gets stuck on the boot animation.
simg2img ./system.img system.raw
sudo mount -t ext4 -o loop system.raw ./mount/system/
sudo mkuserimg.sh -s mount/system/ system_new.img ext4 /system 3221028864
I've also tried
sudo mkuserimg.sh -s mount/system/ system_new.img ext4 /system 3195826176
Neither one works. The first one gets the file size of the .raw files to match, but the number of blocks (per tune2fs) differ. The second one gets the number of blocks to match, but not the .raw file sizes.
The base system.img I have flashes without any problems.
Appreciate any help!
Did you disabled the encryption in the boot.img ? It might be getting stuck since the signatures don't match. Have a look at the boot.img used to root. The fstab entries are relaxed. I think there is another change from stock.
gee one said:
Did you disabled the encryption in the boot.img ? It might be getting stuck since the signatures don't match. Have a look at the boot.img used to root. The fstab entries are relaxed. I think there is another change from stock.
Click to expand...
Click to collapse
Definitely using a boot.img with encryption disabled. Using this one: http://forum.xda-developers.com/apps/supersu/wip-android-6-0-marshmellow-t3219344
I've tried running both stock system.img through the repack process and a AOSP built system.img and both images stop working once run through mkuserimg
Maybe I'll give the ElementalX kernel a try.

Repackaging Odin package

Hi all. I'm trying to repackage Odin package. I need to change smth. in cache.img.
Package contains cache.img and recovery.img.
I'm following these steps:
Untar package
simg2img cache.img cache.raw.img
mount -o loop -t ext4 cache.raw.img cache
umount cache
ext2simg cache.raw.img cache.img
tar -H ustar -c cache.img recovery.img > pkg.tar.md5
md5sum -t pkg.tar.md5 >> pkg.tar.md5
I do not change anything in cache.img, hust mounting to verify that image unpacks successfuly.
Then I'm trying to flash the package, but flashing fails on "NAND Write start" for cache.img.
As I understood, I've made a mistake when at the 5 step. How should I fix it?
Ax-Soft said:
I'm following these steps:
tar -H ustar -c cache.img recovery.img > pkg.tar.md5
...
try this:
tar --create --format=gnu -b20 --quoting-style=escape --owner=0 --group=0 --totals --mode=644 -f pkg.tar boot.img recovery.img
md5sum -t pkg.tar >> pkg.tar
mv pkg.tar pkg.tar.md5
Click to expand...
Click to collapse

Categories

Resources