cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
wschaub
Punch Card
Posts: 55
Registered: ‎05-24-2013
Location: United States
Views: 8,114
Message 1 of 7

T530 settings for Ubuntu 12.04 LTS (precise)

I have just finished creating a script that configures Ubuntu 12.04LTS to work with the thinkpad T530. 

 

I will be documenting all of the configuration changes in this thread soon but in the mean time you can grab it and examine what the script does at  https://github.com/wschaub/T530-settings

 

This will basically:

  • install and setup fingerprint reader software
  • patch the thinkpad_acpi module to support the mic mute button as well as the mic mute LED.
  • install power management scripts to handle dismounting SD cards before suspend so that suspend/hibernate does not hang
  • install power management script to restore mic mute LED state
  • add additional modules to SUSPEND_MODULES= in /etc/pm/config.d/modules
  • enable hibernate in policykit
  • enable advanced battery management and set up the battery to start charging at 40% and stop charge at 80%
  • not necessarily a thinkpad specifc thing but enable manual configuration of interfaces in network manager by using a policykit rule.
  • add ACPI event script to handle mute button/LED
  • modify /etc/rc.local to mute the mic and light the mute LED on boot, and also set up the battery charge thresholds if they have changed back to the defaults.
  • add aesni-intel, xts and acpiphp to /etc/initramfs-tools/modules

You will want to be running the 3.2.0 kernel instead of the 3.5.x one installed by newer 12.04LTS install disks. 

 

I hope this helps people save some time looking around to figure out how to do all of that on a T530 or similar laptop.

 

my next post will document all of this so you can do it manually on your system without the script and explain what each change does and why. 

wschaub
Punch Card
Posts: 55
Registered: ‎05-24-2013
Location: United States
Views: 8,039
Message 2 of 7

Re: T530 settings for Ubuntu 12.04 LTS (precise)

as promised I'm documenting what all those config files do. A lot of this stuff is re-posted from my posts to the linux user's group of rochester's mailing list documenting all of this stuff. The stuff that is in github is the most recent versions that I use all packaged up in one place and they may be slightly different than what is posted here but essentally it's the same thing. 

 

so here's the posts in order:

 

Post #1:

 

I got the think with windows 8 64 bit pre-installed. I wanted to try a dual boot setup with it but that just wasn't working well at all with Ubuntu precise. in fact even though ubuntu precise does have grub support for EFI assuming you disable secure boot. I wasn't able to get it to boot at all without doing a firmware upgrade from a cd image.

once that was done I had to work with getting X working with both the intel HD4000 GPU and the nvidia graphics.
it seems that the open source nvidia driver doesn't like to work with it in descrete graphics mode. but the experimental nvidia driver works fine. optimus is not supported under linux (aside form the experimental bumblebee stuff which I don't want to screw with) thankfully unlike some other optimus laptops you can select in bios to have the OS only see either the intel or the nvidia graphics. so I can choose at boot time whether I want better graphics performance or better power consumption. Honestly though I haven't really had anything to complain about so far with just keeping it on the intel graphics.

On nvidia graphics the linux text console does not show up and you can't see anything until X starts. other than that it works fine.

in order to suspend and have hibernate work I had to make sure the wireless module unloads on suspend by adding the following to /etc/pm/config.d/modules:
SUSPEND_MODULES="uhci_hd button ehci_hd iwlwifi"

finally I wanted to get the fingerprint reader working. I had already set it up in the bios to authenticate me for my power on password/supervisor password via fingerprint. and enrolled those fingerprints with the lenovo fingerprint software under windows. If you want to use your fingerprint reader for pre-boot stuff I would recommend setting up your prints from the windows utility and selecting the power on checkbox for the enrolled prints first before messing around under linux.

Finally making the fingerprint reader work under linux required following the instructions at this link here:
http://askubuntu.com/questions/193528/how-to-enable-fingerprint-device-for-thinkpad-t430s-in-12-04/2...

I hope someone on this list finds this info helpful. another thing I did was to remove the boot splash and unhide the grub menu but that's more a matter of personal taste.  aside from linux tweaks I'm very happy with this laptop and can't wait to get 16GB of ram put into it soon. Does anyone know of a good 1TB (or bigger) drive that for sure works and fits in this thing? doing searches online I can only find 500GB drives. I know I can put an extra drive in the ultrabay but I kind of want to keep my dvd-rw drive.

