OXBLOG

… because I forget simple little things too soon …

12 Feb

Crazy Town

Punk pirates listen to radio rage
Machine guns are born by the underage
A felon is let out of her corny cage
This town is maxed out on its crazy gauge

Bags of shuffled cards are dealt
Haze of every look is felt
A runaway not far away has knelt
’round his neck a firmly tightened belt

Laughter is heard at the sight of gore
Heavy grime washes off the shore
Bored is happy to pay plenty for more
Living souls are rotten to the core

Barbers are cutting limbs for cash
Sitters let kids on their hash
Curtain tops are now a trendy fash
White and fresh is sure to earn a bash

On radio a line is said
On this chaos a light is shed
To the savvy, a lie is fed
“Pain in this town, has long been dead”

8 Jan

Qualcomm Quick Charge 2.0 protocol specification and support

I got myself a PureGear Extreme USB Wall Charger few months ago. It’s Quick Charge 2.0 (QC2.0) enabled. But it didn’t live up to the claims made by Qualcomm to charge from 0% to 60% in 30 minutes. So I figured either the charger wasn’t doing what it promised to, or my phone was the culprit. Gotta find out which.

In a non-QC2.0 charger that conforms to USB Charging Specification, a certain resistance is connected across the USB data lines. When a phone is plugged in, the phone measures this resistance to find out how much current it’s allowed to draw from the charger. The voltage is always 5V. Lower the resistance means higher maximum current draw allowed. A resistance of 0Ohms means draw as much as you want.

In QC2.0 chargers, maximum current information is no longer communicated to the phone. Instead, there is an interface chip that takes commands from the phone over the USB data lines. The commands only tell the charger what voltage to supply. Choices are 5V, 9V, 12V and 20V. The protocol is simple. After the phone is plugged in, it asserts certain voltages on the USB data lines. The charger measures the voltage on the data pins and sets the output voltage accordingly. The details can be found in the datasheet of a QC2.0 charger IC (CHY100) that I found with a bit of googling. Note that a higher maximum current cannot damage a phone (a phone only draws what it needs), but a higher input voltage regardless of maximum current can damage the phone.

Now the fun part. I striped a mid section of a USB cable and hooked up probes to each lead to measure voltages on all lines. Then I plugged my HTC One M8 with initial charge of 5%. I then ran adb connect 10.1.1.216:5555 followed by adb shell to open a terminal session to the phone. The IBAT(uA) line in /sys/devices/platform/htc_battery/power_supply/battery/batt_attr_text gives the current draw. At 5% charge, my phone was drawing 1400mA at 5V. Even if the charging process is 100% efficient and the current draw stays at 1400mA, charging a 2600mAh battery to 60% will take longer than an hour. Not the 30 minutes I was promised.

So I measured the voltage on the USB data lines to see if the phone was indeed talking to the charger block over QC2.0 protocol. Turns out it did. It was asking it for 5V, by pulling the D+ pin to 0.7V and D- to GND. I kind of wish it didn’t talk QC2.0 so that it could be enabled somewhere. Now the odds are: either the phone isn’t asking for more voltage because it can’t handle it or that the kernel is not configured to ask for more. I really hope it’s the latter.

I will update this post as I find more info about this.

Quick Charge 2.0 Specification Diagram
Simple table showing what voltages on data lines corresponds to what output voltage. Be sure to read the CHY100 datasheet in detail for the exact working.

2014-01-08: OK. I can confirm that the issue is the ROM I’m using (Cyanogenmod 11 Nightly). I just restored the stock recovery and plugged in the phone while in recovery and it now configures the charger for 9V output. Now I know where to dig.

2014-01-09: Upgraded to Cyanogenmod 12 Nightly. Issue still there. I noticed that sometimes the phone puts 3V on D+ but 0V on D-. I suspect cyanogenmod uses outdated device tree.

2014-01-13: Got it. The problem was that CM didn’t have a daemon called hvdcp which configures the DCP (Dedicated Charger Port) circuitry of the phone and requests 9V input. After some time of hacking, I managed to fix it all up and submitted a patch to CM for review. The battery now charges at 2500mA compared to 1400mA before the change. That means, 60% of the battery will be charged in 37 minutes which is pretty close to Qualcomm’s promise of 30 minutes.

7 Jan

Statsic: Make sense of statistics

A while back I had to make a decision that could affect my life in a significant way, forever! This decision depended entirely on odds — whether it was worth the risk. In search for some hard numbers, I realized that such statistics is very difficult to come by and when you do find it, the useful bits are buried among pages and pages of text and formulas in some research paper. I read 1000 page manuals every other week and even I don’t usually make it to the end of these papers.

The previous paragraph is perhaps a little abstract. A concrete but a silly example is if you were thinking of spending some big buck on a lottery ticket. What chance are you taking? Finding the numbers for this particular example is not that difficult. Any lottery organization must provide the odds of each game to players before they purchase their tickets. However, what you get is always a number, something like 1:4132766. But what does that mean? It literally means the odds of a single ticket hitting the jackpot is 1 to 4132766. OK, but how big is 4 million. Without fail, you are inclined to ask: “what’s something with similar odds?”

And so the idea to compare probabilities was born. It’d be much more helpful to be told that you are as likely to hit the jackpot as you are to be eaten by a white shark (this is an example, I don´t know the odds of either). I figured one person (me for now) should suffer once and from then on, everyone should benefit. I put together a simple site in two weeks with some initial data. Statsic was the most creative name I could come up with. As I’m not a statistician and frankly hated statistics back in college, I may have made a lot of boo boos in my analysis of the data on the site. However, I am intending to learn as I go and provide a high quality original source that is reliable and comprehensive.

