[MOD] charger repair - /system/bin/charger - Official SE charger

Search This thread

MrHassell

Senior Member
Dec 10, 2010
393
249
Melbourne
innertech.com.au
This file protects your phone from running below a dangerous level and potentially rendering X10 devices to an unusable or hard brick.

Hello XDA developers :)

Latest Version 3 :: Please use the latest version and report back the contents of - /data/local/tmp/extract_charger_status.txt - with any issues and state which firmware you were using this with.

I've identified an issue after killing an X10a involving the offline charger. I hope the following can save any further problem's by using the following charger_fix_v3.zip with xRecovery as it is a simple case of rebooting into xRecovery and loading the update. This file is safe for X10 owners as it introduces a stock SE file back to the system, which if not present can render the system a brick.

[ROM] - TripNRaVeR - TripNMiUI - should not be used with this patch as an unknown issue exists with the charger that is currently being researched, until further notice DO NOT apply this update if you are using TripNMiUI or any variant.

There is no SETUID for Android. Android developers state there is no need as Dalvik code will never require elevated or root permissions and hence, it introduces a potential security flaw.

Q: What is it?
A: SE Official charger file - /system/bin/charger - has special permissions which can not be set by root or any other user, the file need's to be moved into place, as it contains setuid or the "Sticky" Unix file system permission.

Wait! How about - chmod 06755 or chmod 04755 - I hear you say? Forget it.. This is not a simple file, it's a Linux binary an ELF Linker file that contains critical system links to (among others//).. the following;

Code:
/sys/class/power_supply/battery/capacity
/sys/devices/platform/msm_pmic_vibrator/enable
/system/bin/chargemon

Nothing special here? Well if you say so! Wait does this look familiar to anyone?

Code:
/sys/class/leds/lv5219lg
RGB LED interface

WLOD (white led of death) issues, or seeing three red blinking led lights ;)

Code:
/sys/class/power_supply/usb/online
/sys/class/power_supply/ac/online
/system/etc/semc/chargemon

This charger file defines the CPU scaling and governor, which is of massive importance to anyone having issues with poor battery life and general performance of their custom rom ;)

For anyone working with customizations around chargemon, you need to include this file and ensure to include - /system/bin/charger - as an entry in any modifications to chargemon right after

#!/system/

It should ALWAYS be the 2nd line in the chargemon file. No questions asked, this file must be optimized and present, it can not be a touch file with any old permission set assigned!

(*ATTN ALL ROM DEVELOPERS*)

Important lesson when handling Android files. You must set the correct permissions and assign the correct security groups - setuid - as they are held in memory. If a part of code executes and is unable to reach the expected memory - WLOD

Not to be patronizing or arrogant, I suspect the issue arrived with Froyo (now in Beta 4), which made it's way via TripNrAvER to a further ROM developers and the issue exists and is present in many (possibly all 2.2.1 Froyo x10 roms) although most user complaint's arrive in strange or hard to understand messages, which is too often interpreted around the forums as just being n00bish and not knowing how to use SEUS or Flashtool...

This thread is specifically for ROM developers and is a deep technical issue. Please do not move this thread to apps or general :)

/data/local/tmp/charger.tar.gz

Thank you DoomLoRD, Androxyde, Bin4y, Zdzihu & Jerpelea for their excellent work and patience, who without their presence and effort on XDA the X10 would never be half of what it is today :)

EDIT: - v1 was not copying to location correctly - v2 uploaded
 

Attachments

  • charger_fix_v1.zip
    11.2 KB · Views: 599
  • charger_fix_v2.zip
    10.8 KB · Views: 355
  • charger_fix_v3.zip
    10.9 KB · Views: 869
Last edited:

MrHassell

Senior Member
Dec 10, 2010
393
249
Melbourne
innertech.com.au
updates

Latest! - zdzihu has released a new version which is for Beta 4 variants specifically - http://www.mediafire.com/?5rr5ygl1udldla1

This fix should not be applied on Trip's MIUI ROM until further notice!

Thanks to My_Immortal & kmilof for pointing out that there is an issue with TripNRavER MIUI :)

Unsure why there was a problem with TripNMui, I will investigate. The permission groups are different and am investigating.

1: Replaces a critical system file with correct system permissions.

How to tell if this exists or if you need this update? It's very easy :) Using a file explorer (i.e; Root Explorer) also others work, browse to the directory; /system/bin/ <- look for the file charger as @cobrato pointed out, it should be identical.

14356 = Binary file size
-rwsr-xr-x = Unix file permission

The permissions are the important part and during the night it was posed, this could be handled with the following command - busybox chmod u+s - while this is true, it is context sensitive. For example if this command is issued in the context of root, the setuid is included and created for root. This file belongs to a special group which can't be modified. If anything it should reset permissions on a file which exists and enable correct permissions on the charger and enable it to work again.

It appears to have been too late for one x10 last night. I received another P.M of death by USB and the problem is real and has claimed many devices, although I am having a hard time pinpointing what caused it, I'm unable to say that much other than this is potentially a cure if even partial as pointed out by picking up on a modification from DooMLoRD, to optimize offline charging.

