How to install a custom ROM (Lineage OS) on your Xiaomi 4x Phone

Out of the box, your Xiaomi Redmi 4X codenamed:santoni comes out of the box with Android 6.0.1 (Marshmallow), upgradable to 7.1.2 (Nougat); MIUI 10 with no option to use an SD card as additional internal storage. You can put your pictures, videos and other files but you cannot install those gigabits of mobile games into it! So with the release of android 8 and 9 you can now use your SD card as if it's an internal storage.
In this tutorial I will guide you in installing Lineage OS that is based on Android 8 Oreo.

Before you can install a custom ROM on your Xiaomi Redmi 4x the device's bootloader should be unlocked, if not then follow this;

Unlocking the bootloader

  1. Visit Xiaomi’s official unlocking website and apply for unlocking permissions. (I just tole them I want to install Oreo on my phone)
  2. Wait until you get the approval, which may take some days. (Mine took just an hour)
  3. At the same time, link the device to your Mi account in Settings > Additional settings > Developer options > Mi Unlock status. This step is mandatory and will trigger a countdown of 360 hours, the waiting period before a device can be unlocked.
  4. Once you get the approval, visit the website again and you will be redirected to the Mi Unlock app download page.
  5. Download the Mi Unlock app (Windows is required to run the app).
  6. Once the 360 hours waiting period is over, run the Mi Unlock app and follow the instructions provided by the app.
  7. After device and Mi account are successfully verified, the bootloader should be unlocked.
  8. Since the device resets completely, you will need to re-enable USB debugging to continue.



What we need:

If this is your first time installing this then you need to download and install (adb) and Fastboot. ADB or android debug bridge is like the driver so your phone would be recognized by the computer while fastboot is like the bios where you would be sideloading the ROM.

The following instructions below are from https://wiki.lineageos.org/adb_fastboot_guide.html
I intentionally changed the path so it would be much easier.

Installing adb and fastboot

Google hosts zips including only adb and fastboot. You can set these up for use with the instructions below.

On Windows

  1. Download the Windows zip from Google.
  2. Extract it somewhere - for example, c:\Xiaomi\ad-fastboot
  3. On Windows 7/8:
    • From the desktop, right-click My Computer and select Properties
    • In the System Properties window, click on the Advanced tab
    • In the Advanced section, click the Environment Variables button
    • In the Environment Variables window, highlight the Path variable in the Systems Variable section and click the Edit button
    • Append c:\Xiaomi\ad-fastboot to the end of the existing Path definition (the semi-colon separates each path entry)
  4. On Windows 10:
    • Open the Start menu, and type “advanced system settings”
    • Select “View advanced system settings”
    • Click on the Advanced tab
    • Open the “Environment Variables” window
    • Select the Path variable under “System Variables” and click the “Edit” button
    • Click the “Edit Text” button
    • Append c:\Xiaomi\ad-fastboot to the end of the existing Path definition (the semi-colon separates each path entry)
  5. Install the universal adb driver, and reboot.

On macOS

  1. Download the macOS zip from Google.
  2. Extract it somewhere - for example, ~/adb-fastboot.
  3. Add the following to ~/.bash_profile:
    if [ -d "$HOME/adb-fastboot/platform-tools" ] ; then
     export PATH="$HOME/adb-fastboot/platform-tools:$PATH"
    fi
    
  4. Log out and back in.

On Linux

  1. Download the Linux zip from Google.
  2. Extract it somewhere - for example, ~/adb-fastboot.
  3. Add the following to ~/.profile:
    if [ -d "$HOME/adb-fastboot/platform-tools" ] ; then
     export PATH="$HOME/adb-fastboot/platform-tools:$PATH"
    fi
    
  4. Log out and back in.
  5. You may also need to set up udev rules: see this repository for more info.

  • adb shell - launches a shell on the device
  • adb push  - pushes the file  to 
  • adb pull [] - pulls the file  to . If  isn’t specified, it will pull to the current folder.
  • adb logcat - allows you to view the device log in real-time. You can use adb logcat -b radio to view radio logs, and adb logcat -C to view logs in colour
  • adb install  - installs the given .apk file to your device

Preparing the phone

Enable USB Debugging on your phone. 

To use adb with your device, you’ll need to enable developer options and USB debugging:
  1. Open Settings, and select “About”.
  2. Tap on “Build number” seven times.
  3. Go back, and select “Developer options”.
  4. Scroll down, and check the “Android debugging” entry under “Debugging”.
  5. Plug your device into your computer.
  6. On the computer, open up a terminal/command prompt and type adb devices.
  7. A dialog should show on your device, asking you to allow usb debugging. Check “always allow”, and choose “OK”.
Congratulations! adb is now ready to use with your device.

Setting up fastboot

Using fastboot (if your device supports it) should simply involve rebooting to fastboot mode. While in fastboot mode, you can type fastboot devices to verify that your device is being detected.

Installing a custom recovery using fastboot

  1. Download a custom recovery - you can download TWRP. Simply download the latest recovery file, named something like twrp-x.x.x-x-santoni.img. and put it in your c:\Xiaomi folder
  2. Connect your device to your PC via USB.
  3. On the computer, open a command prompt (on Windows) or terminal (on Linux or macOS) window, and type:
    adb reboot bootloader
    
    You can also boot into fastboot mode via a key combination:
    • With the device powered off, hold Volume Down + Power. Keep holding both buttons until the word “FASTBOOT” appears on the screen, then release.
  4. Once the device is in fastboot mode, verify your PC finds it by typing:
    fastboot devices
    
  5. Flash recovery onto your device:
  6. fastboot flash recovery twrp-x.x.x-x-santoni.img
    
  7. Now reboot into recovery to verify the installation:
    • With the device powered off, hold Volume Up + Volume Down + Power.

Installing LineageOS from recovery

  1. Download the LineageOS install package that you’d like to install or build the package yourself.
    • Optionally, download additional application packages such as Google Apps (use the arm64 architecture). I personally used Pico as the variant and put the files in your c:\Xiaomi folder.
  2. If your device isn’t already booted into recovery, do so:
    • With the device powered off, hold Volume Up + Volume Down + Power.
  3. (Optional, but recommended): Tap the Backup button to create a backup. Make sure the backup is created in the external sd card or copy it onto your computer as the internal storage will be formatted later in this process.
  4. Go back to return to the main menu, then tap Wipe.
  5. Now tap Format Data and continue with the formatting process. This will remove encryption as well as delete all files stored on the internal storage.
  6. Return to the previous menu and tap Advanced Wipe.
  7. Select the Cache and System partitions to be wiped and then Swipe to Wipe.
  8. Sideload the LineageOS .zip package:
    • On the device, select “Advanced”, “ADB Sideload”, then swipe to begin sideload.
    • On the host machine, sideload the package using: adb sideload filename.zip
  9. (Optional): Install any additional packages using the same method.
  10. (Optional): Root the device by installing the LineageOS SU Addon (use the arm64 package) or using any other method you prefer.
  11. Once the installation has finished, return to the main menu, tap Reboot, and then System.
Instructions are copied and edited from https://wiki.lineageos.org/devices/santoni/install

Comments