Ramble: Flappy Bird crash investigation

Although it’s already been pulled off the iOS App Store and the Google Play Store, I managed to get a copy of the .apk file and decided to play it on my phone. Seeing others’ experiences along with my own, I noticed there is a pattern to how the annoying little birds fly and crash.

Bird-control theory

The bird is controlled by tapping the screen, which causes the bird to move upward shortly before falling down again. Unlike other similar games, the screen needs to be periodically tapped to keep the bird in the air. This is basically pulse-density modulation at work; each tap of the screen causes a rise of a fixed amplitude and duration.

After playing over 200 rounds, I tabulated the data in a giant Excel spreadsheet, documenting the score along with how and where the bird crashed. With this data, I created a bunch of charts showing how and where crashes occur.

Charts

scorescrash typecrash locationscrash proximityBreakdown

From what I’ve collected, the majority of crashes are overshoots (the bird flies too high and hits the pipe), hitting the top pipe either to the left side or in the center. This can be attributed to the bird’s behavior when flying. When the screen is tapped, the bird moves a certain distance upwards but cannot be controlled. If the bird is too close to the pipe, an overshoot will occur and crash the bird.

I created a bunch of statistics in the spreadsheet outlining the most common crash IDs (explained in the picture) and score information (my highest was 34 πŸ™‚ )

statsWas this a good way to cure boredom? Probably, but also possibly a bit too much work given the premise of this game.

If you want a copy of the Excel spreadsheet, click the link below.

Flappy Bird Crash Data

Advertisement

Looking inside an iPhone 4/4S battery

A classmate of mine had a couple broken iPhones that he ‘relieved’ of their batteries and let me take a look at them. Being the curious type I peeled away the outer layers of tape to reveal the protection circuit. I spotted a current sense resistor, andΒ  that got me thinking…

… can it be? Yes, I found a bq27541 fuel gauge chip inside the battery! After fooling around with the battery, I found out that the battery is using the HDQ interface.

iphone battery pinoutThe HDQ bus, which stands for ‘High-speed Data Queue’, is a single-wire communications bus used by TI fuel gauges. It’s similar to Maxim’s 1-Wire protocol but runs with different protocols and timing. It operates at 7 kilobits per second (so much for ‘high speed’ right? πŸ˜› ) and a refresh of the data memory in the TI software can take almost half a minute. However, it’s good enough for occasional polling (like every minute or so) since it’s unlikely that the gauge will be read from every second.

The bq27541(labeled BQ 7541) in the iPhone battery runs an unusual firmware version. It’s running version 1.35 and doesn’t match with any release on TI’s website. The gas gauge is sealed so initially it seems like gaining access to the Data Flash memory would be impossible. However, in non-Apple fashion, the gauge’s passwords are left at the default; 0x36720414 and 0xFFFFFFFF for the unseal and full-access keys, respectively (and it’s not the first time Apple’s done this!). Since the firmware version is unknown, I told bqEVSW to treat the chip as if it were the bq27541-V200. I then saved only the calibration, capacity, resistance and lifetime data.

Updating the firmware over HDQ was a nightmare. It took over a dozen tries for each of the two batteries I had, and the update process took 45 minutes (!) to update the bq27541 to the V200 firmware. At one point, it seemed as if I bricked the chip, but a power-on reset of the chip by shorting the cell very quickly πŸ˜€ sent the device into ROM mode (ie. firmware-update mode). From there I used bqCONFIG to update the firmware, and it was successful! Now I could use GaugeStudio to interface with the gauge rather than the unsightly bqEVSW software.

bq27541 updated to version 2.00

bq27541 updated to version 2.00

Given how long it took for me to update the firmware of the gauge, I have doubts that iPhones will update their batteries’ firmware in-system. Hell, the iPhone OS ignores the bq27541’s State of Charge readings and substitutes its own. Nice going, Apple!

Now to start going through cell phone recycling bins to pull out dead iPhone batteries for their gauges…