Audio (alsamixer) in T42

I realised that audio on my T42 was not working only when I tried to play a youtube video today. I have installed alsa-utils, volume was not muted when checked in volume control applet (I’m on MATE),  changing volume does nothing. A quicklook at wiki mentioned that we need to be in ‘audio’ group which I was. When I tried ‘alsamixer’ from both my account and root, it showed error ‘…no such file or directory’. The permissions on /dev/snd were proper (atleast as it was in LMDE). So, what was the problem?

Output of ‘cat /proc/asound/cards’ showed my card.
genT42 linux # cat /proc/asound/cards
0 [I82801DBICH4 ]: ICH4 - Intel 82801DB-ICH4
Intel 82801DB-ICH4 with AD1981B at irq 11
5 [ThinkPadEC ]: ThinkPad EC - ThinkPad Console Audio Control
ThinkPad Console Audio Control at EC reg 0x30, fw 1RHT71WW-3.04

Output of ‘lspci’ showed the following:
genT42 ~ # lspci | grep -i audio
00:1f.5 Multimedia audio controller: Intel Corporation 82801DB/DBL/DBM (ICH4/ICH4-L/ICH4-M) AC'97 Audio Controller (rev 01)

Since, I usually compile everything into kernel and not as module I was not sure if necessary drivers were compiled in. So, I checked menuconfig and found by default “Intel HD Audio” was compiled-in and “Intel/SiS/nVidia/AMD/ALi AC97 Controller” was not selected.

I then compiled AC97 controller as a module (snd_intel8x0), rebooted and voila! I have sound.

Device Drivers
   > Sound card support
      > Advanced Linux Sound Architecture
        > PCI sound devices
         > Intel/SiS/nVidia/AMD/ALi AC97 Controller

Following the wiki, I added the alsasound to boot with,
rc-update add alsasound boot

This would ensure the volume levels would be retained at next boot.

It’s time to enjoy some music 😉


Wireless on Thinkpad T42

Few blogs earlier I mentioned that I have a Thinkpad T42 available for use; not mine but permitted to use. It’s an old beast. It has modest hardware, by today’s standards, but still good. Display, keyboard, joystick (or whatever it is called), touchpad and all the ports are working fine. Only exception is a bad battery. That’s not so bad as most laptops develop battery problem after few years. I have two such case at home.

I installed Gentoo 486 version on it as it does not support PAE. Following are some detail about my T42.

Output of ‘lscpu’:

Architecture: i686
CPU op-mode(s): 32-bit
Byte Order: Little Endian
CPU(s): 1
On-line CPU(s) list: 0
Thread(s) per core: 1
Core(s) per socket: 1
Socket(s): 1
Vendor ID: GenuineIntel
CPU family: 6
Model: 13
Model name: Intel(R) Pentium(R) M processor 1.70GHz
Stepping: 6
CPU MHz: 1700.000
CPU max MHz: 1700.0000
CPU min MHz: 600.0000
BogoMIPS: 3397.05

Output of /proc/cpuinfo:

processor : 0
vendor_id : GenuineIntel
cpu family : 6
model : 13
model name : Intel(R) Pentium(R) M processor 1.70GHz
stepping : 6
microcode : 0x18
cpu MHz : 1700.000
cache size : 2048 KB
fdiv_bug : no
f00f_bug : no
coma_bug : no
fpu : yes
fpu_exception : yes
cpuid level : 2
wp : yes
flags : fpu vme de pse tsc msr mce cx8 sep mtrr pge mca cmov clflush dts acpi mmx fxsr sse sse2 ss tm pbe bts est tm2
bogomips : 3397.29
clflush size : 64
cache_alignment : 64
address sizes : 32 bits physical, 32 bits virtual
power management:

Output of ‘lspci’:

