User Tools

Site Tools


hardware:mobile_devices:nexus_5x

Nexus 5X Phone

The Nexus 5X a.k.a. bullhead is a mobile phone with an arm64 CPU and 2G/3G/4G cellular.

Product name: bullhead

Variant: bullhead LG-H790 32GB

Special boot mode: With the device powered off, hold Volume Down + Power.

Android versions:

Operating systems available:

  • LineageOS (worked with micro GApps) - This seems to be the best choice in my opinion.
  • /e/ OS (worked with micro GApps) - A further modified downstream version of LineageOS with more privacy features. This installed and worked OK. They sell phones with the OS already on it too.
  • MaruOS (worked with pico GApps) - This installed OK, but I couldn't get the Mate X desktop to work when connecting HDMI.
  • Kali NetHunter (Couldn't get to work, “Please complete the Android setup wizard before installing”
  • Android full OTA factory ROM - For example, the last 8.1 factory image and drivers: https://developers.google.com/android/drivers#bullheadopm7.181205.001
  • PostmarketOS (Long build process, haven't tried.)

Flashing a custom recovery

Download a recovery image from https://dl.twrp.me/bullhead/.

When the custom recovery is installed, you can plug the phone into the computer over USB and power it on while holding the volume-down button. This will load it into the simple bootloader where you can press down twice and enter “Recovery” mode which will then enter the TWRP recovery program. TWRP allows you to backup things, install new operating systems, etc.

The other way to boot into the bootloader menu is to plug the phone in to the computer and use adb to run adb reboot bootloader which will restart to the boot menu asking if you want to boot normally or boot into recovery image. In order for this to work you might have to turn on USB debugging by going into the Android menu to Settings | System | About and tap Build Number seven times, then go back to Developer Options and turn on USB debugging.

# Restart phone to the boot menu (fastboot)
adb reboot bootloader
# Alternatively, power on while holding volume-down

Once it is in this bootloader menu and the phone is plugged into the PC, you can run fastboot devices and it should show up as fastboot in the list. You might need to use sudo to run fastboot from Android SDK tools (likely ~/Android/Sdk/platform-tools/fastboot).

# Verify it's got connection and you can see it
fastboot devices

If you need to unlock it use fastboot flashing unlock. It will simply decline if you have already unlocked and tell you it's already unlocked.

fastboot flashing unlock

From here, you can run fastboot flash recovery twrp-3.5.1_9-0-bullhead.img and it will install the TeamWin - TWRP recovery image.

# Download latest from https://twrp.me/lg/lgnexus5x.html
wget "https://dl.twrp.me/bullhead/twrp-3.5.1_9-0-bullhead.img"
fastboot flash recovery twrp-3.5.1_9-0-bullhead.img

If all goes well, reboot manually while holding volume-down or use fastboot to reload into bootloader.

# Power off and power on while holding volume-down or use fastboot
fastboot reboot bootloader

Then in the bootloader menu, press volume-down twice and then the power button once to enter into Recovery mode, which should now be the latest TWRP that we just flashed.

## Wiping and formatting

In TWRP, if you want to wipe, doing a “default wipe” will wipe Data, Cache, and Dalvik Cache. This will reset the OS back to a fresh install, but it will leave the OS there. It will greet you as if it was the first boot and have you setup the first user.

If you want to wipe the OS too, choose Advanced Wipe, then choose Dalvik, Data, and Cache from the default wipe and then also add in System. Leave Internal Storage unchecked if you want to keep /data/media/ and /sdcard/ which is where you might have some OS/GApp install files you want to re-use. If you had any pictures, those will remain if you leave Internal Storage unchecked. There will be no OS after wiping System so it will just hang if you try to boot into the system. You can only boot into the bootloader(fastboot) or recovery mode.

If you don't care about the internal storage and you want to do a total wipe, check all boxes.

If you want to completely wipe everything, use the format option. This will remove any encryption and be the most complete wipe.

Build LineageOS

You can download a pre-built ROM at https://lineageosroms.com/bullhead/, or you can build your own. The download was not working for me so I had to build my own.

Full build instructions at https://wiki.lineageos.org/devices/bullhead/build.

Install some dependencies on Debian first:

sudo apt install -y bc bison build-essential ccache curl \
  flex g++-multilib gcc-multilib git gnupg gperf imagemagick \
  lib32ncurses5-dev lib32readline-dev lib32z1-dev liblz4-tool \
  libncurses5 libncurses5-dev libsdl1.2-dev libssl-dev libxml2 \
  libxml2-utils lzop pngcrush rsync schedtool squashfs-tools \
  xsltproc zip zlib1g-dev openjdk-11-jdk
 
# And Java JDK. I'm using 11. ''openjdk-11-jdk''.
# If you need to download Java, visit [[https://adoptopenjdk.net/]].
# If you need to: ''update-alternatives java''

And the steps I took for building:

nexus_5x_lineageos_build_steps.txt
mkdir ~/lineage_build; cd ~/lineage_build
mkdir bin; mkdir -p android/lineage
curl https://storage.googleapis.com/git-repo-downloads/repo > bin/repo
chmod +x bin/repo
export PATH=$PATH:$(pwd)/bin
export USE_CCACHE=1
export CCACHE_EXEC=/usr/bin/ccache
# Set cache size to 50GB. Add into bashrc/zshrc: `ccache -M 50G` or just run it once.
export ANDROID_JACK_VM_ARGS="-Dfile.encoding=UTF-8 -XX:+TieredCompilation -Xmx4G"
 
git config --global user.email nanodano@devdungeon.com; git config --global user.name "John Leon"
 
cd android/lineage
repo init -u https://github.com/LineageOS/android.git -b lineage-15.1
repo sync  # then wait
 
source build/envsetup.sh
breakfast bullhead  # Download Nexus 5X device specific config
 
# This threw some makefile errors, I used the Binary Driver downloads from Google official and extracted and ran the `extract.sh` file it came with inside the `lineage_build/android/lineage` directory, and it stuffed more stuff into the `vendor/` directory.
# Then reran `breakfast bullhead`
# Then got no errors.
 
croot
brunch bullhead
# It complained I did not have Java 1.8 then it complained I didn't have an OpenJDK version
# I had to download a prebuild openJDK 8 version from
# https://adoptopenjdk.net/?variant=openjdk8&jvmVariant=hotspot
# Then re-running `brunch bullhead` worked.
 
cd $OUT
 
ls lineage-15.1-*-UNOFFICIAL-bullhead.zip
ls recovery.img
 
# Then install the .zip
# I chose not to install the recovery img and leave TWRP.
 
 
# I then downloaded GApps from https://wiki.lineageos.org/gapps.html
# https://opengapps.org/?api=8.1&variant=nano
# Then move that zip over to the phone, and install it using TWRP recovery mode.
# It didn't work, but I read the micro version instead of nano works. Trying that.
# I also downloaded the su tool for 15.1 https://download.lineageos.org/extras
# https://mirrorbits.lineageos.org/su/20190709/addonsu-15.1-arm64-signed.zip
# Wiped, formatted, queued up those 3 zips (lineage os, gapps, su).
# Doing all three of these worked!! I bet this is what I needed for /e/ os and Maru OS too.

## NanoDroid instead of GApps

NOTE: Instead of using GApps which still comes with Google things like a personal Advertising ID and Google sync, try [https://github.com/Nanolx/NanoDroid](https://github.com/Nanolx/NanoDroid). I downloaded [https://downloads.nanolx.org/NanoDroid/Stable/NanoDroid-23.1.2.20210117.zip](https://downloads.nanolx.org/NanoDroid/Stable/NanoDroid-23.1.2.20210117.zip) from [https://downloads.nanolx.org/NanoDroid/Stable/](https://downloads.nanolx.org/NanoDroid/Stable/) and it had a ton of apps on it including basics like an alarm, file browser, calendar, media player, etc. You should install F-Droid so you can download apps. Here are a few apps I'd recommend with F-Droid as a package manager.

Install an OS using TWRP recovery

You can wipe the whole disk first if you want. Boot into the TWRP recovery app (see previous section), and then choose `Wipe` and then do Advanced Options and wipe everything there too. Then go back to the main menu and chose Reboot | Recovery.

You'll need a ZIP of an OS to install. Either follow the steps for building LineageOS or download the pre-built MaruOS.

To install, you have two options:

  • Copy the ZIP to the device. You can put it on an SD card, or you can connect the phone to a PC while it's in recovery mode, and then copy the zip to the phone's internal storage. Then in the recovery app you can choose Install and find the zip on the filesystem.
  • Use ADB sideloading. In the TWRP recovery app, choose `Advanced | ADB Sideload`. Then the phone will sit and wait for you to use `adb` on the computer to push something. You can press cancel if you're not ready.

DONT FORGET: You need to also install the Open GApps to get things to work. I needed to get the arm64 8.1 pico version, but if one version doesn't work try another (pico/nano/micro/etc). Install these when you install the OS, before first boot.

Alternatively, instead of using GApps use NanoDroid. AuroraStore was the only one that kept crashing.

References

hardware/mobile_devices/nexus_5x.txt · Last modified: 2021/04/06 00:52 by nanodano