I wanted to like MATE but it was buggy under precise so I ended up using cinnamon which seems to give me everything I need so far. I hear that secure boot support will be added in the next precise point release. it will be interesting to see how well that works for me then. I basically want to re-do the system dual booting windows 7 and precise living on an encrypted LVM when I upgrade to a larger disk.

 

Post #2:

Forgot to mention hibernate support basically make sure you edit /etc/default/grub and
you have a line that looks similar to this GRUB_CMDLINE_LINUX_DEFAULT="resume=/dev/sda3 loop.max_part=63"
the /dev/sda3 part can and probably should be the swap partition's UUID  you will also want to enable hibernate in the GUI by creating a policy file (/etc/polkit-1/localauthority/50-local.d/com.ubuntu.enable-hibernate.pkla)
that looks like:
[Re-enable hibernate by default]
Identity=unix-user:*
Action=org.freedesktop.upower.hibernate
ResultActive=yes

make sure you run update-grub and reboot and things should start working (make sure you take care of the stuff to make suspend work first before you try to hibernate though)

the loop.max_part=63 bit is a tweak I do to make loop devices recognize partitions and have them show up at /dev//loop0p1, /dev/loop0p2 etc. 

 

Post #3:

I managed to get the mic mute button and light working by mostly following the instructions below:
http://askubuntu.com/questions/125367/enabling-mic-mute-button-and-light-on-lenovo-thinkpads

I used the instructions here along with the linux-source package to build just the thinkpad_acpi module with the patch
referenced from the first link:  ( http://permalink.gmane.org/gmane.linux.drivers.platform.x86.devel/1962)
http://www.codewhirl.com/2012/04/how-to-compile-a-single-module-in-ubuntu-linux/

after placing the acpi.patch file inside the kernel tree I ran the following commands to re-build and install the new thinkpad_acpi module:

sudo apt-get install linux-source
mkdir src
cd src
tar xvf /usr/src/linux-source-3.2.0.tar.bz2
cd linux-source-3.2.0
patch -p1 <acpi.patch
cp -vi /boot/config-`uname -r` .config
cp /usr/src/linux-headers-3.2.0-36-generic/Module.symvers .
make -j8 EXTRAVERSION=-36-generic oldconfig
make -j8 EXTRAVERSION=-36-generic prepare
make -j8 EXTRAVERSION=-36-generic archprepare
make -j8 EXTRAVERSION=-36-generic modules SUBDIRS=scripts
make -j8 EXTRAVERSION=-36-generic modules SUBDIRS=drivers/platform/x86
sudo cp drivers/platform/x86/thinkpad_acpi.ko /lib/modules/3.2.0-36-generic/kernel/drivers/platform/x86/
sudo depmod -a
sudo update-initramfs -v -u -k `uname -r`

after this is done it should reboot with the new acpi module.

there is just the acpi event/shell script left over.

there are 3 files attached to this email:
acpi.patch which contains the thinkpad_acpi patch from the mailing list
lenovo-mutemic which belongs in /etc/acpi/events
lenovo-mutemic.sh which belongs in /etc/acpi and needs to be executable. (chmod a+x /etc/acpi/lenovo-mutemic.sh)

you will want to edit the script to contain your username so that notifications get sent to the right user (or just comment out those lines since the mic mute light will be toggled anyway.)

Finally I added the following to /etc/rc.local to make sure the mic is always muted if it isn't already at boot and to make sure the mic mute light is on if the mic has already been muted when the machine boots.

#mute microphone on boot
INPUT_DEVICE="'Capture'"
MICMUTE=/sys/devices/platform/thinkpad_acpi/leds/tpacpi::micmute/brightness
if amixer sget $INPUT_DEVICE,0 | grep '\[on\]' ; then
    amixer sset $INPUT_DEVICE,0 toggle
    echo 1 > $MICMUTE
else
#already muted, restore LED state
    echo 1 > $MICMUTE
fi


just reboot or restart acpid at this point and you should be good to go. This seems to be the last thing  on my T530 that I wasn't able to make work out of the box. I hope all this info will be of use to someone reading the mailing list. 

 

Post #4:

I just ran into another problem it seems that having any sd cards mounted on suspend will cause a hang. I found a nice script at
https://help.ubuntu.com/community/AspireOne/Ubuntu9.10 that seems to do the trick.

# Drop to: /etc/pm/sleep.d
# Use this script to prevent data loss on mounted MMC/SD
# cards. It syncs data and umounts all mmcblk devices prior to
# suspend, and cancels suspend if umounting was not possible
# (i.e: something locks a file)
case "${1}" in
    hibernate|suspend)
        /bin/sync
        for drive in $( /bin/ls /dev/mmcblk?p* ); do
            /bin/umount ${drive} > /dev/null
            # If umount failed: abort suspend
            if [ $? -gt 0 ]; then
            # Test if device keeps mounted. Previous command could fail
            # (i.e device was not mounted) with a non-stopper
            # problem for the suspend process.
            /bin/mount | /bin/grep ${drive}
            if [ $? -eq 0 ]; then
                exit 1
            fi
            fi
        done
        ;;