00:00.0 Host bridge: Intel Corporation 82855PM Processor to I/O Controller (rev 03)
00:01.0 PCI bridge: Intel Corporation 82855PM Processor to AGP Controller (rev 03)
00:1d.0 USB controller: Intel Corporation 82801DB/DBL/DBM (ICH4/ICH4-L/ICH4-M) USB UHCI Controller #1 (rev 01)
00:1d.1 USB controller: Intel Corporation 82801DB/DBL/DBM (ICH4/ICH4-L/ICH4-M) USB UHCI Controller #2 (rev 01)
00:1d.2 USB controller: Intel Corporation 82801DB/DBL/DBM (ICH4/ICH4-L/ICH4-M) USB UHCI Controller #3 (rev 01)
00:1d.7 USB controller: Intel Corporation 82801DB/DBM (ICH4/ICH4-M) USB2 EHCI Controller (rev 01)
00:1e.0 PCI bridge: Intel Corporation 82801 Mobile PCI Bridge (rev 81)
00:1f.0 ISA bridge: Intel Corporation 82801DBM (ICH4-M) LPC Interface Bridge (rev 01)
00:1f.1 IDE interface: Intel Corporation 82801DBM (ICH4-M) IDE Controller (rev 01)
00:1f.3 SMBus: Intel Corporation 82801DB/DBL/DBM (ICH4/ICH4-L/ICH4-M) SMBus Controller (rev 01)
00:1f.5 Multimedia audio controller: Intel Corporation 82801DB/DBL/DBM (ICH4/ICH4-L/ICH4-M) AC'97 Audio Controller (rev 01)
00:1f.6 Modem: Intel Corporation 82801DB/DBL/DBM (ICH4/ICH4-L/ICH4-M) AC'97 Modem Controller (rev 01)
01:00.0 VGA compatible controller: Advanced Micro Devices, Inc. [AMD/ATI] RV200/M7 [Mobility Radeon 7500]
02:00.0 CardBus bridge: Texas Instruments PCI4520 PC card Cardbus Controller (rev 01)
02:00.1 CardBus bridge: Texas Instruments PCI4520 PC card Cardbus Controller (rev 01)
02:01.0 Ethernet controller: Intel Corporation 82540EP Gigabit Ethernet Controller (Mobile) (rev 03)
02:02.0 Network controller: Intel Corporation PRO/Wireless LAN 2100 3B Mini PCI Adapter (rev 04)

Everything was working, but network. The wireless device would not initialise at all. If we do ‘/sbin/ifconfig’ device does not report wireless connection, if we check ‘/sys/class/net’ the wireless device is not listed.

As can be seen from the output of ‘lspci’ the wireless device is Intel Ipw2100. I had tried everything I could think of (drivers, firmware, PHY, wpa_supplicant, ppp etc.). I even enabled almost all PCMCIA, PCI, ISA options thinking it could be related to one those (I’m not master Oogway, you know). Nothing worked.

I used genkernel instead of handmade kernel. Wireless did not work. I have LMDE on another partition and network worked fine on it. So, it was not issue with hardware itself. I then copied config from LMDE (although it is few version behind Gentoo’s), ran ‘make oldconfig’ which ‘Gentoo’ised the config and then compiled kernel. Now to my surprise the network started to work!

I was not satisfied, because in most of the distros the kernels are generic and contain almost all of the features provided in the kernel (except perhaps debug options), either built-in or as modules. That’s not the way I want my kernel. That’s not the way we live on Gentoo side.

I took a diff of my original config and LMDE’s modified config, especially giving attention to network/PHY/driver/firmware related terms. I configured and compiled my kernel again. Alas, the network would not work. Then I noticed something. When the system would boot on LMDE or Gentoo with modified LMDE config, the wireless LED would glow at a stage that reads something like “…waiting for uevents…”. When I booted my kernel, wireless LED would not glow at the same stage.

I googled and found it was related to device initialization by udev. One link led to another and gave idea on further refining my search. I finally ended up on this page. The moment I read initial few lines I rolled on the floor laughing at my stupidity. All the while I was doing a silly mistake. I ‘compiled-in; the ipw2100 driver into my kernel (as I do mostly, to avoid an initrd) whereas the help section for this driver clearly mentioned to compile it as a ‘module’! Following is the excerpt from the help file:

It is recommended that you compile this driver as a module (M)
rather than built-in (Y). This driver requires firmware at device
initialization time, and when built-in this typically happens
before the filesystem is accessible (hence firmware will be
unavailable and initialization will fail). If you do choose to build
this driver into your kernel image, you can avoid this problem by
including the firmware and a firmware loader in an initramfs.

