How to charge your Android phone battery in hboot

The situation was grim. My HTC One X was stuck at the hboot screen. The bootloader was re-locked (I was trying to flash a new RUU) so I couldn’t get to CWM Recovery. The battery was dying. Things did not look good.

I had ignored the advice on the xda forum and was messing around on a low battery charge…

At this point, I would usually just flash the Unlock_code.bin file and reopen the bootloader, except I couldn’t – the battery was too low. And the battery can’t charge in hboot, it can only charge in CWM recovery. But I couldn’t get to CWM because the bootloader was relocked. Oh, what a frustrating paradox.

Using the fastboot getvar battery-voltage command I could see that there was an ever so small change in voltage when I charged, but not enough. I needed 3680mV in order to be able to flash the unlock token.

Luckily, I found this amazing ingenious trick on the XDA forums: http://forum.xda-developers.com/showthread.php?t=1658084&nocache=1

 

[infobox]

@echo off
:start
fastboot getvar battery-voltage

fastboot reboot-bootloader

ping /n 6 localhost >nul

goto start

[/infobox]

 

How to run the script when in USB Fastboot mode

  1. Open a text editor and paste in the code above
  2. Save as a .bat file. I saved mine as loop.bat – make sure it is in the same folder as fastboot and adb
  3. Connect phone to computer by usb and check to that Fastboot can see it (‘fastboot devices’)
  4. Start the batch in command prompt ‘start loop.bat’
  5. Get hyponitised by the slow, steady progress
  6. Once you reach the required 3680mV type ‘stop’
  7. Flash your unlock token by executing ‘ fastboot flash unlocktoken Unlock_code.bin’
  8. Cross your fingers

What this does is reboot the bootloader repeatedly. Which each reboot, the charge moves up incrementally, maybe 1 or 2 mV; and sometimes even down.

After leaving the bat file to run for an hour, I finally made it 3680mV and flashed the Unluck token. The stretch between 3660mV and 3680mV is the most agonizing, with change happening suuuuuuper slooooooowly.

Once you can get to CWM recovery, let your phone charge for a few hours, so that you can install your ROM or RUU without fear. As and aside, the ‘Mount USB’ commend does not work for the HTC One X on the build I tried (5.8.4) of Clockword Mod Recovery Touch, but it does work in the regular version, so if you still need to copy your rom to your USB, don’t use Touch. Although, it is easier just to flash using fastboot flash rom zip nameofrom.zip

9. Breathe a sigh of relief