Do check it out and if you know of any good sources of data that fits this model, please share.

12 Nov

Shock Stall

Shaking off the glory
Sitting you down for a quiet story
Drink up my buzzed and fuzzed honey
Dinner isn’t gonna be ready

Had a mishap today at the shop
Told the cashier that at aisle 24, someone threw up
Asked and told and ran and got shot
I was the one who did it on someone’s top

Had a long day, bit an apple rotten to the core
Yellow curtains of your half open door
Covered my drooling mouth as I entered the corridor
Saw the swinging cut out of our lord, land head on on the floor

Sore sailing the waves of this scenery
Taking nothing for granted, there is nothing to take
Bone to bone to the song of this mockery
Layers of irony start to flake and flake

Wave at and blow kisses to hard rock lovers
Long live the Napolean of fish fodders
Hats off to room bargers, and shirt tuckers
Cult of card cutting cowards and lucky lusters

Switched on, full on at the start of this robbery
Commence the countdown to the end of our misery
Load up your guns, it is customary
to off everyone cold and steal no money

1 Nov

Null Encounters

Lights are on
Curtains down
Corners of the room
Trenches for our doom

Cyanide in hand
Roll of nails on sand
Can of can’ts on the shelf
Sharp minds adrift

Second thoughts first
Tell and show oppressed
Yet agains yet again
Unknown, ruled a sin

Down lookers and hopers
Miles out of focus
A poke for a cheap laugh
made a hole in the raft

Perky form outlawed
Perfect deemed flawed
Backs bare to the waist
Shoes laced in a haste

Ill-endowed with time
Sulked but felt fine
Be-all end-all of doubt
Prepared but wants out

Misguided and unsure
Ruled under, beat and sore
Pour a heart in a lake
Rid the chest of the ache

Lights dimmed
Talks and walks trimmed
Corners curved
Poison served

31 Oct

Greetest

I’m Kermit and I’m enjoying your heat
You’re hot as shit and I am terribly sweet
Your busts are banging, sight of them a treat
I rhyme like a motherfucker, it is pretty neat

I’m Kermit and that is how I greet
a hot mama on a train, on the street
Next to me or on my lap, please take a seat
I’ll offer you milk, like monsieur Lapadite

23 Oct

Up my game

Up my game
Down-level an amount worthy of my fame
Disengage from the roaring torque of your engine
Disparage my opponents, call them names

Up my game
Reid this empty house, rape it with an emptier flame
Deceive me with your age old finest deceit
Revel as I break and fall to my knees

Up my game
Deplete the building desire to dismiss it as vain
Exert a microscopic effort to advance me
An extra breath for you, means the world to me

Up my game
Bear the burden that what you do is lame
Agitate your friends, and save me the calm you
Wholeheartedly laugh when pain is flowing through you

Up my game
Train me until I’m clean and tame
Play me, whisper to me “who knows whom to blame?”
Frame me with good intentions, a noble aim

Up my game
But quash the thought of me doing you the same
Bet on your life that for the rest of it you will regret
spending a single moment, upping my game

Up my game
I dare you
Are you game?

21 Oct

Touch Adapter Voice 2, silenced for good

Volkswagen Polo 2012 model
That’s not me driving. I drive in the real world!

We have a Volkswagen Polo that is a few years old. The bluetooth setup on this car is a disaster.

The car itself has bluetooth and it can play music over A2DP profile, make and receive phone calls over HFP profile and it can even download your phonebook and some more. Enter Touch Adapter Voice 2, a cell phone sized device that sits in a dock on the passenger side. Without it, the car refuses to connect to any bluetooth device. So you’d think leaving it in the dock is all that’s needed. Errrr. Wrong. The Touch Adapter also has bluetooth, and just like a phone, it tries to connect to the car over bluetooth. But of course only one device can be connected at a time, so getting one’s phone connected is a gamble. I hear you ask: why the hell does the Touch Adapter need to talk to car over bluetooth? Hear me say: !@#$%!@! Who knows?!! It acts like a relay between the phone and the car. What? Relay bluetooth? Yep! Folks at Volkswagen are on something heavy. Did I mention that in the relay configuration, music playback is gone? Yep. I’m not even sure if it’s legal to advertise the car as A2DP capable when that functionality works only sometimes.

Touch Adapter in its dock

19 Oct

The Birthday Song

Happy Happy Birthday
Eat all you can, off the tray
Get tad funky, get all cray
Is this too much, we say nay

Happy Happy Birthday
Should you want us, we will stay
Until dawn, till the next day
but tonight, wish you the best lay

9 Oct

Show me

Show me a watch that counts the breaths
that you wasted clinging to this flesh

Show me a get away car
that can race through the narrow corridor

Show me a half lit room in the attic
that would shield us from the world

Show me a sign, I’m about to resign
unless I see you bleeding from the same cuts as mine

Show me your face, pick up this pace
we need a titanium strength will to displace

Show me your wrist, bare it, I insist
My bet is on your strong pulse
that beats despite your fierce fist

Show me your grace, lace up the case
We need to hide it away from the eyes of the saints

Show me courage, don’t be shy about it
Stay and fight, save the wings for the nightfall instead

Show me no more, we made it
Let’s not shake hands, let’s not say “see you later”
I know, I’ve been told I’m cruel that way

besides ranting, you may also find me asking silly questions, write code for the world or just plain showing off. Make sure you read the privacy policy.