Friday, November 16, 2018

fix Nexus 6p bootloop, the right way, you bastard

If your 6p is bootlooping, you have a two options - either (1) search the internet for hours, reading multiple conflicting guides and trying solutions that put your phone deeper in the hole, or (2) read this.

(The 6p bootloop (aka "Bootloop of Death", or BLOD), in case your search is just starting out and you aren't quite sure how to refer to your phone's problem, is when the phone shuts down randomly, then shows the early-boot "Google" logo on a black background for ~10 seconds, then you get one second of black screen, and then "Google" comes back, and this repeats endlessly.  You can't shut it down, you can't do shit but watch it cycle as it drains your device of life.)

The overview of what's below: find the bootloader that your phone needs, manually modify the files so that the performance cores (4-7) are disabled, only leaving you with the lightweight cores (0-3), and upload the new bootloader files to your phone.  Idk if this keeps working through an OTA update or not, but it's a pretty easy process once you get the hang of it.

Also, this guide is for a linux host - everything should be almost the same for windows and mac, but the commands are slightly different and you have to download different versions of host tools.

Here's the future-proof-ish way to fix your goddam phone:
  1. Get the latest "platform-tools".  Or at least get this one, it worked for me.
  2. Unzip that shit and cd into the new dir it created, hereafter referred to as ~/Downloads/platform-tools.
  3. Boot your piece of shit brickphone into the recovery menu by holding the power and "volume down" buttons for what feels like an eternity.  Seriously, when the 6p is bootlooping, it can take like 20 seconds.  Don't let up until you get into a strange and magical menu you've either (1) never seen before, or (2) you have seen before and can identify as the fucking recovery menu.

    Or, if the handset can still boot to android, and it has, and you're in ~/Downloads/platform-tools, you can run:

    ./adb reboot bootloader

    This adb command will only work if, on your phone, you've previously gone into Settings -> System -> About Phone, scrolled to the bottom, and tapped "Build number" about a thousand times, and then gone into Settings -> System -> Developer options and enabled "USB debugging".

    But the fucking point is to get to the recovery menu. 
  4. Make sure your PC can talk to your phone.  Plug the phone into the PC.  On your linux PC, with pwd inside the unzipped platform-tools dir, run this:

    ./fastboot devices

    If that spits out nothing, then either your phone is totally fucked or you've done something dumb and you need to go back to step 3 and actually make sure you're booted into the recovery menu.  If it spits out one (or more! who knows what the future holds for ./fastboot devices!) line of stuff, then proceed.
  5. Unlock the bootloader.  THIS WILL WIPE ALL YOUR DATA, but you have to fucking do it man.  Just do it, c'mon.

    ./fastboot flashing unlock

    Now your user data is toast - hope you backed up all the important shit, like the photos of your cat and the food you ate.  You'll have to factory reset at some point after this, though I'm skipping the pain steps I went through here for your fucking benefit so I don't know when that reset will be forced upon you exactly.

    (Whenever your pattern or unlock code or whatever doesn't work, that's when you need to start googling how to do the factory data reset.  It doesn't affect anything else, in this guide we're modifying the boot partitions.  If you've read this far you can branch off and figure out that one discrete step whenever it's time.  Sorry.)
  6. Now you need to get the most recent bootloader for this ancient handset.  This is the site where they're all available, and this is the direct link to the current one that worked for my Project Fi 6p as of 2018/11/16.  Stay frosty yokels, this is a ~1GB download.

    You aren't sure which one is the right one to download!  So if you're reading this too long after publication, you should probably scroll to the bottom of the 6p downloads in that first link and grab the most recent, if your phone is up to date.  If you're on the cutting edge of sarcastic linux blogging and you read this soon after I wrote it, or if there aren't any more updates for the 6p at all after this point, then you might be good with the second link above.  Otherwise, who knows!  Any of those downloads could be the right one!  You'll just have to try flashing a bunch and figure out which one allows your phone to boot!  (Or find some way to determine which you need, which sadly is outside the scope of this "article".)  Sorry I'm such a shit.  But don't worry, if you follow these instructions and your phone won't boot, all you have to do is flash the right bootloader to fix it.

    Note also that you'll have to unzip the inner zipfile (something like inside the downloaded angler zipfile to get to the actual file you're really after here, which in this case is boot.img.  
  7. We're going to be manually patching this pile of garbage, so we need a utility that can unpack and repack android boot images.  It's called AIK (Android Image Kitchen), get the version I used here.  Untar it, blah blah blah, sorry again.  Something like tar xvf AIK-Linux-whatever.tar.gz.  The place where all this lives is hereafter referred to as ~/Downloads/AIK-Linuxcd into it now.
  8. Ok, the scallops are minced and the lettuce is browned and we have a fresh liter of chili powder on standby - time to cook!
  9. We need to cp the boot.img into the local dir and unpack it so we can do some surgery.  From ~/Downloads/AIK-Linux:

    cp -v ../angler-whatever-do-I-look-like-I-fish/boot.img .
    ./ boot.img

    (You'll be sudo prompted, for some reason.  So if you're getting the five-finger discount on clock cycles from your university's timeshare system, look out!)
  10. This unpacks into two dirs, ramdisk and split_img.  You need to make the same modifications as in the following github changesets.  (Sorry, this would have been super easy to script, but so much more fun to write about.  This is our cycle of violence, fellow nerds.)

    Adding "maxcpus=4" to the end of the line. (in split_img/boot.img-cmdline)
    Changing everything to use CPUs 0-3 only. (in ramdisk/init.angler.rc)
  11. Then you have to repack that turd so it'll fit back into your phone:

  12. The output file of the script is boot-new.img.  Make sure your phone is still in recovery (see step 3) and run the following to flash the new bootloader:

    cd ~/Downloads/platform-tools
    ./fastboot flash boot ../AIK-Linux/boot-new.img
  13. Then reboot:

    ./fastboot reboot
  14. And I expect you should be booted into a device that you can't unlock and you'll have to google how to factory reset it!  But once you do, the failed big cores will be disabled, and your 6p will become a family heirloom passed down to your great-great grandkids.  And honestly, to me, so far the device's performance actually seems a lot better without those failed big cores - I thought the phone would be horribly sluggish, but I was wrong (imagine that!).  The responsiveness is better than before the fix on my handset, at any rate.
Thanks for reading this far, and sorry I was so angry.  I fucking hate fixing phones, and hope that this may help someone to not have to feel the frustration I've felt, but instead get to laugh at me and have a functional phone again in a shorter time than it took me.  Thanks to all those insane motherfuckers on XDA, youtube, etc who actually figured this shit out - I would call you out by name but I cobbled this together from like 15 different guides.

Saturday, October 21, 2017

installing Dell bios update on 64-bit linux

Unlike many motherboard OEMs, Dell releases BIOS updates that can be executed from linux.  Unfortunately, a portion of these updates are precompiled binaries for 32-bit linux only.  Here's how I made the BIOS update work for my Precision T5400.

Get the update:

md5sum T5400A11.bin
# should be 11a13eae55e01ca5aaadda459b78cf2a
chmod a+x T5400A11.bin

Like many vendors of proprietary software in the world of FOSS, the update takes the form of a short shell script that extracts and unzips a precompiled binary from itself.  All the work is done in that binary.  Unfortunately, when you try to run it under a 64-bit Debian install, you'll get something unhelpful like:

./flash: No such file or directory

So here's the solution to run this binary under 64-bit Debian:

dpkg --add-architecture i386
aptitude update
aptitude install libc6:i386 libstdc++6:i386 zlib1g:i386

Now you should be able to run the update!


Monday, August 28, 2017

dumping the contents of your netflix dvd queue

That Netflix DVD queue can sometimes get out of hand.  If you ever want to do some data on the contents of your queue, I'm pretty sure they still have an API for that.  But maybe you want to back up your queue just in case, or maybe you want to write a thing to tell you if you're about to spend your slot on crap, or maybe you're thinking about pausing your subscription and want to keep a list of what it was that you wanted to watch.  If you want this information and you want it in the browser console and you want it NOW, here is some jQuery garbage I just hacked together to make your dreams come true.

var all = []; $("#activeQueueItems, #savedQueue").find("*").each(function(i,el){var titlez = $(el).attr('aria-label'); titlez && titlez.includes("Table row for") && all.append(titlez.replace("Table row for", "")); }); console.log(all)

Or, slightly less hideously:

var all = [];
$("#activeQueueItems, #savedQueue").find("*").each(function(i, el) {
  var titlez = $(el).attr('aria-label'); 
  titlez && titlez.includes("Table row for") && all.append(titlez.replace("Table row for", ""));

Works in Chrome, if you're using something else then get with the program.  Remove the "#savedQueue" if you only want to see items that are active in the queue (not saved DVDs).  Happy hacking!

Thursday, August 17, 2017

compiling synergy on debian 9 stretch

The packaged version in Debian has always been ancient and terrible, but with the recent release of Stretch, the Synergy devs have yet to catch up.  Here's how to compile and install the latest stable Synergy (1.8.8) at the time of this writing.

  1. sudo aptitude install build-essential cmake libavahi-compat-libdnssd-dev libcurl4-openssl-dev libssl1.0-dev lintian python qt4-dev-tools xorg-dev fakeroot
  2. git clone
  3. cd synergy 
  4. git checkout tags/v1.8.8-stable
  5. QT_SELECT=4 ./ conf -g1
  6. ./ build
  7. ./ package deb
  8. sudo dpkg -i bin/synergy-HEAD-stable-c30301e2-Linux-x86_64.deb

Tuesday, July 21, 2015

automatic backup with proxmox

This was such a pain in the ass to find... but this is obviously a noob problem.  The steps:

  1. Click the "Datacenter" root of the tree on the left of the UI.  Doesn't matter what view you have selected.  Right where this giant-ass red arrow is pointed:

  1. Next, click the "Backup" tab.  Not sure what else you'd do at this point.  Look for the huge red arrow again:

  1. Now click "Add".  Another enormous arrow points the way:

  1. Now you get a fairly self-explanatory popup for configuring your automatic backups.  No arrows this time :(

  1. Some potential sticking points on the backup form:
    1. If you have no options under "Storage", you need to set up some storage other than the Proxmox boot disk.  Google around for it, I don't have any big-ass arrow-covered guides for that.
    2. The mode you choose matters: 
      1. "Snapshot" is not a real backup - if your VM server's disk craps out and you want to restore from backups, you'll be SOL if you chose snapshots.
      2. "Stop" is the mode I use - while the backup is happening, the VM will not be running, but you get the entire state of the VM into the backup, which makes it a real backup.  On my Xeon E3-1250 (v1 or v2) with several dozen GB disks, this takes an extremely small amount of time, and I'm using the best compression as well.  If you have giant VMs or otherwise really care about performance, you may want to investigate further.
      3. "Suspend" is identical to "Stop" for folks using KVM (VMs).  It differs only for the poor bastards who chose the HD-DVD of virtualization technologies, OpenVZ.  (If you're one of those poor bastards, get out as soon as possible - they're chopping OpenVZ support out of newer versions of Proxmox.  Your pain is my gain, because this allows Proxmox to move away from than ancient 2.6 kernel!)

Wednesday, July 15, 2015

windows nut client configuration

Part 2... (continued from part 1, here)

1. Allow remote connections on the server

# sudo vi /etc/nut/upsd.conf

Add a listen directive to the IP:

LISTEN (your IP) 3439

And then restart upsd:

# sudo pkill upsd
# sudo upsd

Make sure it came back, and that the new directive is good:

# sudo upsc bu650@localhost
# sudo upsc bu650@(your IP)

2. Add a slave user on the server

# sudo vi /etc/nut/upsd.users

    password = somethingelse
    actions = SET
    instcmds = ALL
    upsmon slave

3. Install WinNut

Here is the most recent project page, here is the downloads page (not updated since 2011, ack). and here is a direct link to the most recent msi installer.  Verified to work on Windows 7.

Now install that sucker.

4. Configure WinNut

Open WinNut.  The second row should be labeled "Configuration file path", and have an edit button on the right side.

Click that.  This should open an editor to a upsmon.conf, just like we had on the server.  Add a monitor directive to the server, with the new slave credentials we created in step 2:

MONITOR mybu650@(your IP) 1 slave4u somethingelse slave

Save and close that, click "Apply and start WinNut", and then click the "View" button to see the log file.  If you did it all right, it should say that you're connected!

5. Conclusion

WinNut seems ultra weak.  But it also appears to work, so I'll let it go for now.  But not for long...


Tuesday, July 14, 2015

nut server configuration

Nut sucks to configure.  There is hardly any recent, reliable info out there (aside from the inline documentation in the conf files, wealth of information on the official site, and helpfule error output - but who wants to wade through that ;).  Plus, a few years ago it was a LOT worse, so count your blessings and use a recent distro, ya whippersnappers.

So let's change that.  Here's a guide that's easy to digest and may even work for you!

1. Hardware and driver selection

I'll be setting up a nut server in this one, with my ancient APC Back-UPS 650.  No, not the one you get when you google that - mine is so old, they are now reusing the name for a newer product.  But it's heavy as hell (that's a positive for me), I just replaced the battery, nut supports it, and I got it for free.

The Back-UPS uses a serial interface, and since the desktop I'm setting up as the server has no serial ports, I'm using a USB-serial converter, available for a few dollars everywhere.

Using a USB-serial converter means you'll be using /dev/ttyUSB[0-9], instead of who knows what for a USB UPS.  It's probably at /dev/ttyUSB0, but run this command to find it:

# ls /dev/ttyUSB*

If that comes back with nothing, then you probably hooked up your UPS wrong, (if your UPS is on a real serial port, it will probably be at ttyS[0-9], or maybe ttyO[0-9], or something else weird).  If that command comes back with several ttyUSB entries, you'll have to try them all in turn in the section below, or try unplugging and replugging the UPS, checking which dev entry goes away and then comes back.

First, you're going to need to find your UPS on the nut HCL.  The point is to find which driver and arguments are needed to drive your UPS.  I'll wait.

Now, if you don't find what's obviously your UPS, don't panic.  All may not be lost.  My search, for example, returned three UPS variants, none of which were the 650.  The differences relate to different cabling configurations, and all use the same "genericups" driver, but with different "upstype" arguments.  Since I don't know how my UPS is cabled, I'll just try each of them.

Of course, before we start we also have to install the server package:

# sudo aptitude install nut-server

2. Configure the UPS driver

Open the config file for your UPS hardware:

# sudo vi /etc/nut/ups.conf

Add a section for your UPS - make sure you put it AFTER all the configuration directives:

    driver = genericups
    port = /dev/ttyUSB0
    upstype = 1
    desc = "The beige tractor battery"

The heading is whatever you want to call this UPS.  The driver (and, for me, the "upstype" argument) comes from the nut HCL.  We found the port in the section above.  And the description is also just another place to put some useless text you'll probably never see.

Save the file.

You'll also probably need to add the nut user to the dialout group, so it can access the serial port:

# sudo usermod -aG dialout nut

Now, to test the config, run:

# sudo upsdrvctl start

This will probably fail, because configuring nut is hard.  Read the error output, fix stuff, and try again.

Otherwise, if you get no error messages, your driver config is correct!

3. Configure users

Open the users file:

# sudo vi /etc/nut/upsd.users

Add a user and pass:

    password = something
    actions = SET
    instcmds = ALL
    upsmon master

4. Configure the data server

Open the config file for your UPS daemon:

# sudo vi /etc/nut/upsmon.conf

Add a MONITOR directive:

MONITOR mybu650@localhost 1 admin something master

Start upsd:

# sudo upsd

If you've managed to not mess anything up, you should get no angry messages.  If you got some, read them and fix the problem.

Now, check that you're connected:

# sudo upsc mybu650@localhost

This should give you a bunch of output, the most important of which is the ups.status line.  Of course, since this is nut we're talking about, the value is cryptic, but basically if it says "OL", that means "online", and everything is good!

5. BONUS: Configure a tray icon

If your nut server is also a desktop, you might want a status icon.  This is simple.  Install nut-monitor, aka NUT-monitor:

# sudo aptitiude install nut-monitor

You can start it like this:

# NUT-monitor

I have no idea why you have to yell it.  If you want to make it autostart in the tray, start it like this:

# NUT-monitor --start-hidden

Careful, it's a bitch to kill like that - Ctrl-C wouldn't do it for some reason.

Add that command to your startup scripts to get nut status all the time.  For example, on an openbox system, just:

# vi ~/.config/openbox/autostart

And add:

NUT-monitor --start-hidden &

Boo yah!

(Go to part 2 to see how to install nut for a Windows 7 client.)