To prevent your x10 from battery death after modification, never allow the battery to run below 5% - replacing battery might be the only hope if this happens!
 
Last edited:
  • Like
Reactions: guimmp

gregbradley

Retired Forum Moderator
Thanks for your effort in explaining what this zip does.
Not entirely sure what it all means but I understand it to mean everyone on any 2.2 CUSTOM ROM should flash this. I will do so and report back any issues.
PS. I have never had a WLOD FC yet.
BB58 wolfbreak latest update and tweaks test zip. Stock kernal

EDIT: Flashed onto WB ROM...no issues so far.

Sent from my X10i using XDA App
 
Last edited:

colossus

Retired Senior Moderator
Aug 28, 2009
3,215
3,072
@mrHassell

my question is, do we need to flash this everytime we flash a new rom or is it something that just needs to be done once?

I have said before, but thanks again for your tirelress work, you too give a great deal to our x10 forum, thanks for your hardwork my friend.;)
 

jimbo77

Inactive Recognized Contributor
Nov 2, 2010
2,191
2,948
Guatemala
Samsung Galaxy S23 Ultra
@mrHassell

my question is, do we need to flash this everytime we flash a new rom or is it something that just needs to be done once?

Well if the new Custom Roms that will be developed from now onwards include it you won't need to flash it every time but lets said that you'll be flashing FreeX10Beta4 or WB CM 6 ROMS you'll have to do it every time since those ROMS doesn't include it for now and every time you flash a new ROM it overwrites the existing /system/bin folder...

Jim
 

kmilof

Senior Member
Aug 19, 2010
253
18
Linares
i flashed this in TripNMiUI FINAL 1.0.63.. after bootanimation screen's turn black, cant do anything =/.
 

kmilof

Senior Member
Aug 19, 2010
253
18
Linares
I flashed it over Trip's 1.0.2 and everything went fine. Phone booted normally.
I haven't 100% understood what it does, but it certainly did not do me any damage.
Did you make a nandroid before flashing?

yup, i did make a nandroid before flashing, i could restore it and the everything went back to normal. :p

maybe something changed between trip 1.0.2 and 1.0.63 :p
 

kozxmartt

Senior Member
Feb 22, 2011
252
59
I flashed this over reindeiro's scramble ROM without any issues. Thanks for this.

Sent from my X10i using XDA App
 

chiefy009

Senior Member
Oct 29, 2010
4,158
796
Not entiley sure what this is for but still flashed into beta 4 all ok. Thanks

sent from my Z orignal and modded 2.2 powered c64
 

fiscidtox

