Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

My brand new Thinkpad X120e is working well with Ubuntu Natty. Now I want to get the tp_smapi module to work so I can control battery charge behavior. Unfortunately I get "no Thinkpad embedded controller" (below).

The thinkwiki tp_smapi page says in this case "you should upgrade your BIOS. Some early BIOS (like 1.x on the X31) don't handle the embedded controller". But in my case, dmidecode suggests I'm already using the almost-newest BIOS from IBM.

# apt-get install tp-smapi-dkms
...(works)...
# modprobe -v tp_smapi
WARNING: Error inserting thinkpad_ec (/lib/modules/2.6.38-7-generic/updates/dkms/thinkpad_ec.ko): No such device
FATAL: Error inserting tp_smapi (/lib/modules/2.6.38-7-generic/updates/dkms/tp_smapi.ko): No such device
# tail -1 /var/log/syslog
Apr 19 23:45:05 xilotl kernel: [ 5552.149408] thinkpad_ec: no ThinkPad embedded controller!
# dmidecode -s bios-version
8FET26WW (1.10 )

Any other idea how to make this work?

UPDATE: Here are other relevant portions of dmidecode (that is, dmidecode -t0 -t1 -t11):

Handle 0x0000, DMI type 0, 24 bytes
BIOS Information
    Vendor: LENOVO
    Version: 8FET26WW (1.10 )
    Release Date: 03/09/2011
    ...

Handle 0x0001, DMI type 1, 27 bytes
System Information
    Manufacturer: LENOVO
    Product Name: 0596CTO
    Version: ThinkPad X120e
    ...

Handle 0x0027, DMI type 11, 5 bytes
OEM Strings
    String 1: OEM default string
share|improve this question
add comment

3 Answers

I was able to make this work by editing the source code of thinkpad_ec.c.

The code expects that when you run dmidecode -t 11 your output should mention "IBM ThinkPad Embedded Controller". However, the new Thinkpad X120e has a good embedded controller which is not mentioned under dmidecode -t 11. As a result, the code failed with the error "thinkpad_ec: no ThinkPad embedded controller!".

To sidestep this check, I added ThinkPad X120e to the current list of whitelisted ThinkPad models in thinkpad_ec.c, then rebuilt the module. It loaded successfully and I was able to set my battery's stop-charge-threshold in /sys/devices/platform/smapi/BAT0 as advertised.


If you are a Thinkpad X120e user and want to use tp_smapi module now, here's how I got past the module load failure:

$ sudo su
# apt-get install tp-smapi-dkms
...(works)...
# modprobe -v tp_smapi
WARNING: Error inserting thinkpad_ec (/lib/modules/2.6.38-7-generic/updates/dkms/thinkpad_ec.ko): No such device
FATAL: Error inserting tp_smapi (/lib/modules/2.6.38-7-generic/updates/dkms/tp_smapi.ko): No such device
# tail -1 /var/log/syslog
Apr 19 23:45:05 xilotl kernel: [ 5552.149408] thinkpad_ec: no ThinkPad embedded controller!

edit the crucial file using vi /usr/src/tp-smapi-0.40/thinkpad_ec.c to add the line marked with +:

diff --git a/thinkpad_ec.c b/thinkpad_ec.c
index a924d18..90d117e 100644
--- a/thinkpad_ec.c
+++ b/thinkpad_ec.c
@@ -460,6 +460,7 @@ static int __init check_dmi_for_ec(void)
                TP_DMI_MATCH("IBM", "ThinkPad A30"),
                TP_DMI_MATCH("IBM", "ThinkPad T23"),
                TP_DMI_MATCH("IBM", "ThinkPad X24"),