#    resume|thaw)
##       Do nothing. All devices will be automatically mounted again.
#       ;;
esac 

 

Post #5:

Today I set up the laptop to only start charging the battery at 40% and stop charge at 80% to help improve battery life since I don't disconnect from power very often. tp-smapi doesn't work on newer thinkpads but I found something that works just fine on the arch linux site.

just run git clone git://github.com/teleshoes/tpacpi-bat.git and then run install.pl as root. This will fetch and build a kernel module used to talk to ACPI that allows the command to work. Changes made with tp-acpi persist across reboots/power cycles, they do however seem to be reset when the battery is removed and re-inserted.   My script only checks the status of battery 1. if you have a second or 3rd battery you will want to modify the script a bit to check those as well. specifying battery 0 sets that option for all currently attached batteries.

I put this inside my /etc/rc.local to only change the settings when necessary on boot. (make sure /usr/local/bin is in your path or this will do nothing!)
#Set up battery charge threshold only if it diverges from the norm
if [ "40" = "$(tpacpi-bat -g ST 1 | awk '{ print $1 }')" ]; then
    echo 'Battery charge start threshold already at 40 percent'
else
    echo 'Setting battery charge start threshold to 40 precent'
    tpacpi-bat -s ST 0 40
fi
if [ "80" = "$(tpacpi-bat -g SP 1 | awk '{ print $1 }')" ]; then
    echo 'Battery stop charge threshold already at 80 percent'
else
    echo 'Setting Battery stop charge threshold to 80 percent'
    tpacpi-bat -s SP 0 80
fi 

 

wschaub
Punch Card
Posts: 55
Registered: ‎05-24-2013
Location: United States
Views: 8,034
Message 3 of 7

Re: T530 settings for Ubuntu 12.04 LTS (precise)

Now here is what you will find in the git repo:

 

install.sh will copy over all of the config files mentioned here, including rc.local it attempts ot run a diff and ask you first if you want to copy it over if it's different than what I have. it should also attempt to make a backup copy but having a backup of your /etc/ files might be wise.

 

The only thing install.sh doesn't do is edit /etc/default/grub to add the resume= option to the kernel command line.

you will want to set this to either UUID= and the uuid of your swap device or something like /dev/mapper/T530-swap if you are using LVM like I am. if you never intend to hibernate you can ignore this entirely, but might as well have hibernate support if you can get it.

 

after it's done copying the config files over and installing the fingerprint reader software it will run patch_acpi.sh which pulls in the linux kernel source, patches the thinkpad_acpi module to support the extra leds like the mic mute LED and

recompiles the module and installs it, then it installs the tpacpi-bat command (which also installs the acpi call module it uses to invoke ACPI methods into your kernel) 

 

You will want to run patch_acpi.sh every time you get a new kernel update. I've only tested it with the 3.2.0 kernel that comes with 12.04LTS. there is a 3.5.x and 3.8.x kernel available as well but there is no linux-source packages for that to pull down so you would have to modify the script to take care of that for you. (the acpi patch does work on those kernels BTW once you find the source).

 

I have also done some uncommitted changes to better support switching between integrated and descreet graphics with this new version of /etc/rc.local it's a bit hacky but unless there is some secret way to re-route the mini displayport to the Intel HD4000 I will have to re-boot into descreet mode if I want to use my displayport for HDMI.

 

