Monday, March 12, 2012

Toshiba Satellite L640 battery in Ubuntu Linux

A vanilla installation of Ubuntu Natty (11.04) doesn't show a battery indicator for my Toshiba Satellite L640 PSK0LA-05X00T. No battery is detected.

The problem seems to be in the process of being fixed, but in the meantime there is a workaround. The instructions below are a blend of those taken from posts by Faheem and Michael Kuron. Thanks!

  1. Extract the current DSDT.

    $ sudo cat /sys/firmware/acpi/tables/DSDT > dsdt.dat
  2. Decompile it.

    $ sudo apt-get install iasl
    $ iasl -d dsdt.dat
  3. Patch the source, as described here.

    $ sed -i 's/OperationRegion (EMEM, SystemMemory, 0xFF808001, 0xFF)/OperationRegion (EMEM, EmbeddedControl, 0x00, 0xFF)/g' dsdt.dsl
  4. Recompile the modified source.

    $ iasl -tc dsdt.dsl
  5. Configure GRUB to use the modified DSDT.

    $ sudo cp dsdt.aml /boot/
    $ sudo nano /etc/grub.d/01_acpi
    ----
    #! /bin/sh -e
    
    # Uncomment to load custom ACPI table
    GRUB_CUSTOM_ACPI="/boot/dsdt.aml"
    
    # DON'T MODIFY ANYTHING BELOW THIS LINE!
    
    prefix=/usr
    exec_prefix=${prefix}
    libdir=${exec_prefix}/lib
    
    . ${libdir}/grub/grub-mkconfig_lib
    
    # Load custom ACPI table
    if [ x${GRUB_CUSTOM_ACPI} != x ] && [ -f ${GRUB_CUSTOM_ACPI} ] \
            && is_path_readable_by_grub ${GRUB_CUSTOM_ACPI}; then
        echo "Found custom ACPI table: ${GRUB_CUSTOM_ACPI}" >&2
        prepare_grub_to_access_device `${grub_probe} --target=device ${GRUB_CUSTOM_ACPI}` | sed -e "s/^/  /"
        cat << EOF
    acpi (\$root)`make_system_path_relative_to_its_root ${GRUB_CUSTOM_ACPI}`
    EOF
    fi
    ----
    $ sudo chmod +x /etc/grub.d/01_acpi
    $ sudo update-grub2
    ...
    Found custom ACPI table: /boot/dsdt.aml
    ...
  6. Reboot and enjoy proper battery support.

No comments:

Post a Comment