{"id":1559,"date":"2017-01-01T23:21:59","date_gmt":"2017-01-02T03:21:59","guid":{"rendered":"https:\/\/lowtek.ca\/roo\/?p=1559"},"modified":"2017-01-01T23:21:59","modified_gmt":"2017-01-02T03:21:59","slug":"installing-custom-firmware-on-nexus-5","status":"publish","type":"post","link":"https:\/\/lowtek.ca\/roo\/2017\/installing-custom-firmware-on-nexus-5\/","title":{"rendered":"Installing custom firmware on Nexus 5"},"content":{"rendered":"<p>Until very recently the phone in my pocket was\u00a0a <a href=\"https:\/\/en.wikipedia.org\/wiki\/Nexus_4\">Nexus 4<\/a> that I bought used 2+ years ago, it&#8217;s seen a couple of battery changes and a full brain transplant (motherboard) swap. \u00a0It&#8217;s running Android <a href=\"https:\/\/en.wikipedia.org\/wiki\/Android_Marshmallow\">Marshmallow<\/a>, but there is a <a href=\"https:\/\/en.wikipedia.org\/wiki\/Android_Nougat\">Nougat<\/a> version available &#8211; so it still feels current. Phones feel like they&#8217;ve hit the same plateau that computers have, sure there are newer and faster models &#8212; but for most needs models a couple of years old are just fine.<\/p>\n<p>The <a href=\"https:\/\/en.wikipedia.org\/wiki\/Nexus_5\">Nexus 5<\/a> hit my magic price point of ~$160 on the used market, even for the 32Gb version &#8211; making it too tempting an upgrade for me to pass on. The <a href=\"https:\/\/developers.google.com\/android\/images#hammerhead\">stock firmware<\/a> only offers 6.01 (Marshmallow) but the Nexus 5 is still a well supported device in the custom ROM space. I&#8217;m a big fan of <a href=\"https:\/\/en.wikipedia.org\/wiki\/CyanogenMod\">CyanogenMod<\/a> but that&#8217;s come to a fairly <a href=\"http:\/\/lifehacker.com\/cyanogenmod-is-dead-and-its-successor-is-lineage-os-1790554964\">spectacular end<\/a> recently. I&#8217;m eagerly waiting for it&#8217;s successor <a href=\"http:\/\/lineageos.org\/\">LineageOS<\/a> to get their infrastructure in place and regular builds happening.<\/p>\n<p>Installing custom firmware on the Nexus 5 is similar to any well supported Nexus device, Google really did a good thing allowing the hardware to be friendly to developers. Read on for the detailed steps.<\/p>\n<p><!--more--><\/p>\n<p>Two key references: <a href=\"http:\/\/web.archive.org\/web\/20161224193406\/https:\/\/wiki.cyanogenmod.org\/w\/Hammerhead_Info\">The CM details on the phone (hammerhead)<\/a>\u00a0and <a href=\"http:\/\/web.archive.org\/web\/20161224205206\/https:\/\/wiki.cyanogenmod.org\/w\/Install_CM_for_hammerhead\">the CM install instructions for hammerhead<\/a>\u00a0&#8211; and thank goodness for <a href=\"https:\/\/archive.org\/\">archive.org<\/a>\u00a0helping preserve the internet.<\/p>\n<p>We&#8217;ll assume that this phone is fully stock, and the bootloader is still locked. Also, that you&#8217;re computer is running <a href=\"https:\/\/www.ubuntu.com\/\">Ubuntu<\/a> (16.04).<\/p>\n<p>To start, we need to get the phone into the bootloader (fastboot mode).\u00a0<span class=\"s1\">Hold down power button and volume down button until we get to the bootloader screen. [yes, the picture shows the unlocked state &#8211; it was taken after we did these steps]<\/span><\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter wp-image-1562 size-medium\" src=\"https:\/\/lowtek.ca\/roo\/wp-content\/uploads\/2017\/01\/IMG_3160-e1483326565124-314x500.jpg\" width=\"314\" height=\"500\" \/><\/p>\n<p>On your Ubuntu machine, you need to install the fastboot tools.<\/p>\n<pre class=\"lang:default decode:true \">$ sudo apt-get install fastboot<\/pre>\n<p>Plug your phone into the Ubuntu machine, and issue the following command to unlock the bootloader.<\/p>\n<pre class=\"lang:default decode:true \">$ sudo fastboot oem unlock<\/pre>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter wp-image-1563 size-medium\" src=\"https:\/\/lowtek.ca\/roo\/wp-content\/uploads\/2017\/01\/IMG_3159-e1483326606389-299x500.jpg\" width=\"299\" height=\"500\" \/><\/p>\n<p class=\"p1\">Now that the bootloader is unlocked, we can install a recovery image. I like <a href=\"https:\/\/twrp.me\/\">TWRP<\/a>, so we&#8217;ll get the version of that for <a href=\"https:\/\/twrp.me\/devices\/lgnexus5.html\">hammerhead<\/a> and install that. Always verify the digital signature of the download, it&#8217;s easy and avoids hard to diagnose issues. Installing is done from the Ubuntu machine using fastboot.<\/p>\n<pre class=\"lang:default decode:true\">$ sudo fastboot flash recovery twrp-3.0.2-0-hammerhead.img\r\n\r\ntarget reported max download size of 1073741824 bytes\r\nsending 'recovery' (14524 KB)...\r\nOKAY [  0.798s]\r\nwriting 'recovery'...\r\nOKAY [  1.119s]\r\nfinished. total time: 1.917s<\/pre>\n<p>At this point I took a mis-step, or something went sideways. You can skip this section (bullets)\u00a0but I&#8217;ll still document what I did.<\/p>\n<ul>\n<li>Now use the volume keys to &#8216;Restart Bootloader&#8217;<\/li>\n<li>Once it reboots, now pick &#8216;Recovery mode&#8217;<\/li>\n<li>This should boot us into TWRP &#8211; but no.. I&#8217;m in a boot loop while it tries to run Open Recovery script?<\/li>\n<li>Well.. tried again. Hold power &amp; volume down until we get the bootloader screen.<\/li>\n<li>Re-install the\u00a0TWRP recovery with fastboot<\/li>\n<\/ul>\n<p class=\"p1\"><span class=\"s1\">What I should have done was\u00a0immediately enter &#8216;Recovery mode&#8217; &#8212; which I did and I&#8217;m good to go.<\/span><\/p>\n<p class=\"p1\">In TWRP &#8211; under &#8216;Wipe&#8217; choose &#8216;Format Data&#8217; to create a working filesystem. This will allow us to copy the custom ROM onto the phone for installation.<\/p>\n<p class=\"p1\"><span class=\"s1\">Now we can mount the phone as a filesystem on the Ubuntu machine\u00a0and copy over the custom ROM. \u00a0In my case it was \u00a0CyanogenMod 14.1 \u00a0+ <a href=\"http:\/\/opengapps.org\/\">gapps (nano)<\/a>. Once you&#8217;ve copied the files over (and did I mention verifying the checksums on the files is a good idea?) we can use TWRP to install the files. Install the ROM first, then the gapps package.<\/span><\/p>\n<p class=\"p1\"><span class=\"s1\">All should go well, now on TWRP pick &#8220;Reboot&#8221; and pick &#8220;System&#8221; and after a while, you should be in a new\u00a0custom ROM.<\/span><\/p>\n<p class=\"p1\">Along the way I discovered that you can <a href=\"http:\/\/android.stackexchange.com\/questions\/58410\/how-to-re-lock-android-bootloader\">relock the bootloader<\/a>\u00a0&#8211; cool. I wouldn&#8217;t expect this to work with any system modifications, but if you wanted to go back to fully stock, this is a nice feature.<\/p>\n<pre class=\"lang:default decode:true \">$ sudo fastboot oem lock<\/pre>\n<p>&nbsp;<\/p>\n<p class=\"p1\">\n","protected":false},"excerpt":{"rendered":"<p>Until very recently the phone in my pocket was\u00a0a Nexus 4 that I bought used 2+ years ago, it&#8217;s seen a couple of battery changes and a full brain transplant (motherboard) swap. \u00a0It&#8217;s running Android Marshmallow, but there is a Nougat version available &#8211; so it still feels current. Phones feel like they&#8217;ve hit the &hellip; <a href=\"https:\/\/lowtek.ca\/roo\/2017\/installing-custom-firmware-on-nexus-5\/\" class=\"more-link\">Continue reading<span class=\"screen-reader-text\"> &#8220;Installing custom firmware on Nexus 5&#8221;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[17,12],"tags":[],"class_list":["post-1559","post","type-post","status-publish","format-standard","hentry","category-android","category-how-to"],"_links":{"self":[{"href":"https:\/\/lowtek.ca\/roo\/wp-json\/wp\/v2\/posts\/1559","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/lowtek.ca\/roo\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/lowtek.ca\/roo\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/lowtek.ca\/roo\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/lowtek.ca\/roo\/wp-json\/wp\/v2\/comments?post=1559"}],"version-history":[{"count":3,"href":"https:\/\/lowtek.ca\/roo\/wp-json\/wp\/v2\/posts\/1559\/revisions"}],"predecessor-version":[{"id":1565,"href":"https:\/\/lowtek.ca\/roo\/wp-json\/wp\/v2\/posts\/1559\/revisions\/1565"}],"wp:attachment":[{"href":"https:\/\/lowtek.ca\/roo\/wp-json\/wp\/v2\/media?parent=1559"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/lowtek.ca\/roo\/wp-json\/wp\/v2\/categories?post=1559"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/lowtek.ca\/roo\/wp-json\/wp\/v2\/tags?post=1559"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}