the new /etc/rc.local script (which I haven't committed yet) detects if the nvidia module (from the nvidia-current package) is loaded. and if so switches around the alternatives symlinks so the system uses the nvidia libraries/xorg drivers, if the nvidia module is not loaded it switches back to the standard MESA GL libs and regular xorg glx driver etc. 

 

this is what the new /etc/rc.local looks like:

 

#!/bin/sh
#
# rc.local
#
# This script is executed at the end of each multiuser runlevel.
# Make sure that the script will "exit 0" on success or any other
# value on error.
#
# In order to enable or disable this script just change the execution
# bits.
#
# By default this script does nothing.

PATH=$PATH:/usr/local/bin

export PATH

#launch dmeventd
/sbin/dmeventd
#The nvidia driver somehow **bleep**s with ACPI, if we are running the nvidia driver
#force reload of the thinkpad_acpi driver.
#we also need to hack around various **bleep** done by alternatives when we are
#booted into integrated graphics mode so we can easily switch back and forth
#by changing the BIOS setting. This should fix this case too... UGH!
lsmod | grep -i nvidia 2>&1 >/dev/null
if [ $? -eq 0 ]; then
#NVIDIA workarounds
service lightdm stop
sleep 2
(cd /etc/alternatives; rm -f x86_64-linux-gnu_xorg_extra_modules; ln -s nvidia_xorg_modules x86_64-linux-gnu_xorg_extra_modules)
(cd /etc/alternatives; rm -f x86_64-linux-gnu_gl_conf; ln -s nvidia_x86_64_gl_conf x86_64-linux-gnu_gl_conf)
(cd /etc/alternatives; rm -f i386-linux-gnu_gl_conf; ln -s nvidia_i386_gl_conf i386-linux-gnu_gl_conf)
ldconfig
service lightdm start
sleep 3
modprobe -r thinkpad_acpi
modprobe thinkpad_acpi
service acpid restart
else
#Undo NVIDIA hacks
if [ "default_xorg_modules" = "$(readlink /etc/alternatives/x86_64-linux-gnu_xorg_extra_modules)" ]; then
true
else
(cd /etc/alternatives; rm -f x86_64-linux-gnu_xorg_extra_modules; ln -s default_xorg_modules x86_64-linux-gnu_xorg_extra_modules)
(cd /etc/alternatives; rm -f x86_64-linux-gnu_gl_conf; ln -s default_x86_64_gl_conf x86_64-linux-gnu_gl_conf)
(cd /etc/alternatives; rm -f i386-linux-gnu_gl_conf; ln -s default_i386_gl_conf i386-linux-gnu_gl_conf)
ldconfig
service lightdm stop
sleep 1
service lightdm start
fi
fi
#mute microphone on boot
INPUT_DEVICE="'Capture'"
MICMUTE=/sys/devices/platform/thinkpad_acpi/leds/tpacpi::micmute/brightness
if amixer sget $INPUT_DEVICE,0 | grep '\[on\]' ; then
amixer sset $INPUT_DEVICE,0 toggle
echo 1 > $MICMUTE
else
#already muted, restore LED state
echo 1 > $MICMUTE
fi
#Set up battery charge threshold only if it diverges from the norm
testbat
if [ $? -ne 0 ]; then
tpacpi-bat -s ST 0 40
tpacpi-bat -s SP 0 80
fi
exit 0

 

testbat is simply a small shell script in /usr/local/bin that looks like this:

#!/bin/sh
if [ "40" = "$(tpacpi-bat -g ST 1 | awk '{ print $1 }')" ]; then
echo 'Battery charge start threshold already at 40 percent'
else
echo 'Battery charge start threshold set to something else!'
tpacpi-bat -v -g ST 1
exit 1
fi
if [ "80" = "$(tpacpi-bat -g SP 1 | awk '{ print $1 }')" ]; then
echo 'Battery stop charge threshold already at 80 percent'
else
echo 'Battery stop charge threshold set to something else!'
tpacpi-bat -v -g SP 1
exit 1
fi
exit 0

 

In order for the /etc/alternatives switching to work you will need several symlinks setup inside of /etc/alternatives

(or you will have major problems with X if you try to use this new rc.local script without them in place. this assumes you have the closed source nvidia driver installed via the nvidia-current package:

ln -s /usr/lib/xorg default_xorg_modules 

ln -s /usr/lib/i386-linux-gnu/mesa/ld.so.conf default_i386_gl_conf

ln -s /usr/lib/x86_64-linux-gnu/mesa/ld.so.conf default_x86_64_gl_conf

 

ln -s /usr/lib/nvidia-current/xorg nvidia_xorg_modules

ln -s /usr/lib/nvidia-current/ld.so.conf nvidia_x86_64_gl_conf

ln -s /usr/lib/nvidia-current/alt_ld.so.conf nvidia_i386_gl_conf

 

The rest of the new stuff in rc.local is just to make sure that X is restarted with the correct libs/modules and in the case of nvidia drivers being loaded, re-loads the thinkpad_acpi driver so that hotkey presses (anbd possibly other events) are actually seen. I have no idea why this happens with descrete graphics mode and the closed source (and even open source nvidia drivers) but it does.

 

The only 2 issues I have yet to resolve with booting with the nvidia drivers are the fact that the linux text console doesn't show up at all. and the brightness control does not work. I've tried everything and it just doesn't want to co-operate. there is an ACPI backlight detected by the kernel and using the brightness keys does change the values in /sys/class/backlight but the brightness never changes. 

 

I rarely boot into descreet graphics anyway so it's not the biggest problem ever. HD4000 graphics is more than powerful enough for me in most cases. If there was a way to make it work with the displayport when booted into integrated graphics mode I would be very happy and only ever use the nvidia card under windows 

 

anyway I hope this info helps someone that wants to set up a similar laptop under Ubuntu. I would bet a lot of this has been rolled into newer releases than 12.04LTS but I like a long term support release for my every day machine so I can tweak it the way I want it and not have the while system change out from under me every 6 months or so. 

 

wschaub
Punch Card
Posts: 55
Registered: ‎05-24-2013
Location: United States
Views: 8,014
Message 4 of 7

Re: T530 settings for Ubuntu 12.04 LTS (precise)

rebooting into windows resets the battery settings unfortunately so I added a power management script to reset it after resume from hibernate. once we get back into linux. (I sometimes hibernate and then boot into windows for something and then resume linux where I left off)

 

I also found and corrected a bug in my rc.local init script. (and edited the posts to reflect that) you need /usr/local/bin in your path or the tpacpi-bat script will not get run.

 

 

wschaub
Punch Card
Posts: 55
Registered: ‎05-24-2013
Location: United States
Views: 7,929
Message 5 of 7

Re: T530 settings for Ubuntu 12.04 LTS (precise)

I just created an eSATAfixes branch to share the work I had to do (hunting down and applying 2 libata-pmp kernel patches) to get my sil3826 based eSATA JBOD enclosure to work with my startech.com ECESATA1 card.

https://github.com/wschaub/T530-settings/tree/eSATAfixes

 

I did it as a seperate branch from main since this is more specific to add on hardware that I'm using and not anything specific to just the T530. The enclosure I'm using is a Sans Digital TR4M-BNC.

 

I really wish the T530 had an eSATA port on it. I don't have a dock with eSATA so I have had no way to test the internal SATA controller with port multipliers. The 3826 has the same quirks it seems as the older 3726 and it seems that this patch has not made it into the kernel, if you search hard enough you can find both patches on various mailing lists and bug rackers though. I would expect it to give trouble no matter what card you use (assuming it exposes the PMP to the OS, I did have one card that didn't expose the PMP to the OS for libata to do anything with it (some marvell chipset) but it had I think a hardware problem where it just stopped responding after pushing so many GB through it (even under windows!) so I ditched it for a slower SIL3132 based card instead) 

 

I hope this helps someone else avoid a lot of frustration. If I find a 34mm 6GBPS eSATA expresscard that doesn't totally suck I will probably update this post or maybe start a new thread. 

wschaub
Punch Card
Posts: 55
Registered: ‎05-24-2013
Location: United States
Views: 7,861
Message 6 of 7

Re: T530 settings for Ubuntu 12.04 LTS (precise)

I recently added some example backup scripts (the ones I use) and the ultrabay-scripts from http://sourceforge.net/projects/wmlive/files/ultrabay-scripts/ to the git tree.

wschaub
Punch Card
Posts: 55
Registered: ‎05-24-2013
Location: United States
Views: 6,457
Message 7 of 7

Re: T530 settings for Ubuntu 12.04 LTS (precise)

I just committed a fix for the laptop sometimes waking immediately after sleep. turns out that ubuntu now compiles in the usb controller drivers instead of having them as modules. so I have a new /etc/pm/sleep.d script that unbinds the usb buses from the drivers and puts them back on wakeup. It seems to work fine for the last few days.

Check out current deals!


Shop current deals

Top Kudoed Authors