[Xperia Arc General] Bazoocaze:
If you are using this workaround and are happy with it, please show it and press the thanks button. :D

Thank you,

Bazoocaze

Latest updates

29/nov/2012: Fuel Gauge Fix on Google Play

I published the Fuel Gauge Fix application v1.6.3 on the Google Play:

Free version:

https://play.google.com/store/apps/details?id=br.bazoocaze.fuelgaugefix.free

Donate version:

https://play.google.com/store/apps/details?id=br.bazoocaze.fuelgaugefix.donate

There is no differences between versions - install the version you want. Uninstall the standalone version before installing the play store version. The application data will not be transported between the standalone version and play store version, so take note of your customizations before uninstalling.

Changes in version 1.6.3:

-Added an option to allow changing the notification icon type.

18/sept/2012: Kernel patch (unlocked bootloader) for ICS .587

See the Patched kernel download section.

13/set/2012: CM9/10 FXP patched kernel

Thanks to svanteson

http://xdaforums.com/showthread.php?t=1763227

12/set/2012: Locked bootloader patch updated to work with .587 stock firmware

http://xdaforums.com/showthread.php?p=28871812#post28871812

10/aug/2012: Doing some research

You asked, so I'm doing some more research on an automatically way of restarting from software an early aborted charging process.

APK Updates

11/feb/2012: New FuelGaugeApp v1.6

There is a new FuelGaugeApp version - now it supports CPU clock detection.

APK Fix From Bazoocaze:

Please use the latest version, and with patched kernel v4 or later. See "Android APK helper". See "APK Issues".

v1.6 :) Detects CPU clock and calculates CPU consumption

v1.5.4: :) set battery to 100% on charger disconnected

v1.5.3: :) old - test version

v1.5.2: :) old - updated charger detection

v1.5.1: :) old - updated to sense GPS state and screen brightness

v1.5: :( old - this version was deployed with a bug in charging logic - please dont use

v1.4: :) old - updated menu icons, and show battery % on notification text.

v1.3: :) old - updated notification icon[/B]

v1.2: :) old - ugly notification icon, first charge issues

