How do I build/make custom driver into kernel?

Hi All,

I’m new to linux and recently installed openSUSE 11.1 on my Lenovo Thinkpad SL500. So far it’s great… only problem is the hotkeys and brightness control don’t work.

Digging around online I found this “experimental” driver that purportedly works fine, but I have no idea how to compile, install, or otherwise use it. Here…

tetromino’s lenovo-sl-laptop at master - GitHub

I’m not sure what to do with the makefile and C file provided. For example, what do I do with this instruction…

“To enable the brightness control, load the module with the
“control_backlight=1” module parameter (i.e.
insmod lenovo-sl-laptop.ko control_backlight=1 )”

I know someone on here will be able to explain how to do this in a “computer engineering for chemists” language! I’m comfortable enough working in the terminal with commands, but have found no real straightforward explanation of how to do so (only “programming” experience is MATLAB m file writing).

Thanks!

Erik

(Sorry about reposting in general Hardware; thought I might get more views here.)

Hi
If you search here now on lenovo I’ve built two files for you;
Get It

1 - lenovo-sl-laptop-kmp-<your kernel type>-<arch>
2 - lenovo-options

If you use the uname -r command to confirm your kernel version and
download the correct version, if you have updated the kernel it should
be 2.6.27.19-3.2-<your kernel type>

Download and change to the download location. Then install via the
following command;


sudo rpm -Uhv lenovo*
sudo /sbin/insmod lenovo-sl-laptop

This will install the kernel module and implement the options for the
backlight.

You may need to add lenovo-sl-laptop to the MODULES_LOADED_ON_BOOT
variable in /etc/sysconfig/kernel so it adds itself during boot.

To see what was down download the src files and extract them and look
at the spec file.


