Comprehensive Guide for Setting Up and Using TIK Tool on Debian WSL

Posted on Sep 4, 2024

This guide provides a detailed, step-by-step process for setting up Debian on Windows Subsystem for Linux (WSL), installing necessary tools, and using the TIK tool for ROM modification.

Setting Up Debian on WSL

  1. Install Debian from Microsoft Store:

    • Open the Microsoft Store and install Debian: Click Here
  2. Set Up Username and Password:

    • After installation, open Debian and set up your username and password.
  3. Update and Install Necessary Packages:

    • Run the following commands to update and install necessary packages:
       sudo apt-get update
       sudo apt dist-upgrade
       sudo apt install -y man-db wget curl python3 python3-pip python3-tk git zip android-sdk-libsparse-utils
      

Setting Up TIK Tool

  1. Clone the TIK Tool Repository:

    • Clone the TIK tool repository from GitHub:
       git clone https://github.com/AbhiTheModder/TIK_en.git TIK && cd TIK
      
  2. Build the TIK Tool:

    • I use uv to build the tool:
       uv run build.py
      
    • Alternatively, you can use python3 build.py.
  3. Set Executable Permissions:

    • Run the ls command to check if the run and LICENSE files are in green. If not, set executable permissions:
       chmod a+x ./*
      
  4. Move ROM File to TIK Directory:

    • Copy your ROM file from Windows to the TIK directory in WSL. For example, if your username is abhi, copy the ROM from the Pictures folder to the TIK folder:
       cp /mnt/c/Users/abhi/Pictures/your_rom.zip ~/TIK/
      
  5. Run the TIK Tool:

    • Execute the TIK tool:
       ./run
      

Using the TIK Tool

  1. Select Option to Unpack ROM:

    • Choose option 55 to unpack the ROM. Ensure your ROM zip is in the TIK directory:
       ~/TIK$ ls
       bin  LICENSE  run  your_rom.zip
      
  2. Select ROM from List:

    • Choose the ROM from the list and press Enter:
       >ROM List
       Please place the ROM in /home/abhi/TIK!
       [1]- your_rom.zip
       --------------------------------------------------
       Please enter the corresponding serial number:1
      
  3. Name Your Project:

    • Optionally, name your project:
       Please enter the project name (can be left blank):My_Project
      
  4. Unpack the ROM:

    • The tool will start unpacking the ROM. Be patient as this may take some time.
  5. Unpack All Files:

    • When prompted, enter 0 to skip unpacking all files:
       >Project Menu
       Project:My_Project(Incomplete)
       0> Return to Home      2> Unpack Menu
       3> Pack Menu      4> Plugin Menu
       5> One-Click Packaging     6> Custom Features
       Please enter the number:
      
  6. Exit the TIK Tool:

    • Press Ctrl+D to exit the TIK tool. Ignore any errors if they appear.
  7. Merge Super Images:

    • Copy the super images to the project directory:
       cp My_Project/your_rom/images/super.img.* ./My_Project/
      
  8. Verify Copied Files:

    • Verify the files are copied correctly:
       ~/TIK$ ls My_Project/
       super.img.0  super.img.5  super.img.10
       super.img.1  super.img.6  TI_out
       super.img.2  super.img.7  your_rom
       super.img.3  super.img.8
       super.img.4  super.img.9
      
  9. Merge Super Images:

    • Run the TIK tool again and select your project. Choose 6> Custom Features and then 4> Merge *sparsechunk*:
       >Custom Menu
       Project:My_Project
       0> Return to Previous  1> Magisk Patch
       2> Remove avb   3> Remove data encryption
       4> Merge *sparsechunk*
       Please enter the number: 4
      
  10. Move and Unpack Super Image:

    • Move the super.img to the project directory and unpack it:
       mv My_Project/TI_out/super.img  My_Project/
      
  11. Unpack All Images:

    • Choose to unpack all images:
       Please place files in the root directory of /home/abhi/TIK/My_Project!
       [0]- Decompose all files
       [Img] Files
       [1]- system_ext_a.img <EROFS>
       [2]- vendor_a.img <EROFS>
       [3]- odm_a.img <EROFS>
       [4]- super.img <EROFS>
       [5]- system_a.img <EROFS>
       [7]- mi_ext_a.img <EROFS>
       [8]- vendor_dlkm_a.img <EROFS>
       [9]- product_a.img <EROFS>
       [00] Return  [77] Loop Unpack
       --------------------------------------
       Please enter the corresponding serial number:77 # 77 to loop unpack
       Unpack all files? [1/0]0
       Unpack system_ext_a.img? [1/0]0
       Unpack vendor_a.img? [1/0]0
       Unpack odm_a.img? [1/0]0
       Unpack super.img? [1/0]0
       Unpack system_a.img? [1/0]0
       Unpack mi_ext_a.img? [1/0]0
       Unpack vendor_dlkm_a.img? [1/0]0
       Unpack product_a.img? [1/0]1 # Select the image you want to unpack
       [18:56:25][img] Unpacking product_a.img...
       [18:56:25][erofs] Unpacking product_a.img...
       Extract: Starting...
       Extract: fs_config|file_contexts|fs_options  saving...
       Extract: fs_config|file_contexts|fs_options  done.
       Extract: [ 100.00% ]
       Extract: The operation took: 20.461 second(s).
       Press any button to continue
      
  12. Modify and Repack Images:

    • Modify the unpacked images as needed and repack them:
       >Pack
       [0]- Pack all images
       [1]- product_a <erofs>
       [55] Loop Pack [66] Pack Super [77] Pack Payload [00] Return
       --------------------------------------
       Please enter the corresponding serial number:1
       Manually pack all partition formats as: [1] ext4 [2] erofs [3] f2fs:2
       Output all file formats [1] br [2] dat [3] img:3
       [19:03:28]Packing product_a
       The size you set is too small, and the size will be adjusted dynamically!
       Multiple:1.1258
       FsPatcher: Load origin 1356 entries
       Add [product_a['0', '0', '0755']]
       Add [/lost+found['0', '0', '0755']]
       Add [/product_a/lost+found['0', '0', '0755']]
       Add [/product_a/['0', '0', '0755']]
       FsPatcher: Add 4 entries
       No need to handle
       No need to handle
       mkfs.erofs 1.7.1-g64fa6832
       loaded 1358 fs_config entries
      
  13. Repack Super Image:

    • Move all unpacked images to the super folder and repack the super image:
       mv My_Project/TI_out/super.img  My_Project/
      
      Then run the tool again and choose to repack the super image from Pack menu:
       >Pack
       [0]- Pack all images
       [1]- product_a <erofs>
       [55] Loop Pack [66] Pack Super [77] Pack Payload [00] Return
       --------------------------------------
       Please enter the corresponding serial number:66
       Please place the partition images to be packed in /home/abhi/TIK/My_Project/super!
       Please enter the Super type: [1]A_only [2]AB [3]V-AB-->2
       Set partitions as read-only? [1/0]0
       Pack as sparse image? [1/0]1
       Please set the Super.img size:[1]9126805504 [2]10200547328 [3]16106127360 [4]Tool Recommended:  6979321856 [5]Custom4
       [19:14:24]Packing to TI_out/super.img...
       Added partition:system_ext
       Added partition:vendor
       Added partition:odm
       Added partition:system
       Added partition:mi_ext
       Added partition:vendor_dlkm
       Added partition:product
       09-04 19:14:24.878  9811  9811 I lpmake  : builder.cpp:1093 [liblp] Partition system_ext_a will resize  from 0 bytes to 529293312 bytes
       09-04 19:14:24.879  9811  9811 I lpmake  : builder.cpp:1093 [liblp] Partition vendor_a will resize from  0 bytes to 795885568 bytes
       09-04 19:14:24.879  9811  9811 I lpmake  : builder.cpp:1093 [liblp] Partition odm_a will resize from 0  bytes to 843776 bytes
       09-04 19:14:24.879  9811  9811 I lpmake  : builder.cpp:1093 [liblp] Partition system_a will resize from  0 bytes to 632598528 bytes
       09-04 19:14:24.879  9811  9811 I lpmake  : builder.cpp:1093 [liblp] Partition mi_ext_a will resize from  0 bytes to 12288 bytes
       09-04 19:14:24.879  9811  9811 I lpmake  : builder.cpp:1093 [liblp] Partition vendor_dlkm_a will resize  from 0 bytes to 32960512 bytes
       09-04 19:14:24.879  9811  9811 I lpmake  : builder.cpp:1093 [liblp] Partition product_a will resize  from 0 bytes to 3182952448 bytes
       [19:14:36]Successfully created super.img!
       Press any button to continue
      
  14. Flash ROM:

    • Put your super.img file into the unpacked ROM folder, modify the flash scripts since our original rom had multiple super image files you’ll find many lines for the flashing of them so remove them and just keep 1 line for the super.img.
    • Now flash the ROM using the flash script.
    • ⚠️ Warning: Flashing the wrong image to the wrong partition can brick your device. Always double-check your commands and file paths.
    • 💡 Tip: If you encounter any issues during the flashing process, consider using a tool like OrangeFox Recovery or TWRP
    • 📝 Note: After flashing, your device may take some time to boot up. Be patient and allow it to complete the process.
    • 🎉 Congratulations: If everything goes well, you have successfully flashed a custom ROM on your device. Enjoy your new setup!

This guide provides a comprehensive and professional approach to setting up and using the TIK tool on Debian WSL. By following these steps, users can efficiently modify and repack ROMs for their devices.