Fix Toshiba battery issue for Linux

Its been a year since I made my last post and have been thinking about what I could write  to start posting again. I have finally found a perfect one. Yepieeee, Its about vexing Toshiba battery conflict with the kernel.  I have got my battery issue fixed after a long wait. First of all let me thank Steve who proposed the perfect resolution for this issue and many thanks to other people who were also part of this seeking for a resolution.

Here was the scenario.

Laptop Made : Toshiba L650 X5310

OS : Ubuntu, Centos, BackTrack Linux

Issue : None of them detects and show my battery status.

I have tried different versions of Ubutnu, distros, Kernels and none of them helped and hence raised a bug report at https://bugs.launchpad.net/ubuntu/+source/linux/+bug/703302

Surprisingly the thread got replies/responses from many people who were having the same issue and none had a clue about the fix. But reply no:16 by George Moutsopoulos helped me to find the solution.

Old Results :

[bash]efheem@tuxjockey:~$ cat /proc/acpi/battery/BAT1/*
present:                 no
present:                 no
present:                 no
efheem@tuxjockey:~$ dmesg | grep batt
[    1.370268] ACPI: Battery Slot [BAT1] (battery absent)[/bash]

The cause of issue is because Toshiba included two sets of boot data that tell the OS what hardware exists in the machine. Windows reads the correct one whereas Linux doesn’t. We will need to build our own kernel to make this happen. We will need to extract the DSDT (Differentiated System Description Table) from the machine, the ASL modified, and a new AML DSDT can be compiled. The sections below show the way to tell Linux to use this modified DSDT instead of the version that came with the BIOS.

Get the original DSDL of machine:

[bash]# cat /sys/firmware/acpi/tables/DSDT > DSDT.dat[/bash]

Disassemble it

[bash]# iasl -d DSDT.dat[/bash]

Make the changes:

[bash]# vi DSDT.dsl[/bash]

search for line : OperationRegion (EMEM, SystemMemory, 0×FF808001, 0×FF)
and replace it with : OperationRegion (EMEM, EmbeddedControl, 0×00, 0×FF)
save the file.

Build it:

[bash]# iasl -tc DSDT.dsl[/bash]

This will create a file DSDT.hex (This file is used for kernel recompilation)

I received the below two errors during this compilation

N:B :- You can actually ignore these errors, this works even having these error unfixed. But if interested you can work out to get those fixed.  Else directly goto ‘Kernel Recompilation’ section.

———————————-

[bash]DSDT.dsl  2656:                     0×00000000,         // Length
Error    4122 -                              ^ Invalid combination of Length and Min/Max fixed flags

DSDT.dsl  2663:                     0×00000000,         // Length
Error    4122 -                              ^ Invalid combination of Length and Min/Max fixed flags[/bash]

———————————-

Fix : (If you didnt receive any error please skip this part )

open DSDT.dsl file and go to the line where iasl indicated the error. In my case I go to lines 2656 and 2663.

iasl is complaining about the “Length” line “0×00000000″. This is wrong. Look at the “Range Minimum” and “Range Maximum”. Open up your Kcalc or whatever you Gnome people use and change it to Numeral System Mode. Make sure HEX is selected and now we subtract the minimun range from the maximun range and then we add 1. Since the minimum range is 0 (And you can’t subtract 0) I will input  FEAFFFFF and then add 1 which gives me FEB00000  (Don’t get confused, I’m simply omitting “0x”, the calculator doesn’t need this). I change 0×00000000 to 0xFEB00000 by Length. So now it looks like this:

0×00000000,         // Granularity
0×00000000,         // Range Minimum
0xFEAFFFFF,         // Range Maximum
0×00000000,         // Translation Offset
0xFEB00000,         // Length

Line 2663 changed to

0×00000000,    // Granularity
0xFED40000,         // Range Minimum
0xFED44FFF,         // Range Maximum
0×00000000,         // Translation Offset
0×00005000,         // Length

compile again.

Kernel Recompilation :

Install necessary packages:

[bash]apt-get install fakeroot kernel-wedge build-essential makedumpfile kernel-package libncurses5 libncurses5-dev[/bash]
[bash]apt-get build-dep –no-install-recommends linux-image-$(uname -r)[/bash]
[bash]mkdir /root/source

cd /root/source

apt-get source linux-image-$(uname -r)[/bash]

NB: My uname -r was 2.6.38.2-generic

[bash]cd linux-2.6.38[/bash]

(replace this with your kernel version)

copy kernel config file from your current kernel:

[bash]cp -vi /boot/config-`uname -r` .config[/bash]

now copy the DSDT.hex file to the include folder inside kernel source

[bash]cp DSDT.hex /root/source/linux-2.6.38/include[/bash]

open .config file we have just copied

[bash]vi /root/source/linux-2.6.38/.config[/bash]

Make the below changes

[bash]CONFIG_STANDALONE=n
CONFIG_ACPI_CUSTOM_DSDT=y
CONFIG_ACPI_CUSTOM_DSDT_FILE="DSDT.hex"[/bash]

save and quit.

My pwd : /root/source/linux-2.6.38

start compiling the Kernel:

[bash]make menuconfig[/bash]

load the .config file, save the menu file and exit.

We are about to start the compile process . A little trick you can do is to set the CONCURRENCY_LEVEL variable to speed up the compile of the kernel. The number should be the number of processors you have plus one. So in my case I have a Intel Core i5 processor so I will add one with the 4 available.

[bash]cat /proc/cpuinfo | grep -i processor
processor    : 0
processor    : 1
processor    : 2
processor    : 3[/bash]

I have got 4 processors, so concurrency will be 4+1

[bash]# export CONCURRENCY_LEVEL=5[/bash]

Start Building :

Here I named my custom kernel as tuxsage, replace it with the one you wish.

[bash]# make-kpkg clean[/bash]
[bash]# fakeroot make-kpkg –initrd –append-to-version=-tuxsage kernel-image kernel-headers[/bash]

(This will take some time)

Once this is completed you will find the built kernel one directory up from your present directory

[bash]# cd /root/source
# dpkg -i linux-image-2.6.38.(This part will be whatever name you gave it).deb
# dpkg -i linux-headers-2.6.38.(This part will be whatever name you gave it).deb[/bash]

Make initramfs:

[bash]# update-initramfs -c -k 2.6.38+tuxsage (replace tuxsage with correct name)[/bash]

Update Grub :

[bash]#update-grub[/bash]

Reboot to the New Kernel :)

UPDATE : If you are using latest Ubuntu (11.10) with kernel 3.0.0-12-generic then you can get my custom compiled kernel with battery fix downloaded directly from http://www.4shared.com/file/O8CRV1qo/Toshiba-kernel-304-tuxsagetar.html which you can install and use. Have a look at ReadMe.txt for install instructions.

N:B : This post was made very soon after I got this fixed and you may find typos and other errors. Will proofread and fix those soon if any :-)

References :

https://bugs.launchpad.net/ubuntu/+source/linux/+bug/703302

https://bugzilla.kernel.org/show_bug.cgi?id=34532
https://bugzilla.kernel.org/show_bug.cgi?id=15707

http://homeport.org/~bcordes/satellite-l500-install.html

http://www.insanelymac.com/forum/lofiversion/index.php/t189272-100.html

http://en.gentoo-wiki.com/wiki/ACPI/Fix_common_problems

http://www.lesswatts.org/projects/acpi/overridingDSDT.php

http://www.question-defense.com/2010/09/26/how-to-recompile-your-ubuntu-10-10-kernel-for-patching-or-to-add-support-for-a-specific-device

123 thoughts on “Fix Toshiba battery issue for Linux

  1. Well this works as dream. Although this post was not available when I just deal with this, I followed the same procedure to get rid of that long term headache. I ignored the 2 errors given when building DSDT.hex, so far no problems.

    Big thank for steve who came up with this. It is the first workaround I could find whoch actually solved the problem. Thanks everybody who worked hard to get this weired battery issue fixed.

  2. This works like a charm, I thought I would mess something up but with precisely written instructions – I did not!

    Thanks!

  3. Question: Would this fix survive a firmware update? Assuming that the released firmware would not have the fix.

    1. Kumar, I am unsure about this to be frank, need to try it and see. Btw an upgrade completely overwrites the configuration ? I guess it will not and in such case this should remain untouched.

  4. Hi Faheem. It's so good to see this working finally and your how-to is nice indeed. I just wanted to say the true hero is a guy called Steve.

  5. HOLY CRAP!!!! It finally works!!! Thank you so much you would not believe how happy I am now to see my battery status. Now everything on Ubuntu Works Perfectly. :) You're awesome

  6. I can't get it work.

    When I type apt-get build-dep –no-install-recommends linux-image-$(uname -r)

    like above

    I get a message telling that there is no such file or folder.

    Plz give me solution.

  7. Trying that command :

    Result :

    Reading package lists… Done

    Building dependency tree

    Reading state information… Done

    E: Could not open file /var/lib/apt/lists/ppa.launchpad.net_info-g-com_gc-sane_ubuntu_dists_maverick_main_source_Sources – open (2: No such file or directory)

    1. Amule,
      Goto Synaptic Package Manager -> Settings -> Repositories -> Check all the boxes expect "Source Code" And then click on Reload. Try to execute the command again, if this is not yet fixed then you may need to try the fix that 'Sub' has mentioned. Or else just follow the instructions here http://www.howtogeek.com/howto/ubuntu/how-to-cust… (another way for kernel recompilation)

    1. Just follow the instructions that I have mentioned in the post, scroll down to the end of "make menuconfig" menu , load the "config" file, save and just proceed with the rest of instructions.

  8. Friend I have a problem, when throwing the command "fakeroot make-kpkg –initrd –append-to-version=-tuxsage kernel-image kernel-headers", after various time of compiling the screen turns green and restarted the pc :(

  9. Yay ! It finally works. Now I no longer have to rely on the LEDs anymore to find out my battery are on the red.

    Thanks a lot !

  10. Faheem, I fix the green screen wil error, only now I have a problem, pulling the command, " update-initramfs -c -k 2.6.38+tuxsage (replace tuxsage with correct name)"he said found nothing, I put the same name as your tuxsage.

  11. I'm receiving a different error during compilation.:

    ————————————————————————————————————————-

    vamirr@vamirr-remote:~/battery$ iasl -tc DSDT.dsl

    Intel ACPI Component Architecture

    ASL Optimizing Compiler version 20100528 [Oct 15 2010]

    Copyright (c) 2000 – 2010 Intel Corporation

    Supports ACPI Specification Revision 4.0a

    DSDT.dsl 1: ACPI If (SCMP (_OS, "Windows 2006"))

    Error 4096 – ^ syntax error, unexpected PARSEOP_NAMESEG, expecting PARSEOP_DEFINITIONBLOCK

    ASL Input: DSDT.dsl – 16350 lines, 652398 bytes, 0 keywords

    Compilation complete. 1 Errors, 0 Warnings, 0 Remarks, 0 Optimizations

    ————————————————————————————————————-

    Any ideas? This is on a Toshiba L745

  12. @ Faheem

    Ignoring the error, iasl does create the hex file, but it only contains the header:

    /*

    *

    * Intel ACPI Component Architecture

    * ASL Optimizing Compiler version 20100528 [Oct 15 2010]

    * Copyright (c) 2000 – 2010 Intel Corporation

    * Supports ACPI Specification Revision 4.0a

    *

    * Compilation of "DSDT.dsl" – Sat Jul 23 18:06:15 2011

    *

    1. This is all what you have got in DSDT.hex file? Can you send me your DSDT.dsl to techinterplay at gmail dot com ?

  13. I follwed the steps , and am stuck at this step > # iasl -tc DSDT.dsl is not creating the file DSDT.hex ..

    its just giving this output >

    —-

    Intel ACPI Component Architecture

    ASL Optimizing Compiler version 20100528 [Oct 15 2010]

    Copyright (c) 2000 – 2010 Intel Corporation

    Supports ACPI Specification Revision 4.0a

    Non-ascii input file – DSDT.dsl

    how do i fix this ?

  14. i got this message

    dpkg -i linux-image-2.6.38.tuxsage.deb

    dpkg: error processing linux-image-2.6.38.tuxsage.deb (–install):

    cannot access archive: No such file or directory

    Errors were encountered while processing:

    linux-image-2.6.38.tuxsage.deb

    i gave same name is tuxsage, anyone help ?

  15. To All, If any one is still having difficulties in doing this whole process done, just send me your current kernel version and Laptop model to techinterplay at gmail dot com and I will try to make a custom kernel compiled which you can download, install and use. I am not sure weather it will work properly, but could just give a try :-)

    Regards,

    Faheem.

    1. i surely woulld like to accept your kind offer of compiling a kernel for me, if you have no matter wit that. I’ll email you my kernel version and my laptop.

      Also thanks for this article… is nice to see someone happy using linux out of problems :D .

        1. I am very happy now, this is one of the few things that went wrong with my laptop.. bud no w it seems its over! Thanks for all the help!!!

  16. Hey great work! I can’t thank you enough. Never thought I would compile my own kernel. These instructions were very easy to follow. Thanks again.

    1. By the way, before following this guide, I had also tried Ubuntu 11.10 Alpha 3 which includes the 3.0 kernel. I read on some of the bug reports that this Toshiba problem had been fixed but alas no luck they did not work. Only solution I have found is the excellent tutorial here.

      1. Kevin, its sad that the community is not interested in fixing this bug for us in the new releases. One of my friend contacted the developers and he was informed that they are so busy with other stuffs and this bug is having the one among those with least priority

  17. This worked great for the 2.6 kernel, but on debian wheezy I’m running 3.0.0-1 now, and when I get to the step apt-get build-dep –no-install-recommends linux-image-$(uname -r) it says “Picking ‘linux-2.6′ as source package instead of ‘linux-image-3.0.0-1-amd64′

    It seems to me that this isn’t what I want it to do. Any suggestions?

    1. doing an apt-get install linux-source got me what I needed to get going again. I just had to copy it to the the same directory that you used /root/source and change a few of the names in the commands to get it to work.

  18. this really works!!!!! Thanks Faheem for the wonderful post…also for @ gameon you need to edit the file manually rather replacing them in vi or editor…..try that it worked for me….

  19. Hi All,

    This is THE BEST DAY since i got my laptop :D

    its been around 8 month since i bought this laptop and i am a LINUX guy… and i was fairly disappointed with the fact that its battery was not detected, and EVERYTHING else i was able to fix but not this one.

    Also tried to get DSDT hex from windows using the iasl for windows and recompiling linux kernel with that … but no joy…

    That was around 6 months back and i’v almost started to fogget that my laptop came with a battery :P . And i even foggot to follow up with the bugzilla posts .

    I was hoping this will be addressed in the linux kerel 3 , but when i compiled the kernel last day , the battery still was not detected.

    Then i went to the bugzilla , i saw that this was fixed then from there i came here … to your post….

    Man this was easy … now i am having acpi + linux kernl 3.1 …. mmm ur grt.. thanks for all the one followed up with bugzilla and to you for creating this howto page…

    PS : Maan i shoud’v bit more careful when i recompiled the kernel way back….

  20. Hi every1,

    At the time this hack was inducted, kernel developers were notified of this and they also professed to include a patch for upcoming kernel versions. 3.0 is here and seems that it just got swept under the rug. The issue needs to be properly fixed at the kernel level without the need of a hack like this to be done every time.

    Steve, the guy who proposed the hack we all are enjoying has opened a new bug here at

    https://bugzilla.kernel.org/show_bug.cgi?id=41592

    to notify the developers of including a permanent patch for kernels from now on. If you could all make a post (with 3.0 kernel ) with your 1) raw acpidump 2) laptop model it would be a great help to him, indeed a gratitude :)

    Thanks,

  21. Thank you so much for this. I have a Toshiba L645 and it does work. It took me 3x to get it to work but it was worth it. The main problem I had was with the following step:
    Make initramfs:
    1 # update-initramfs -c -k 2.6.38+tuxsage (replace tuxsage with correct name)

    What I had to do was use “All” (# update-initramfs -c -k all) instead of the name. No matter what I put as a name would be accepted. I kept tuxsage as a name as in the example so I could just cut & paste commands. I also found that some of the commands require that you log in as SUDO -i. There may be an easier way to do it, I’m new to Linux…

  22. When I build
    # fakeroot make-kpkg –initrd –append-to-version=-tuxsage kernel-image kernel-headers
    My comps seems to freeze around ~1.5 hrs and the display is off. Should I output to a file so I know where it’s freezing? or keep on the display?

      1. grep processor /proc/cpuinfo
        processor : 0
        processor : 1

        So I export CONCURRENCY_LEVEL=3
        I tried building a 3rd time and it worked this time, the only difference was I piped output to a file… weird.

        But now my headphone jack does not function, sound always plays out the laptop speakers whether external speakers are plugged into the audio jack or not. (and no sound from the external speakers). This happens on all kernels of linux now, so I figure that the problem arose because something became corrupt when shutting off the computer when it was frozen (or else the new adobe flash plugin messed something up). This problem is mostly unrelated, so I declare the new kernel a success! Thanks!

        1. And I fixed the headphone jack problem by adding
          options snd-hda-intel model=thinkpad
          to /etc/modprobe.d/alsa-base.conf
          I wonder why it worked originally. Anyway, Thanks again.

  23. Please help! I’ve gotten up until the make initramfs part. I have no idea what the correct name is, and I’m getting to the point where I want to smash my boyfriends laptop!

    1. Where are you stuck at? Are you getting any error message? If you are a Linux newbie and want me to get the compiled kernel for you, just send me the DSDT.hex files and current kernel version, I shall try from my end and send you the kernel which you can just install and use.

      N:B : Do not smash his laptop, at-least he runs Linux ;)

  24. i cant follow your instruction. it already been denied when i start to write

    cat /sys/firmware/acpi/tables/DSDT > DSDT.dat

    please help me. im using ubuntu 10.10. and im using toshiba satelite L640. thank you

  25. thank you.
    it works like magic.

    but, i have one question.
    do you know why my toshiba l645 fan constantly on?
    it seems something wrong with heat control.

  26. Wait. Maybe I posted too soon, I’m getting the following error message now that I’m trying to make any installation:

    E: The package linux-image-2.6.32.44+drm33.19-tuxsage needs to be reinstalled, but I can’t find an archive for it.

    Help, please?

  27. Thanks for the custom compiled kernel. I can now see the capacity of my battery on my Toshiba Satellite L655.

    However, whether my laptop is plugged in or not, the battery monitor shows the AC adapter as being plugged in. This is not a huge deal for me, but it does mean that I can’t use profiles like “Profile assignment when AC adapter is unplugged” since Ubuntu always sees the adapter as plugged in.

    Is there any information that I can provide you that might help in solving this problem?

    Thanks again!

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>