compressionsamsung-mobilelzwlossless-compressionlz4

Odin FAIL! LZ4 is invalid


I have a ROM that I can flash on Samsung S10 5G(Qualcomm) successfully. My goal is to check whether I can modify system.img file of the ROM or not but before modification, I just want to verify that the AP file can be flashed after unpacking and packing of the system.img. To check this I have tried following:

Unpack-Pack AP file:

A) tar flashing:

  1. Extracted AP file using tar -xf AP...tar.md5 command.
  2. Compress the extracted files using tar -cvf AP...tar *
  3. Flash it with Odin3 v3.13.

B) tar.md5 flashing: - Get tar by following steps in A) and then run md5sum -t AP...tar >> AP...tar and mv AP...tar AP...tar.md5

Both Ap...tar and AP...tar.md5 flashed successfully.

Unpack-Pack system.img.ext4.lz4

  1. Extracted AP file using tar -xf AP...tar.md5 command. Extracted files are "boot.img.lz4, meta-data, userdata.img.ext4.lz4, carrier.img.ext4.lz4, persist.img.ext4.lz4, vbmeta.img.lz4, dqmdbg.img.ext4.lz4, recovery.img.lz4, vendor.img.ext4.lz4, dtbo.img.lz4, system.img.ext4.lz4".
  2. Extract system file using unlz4 system.img.ext4.lz4 command. This is giving me a system.img.ext4 Android sparse image.
  3. Tried following commands to compress system.img.ext4 without doing any modification:
    lz4 system.img.ext4 system.img.ext4.lz4                     - Default Compression
    lz4 -9 system.img.ext4 system.img.ext4.lz4              - High Compression 
    lz4 -l system.img.ext4 system.img.ext4.lz4              - Default Compression in Legacy format
    lz4 -l -9 system.img.ext4 system.img.ext4.lz4           - High Compression in Legacy format
    lz4 -0 -l system.img.ext4 system.img.ext4.lz4           - No Compression in Legacy format
    lz4 -B4 system.img.ext4 system.img.ext4.lz4             - Default Compression with Block size 4
    lz4 -B5 system.img.ext4 system.img.ext4.lz4             - Default Compression with Block size 5
    lz4 -B6 system.img.ext4 system.img.ext4.lz4             - Default Compression with Block size 6
    lz4 --no-frame-crc system.img.ext4 system.img.ext4.lz4   - Default Compression with no crc frame

and make an AP file by replacing the original system.img.ext4.lz4 file with the compressed file from above command(one at one time) and tried to flash it but every time it fails with "Odin FAIL! LZ4 is invalid"

LZ4 command detail: 1. Working on Ubuntu 18 2. Using "LZ4 command line interface 64-bits r128, by Yann Collet (Apr 3 2018)"

Tried with "LZ4 command line interface 64-bits v1.9.2, by Yann Collet" but get the same result.

file system.img.ext4.lz4 output:

So, I think it means the file should be compressed without legacy flag.

Size

  1. With -9 flag i.e. High Compression the output file is of 3.3 GB.
  2. Without -9 flag i.e. Default Compression the output file is of 3.6 GB.

The Original file is of size 3.6 GB so, I think high compression should not be used.

But still the same error throws by Odin.

Any suggestion why it is happening?


Solution

  • Use This:

    lz4 -B6 --content-size in.img out.img.lz4
    

    For More Info: https://www.mankier.com/1/lz4

    Found this solution from: https://forum.xda-developers.com/galaxy-s9/help/how-to-compress-samsung-images-lz4-t3844760