This is the reason why it was working on LMDE and Gentoo compiled with modified LMDE config because (almost) all drivers in other distros are built as modules.

I had spent nearly 12-13 days scratching and banging my head, in frustration, trying to figureout what mistake I was making. My mistake was soooo fundamental: not reading help section/manual. I deserve to be RTFMed! 😀

Anyway, it was a wonderful experience. Now, let me concentrate on installing useful software so that I can turn an aging hardware into useful workstation.


Linux kernel compilation notes

DISCLAIMER: This is just what the name says, notes. This is not official guide.

Kernel compilation involves the following:

  1. Obtaining source
  2. Installing essential packages for kernel compilation
  3. Configuring
  4. Compiling and Installing

   The procedure varies from distro to distro. I will go through steps for a general compilation with distro specific notes added.

1. Obtaining source

   Linux kernel source is available from kernel’s homepage Some distro specific commands are as follows:

  • Gentoo linux: emerge gentoo-sources
  • Debian linux: apt-get source linux
  • Ubuntu linux: apt-get source linux-image-$(uname -r)

   It’s usually recommended (even by Linus, I guess) to extract the source to user’s home under a directory say, kernel ($HOME/kernel/). But on Gentoo and Slackware, we usually extract to /usr/src/ and configured, compiled and installed as root. I’m usually on Gentoo or Slackware. Never bothered to ask the folks why they do it the way that’s frowned upon. It works. So be it.

2. Installing essential packages

   At a minimum we need gcc. Depending on distro we may need other packages as well. For eg., in Debian we need, fakeroot, kernel-package, linux-sources, libncurses5-dev and build-essential. Since in Gentoo everything is compiled and in Slackware recommended install method is to choose ‘full’ all necessary softwares are already present.

3. Configuring

   For generic compilation, we can start with,
   make mrproper (this was two step in v2.4 kernel as “make dep; make clean“)

   Above step is not essential but when executed cleans-up source and deletes any customization including deleting .config file. So don’t forget to backup a working .config file.

   Then if we already have a working .config file we can use it as safe point or for upgrade.
   make oldconfig

   Actual configuration is started with any of the following commands:

  • make config – text based question and answer type, very minimal, best suited for ultra geeks 🙂
  • make menuconfig – menu driven, ncurses based method, good on any desktop or no desktop. This needs libncurses package
  • make xconfig – graphical method, Qt based, best fits on KDE desktop
  • make gconfig – graphical method, GTK based, best fits on GTK based desktops (GNOME, XFCE).

4. Compiling and Installing

   Compiling is done with just one command:

This is (now) equivalent of ‘make all’ and ‘make bzImage modules vmlinux’ where,

  • vmlinux – uncompressed linux kernel
  • bzImage – compressed linux
  • modules – any modules compiled.

   This will compile linux kernel and create a bzImage under arch/x86/boot/ (assuming we are compiling for x86 or x86_64 platform). We can copy this bzImage file to /boot and update the bootloader. The other method is to run
   make install

   This will install/copy the following to /boot

  • bzImage as vmlinuz-x.y.z
  • .config as config-x.y.z
  • as


  • x-major linux version,
  • y-minor version (odd number being development version and even number being stable version) and
  • z-patch version

   If we have configured some features as modules, we can do
   make modules_install

   This will install/copy all the modules to /lib/modules/<kernel-version>/ directory.

   We can then update our bootloaders and reboot. If all has been done right we will have a working system with new kernel. If not necessary troubleshooting has to be done.

   Now we will examine kernel compilation specific to distros.

A) Debian way
   Debian way is to create a .deb package for kernel and modules which can then be installed (and maintained) with dpkg. As mentioned before, configuring and compiling as root is discouraged. Only time root is used is to actually install the new kernel and modules. Debian uses a method called ‘fakeroot’ for this purpose. This simulates the root user. Another script called make-kpkg is used which automates make dep; make clean (or make mrproper), make bzImage, make modules etc.

   The format for make-kpkg is “make-kpkg <options> <target>” where target is kernel image usually called kernel_image. Options include,
