You will need:
- Ubuntu (or other Linux distribution) computer
- TWRP image for your tablet model. Search for it on https://twrp.me/Devices/
- latest firmware for the Android tablet. For example download it from sammobile.
- The heimdall command. Download it with
sudo apt-get install heimdall-flash
- Binaries for manipulating Android images: ext2simg and sgs4ext4fs.
- On your computer, download the latest firmware for your tablet. You should end up with folder containing partition images.
- Put the tablet in download mode: power if off, then press home + volume down + power.
- Flash the firmware to the tablet:
heimdall flash --BOOTLOADER sboot.bin --BOOT boot.img --RECOVERY recovery.img --SYSTEM system.img --CACHE cache.img --HIDDEN hidden.img --RADIO modem.bin
- Once the tablet boots, do a factory data reset from the settings menu.
Install and configure apps, adjust the settings, etc.
- Download the TWRP image for your tablet model.
- Put the tablet in download mode.
- Flash TWRP to the tablet:
heimdall flash --RECOVERY TWRP_sm815.img
- Power off the tablet.
- Boot into recovery: hold home + volume up + power until you see the boot screen.
- Insert an SD card into the tablet. The SD card should be bigger than the internal storage of the tablet.
- In the TWRP menu, go to Mount and check "Micro SDCard"
- In the TWRP menu, go to Advanced > Terminal.
- From the TWRP terminal, copy the data partition to the SD card:
dd if=/dev/block/mmcblk0p22 | gzip > /external_sd/userdata.gz
- Note: you can find which link in /dev/block corresponds to the data partition by running
ls -lR /dev/block
.
- Insert the SD card in your computer, and transfer userdata.gz
- gunzip this file:
gunzip userdata.gz
. You should now have the userdata file, which is a Linux file system. - Transform the file to a sparse Android image. From the folder that contains the
ext2simg
andsgs4ext4fs
files, run:
./ext2simg userdata userdata_28bit.img && rm userdata
./sgs4ext4fs --bloat userdata_28bit.img userdata.img && rm userdata_28bit.img
chmod 644 userdata.img
- Put the
userdata.img
file in the same folder as the other system files, then cd into that folder. - Use the tar command to combine the created userdata.img with the system files into one Odin flashable image:
chmod 644 *
tar -H ustar -c boot.img cache.img hidden.img modem.bin recovery.img sboot.bin system.img userdata.img > odin_repack.tar
Done! You can now flash this file using Odin.