Contribute
Register

[Guide] How to patch DSDT for working battery status

Mr. Rehabman, please help me to checking what is wrong with my dsdt patching for battery status... I am following your guide from the first post, I am convert any 16 bit into 8 bit, breaking into low and high...after compile and put dsdt into extra folder (i am using enoch boot loader)..my battery status is show up...charging and discharging detection work correctly, but the percentage not working normally (some time jumping into 100% or stuck 99% while charging and when discharging the percentage is not decrease correctly, remaining time shown 0:00)

Behaviour percentage while charging is from 0% jump to 20% jump to 40%, (add 20% everytime update), while discharging 100% down to 80%...(minus 20% everytime update)..so weird..:crazy:

On the system Information..at power section..another miss behave is Full Charge Capacity (mAh) = 5

With this kind of problem, i don't know with part of dsdt i have to look up to make another correction...please your guidance , tx before

attach original dsdt,patch dsdt and ioreg

The patches you made to the patched DSDT are wrong. Read post #1 or look for an existing patch that matches your DSDT.
 
Hi @RehabMan,

I'm having trouble patching the DSDT for a Lenovo ThinkPad T420. The problem is, this is not the stock BIOS - I'm running coreboot with TianoCore EFI (but it behaves the same as you'd boot it up through Enoch or Chameleon etc.)

Anyways, it seems that most of the data from the battery is OK. The problem is that the battery remaining percentage is not being updated and the Battery Usage from coconutBattery is insanely high and revolves around 172 watts (!). It looks like a division problem to me but I'm not 100% sure.

There are multiple Fields in this DSDT and there is also one section that I can't wrap my head around - a no name 15 bit register followed by a 1 bit one. Could this be the problem?

I have included the stock DSDT.aml (F4 from Clover) and one with a few patches.

Patches from the stock BIOS ThinkPad T420 do not work - this is a completely different ACPI table.

Specs: T420 i5-3360m (HD4000), 6GB DDR3 RAM, coreboot + tianocore DuetPkg + Clover

Thanks for the help.
 

Attachments

  • DSDT.aml
    13.5 KB · Views: 144
  • DSDT_BatteryFix.dsl
    150.2 KB · Views: 131
  • IOReg_onAC.ioreg
    1.6 MB · Views: 137
  • IOReg_onBattery.ioreg
    1.6 MB · Views: 132
  • SSDT.aml
    5.3 KB · Views: 134
Hi @RehabMan,

I'm having trouble patching the DSDT for a Lenovo ThinkPad T420. The problem is, this is not the stock BIOS - I'm running coreboot with TianoCore EFI (but it behaves the same as you'd boot it up through Enoch or Chameleon etc.)

Anyways, it seems that most of the data from the battery is OK. The problem is that the battery remaining percentage is not being updated and the Battery Usage from coconutBattery is insanely high and revolves around 172 watts (!). It looks like a division problem to me but I'm not 100% sure.

There are multiple Fields in this DSDT and there is also one section that I can't wrap my head around - a no name 15 bit register followed by a 1 bit one. Could this be the problem?

I have included the stock DSDT.aml (F4 from Clover) and one with a few patches.

Patches from the stock BIOS ThinkPad T420 do not work - this is a completely different ACPI table.

Specs: T420 i5-3360m (HD4000), 6GB DDR3 RAM, coreboot + tianocore DuetPkg + Clover

Thanks for the help.

Read post #1, "Problem Reporting".
 

Attachments

  • drowy.zip
    521 KB · Views: 108
  • Clover.zip
    2.1 MB · Views: 118
  • kextcache.txt
    291 bytes · Views: 131
  • kextstat.txt
    773 bytes · Views: 140
  • RehabMan.zip
    8.2 KB · Views: 83
I updated my dump to your specifications.

I think it is likely your patched BIOS is causing the problem (resulting in already patched/wrong DSDT).
Try with stock BIOS (re-extract, re-patch as needed).
 
I think it is likely your patched BIOS is causing the problem (resulting in already patched/wrong DSDT).
Try with stock BIOS (re-extract, re-patch as needed).

I can't try with the stock BIOS or its DSDT. The ACPI implementation is completely different. The whole ordeal with coreboot was to use an Ivy Bridge CPU in the T420 which is a Sandy Bridge-only laptop.

The battery meter works OK under Windows and any Linux distributions.

EDIT: OK, I got the current battery capacity working (it was multiplied by 10) but the battery usage rating is still broken.

Could it be caused by the the fact that the battery unit bit is "Zero" and not "One" so it reports the wrong amount?

Code:
                   Name (BATS, Package (0x0D)
                        {
                            Zero, // battery units?
                            0xFFFFFFFF,
                            0xFFFFFFFF,
                            One,
                            0x2A30,
                            Zero,
                            0xC8,
                            One,
                            One,
                            "",
                            "",
                            "",
                            ""
                        })

I also noticed that this code and especially the marked line seem to change the battery usage somehow:
Code:
                     Store (Local0, Index (Arg1, Zero))
                        If (Local1)
                        {
                            Multiply (B1B2 (ARC0, ARC1), 0x0A, Index (Arg1, 0x02))
                            Multiply (Local2, B1B2 (AVO0, AVO1), Local2)
                            Divide (Local2, 0x03E8, , Index (Arg1, One)) //This one, extra comma?
                        }

I'll try to patch the original DSDT again just to make sure I didn't make a mistake somewhere.
 
Last edited:
I can't try with the stock BIOS or its DSDT. The ACPI implementation is completely different. The whole ordeal with coreboot was to use an Ivy Bridge CPU in the T420 which is a Sandy Bridge-only laptop.

You should use the battery code from your native DSDT.
If you want to work with your current buggy DSDT and fix it, use ACPIDebug to determine what is wrong with the code.
 
The patches you made to the patched DSDT are wrong. Read post #1 or look for an existing patch that matches your DSDT.


Thanks @RehabMan....

My DSDT for battery status is now working for my Nec Versapro vx-d (Mac OS Sierra)
I am sharing my DSDT original and DSDT battery fix...so anybody with the similar notebook can learn from it, because i can not write patching code, i am fixing this manually either field definition and method...except B1B2 method, copy paste from you
 

Attachments

  • DSDT.aml
    35.4 KB · Views: 143
  • DSDT_BAT.aml
    35.7 KB · Views: 128
  • Screen Shot 2016-07-29 at 4.59.46 PM.png
    Screen Shot 2016-07-29 at 4.59.46 PM.png
    1 MB · Views: 175
hi Mr. rehabman
this is my first time posting in this forum
so im sorry if i make a mistake
i follow your guide to patch my battery status, after all, my battery icon allways 0% but its show remaining time, i think this time is correct because when i boot windows its show same time, although not entirely true
when i connect charger it allways show '20:00 until full charging'
i modify your patch hp pavilion n012tx because its similiar with my native dsdt, a little. this is my spec
hp pavilion g4 1214 tx
el capitan 10.11.6
bootloader clover
i5 2430m
ram 4 Gb
ihd 3000
would you mind to check my dsdt and my patch?
i attached what you need
im sorry for my bad english
thank you for your time and your attention
 

Attachments

  • CLOVER.zip
    1.9 MB · Views: 61
  • DSDT_native.zip
    20.6 KB · Views: 84
  • DSDT_patched.zip
    20.7 KB · Views: 71
  • ioregistry.zip
    282.1 KB · Views: 79
  • my patch.zip
    1.4 KB · Views: 86
  • output.zip
    1.2 KB · Views: 104
hi Mr. rehabman
this is my first time posting in this forum
so im sorry if i make a mistake
i follow your guide to patch my battery status, after all, my battery icon allways 0% but its show remaining time, i think this time is correct because when i boot windows its show same time, although not entirely true
when i connect charger it allways show '20:00 until full charging'
i modify your patch hp pavilion n012tx because its similiar with my native dsdt, a little. this is my spec
hp pavilion g4 1214 tx
el capitan 10.11.6
bootloader clover
i5 2430m
ram 4 Gb
ihd 3000
would you mind to check my dsdt and my patch?
i attached what you need
im sorry for my bad english
thank you for your time and your attention

Your DSDT is not patched correctly. You missed several multibyte EC fields.

Looks to me that existing patches "HP G2 2221ss" or "HP DV6 3165sf" are potential matches.
 
Back
Top