Skip to content

Latest commit

 

History

History
162 lines (118 loc) · 5.55 KB

HOW-TO-FLASH-SUPER.md

File metadata and controls

162 lines (118 loc) · 5.55 KB

How to modify super.img and then flash it onto the device.

For some reason I don't know of yet the install script won't be able to change the partition size inside super.img. When this happens the recovery will only schon an error 7 mentioning an "assert failure" with dynamic_partitions_op_list. To overcome this problem you need to change the partiton layout manually on your computer and then flash the whole super.img back onto the device.

Installing needed utilities

Install brotli

First of you need brotli to uncompress the image files

sudo apt install brotli

Install lpmake

Build lpmake yourself

Make sure lpmake is build

cd ~/android/lineage
source build/envsetup.sh

# For the Atom L EEA use
breakfast Atom_L_EEA
# For the atom XL EEA use
breakfast Atom_XL_EEA
# For the Atom L TEE use
breakfast Atom_L_TEE
# For the atom XL TEE use
breakfast Atom_XL_TEE

make lpmake

lpmake will be built in

~/android/lineage/out/host/linux-x86/bin/lpmake

Use a precompiled OTA tools package

Head on over to xda-developers.com to download a complete OTA tools package and extract it to a folder of your choice.

Install sdat2img.py

Download sdat2img.py

mkdir -p ~/bin
cd ~/bin
wget https://raw.githubusercontent.com/xpirt/sdat2img/master/sdat2img.py
chmod 755 sdat2img.py

Update your PATH variable for your environment

gedit ~/.profile

Add the following

# set PATH so it includes user's private bin if it exists
if [ -d "$HOME/bin" ] ; then
  PATH="$HOME/bin:$PATH"
fi	

Then update your environment

source ~/.profile

Extracting image files from stock rom files

Follow the instructions to extract the stock rom files to the point where you get system.img, vendor.img and product.img. For this guide we only need vendor.img because the other two files are provided from the LineageOS rom. Create the folder ~/super and copy vendor.img into it.

Extracting image files from LineageOS rom files

Download lineage-17.1-XXX-UNOFFICIAL-YYY-signed.zip from the latest release page of your device. Extract the files from the zip archive into ~/super.

Then we need to extract the brotli compressed files

brotli --decompress system.new.dat.br -o system.new.dat
brotli --decompress product.new.dat.br -o product.new.dat

Finally we need to create real ext4 image files for further useage

sdat2img.py system.transfer.list system.new.dat system.img
sdat2img.py product.transfer.list product.new.dat product.img

(optional) Modifying system.new.dat and product.new.dat

If you want to now is the time to add or remove things from the installation file. You just need to mount the images and do your worst.

Creating super.img

First we need to get the exact sizes of all the image files

stat -c '%n %s' vendor.img
stat -c '%n %s' system.img
stat -c '%n %s' product.img

Alternativly you could also use the filesizes from the zip archive in dynamic_partitions_op_list. Theses sizes are a bit bigger so you are able to add additional components like Gapps or Magisk later on.

With these number we are now able to create the super.img

./lpmake \
 --metadata-size 65536 \
 --super-name super \
 --metadata-slots 1 \
 --device super:4831838208 \
 --group main:4829741056 \
 --partition system:readonly:3670016000:main --image system=./system.img \
 --partition vendor:readonly:367001600:main --image vendor=./vendor.img \
 --partition product:readonly:681574400:main --image product=./product.img \
 --sparse \
 --output ./super.img

Beware that the numbers in this example are not universally valid. You need to adjust them to your needs.

  • -- metadata-size: The maximum size that partition metadata may consume. A partition entry uses 64 bytes and an extent entry uses 16 bytes. I think 65536 should work in most cases.
  • -- metadata-slots: The number of slots available for storing metadata. This should match the number of update slots on the device, 2 for A/B devices and 1 for non-A/B.
  • -- device super: The size of the super partition on the device. It must match exactly, and it must be evenly divisible by the sector size (512 bytes). Best way to get this number is from the scatter file of the stock rom archive.
  • -- group main: The sum of all partitions files sizes.
  • -- partition: Every partition file size with permissions(readonly) and input img file.

Flashing super.img with TWRP recovery

  1. Connect your phone to your PC and open a terminal or a command line window.
  2. Run adb reboot recovery on your PC or simply hold volume up while turning power on to boot your device into the recovery.
  3. Wait for TWRP to boot.
  4. Run adb push super.img /external_sd.
  5. In TWRP select Install.
  6. Use Select Storage to switch to your SD card.
  7. Use Install Image to switch to image installation mode.
  8. Select super.img from the list.
  9. Select Super partition.
  10. Swipe the slider on the bottom to the right to confirm.