Cheers Malcolm °¿° (Linux Counter #276890)
openSUSE 11.1 (i586) Kernel 2.6.27.19-3.2-pae
up 15:36, 3 users, load average: 0.29, 0.34, 0.40
ASUS eeePC 1000HE ATOM N280 1.66GHz | GPU Mobile 945GM/GMS/GME

Thanks Malcolm! I think I almost have it…

I downloaded your lenovo-sl-laptop-kmp-default-1_2.6.27.19_3.2-2.1.i586.rpm

as well as…

lenovo-options-1-1.1.noarch.rpm

When, I keep the .rpm files on my desktop and then try to install, these are the errors I get…

linux-7dqu:/home/Erik/Desktop # uname -r
2.6.27.19-3.2-default
linux-7dqu:/home/Erik/Desktop # sudo rpm -Uhv lenovo*
error: open of <metapackage failed: No such file or directory
error: open of xmlns:os=http://opensuse.org/Standards/One_Click_Install failed: No such file or directory
error: open of xmlns=http://opensuse.org/Standards/One_Click_Install> failed: No such file or directory
error: open of <group> failed: No such file or directory
error: open of <repositories> failed: No such file or directory
error: open of <repository failed: No such file or directory
error: open of recommended=true> failed: No such file or directory
error: open of <name>home:malcolmlewis</name> failed: No such file or directory
error: open of <summary>malcolmlewiss Home Project</summary> <description>General project for openSUSE and SLED rpms</description> <url>http://download.opensuse.org/repositories/home:/malcolmlewis/openSUSE_11.1/</url> </repository> <repository recommended=“false”> <name>openSUSE:11.1</name> <summary>The openSUSE 11.1 distribution</summary> <description>The openSUSE 11.1 distribution rpm and iso file downloads are disabled by intention, please use our official released RCs from the download mirrors. </description> <url>http://download.opensuse.org/distribution/11.1/repo/oss/</url> </repository> </repositories> <software> <item> <name>lenovo-options</name> <summary>Module options</summary> <description>This package contains the lenovo-sl-laptop module options</description> </item> </software> </group> </metapackage> failed: No such file or directory
error: open of <metapackage failed: No such file or directory
error: open of xmlns:os=http://opensuse.org/Standards/One_Click_Install failed: No such file or directory
error: open of xmlns=http://opensuse.org/Standards/One_Click_Install> failed: No such file or directory
error: open of <group> failed: No such file or directory
error: open of <repositories> failed: No such file or directory
error: open of <repository failed: No such file or directory
error: open of recommended=true> failed: No such file or directory
error: open of <name>home:malcolmlewis</name> failed: No such file or directory
error: open of <summary>malcolmlewiss Home Project</summary> <description>General project for openSUSE and SLED rpms</description> <url>http://download.opensuse.org/repositories/home:/malcolmlewis/openSUSE_11.1_Update/</url> </repository> <repository recommended=“true”> <name>openSUSE:11.1:Update</name> <summary>Official Released Updates For openSUSE 11.1</summary> <description></description> <url>http://download.opensuse.org/update/11.1/</url> </repository> <repository recommended=“false”> <name>openSUSE:11.1</name> <summary>The openSUSE 11.1 distribution</summary> <description>The openSUSE 11.1 distribution rpm and iso file downloads are disabled by intention, please use our official released RCs from the download mirrors. </description> <url>http://download.opensuse.org/distribution/11.1/repo/oss/</url> </repository> </repositories> <software> <item> <name>lenovo-sl-laptop-kmp-default</name> <summary>Kernel module lenovo-sl-laptop</summary> <description>This is an experimental driver for the Lenovo ThinkPad SL series, since those laptops are currently not supported by the thinkpad_acpi driver.</description> </item> </software> </group> </metapackage> failed: No such file or directory
linux-7dqu:/home/Erik/Desktop # sudo /sbin/insmod lenovo-sl-laptop
insmod: can’t read ‘lenovo-sl-laptop’: No such file or directory

I’m afraid I might be doing something stupid like actually typing “lenovo*” when the * is indicating I should type something else.

Would it make more sense to use the ymp files instead of doing it in terminal?

Thanks again for your help.

Erik

Hi
Move them to your home directory rather than the Desktop, you also
don’t need to be root user, just use the sudo command.

No, the asterisk (*) is correct, thats the wildcard :slight_smile:

The insmod command doesn’t need the asterisk at the end though.


Cheers Malcolm °¿° (Linux Counter #276890)
openSUSE 11.1 (i586) Kernel 2.6.27.19-3.2-pae
up 19:21, 1 user, load average: 0.24, 0.13, 0.10
ASUS eeePC 1000HE ATOM N280 1.66GHz | GPU Mobile 945GM/GMS/GME

Done. After…

sudo rpm -Uhv lenovo*

It indicates that both lenovo-sl-laptop-etc and lenovo-options-1-1.1.noarch are installed.

Next, after…

sudo /sbin/insmod lenovo-sl-laptop

I get “can’t read” and “No such file or directory,” and the backlight still doesn’t work. Do you think I need to add it to the modules loaded on boot (and how do I do that? It doesn’t seem to be in the /etc/sysconfig in yast. How would I move it using commands in terminal?) or am I still missing something easy?

Thanks,

Erik

Hi
If you run the command;


sudo /sbin/modinfo lenovo-sl-laptop

Do you get output? If so, add the module as below and reboot.

In YaST->System->/etc/sysconfig editor and search on kernel, in the
list you will see the modules entry, highlight and go to, edit as
appropriate :slight_smile:


Cheers Malcolm °¿° (Linux Counter #276890)
openSUSE 11.1 (i586) Kernel 2.6.27.19-3.2-pae
up 0:14, 2 users, load average: 0.28, 0.32, 0.31
ASUS eeePC 1000HE ATOM N280 1.66GHz | GPU Mobile 945GM/GMS/GME

Success!!! Thanks, Malcolm. My first linux system is running great now!

One last (dumb?) question: can I delete the rpm files in my home now and assume they’re “built into” the kernel now?

Hi
Glad it’s all working :slight_smile: Now, be aware if the kernel updates sometimes
the build service may not get an updated kernel in time so it will
break!!

To overcome this you can build from the src rpm except you need to
install additional items;

kernel-source, kernel-syms, linux-kernel-headers, module-init-tools,
gcc and make. Then you would use the following commands to install;


rpmbuild --rebuild lenovo-sl-laptop-1-2.1.src.rpm
sudo rpm -Uhv /usr/src/packages/RPMS/i586/lenovo-sl-laptop-kmp-pae*


Cheers Malcolm °¿° (Linux Counter #276890)
openSUSE 11.1 (i586) Kernel 2.6.27.19-3.2-pae
up 1:03, 1 user, load average: 0.13, 0.13, 0.14
ASUS eeePC 1000HE ATOM N280 1.66GHz | GPU Mobile 945GM/GMS/GME

Thanks malcomlewis. Your kernel module works perfect on my SL500. Did you implement anything else or is it just the brightness and the loudness keys?

Greetings

Hi
Glad you found this thread and it’s all working for you :slight_smile:

No, just those features. Unless you check the original lnk and they
have updated features it could be redone…


Cheers Malcolm °¿° (Linux Counter #276890)
SUSE Linux Enterprise Desktop 11 (x86_64) Kernel 2.6.27.23-0.1-default
up 3 days 11:42, 2 users, load average: 0.14, 0.11, 0.09
GPU GeForce 8600 GTS Silent - Driver Version: 185.18.14

Hi there,

i got openSUSE 11.0 on my newly bought Lenovo SL300, and cannot use the driver. would you please make the driver [as RPM, on Build Service] for my kernel:

anoosh@nasim:~> uname -a
Linux nasim 2.6.25.20-0.5-pae #1 SMP 2009-08-14 01:48:11 +0200 i686 i686 i386 GNU/Linux

Thanks. Two other questions:

  1. how do you have the 2.6.27 kernel? kernels in openSUSE are at most 2.6.25 !!

  2. i downloaded the driver from github, but when i run “make all” i get:

anoosh@nasim:~/Desktop/lenovo-sl-laptop> make all                                                                        
make -C /lib/modules/2.6.25.20-0.5-pae/build M=/home/anoosh/Desktop/lenovo-sl-laptop modules                             
make[1]: Entering directory `/usr/src/linux-2.6.25.20-0.5-obj/i386/pae'                                                  
make -C /usr/src/linux-2.6.25.20-0.5 O=/usr/src/linux-2.6.25.20-0.5-obj/i386/pae/. modules                               
  CC [M]  /home/anoosh/Desktop/lenovo-sl-laptop/lenovo-sl-laptop.o                                                       
/home/anoosh/Desktop/lenovo-sl-laptop/lenovo-sl-laptop.c: In function ‘lensl_radio_rfkill_get_state’:                    
/home/anoosh/Desktop/lenovo-sl-laptop/lenovo-sl-laptop.c:307: error: ‘RFKILL_STATE_HARD_BLOCKED’ undeclared (first use in this function)
/home/anoosh/Desktop/lenovo-sl-laptop/lenovo-sl-laptop.c:307: error: (Each undeclared identifier is reported only once                  
/home/anoosh/Desktop/lenovo-sl-laptop/lenovo-sl-laptop.c:307: error: for each function it appears in.)                                  
/home/anoosh/Desktop/lenovo-sl-laptop/lenovo-sl-laptop.c:315: error: ‘RFKILL_STATE_UNBLOCKED’ undeclared (first use in this function)   
/home/anoosh/Desktop/lenovo-sl-laptop/lenovo-sl-laptop.c:317: error: ‘RFKILL_STATE_SOFT_BLOCKED’ undeclared (first use in this function)
/home/anoosh/Desktop/lenovo-sl-laptop/lenovo-sl-laptop.c: In function ‘lensl_radio_rfkill_toggle_radio’:
/home/anoosh/Desktop/lenovo-sl-laptop/lenovo-sl-laptop.c:327: error: ‘RFKILL_STATE_UNBLOCKED’ undeclared (first use in this function)
/home/anoosh/Desktop/lenovo-sl-laptop/lenovo-sl-laptop.c: In function ‘lensl_radio_new_rfkill’:
/home/anoosh/Desktop/lenovo-sl-laptop/lenovo-sl-laptop.c:361: error: ‘struct rfkill’ has no member named ‘get_state’
/home/anoosh/Desktop/lenovo-sl-laptop/lenovo-sl-laptop.c:366: error: ‘RFKILL_STATE_HARD_BLOCKED’ undeclared (first use in this function)
/home/anoosh/Desktop/lenovo-sl-laptop/lenovo-sl-laptop.c:368: error: ‘RFKILL_STATE_SOFT_BLOCKED’ undeclared (first use in this function)
/home/anoosh/Desktop/lenovo-sl-laptop/lenovo-sl-laptop.c:370: error: ‘RFKILL_STATE_UNBLOCKED’ undeclared (first use in this function)
/home/anoosh/Desktop/lenovo-sl-laptop/lenovo-sl-laptop.c: At top level:
/home/anoosh/Desktop/lenovo-sl-laptop/lenovo-sl-laptop.c:459: error: ‘RFKILL_TYPE_WWAN’ undeclared here (not in a function)
/home/anoosh/Desktop/lenovo-sl-laptop/lenovo-sl-laptop.c: In function ‘led_init’:
/home/anoosh/Desktop/lenovo-sl-laptop/lenovo-sl-laptop.c:786: error: ‘struct led_classdev’ has no member named ‘brightness_get’
make[4]: *** [/home/anoosh/Desktop/lenovo-sl-laptop/lenovo-sl-laptop.o] Error 1
make[3]: *** [_module_/home/anoosh/Desktop/lenovo-sl-laptop] Error 2
make[2]: *** [sub-make] Error 2
make[1]: *** [all] Error 2
make[1]: Leaving directory `/usr/src/linux-2.6.25.20-0.5-obj/i386/pae'
make: *** [all] Error 2

would you help, please?

Hi
Unfortunately I think it may now work with the 2.6.25 kernels :frowning: 2.6.27
is in 11.1 which is the current release, 11.2 is due for release in
November and as can be seen from my signature is running 2.6.31 on this
test version.

Is there a specific reason for running 11 rather than 11.1?


Cheers Malcolm °¿° (Linux Counter #276890)
openSUSE 11.2 Milestone 6 (i586) Kernel 2.6.31-rc6-3-desktop
up 10:25, 2 users, load average: 0.18, 0.14, 0.09
ASUS eeePC 1000HE ATOM N280 1.66GHz | GPU Mobile 945GM/GMS/GME

I installed openSUSE 11.1 . could you please help, how to install lenovo-sl-laptop?

> lenovo-sl-laptop?

open YaST > give root password > Software > Software Management >
WAIT, it takes a while to initalize…be patient…do not abort…

when all activity has stopped there will be a SEARCH blank

> type in lenovo-sl-laptop > click “Search” > on the right side look
for and place a check mark next to lenovo-sl-laptop > click “Accept”
wait until finished…then, maybe just log out (end session) and log
back in…or reboot…

if search in YaST fails to find lenovo-sl-laptop, then:

  1. go to http://software.opensuse.org/search
  2. bookmark it
  3. put lenovo-sl-laptop in blank
  4. spin to openSUSE 11.1
  5. pick the top “1 Click Install” button and follow your nose…read
    carefully when asked questions…you must allow repositories to be
    added, and when finished installing, if asked if the repo should be
    kept or deleted imo it is best to delete it…


goldie
Give a hacker a fish and you feed him for a day.
Teach man and you feed him for a lifetime.

Hi
Further to the above, if you open a termial (gnome-terminal , konsole
etc) and run the command;


uname -r

This will tell you which kernel module to use, default or pae and the
version. If you haven’t selected to update the kernel (eg done all the
updates), it should be the one in openSUSE_11.1


Cheers Malcolm °¿° (Linux Counter #276890)
SUSE Linux Enterprise Desktop 11 (x86_64) Kernel 2.6.27.29-0.1-default
up 3 days 19:28, 2 users, load average: 0.57, 1.28, 1.48
GPU GeForce 8600 GTS Silent - Driver Version: 190.18

Thank you all.

I installed lenovo-sl-laptop successfully and it is working beautifully, brightness, power, etc.

the only remaining problem is that volume control keys on keyboard do not work. do you know anyway i can make them working? i remember there was a tool in terminal which listened to the keyboard entry, and shows when you press a key, what is passed to X. rings a bell?

– A.

> rings a bell?

ding ding ding
man xev


goldie

ok so. may be i have to ring that bell again =))

found that when i press volume control on my laptop, X is notified with keycode 174 & 176 [first one for vol up, second for vol down. ]

how can i make a script so when keycode 174 is given to the system, volume level [kmixer] increases? i am using alsa.

best,

– A.

> how can i make a script so when keycode 174 is given to the system,
> volume level [kmixer] increases? i am using alsa.

now you ask a question that belongs in
http://forums.opensuse.org/programming-scripting/

bye. [which in this case, means: too hard for me, catch’ya later.]


goldie
Give a hacker a fish and you feed him for a day.
Teach man and you feed him for a lifetime.

Is there a possibility not to enable bluetooth and ultrawideband on startup? Would like to have it by default off, hardly ever need those interfaces. It is important to me because of power consumption.