[Samsung Galaxy A12] uluruman:
repacksuper

===========

Copyleft uluruman 2021-2022

(for LINUX/WSL only)

This is the minimalistic set of tools + a script for Linux for the automated

ground-up repacking and flashing of the Samsung Galaxy super.img, replacing

the stock Android system with something much less intrusive and obtrusive

(e.g. LineageOS). Or just some other GSI (Generic System Image).

Additional included scripts (since v1.1) simplify flashing of stock firmware or

separate image files under Linux using Heimdall.

Theoretically should work for any Samsung A-series phones, and may be even for

some others. Tested on SM-A127F/DSN made in India and Vietnam and SM-A325F/DS

made in India, on Debian Linux 11 x64. There are reports of successful flashing

of SM-A127M, SM-A032M and SM-A226B.

Why this method?

----------------

Repacking of super.img is the only method which allows changing of the phone's

operating system without screwing up the Verified Boot (VB) protection

mechanism. Keeping the VB allows you to be sure that everything besides the

platform was indeed compiled by Samsung and wasn't tampered with, no matter from

where you downloaded your stock firmware.

The other reason is that although there are alternative methods of changing the

OS, for phones with dynamic partitioning and no working version of TWRP

available they may be even more complicated than repacking of super.img

externally by this script.

Requirements

------------

Install the following tools from the official repositories of your Linux distro:

simg2img xz-utils lz4 unzip gzip jq file

Basic instructions

------------------

repacksuper.sh: main script for changing your phone's operating system

heimdall_flash_stock.sh: script for flashing stock firmware under Linux

heimdall_flash.sh: script for flashing any custom image file under Linux

Just run a script without any arguments to see help.

Extra tools used (x64 binaries and sources included)

----------------------------------------------------

GitHub - LonelyFool/lpunpack_and_lpmake: android super.img tools

android super.img tools. Contribute to LonelyFool/lpunpack_and_lpmake development by creating an account on GitHub.

github.com

GitHub - amo13/Heimdall: Heimdall is a cross-platform open-source tool suite used to flash firmware (aka ROMs) onto Samsung Galaxy devices. This is a fork of the original repository with a few crucial pull requests merged.

Heimdall is a cross-platform open-source tool suite used to flash firmware (aka ROMs) onto Samsung Galaxy devices. This is a fork of the original repository with a few crucial pull requests merged....

github.com

Additional notes

----------------

The included binaries for the lpunpack, lpmake and Heimdall were compiled for

the x86_64 architecture. If your PC architecture is different (e.g. x86 32-bit

or ARM) you have to compile these tools yourself. The full source code is

included (or otherwise available on GitHub).

Spoiler content hidden.

Spoiler content hidden.

Spoiler content hidden.

Older step-by-step guides are here and here. Also be sure to read this post concerning the importance of optics.img. Concerning the up_param_tool.sh be sure to read this post.

For repacking you will need the stock firmware. You can download it either from SamFw or using Samloader (if you'll figure out how to use it). I don't recommend using the popular shady closed-source utilities made by hackers as, for example, the popular Frija Tool is hosted on GitHub but none of its source code is published there, Samfirm tool looks open-source at first glance but includes several suspicious closed-source DLL files, etc. Downloading from SamFw should be safe as all the firmware data is signed and checked before flashing against the signatures of the previously flashed firmware.

The included binaries for the lpunpack, lpmake and Heimdall were compiled for the x86_64 architecture. If your PC architecture is different (e.g. x86 32-bit or ARM) you have to compile these tools yourself. The full source code is included (or otherwise available on GitHub).