+               TP_DMI_MATCH("LENOVO", "ThinkPad X120e"),
                { .ident = NULL }
        };
        return dmi_find_substring(DMI_DEV_TYPE_OEM_STRING,

rebuild the module:

# dkms remove -m tp-smapi -v 0.40 --all
# dkms add -m tp-smapi -v 0.40
# dkms build -m tp-smapi -v 0.40
# dkms install -m tp-smapi -v 0.40
# modprobe tp-smapi

and finally try using it:

# cd /sys/devices/platform/smapi/BAT0
# echo 60 > stop_charge_thresh

As hwong557 mentions, add tp_smapi to /etc/modules so it will load automatically on boot.


If you are the tp_smapi module maintainer or other knowledgeable person who can get this fixed "right": Is this the "right" fix? Should Thinkpad X120e be permanently added to this whitelist, or is there another way that it should check for existence of the embedded controller? I hope either this change or some other fix for the problem will be added to the upstream source.

share|improve this answer
    
You should submit your patch to maintainer so this can be evaluated for inclusion. Good work. –  kce May 16 '11 at 8:36
add comment

A fix on Arch Linux

Download the tp_smapi modules from AUR.

Build and install: makepkg -i

Attempt to load the module:

$ sudo  modprobe -v tp_smapi   
insmod /lib/modules/2.6.38-ARCH/extra/thinkpad_ec.ko.gz 
WARNING: Error inserting thinkpad_ec (/lib/modules/2.6.38-ARCH/extra/thinkpad_ec.ko.gz): No such device
FATAL: Error inserting tp_smapi (/lib/modules/2.6.38-ARCH/extra/tp_smapi.ko.gz): No such device

Check the sys log:

$ dmesg | tail -1           
[ 1009.371778] thinkpad_ec: no ThinkPad embedded controller!

Edit src/tp_smapi-0.40/thinkpad_ec.c as krubo's answer says, adding a patch to the package:

--- thinkpad_ec.c.orig  2011-05-15 13:35:28.556634244 -0700
+++ thinkpad_ec.c       2011-05-15 13:35:40.466634616 -0700
@@ -460,6 +460,7 @@
                TP_DMI_MATCH("IBM", "ThinkPad A30"),
                TP_DMI_MATCH("IBM", "ThinkPad T23"),
                TP_DMI_MATCH("IBM", "ThinkPad X24"),
+               TP_DMI_MATCH("LENOVO", "ThinkPad X120e"),
                { .ident = NULL }
        };
        return dmi_find_substring(DMI_DEV_TYPE_OEM_STRING,

Edit the PKGBUILD to include the new patch:

patch -Np1 < "$srcdir/thinkpad-x120e.patch"     

Remove any previously built package, and rebuild and install the package (makepkg -i) with this patch

Load the module, and you should be in business:

$ sudo modprobe  tp_smapi
$ dmesg | tail -1
[ 1735.966431] tp_smapi successfully loaded (smapi_port=0xb0).
$ ls /sys/devices/platform/smapi 
ac_connected  BAT0  BAT1  driver  modalias  power 
smapi_request  subsystem  uevent
share|improve this answer
add comment

I've tried krubo's solution for my Thinkpad T420. However at the last step with install, I had to add a --force to make the modprobe successful; otherwise it gave me the same error as initially.

However when I try to modify my battery settings, the echo command to /sys/devices/platform/smapi/BAT0/stop_charge_thresh is successful, but upon reading it, cat still gives 100.

Also upon reboot, the module is no longer loaded, and I need to manually modprobe again. This was fixed by adding tp_smapi to /etc/modules.

However, I'm happy to report that hdaps is working; I had to change the last setting in /etc/defaults/hdaps, FORCEENABLE to yes. I checked it using this link: Verifying hdapsd is working (Thinkpad Wiki).

share|improve this answer
    
Could you post the output of dmidecode -t0 -t1 -t11 so we know what exact system you tested? Also, +1 for adding tp_smapi to /etc/modules –  krubo May 27 '11 at 2:54
    
I do have a fix for stop_charge_thresh (Debian-style), but have not managed to get start_charge_thresh working yet: github.com/ginkel/tp_smapi/commit/… –  Thilo-Alexander Ginkel Jun 2 '11 at 22:51
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.