v1.1: :( failed - found a noob bug on APK - sorry

v1.0: :( failed

v1.0: :( failed

Stock kernel Driver Updates

v4: :) use this: allow driver to fake report 85% battery. Use with lastest APK FIX for online battery capacity changes. See "Kernel Issues". See "Warnings"

v3.1: :( failed: allow driver to fake report 85% battery. See "Issues". See "Warnings".

v3: :( failed: success: allow driver to fake report 100% battery. See "Issues".

v2: :( failed: leave/enter ROM mode (flash mode) - failure to write to 0x16 (0x0B) i2c address

v1: :( failed: reset / factory restore fuel gauge - failure to write to 0xAA (0x55) i2c address

FAQ

[Q] What is this?

[A] This is a workaround/patch to 0% battery issue caused by downgrading firmware from 2.3.4 to 2.3.2.

[Q] I need this patch?

[A] If your battery shows 0% and your android shutdown and does not charge, try to remove battery for 30 seconds and put it back. If this does not solve the issue, flash back stock 2.3.4 firmware. If this does not solve the issue, replace your phone using your warranty from Sony. If this does not solve the issue and you wish to take the risks, then this workaround is for you.

[Q] What kind of failure is this 0% battery issue?

[A] This is an unrecoverable hardware failure on the fuel gauge controller of the Arc/Neo. On our research, we concluded that no software can correct this.

[Q] There will be an official patch from Sony?

[A] No, because it's an unrecoverable hardware failure.

[Q] What I need to take this workaround?

[A] You have two options: unlocked bootloader and locked bootloader

Primary method - for locked bootloader / unlocked bootloader: you need root, BusyBox, android 2.3.3 or later, and follow the steps on http://xdaforums.com/showthread.php?p=28871812#post28871812

Alternate method - for unlocked bootloader: if primary method fail, you need and unlocked bootloader device, android 2.3.3 or later, and follow the steps on this thread.

[Q] Primary method: what are the steps to apply the fix on my phone - (locked and unlocked bootloader)?

[A] First, read the full post, especially the FAQ.

Next, see http://xdaforums.com/showthread.php?p=28871812#post28871812

[Q] Alternate method: what are the steps to apply the fix on my phone (only for unlocked bootloader)?

[A]

Only use this method if the primary method does not work for you.

1. First, read the full post, especially the FAQ. In case of doubt, you can use this guide to know how to do things:

http://xdaforums.com/showthread.php?t=1133650

2. Unlock your booloader

http://xdaforums.com/showthread.php?t=1551494&highlight=bootloader

http://xdaforums.com/showthread.php?t=1034087

3. Grab the most recent kernel patch from this thread. The file is boot.img.xxx.7z for your phone (ARC / NEO). We call this the kernel patch, or only the patch.

4. You must be same firmware and patch version, so if you aren't firmware xxx, use flashtools to flash the correct firmware, and wipe the data if downgrading firmware version. You can find some recent stock firmwares in the [Firmwares (.FTF)] section.

http://xdaforums.com/showthread.php?t=1304634

5. Use fastboot (or flashtools) to flash boot.img contained in file boot.img.xxx.arc.7z (or boot.img.xxx.neo.7z for NEO users). Flash the .img file, not the .7z file :) .

http://xdaforums.com/showthread.php?t=1116970

fastboot flash boot boot.img

6. Now you have a phone showing allways 85% battery capacity.

7. Install most recent FuelGaugeFixV??.apk from this thread (Bazoocaze version).

8. For the first time, make sure the charger is plugged, and select "Start full charge" from the apk fix menu (use the menu button to show options). A full charge takes 2h00 ~ 2h30 for stock charger, and 3h00 ~ 3h30 for USB.

9. Now you have a fully charged phone, and apk fix updates battery % acordingly to phone usage.

10. If you wish, you can now root your phone using the instructions on the section [Root for unlocked bootloaders].

11. See "Kernel issues" and "APK issues".

12. Press the tanks button on this thread, and optionally feel free to buy me some gift/beer/pizza/coffe. :D

http://xdaforums.com/donatetome.php?u=4215483

13. Finish

[Q] There is another way of obtaining online battery % via software?

[A] Simple answer: no. Calculating battery % needs a coloumb counter hardware, that is the fuel gauge in our case. No fuel gauge, no coloumb count, no battery %.

Extended answer: there is no way of obtaining online battery capacity without the help of the fuel gauge, because battery dont have a "% capacity", but have a "full charged maximum capacity" and the actual capacity is the amount of charge left from the total minus the cumulative coloumb count of current drained by phone. The fuel gauge is responsible for sensing the coloumb count, and without it, we are only poor guessing the actual battery % capacity. This way, if the fuel gauge had an unrecoverable hardware failure, none can be made by us nor SE to recover the phone capacity of reporting battery status - its impossible to calculate without a coloumb counter in hardware.

[Q] But I installed your stuff and the battery % seems to be increasing / decreasing with use / charge. You said its impossible to obtain battery % via software. Whats happening?

[A] It's a guess value calculated based on peripheral usage of your phone, and not on stats measured from battery module. The usage is based on statistical usage of my phone, so maybe its not correct, but works.

[Q] I flashed the patch, and now my phone is not charging. Can you help?

[A] Do not let the phone runs out of charge. Recharge frequently. Try to charge with other chargers, and on the USB on PC. Try to leave the phone shuted off charging on PC, and go back after a time (1 hour) to see if the phone gets back on. If this does not work, I cannot help you.

[Q] What are the risks?

[A] See [Warnings] section.

[Q] I dont know how to {flash boot.img / unlock bootloader / use fastboot / use flashtool / etc}. Can you help?

[A] Every tool and proceding on this thread can be found on the XDA forum. Search in the forum for links / tutorials / manuals / guides.

[Q] I want this on CM / MIUI / Stock version xxx. You version/firmware sucks. Please, can you make a patch for the other version/firmware?

[A] See "Compatibility" section, or ask your favorite custom kernel / firmware developer to generate a patched version based on my work. Also, I did post the source code of my changed version of fuel gauge kernel driver, so you can make your own modified kernel version, or port the changes to CM / MIUI or other custom firmwares. Please respect my work and time spent and give me the credits on the kernel patch if you copy/use it.

[Q] I installed your stuff and my battery % is stuck on 85% or other value. Can you help?

[A] Have you installed the Fuel Gauge Fix APK and started the monitor service?

Also, make sure you dont have a task killer messing with the apk fix - it must runs ALL THE TIME to monitor peripheral usage. Also, make sure you installed the correct version of kernel and apk fix - check app version and kernel version, to make sure you have latest version. Also, you need to be on correct stock firmware version before patching the kernel.

If all versions are ok, try to stop the apk fix service and clean app data. If this cannot help, flash stock firmware (watch out to match the firmware version and kernel version), wipe the data, patch the kernel, and install app fix.

[Q]I'm using the patch, but I don't know why it seems like the phone turns off itself and needs to plug in after only X hours of usage or something.

[A] First, you can't charge offline (android not booted up). If the battery percentage doesn't change, battery driver stops the charging process.

Also, remember to choose the app option "Start full charge" BEFORE connecting the charger. Otherwise, the sudden negative variation on the battery charge caused by the option "Start full charge" selected AFTER connecting the charger may stop the process by safety measures.

[Q] Can you hide the icon on notification bar or add it in menu setting?

[A] Yes. Look into the application menu options.

[Q] I want to compile my own version of patched kernel?

[A] See the [Compile your own version] section.

[Q] Where can I find the firmware .FTF files to flash on my device?

[A] You can find some recent stock firmwares (not patched) on the [Firmwares (.FTF)] section. Please note that this versions are STOCK, not patched. Don't forget to apply the kernel patch after flashing this firmwares.

[Q] What can I do and cannot do with this patch on my phone?

[A]You cannot:

- Charge your phone offline (Android not running). The charge will stop after some minutes.

- Charge your phone with the Fuel Gauge Fix App not running. The charge will stop after some minutes.

- Leave your phone charging for a long time / charge it at night. The battery will start to discharge after it reach 100%, so you must disconnect it from the charger after that.

- Connect the charger and then select "Start Full Charge". The charge may stop after some minutes. You must select "Start Full Charge" before connecting the charger. You can try to charge without selecting "Start Full Charge" (if the battery percent is low) and see if it work.

You can:

- Use your phone as you want.

- Use it while charging.

- Play games.

- Set your battery percent to 100% if you charge for more than 1h30 and the percent stops below 100%. In this case the calculated charging rate may be slower than the real charging rate, and the real battery may be reaching 100% before the calculated percent.

- Fine tune the software battery capacity and consumption parameters on the Fuel Gauge Fix App. Try to take a mean of total consumption starting from 1500000uA from your usage, and change the value accordingly. The percent will reflect the value, so if you lower the value (say 1400000) you will get a low percent early, and if you rise the value (say 1600000), you will get a low percent later. Don't forget to mantain the charge current value with a relative value for a 1h30 to 2h30 charging time. Ask for help on thread to know more.

[Q] I like your work, and it worked fine for me. Thank you.

[A] I'm glad to know this. So, hit the thanks button, for me to know you liked. Or buy me some coffe, beer and pizza (fuel of a dev).

APK Issues

All versions:

- When the phone runs out of charge, the phone will simply shutdown without warning. There will be no Android warning, since the dead fuel gauge is the responsible for notifying the system about battery empty. This issue cant be fixed - you need to live with it.

- There is no way for the charger monitor to guess the current charge, so it starts with 100% on the first run. If your battery status is low when you start the monitor for the first time, maybe you get out of charge early before reaching 0%, and them you cant get a full charge until you reach a low percent value again. Use the "Start full charge" menu option on apk fix to make the phone take a full 3 hours charge.

- The phone does not charge to 100% and the charge process stops early: your are not using the correct firmware / patch / apk fix. Verify the instaled versions and install correct version. Also, do not use the phone during charge, because the charge process may be disable by an overheat event occured during charge.

- The phone does not charge to 100% and the charge process stops early: maybe your battery is full and the charging process is done. Disconnect the charger, and set battery to 100% if needed.

Kernel Issues

All versions:

- You must use the same Kernel and System version. This way, your Arc/Neo must be in the correct firmware before applying the kernel patch. Look for the patched kernel version on this thread, and flash the corresponding firmware/ROM stock version. If you dont use same Kernel and System ROM version, maybe you get temporary innoperant Wifi or other hardware malfunction until flash correct version.

Try to flashtool the correct .FTF firmware before flashing the patched boot.img, and see if your issues go away.

- If your phone stops charging, try with different chargers (official / others), and with charging via USB on PC.

- Try to not let your phone shutdown by running out of charge. The battery has a safety circuit to prevent undercharging that shutdown before lower limit, but case the protection fails and battery voltage runs below the lower limit threshould, the battery may become permanent disabled by safety circuit.

- If you know what are you doing, you can try this (kernel patch needed) on android shell to modify battery % capacity (the 85 indicates 85%):

echo 85 > /sys/class/power_supply/bq27520/set_capacity

The /sys/class/power_supply/bq27520/set_capacity file only exists in our patched kernel.

Android APK helper

Please use latest version. Use with patched kernel v4 or later. See "APK Issues".

v1.6:

Last changes:

- Detects CPU clock, and calculates CPU consumption accordingly.

v1.5.4:

Last changes:

- Set battery to 100% on charger disconnected event, after a minimum charging time.

- Charging statistics, like average charge and discharge time.

v1.5.3: test version

v1.5.2: old

v1.5: old

v1.4: old

v1.3: old

v1.2: old - must be kernel patch v4

v1.1: old

v1.0: old

Fuel Gauge Fix APK description

Its a service that runs all the time, calculating battery consumption / charge, and updating the battery % of the phone, trying to mimic te lost functionality of the defective fuel gauge. Use it in conjuntion with the patched Kernel. Its does not works without the patched Kernel (missing set_capacity functionality in kernel).

How to use the APK

- The APK needs android 2.3.3 or later.

- The APK needs patched kernel ou patched fuel gauge module.

- Install the latest patched kernel / module from this thread (watch out for kernel patch firmware version requirement), and this APK.

- The APK only update the battery % on patched kernels.

- Open the APK (Fuel Gauge Fix), Click "Start monitor", and configure the "Charger Monitor" to start on boot.

- Test the APK to see if it changes the battery % on phone.

- If it wont work, look into the screen of APK, on field "Patch status", and report here you problem.

- If it works now you can use your phone (mostly) normally.

- For the first time, and when necessary, do a full charge on the battery, selecting the menu option "Start full charge".

How APK fix works

- Runs every 1 minute on screen disabled, and every 5 seconds on screen enabled.

- Scans for connected / enabled hardware, like charger, screen, bluetooth, wifi, celular.

- Starting from v1.6, it will take in count the CPU clock / usage, too. Use CPU Spy APK to debug CPU usage.

- Generate consumption prediction for enabled hardware.

- Simulate coloumb counting on in memory battery stats, charging / discharging the stats accordingly, and updating the battery % show by phone.

- There is an 1% limit, that is, the phone will never shutdown while there is power on the battery.

- On the first run, the fix start with 100% stats. Full charge your phone to help sincronize the calculated value with the real value. The real value cant be get by software, thanks to the faulty hardware fuel gauge.

- The fix memorize the last stats, so if you stop the service or reboot the device, the monitor must maintain the same stats on next run. Use the app menu to reset stats to 100%.

Kernel / ROM compatibility list

0% friendly: this kernels / ROMs already have the kernel patch, so you only need to install the Fuel Gauge Fix APK start the monitor service:

[ARC/ARC S] DoomKernel (thanks to DooMLoRD)

[ARC/ARC S] CM9/10 FXP kernel (thanks to svanteson)

http://xdaforums.com/showthread.php?t=1763227

[NEO] NightElf (thanks to Night-Elf)

xdaforums.com/showthread.php?t=1468043

0% unfriendly: the developers of these work choose to not integrate the kernel patch, so you will have a hard time trying to make the patch working:

- CyanogenMod 7 / 9 / 10

- FXP

Warnings

- Very important: I just now discovered that the battery temperature sensor may have stopped to work properly because of the the fuel gauge issue. Thus, the battery may overheat in extreme situations, which reduces the average life of the battery or can even result in fire in rare cases. Even so, the sensor is still read correctly by the controller BQ24158, which inhibits the charging in event of overheating (temp > 45oC). Either way, avoid charging the battery and operating the phone at the same time, to minimize the heat generated during charging. Also, please charge the battery away from the sun or hot spots, and no more than three hours on the charger. Knowing this, if you think there is a risk for you or your equipment, please do not use this patch.

- This is an experimental kernel, compiled from stock kernel source code supplied by Sony. Use it on your own risk.

- If you unlock your bootloader, you have NO WARRANTY from Sony.

Requirements for the kernel patch

- Xperia Arc/Neo

- Firmware version 2.3.3 or later (APK fix requirement)

- Unlocked bootloader

- Fastboot (to flash the boot.img)

Credits

Initramdisk from DooMLoRD thread

First APK Fix script v1.1 from FiDra

steryman for various patched version

JasonStein for his MIUI patched version

DooMLoRD for patched DooMKernel version

svanteson for CM patched version

zdzihu for the first locked bootloader patch

Kernel sources from Sony

ARM compiler from CodeSourcery

IDE from Eclipse team

Android SDK from Google

Patched kernel download

:) If you think my work is helping, please press the thanks button.

- All versions here are STOCK kernel, unless explicitly stated. Ignore the image/logo on startup. For other kernels, see "Other kernels" section.

v4:

- Look in the download file name for version information. You must use the same firmware and patched kernel version. See "Kernel issues".

ICS 4.1.B.0.587

ARC: boot.img.4.1.B.0.587.lt15i.7z - 7 MB

http://www.mediafire.com/?jssaye1xm2ohva6

NEO: boot.img.4.1.B.0.587.mt15i.7z - 7 MB

http://www.mediafire.com/?ns8049q084kihio

(old) ICS 4.1.B.0.431

ARC: boot.img.4.1.B.0.431.lt15i.7z

http://www.mediafire.com/?ttldhug1zl487nk

NEO: boot.img.4.1.B.0.431.mt15i.7z

http://www.mediafire.com/?4so293y7o899kwa

- (old) NEO boot.img patched kernel .62:

http://www.mediafire.com/?7g6gz2mpp1ljb46

- (old) Patched Kernel for Xperia ARC / NEO (one zip file, 2 img files - choose arc/neo to flash) version 4.0.1.A.0.283:

http://www.mediafire.com/?64ogvfgp8xp8btg

Stock firmwares (.FTF)

These are stock firmwares, not patched, not rooted. You can flash this firmware using flashtools, then flash the boot.img patch.

If you have an unlocked bootloader you can use the method described in the section "Root for unlocked bootloaders" to root your device after firmware flashing.

GingerBread Android 2.3

NEO Firmware 4.0.2.A.0.42 Android 2.3.4 Generic Global(World)

MT15i_4.0.2.A.0.42_GLOBAL.7z

http://www.mediafire.com/?ic223ahl1sbftbj

http://115.com/file/e6gvbzgp

http://www.multiupload.com/ZHYL4RSZGW

ARC Firmware 4.0.2.A.0.58 Android 2.3.4 Generic HK

http://www.wupload.com/file/2536357702/LT15i_4.0.2.A.0.58_Generic_Global_HK.rar

ARC Firmware 4.0.2.A.0.42 Android 2.3.4 Generic Global(World)

LT15i_4.0.2.A.0.42_Generic_Global.ftf

http://www.wupload.com/file/2328127472/LT15i_4.0.2.A.0.42_Generic_Global.ftf

ARC ICS 4.0.4

LT15i_4.1.B.0.587_Generic Global World.7z

188Mb

http://www.mediafire.com/?xucot63l30epa4y

LT15i_4.1.B.0.431_Generic Central Europe 1 (cust_1247-1041).7z

188Mb

http://www.mediafire.com/?6jrtwqvn2f9mj1d

LT15i_4.1.B.0.431_GenericWorldFR.7z

195Mb

http://www.mediafire.com/?qbip855iltbv5is

Root for unlocked bootloaders

Please use this thread:

http://xdaforums.com/showthread.php?t=1871981

Source code

In this post you can find the source code of my changed version of fuel gauge kernel driver (bq27520-kernel-driver.7z), so you can make your own modified kernel version, or port the changes to CM / FXP / MIUI or other custom firmwares. Please respect my work and time spent and give me the credits on the kernel patch if you copy/use it.

Compile your own version

This are simplified steps. If you dont know how to do, search in the forum.

- First, download the stock kernel source for Xperia (watch out for the correct version), or the sources for your custom ROM you want to use if its not compatible with stock kernel. The developer thread of dev Kalled from Sony (search on developer thread) has some instructions on how to compile the kernel.

This is the direct link to download Sony stock kernel sources:

http://developer.sonymobile.com/downloads/opensource/

- For the ARM compiler, download the CodeSourcery arm eabi compiler version 2010q1.

https://sourcery.mentor.com/sgpp/lite/arm/portal/release1294

- Install the compiler on Linux (You can use a virtual machine if you have Windows - use Virtual Box or VMWave Player, both are free for home use).

- Overwrite the bq27520 driver source code with the patched driver from this thread.

- Next, follow the guide on Kalled thread to select phone version and compile the Kernel.

- In the end of compilation, you get a zImage file, that is YOUR Kernel. Congratulations.

- You need a ramdisk. If you are targeting a custom ROM, get a ramdisk compatible with your custom ROM. Also, you can go to DoomLord thread about ramdisk and get a ramdisk suitable for your building. Or generate/use your own ramdisk if you know how. If you use other's ramdisk, give theirs credit.

- With kernel image and ramdisk, generate the file boot.img using mkbootimg tool from Android SDK, or abootimg tool from kubuntu repositories.

- If you choose to use mkbootimg, download a compiled version of mkbootimg, or compile your own version from Android SDK.

- Now you have a boot.img file. Flash it on your phone using fastboot and you are done. :)

Supporters :D

The following people have appreciated my work and time spent on this, and made me a contributiuon/bought me some gift:

- Beatmakernolv

- icet925

Thank you so much. :D I'm glad you like my work.