Senior Member
Dec 2, 2010
1,573
242
A few people saying their phones have been bricked (thinking they were, you can't brick an x10) and getting either a wlod, or three blinking red led flashes, because their battery level got so low and they were unable to offline charge it.

This fixes it and makes sure that cannot happen.

That is what it is for...
 

GlossGhost

Senior Member
Dec 22, 2010
634
120
Sofia
127.0.0.1
A few people saying their phones have been bricked (thinking they were, you can't brick an x10) and getting either a wlod, or three blinking red led flashes, because their battery level got so low and they were unable to offline charge it.

This fixes it and makes sure that cannot happen.

That is what it is for...

I was thinking to be this, I mean not to let the phone to go in soo low battery level. :cool:
 

BULL3TPR00F

Senior Member
Dec 6, 2009
1,054
149
Toronto
thats weird, i always drain my battery to completely dead (3 red flashes) when im trying to recalibrate the battery and never ran into this issue. I have however had issues with low battery causing multiple WLOD reboots over and over.

Is this recommended to use for 2.3.3 as well? I will try n flash it now on J's CM7 017 STOCK.
 

chiefy009

Senior Member
Oct 29, 2010
4,158
796
A few people saying their phones have been bricked (thinking they were, you can't brick an x10) and getting either a wlod, or three blinking red led flashes, because their battery level got so low and they were unable to offline charge it.

This fixes it and makes sure that cannot happen.

That is what it is for...

I see thanks for explaining.

sent from my Z orignal and modded 2.2 powered c64
 

kmilof

Senior Member
Aug 19, 2010
253
18
Linares
dunno what's happening, i flashed again in trip 1.0.63, and again black screen after the boot screen. any idea? :E
 

9Lukas5

Senior Member
Dec 14, 2010
3,914
2,076
near Stuttgart
is it also installed if i include it in a own package who only removes the existing charger in system/bin and then copys the new one or do i have to install the zip you uploaded that it would be installed right?
 

Top Liked Posts

  • There are no posts matching your filters.
  • 23
    This file protects your phone from running below a dangerous level and potentially rendering X10 devices to an unusable or hard brick.

    Hello XDA developers :)

    Latest Version 3 :: Please use the latest version and report back the contents of - /data/local/tmp/extract_charger_status.txt - with any issues and state which firmware you were using this with.

    I've identified an issue after killing an X10a involving the offline charger. I hope the following can save any further problem's by using the following charger_fix_v3.zip with xRecovery as it is a simple case of rebooting into xRecovery and loading the update. This file is safe for X10 owners as it introduces a stock SE file back to the system, which if not present can render the system a brick.

    [ROM] - TripNRaVeR - TripNMiUI - should not be used with this patch as an unknown issue exists with the charger that is currently being researched, until further notice DO NOT apply this update if you are using TripNMiUI or any variant.

    There is no SETUID for Android. Android developers state there is no need as Dalvik code will never require elevated or root permissions and hence, it introduces a potential security flaw.

    Q: What is it?
    A: SE Official charger file - /system/bin/charger - has special permissions which can not be set by root or any other user, the file need's to be moved into place, as it contains setuid or the "Sticky" Unix file system permission.

    Wait! How about - chmod 06755 or chmod 04755 - I hear you say? Forget it.. This is not a simple file, it's a Linux binary an ELF Linker file that contains critical system links to (among others//).. the following;

    Code:
    /sys/class/power_supply/battery/capacity
    /sys/devices/platform/msm_pmic_vibrator/enable
    /system/bin/chargemon

    Nothing special here? Well if you say so! Wait does this look familiar to anyone?

    Code:
    /sys/class/leds/lv5219lg
    RGB LED interface

    WLOD (white led of death) issues, or seeing three red blinking led lights ;)

    Code:
    /sys/class/power_supply/usb/online
    /sys/class/power_supply/ac/online
    /system/etc/semc/chargemon

    This charger file defines the CPU scaling and governor, which is of massive importance to anyone having issues with poor battery life and general performance of their custom rom ;)

    For anyone working with customizations around chargemon, you need to include this file and ensure to include - /system/bin/charger - as an entry in any modifications to chargemon right after

    #!/system/

    It should ALWAYS be the 2nd line in the chargemon file. No questions asked, this file must be optimized and present, it can not be a touch file with any old permission set assigned!

    (*ATTN ALL ROM DEVELOPERS*)

    Important lesson when handling Android files. You must set the correct permissions and assign the correct security groups - setuid - as they are held in memory. If a part of code executes and is unable to reach the expected memory - WLOD

    Not to be patronizing or arrogant, I suspect the issue arrived with Froyo (now in Beta 4), which made it's way via TripNrAvER to a further ROM developers and the issue exists and is present in many (possibly all 2.2.1 Froyo x10 roms) although most user complaint's arrive in strange or hard to understand messages, which is too often interpreted around the forums as just being n00bish and not knowing how to use SEUS or Flashtool...

    This thread is specifically for ROM developers and is a deep technical issue. Please do not move this thread to apps or general :)

    /data/local/tmp/charger.tar.gz

    Thank you DoomLoRD, Androxyde, Bin4y, Zdzihu & Jerpelea for their excellent work and patience, who without their presence and effort on XDA the X10 would never be half of what it is today :)

    EDIT: - v1 was not copying to location correctly - v2 uploaded
    3
    I'm without an X10 to modify right now and anyone to help isn't available.. What is happening is using "Tar" (Unix tape archive) and Gunzip (compression) to preserve permissions of that special system group.

    If you have the file and it matches the permissions / size, then you don't need it;

    1: copy charger.tar.gz to root of X10
    2: tar -pxvzf /charger.tar.gz /system/bin

    If you have Root Explorer and a terminal, is all you need. I would test more if I had an X10 but it is not in my hands, hence am unable to test it right now but it should be work and I'm surprised that it isn't..

    @MrHassell
    i think i got wht the problem is...
    the charger.tar.gz is trying to extract charger in system/bin/ (which is relative to current path) so... here is a possible solution...
    Code:
    cp /data/local/tmp/charger.tar.gz /.
    cd /
    tar -pxvzf charger.tar.gz
    ls -l /system/bin/charg*

    i will try n create a corrected update.zip in the evening when i am back home....



    EDIT:

    modify the extract_charger.sh in the update.zip as follows:

    Code:
    #!/sbin/sh
    
    cp /data/local/tmp/charger.tar.gz /.
    cd /
    tar -pxvzf charger.tar.gz >> /data/local/tmp/extract_charger_status.txt 2>> /data/local/tmp/extract_charger_status.txt
    rm /charger.tar.gz
    this should work...
    it will also create a "log" file @ /data/local/tmp/extract_charger_status.txt so u can check if the command was executed at all and if any error was encountered (stderr will also be dumped to extract_charger_status.txt) [Thank you anantshri for this 2>> tip ;) ]
    2
    @mrHassell

    my question is, do we need to flash this everytime we flash a new rom or is it something that just needs to be done once?

    Well if the new Custom Roms that will be developed from now onwards include it you won't need to flash it every time but lets said that you'll be flashing FreeX10Beta4 or WB CM 6 ROMS you'll have to do it every time since those ROMS doesn't include it for now and every time you flash a new ROM it overwrites the existing /system/bin folder...

    Jim
    2
    A few people saying their phones have been bricked (thinking they were, you can't brick an x10) and getting either a wlod, or three blinking red led flashes, because their battery level got so low and they were unable to offline charge it.

    This fixes it and makes sure that cannot happen.

    That is what it is for...
    1
    Its already included in my latest ROM :)