–initrd : asking to create an initrd
–append-to-version : our name; avoid generic names like 686, x86, amd64 etc which are usually reserved by distro packaging
–revision : how many times compiled/recreated? changes package name not kernel.

   So, the Debian way will be something like this:

   $ make-kpkg clean : equivalent of make mrproper and perhaps similarly not mandatory.
   $ fakeroot make-kpkg --initrd --revision=custom.1.0 kernel_image

   This step will create .deb packages which can be installed with dpkg.
   # dpkg -i *.deb

B) Ubuntu way
   We obtain kernel source with the following command. However note that we need to execute the following as normal user. Otherwise we will not be able to use fakeroot.
   $ apt-get source linux-image-$(uname -r)

   The necessary packages required for a kernel compilation can be installed in Ubuntu as follows:
   $ sudo apt-get build-dep linux-image-$(uname -r)

   Now do the following:
   $ chmod a+x debian/scripts/*
  $ chmod a+x debian/scripts/misc/*
  $ fakeroot debian/rules clean
  $ fakeroot debian/rules editconfigs

   To build kernel, cd to the root of the kernel source tree
   $ fakeroot debian/rules clean
   $ fakeroot debian/rules binary-headers binary-generic

   If build is successful there will be three deb files above the build root directory.
   $ cd ..
   $ ls *.deb
   $ linux-headers-$(uname -r)_all.deb linux-headers-$(uname -r)_amd64.deb linux-image-$(uname -r)_amd64.deb

Install the kernel with dpkg
   $ sudo dpkg -i linux-*.deb

Minimal ‘wpa_supplicant.conf’ entry for WPA2 connection

I always keep forgetting the entry in wpa_supplicant.conf. So here it is.

ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=wheel
pairwise=CCMP TKIP
psk="password or output of wpa_passphrase here"

“Broken sem_open function (bug 496328)” error when compiling python_2.7:

I have installed Gentoo on a Thinkpad T42 laptop. I have problem setting up wireless network but that is for another day. This blog is related to problem I faced during my system upgrade.

When I tried to do system upgrade, python emerge failed with following error message: ‘”Broken sem_open function (bug 496328)” error when compiling python_2.7:’. There were instructions to –rbind /dev from live media. But I had done it. There were instructions to remount /dev/shm on tmpfs and with mode=1777 permission. But trying to mount failed with no such file/directory error. Then I noticed something.

Since, network is not working (currently) on my Gentoo installation, I chroot from linuxmint on this office laptop and do all installtion/upgradation. Mint has /dev/shm pointing to /run/shm which was empty i.e., there is nothing under /run.

I removed /dev/shm link, created a directory /dev/shm and mounted as tmpfs with 777 permission. After this, python emerge went smoothly.

(chroot) mint-t42 / # rm /dev/shm
(chroot) mint-t42 / # mkdir /dev/shm
(chroot) mint-t42 / # mount -t tmpfs -o rw,mode=1777 shm /dev/shm
(chroot) mint-t42 / # ls -l /dev/ | grep -i shm
drwxrwxrwt 2 root root 40 May 25 11:26 shm
(chroot) mint-t42 / # df -h
df: '/sys/fs/cgroup/openrc': No such file or directory
df: '/sys/fs/cgroup/cpuset': No such file or directory
df: '/sys/fs/cgroup/cpu': No such file or directory
df: '/sys/fs/cgroup/cpuacct': No such file or directory
df: '/sys/fs/cgroup/freezer': No such file or directory
Filesystem Size Used Avail Use% Mounted on
/dev/sda5 21G 4.8G 15G 25% /
tmpfs 21G 4.8G 15G 25% /run
udev 10M 0 10M 0% /dev
cgroup_root 4.0K 0 4.0K 0% /sys/fs/cgroup
shm 759M 0 759M 0% /dev/shm
(chroot) mint-t42 / # mount | grep -i shm
shm on /dev/shm type tmpfs (rw,mode=1777)
(chroot) mint-t42 / #

I don’t know how clean the method is but what I tried worked for me. Once I get network working in Gentoo, I don’t have to chroot anyway.