NIC Drivers

If you happen to be lucky enough to get a motherboard that has an unsupported NIC chipset, you will need to build the driver and install it.

For example, the Realtek RTL8111C chip is supported by a special Realtek r8168 driver, although Mythbuntu thinks it is supported by the generic r8169 driver. If you do not install the special r8168 driver, the NIC will appear to be up and running, when you do ifconfig, but it will not work. Only the special r8168 driver works. Furthermore, the people who build the kernel periodically seem to think they've got this problem licked with their fabulous, new code in the r8169 driver but it never proves to be the case. So, this chipset (which is quite popular, apparently) is bound to be a problem for years to come.

Another Ethernet chipset that is showing up on a lot of motherboards, and which doesn't have support built in to some kernels (although it does appear to be included in Mythbuntu 12.04), is the Atheros 8151 (and its brethren). If your motherboard includes this chipset, you may need to build the driver for it.

Yet another example of a newer chipset that may cause trouble under older kernel versions is the family of Intel gigabit NICs which are supported by the e1000e driver. Some of the later chipsets (e.g. I219-V) do not work with the stock e1000e driver found in earlier versions of Ubuntu (e.g. 12.04). If you're trying to run an older version of Mythbuntu on a newer motherboard, you may need to update this driver so that it supports the newer chipset.

Here's how to replace the driver for any of these chipsets specifically, and other NIC drivers in general.

The first problem, of course, is that the install probably won't fly without a working NIC in the system (the classic, "You can't get there from here"). The easiest way around this problem is to plug a working NIC into one of the PCI slots. A board with the r8169 chipset on it should work well. Any of the older 100 Mbps NICs should work too. Then, you can install Mythbuntu and apply all of the recent patches.

You should probably get rid of the Network Manager (its a real piece of scrap) and set the network up by hand (see Networking Your Way, below). In this case, you'll be setting up the temporary NIC first and then setting up the on-board NIC later on.

For Mythbuntu, building and installing a new driver can be problematic, since the build environment is not included in the distro. To build the driver, start by obtaining and installing a duplicate copy of Ubuntu (on another machine -- you can never have too many) to match your copy of Mythbuntu. Since Mythbuntu is built off of the standard Ubuntu distro, this shouldn't be a problem.

Make sure you have the driver build environment (this is not necessarily the full kernel build environment). To verify that you do have the driver build environment, try:

     ls -l /lib/modules/`uname -r`/build

If you have this directory installed, you're good to go (Ubuntu usually provides it in a typical installation). Otherwise, you'll need to first get the build environment, either using the Package Manager or by doing:

     sudo apt-get install build-essential

Then, you should make sure to install the latest headers for your kernel. When you enter the following command, be sure to use back-quotes:

     sudo apt-get install linux-headers-`uname -r`

Finally, if the link doesn't already exist, link the headers to the build folder in the proper place. This should get you compiling:

     sudo ln -s /usr/src/linux-headers-`uname -r` /lib/modules/`uname -r`/build

After you've got the build environment set up, either on your duplicate system or on you new system with a temporary NIC in it, download the latest version of the NIC driver from the manufacturer's Web site and place it in a convenient directory (you can build it under your home directory).

The download for the latest r8168 driver, for example, is at:

     http://www.realtek.com.tw/downloads/downloadsView.aspx?Langid=1&PNid=13&;
          PFid=5&Level=5&Conn=4&DownTypeID=3&GetDown=false#2

The r8168-8.012.00.tar.bz2 release seems to work on Mythbuntu 8.10 and 9.04. However, if you are using a version of Mythbuntu that is built on 8.04LTS, you may have to get r8168-8.005.00.tar.bz2 (because the later versions blow up during compile on 8.04LTS). You can get r8168-8.005.00.tar.bz2 and then apply the patch that is found at:

     http://ubuntuforums.org/attachment.php?s=f4cb4535bb95f2d96d4aa4d7530f78b1&;
          attachmentid=66030&d=1208224861

We are getting ahead of ourselves but, to apply the patch after you've unpacked the tar file (below), change to the src directory and do:

     patch ../../r8168-8.005.00.hardy.diff.txt

We unzipped the downloaded file and unpacked it in two steps:

     bunzip2 r8168-8.005.00.tar.bz2
     tar -xvf r8168-8.005.00.tar

However, you should be able to get away with:

     tar -xvjf r8168-8.005.00.tar.bz2

There are probably build instructions for the driver in a readme file. You might want to read them before proceeding with the build.

Apparently, it isn't necessary to place the driver in the system source tree any more, in order to build it (i.e. the way it used to be). Of course, you may opt to do this, if you wish, but we build it in our own directory. To do so, try the following:

     cd r8168-8.005.00
     sudo make clean modules

If this blows up with a message about not knowing how to make Makefile in /src, you should change the following line in the Makefile in the src directory:

     #       $(MAKE) -C $(KDIR) SUBDIRS=$(PWD)/src modules
             $(MAKE) -C $(KDIR) SUBDIRS=$(shell pwd) modules

Apparently, somebody has scrod the PWD command in the 8.04LTS version of Ubuntu.

If you choose the build-it-in-the-source-tree option, you should do the following instead:

     sudo mv r8168-8.004.00 /usr/src
     cd /usr/src/r8168-8.004.00
     sudo make clean modules

Once you've successfully done a clean build of the driver, you'll need to get it from the Ubuntu machine to Mythbuntu. Since it may be the NIC that doesn't work (if you aren't using a second NIC), you quite possibly won't be persuing the copy-the-files-over-the-network option. Rather, the requisite driver files may need to be written to a CD or floppy disc. Here is a list of the files for the r8168 driver that should included on the CD or disc (only the ".ko" module is really important):

     -rw-r--r-- 1 eric eric      0 2008-04-02 22:08 Module.symvers
     -rw-r--r-- 1 eric eric  37828 2008-04-02 22:08 r8168.ko
     -rw-r--r-- 1 eric eric  31024 2008-04-02 22:08 r8168.mod.o
     -rw-r--r-- 1 eric eric 242056 2008-04-02 22:08 r8168_n.o
     -rw-r--r-- 1 eric eric 242083 2008-04-02 22:08 r8168.o

Later versions of the driver may include these files:

     -rw-r--r-- 1 eric eric      0 2009-09-05 15:26 Module.markers
     -rw-r--r-- 1 eric eric     54 2009-09-05 15:26 modules.order
     -rw-r--r-- 1 eric eric      0 2009-09-05 15:26 Module.symvers
     -rw-r--r-- 1 eric eric   6144 2009-09-05 15:26 r8168_asf.o
     -rw-r--r-- 1 eric eric  88040 2009-09-05 15:26 r8168.ko
     -rw-r--r-- 1 eric eric  15452 2009-09-05 15:26 r8168.mod.o
     -rw-r--r-- 1 eric eric  66416 2009-09-05 15:26 r8168_n.o
     -rw-r--r-- 1 eric eric  73329 2009-09-05 15:26 r8168.o
     -rw-r--r-- 1 eric eric   2240 2009-09-05 15:26 rtl_eeprom.o

Now, proceed to the Mythbuntu machine, with your CD or floppy disc (or FTP them from the build machine, if the 2nd NIC is working). Load the appropriate driver modules into the local directory where you usually put all of your system modifications. Once that's done, install them onto the system:

     cd r8168-8.005.00/src
     sudo install -m 744 -c r8168.ko /lib/modules/`uname -r`/kernel/drivers/net

There could be an older version of the module that you are replacing or one that conflicts with the new module (typically the r8169 driver tries to take control of the NIC but does not work). You can check, for example, if the r8169 module is installed as follows:

     lsmod | grep r8169

If r8169 is installed then you should remove it:

     sudo rmmod r8169

Now, complete the install of the new module on the Mythbuntu machine:

     cd ..
     sudo depmod -a
     sudo insmod ./src/r8168.ko

By doing these steps, you are essentially duplicating what the module's makefile would have done. But, since the build tools and source code are not available on the system, you cannot run the makefile so you must do it by hand. You can check whether the install is successful by doing:

     lsmod | grep r8168

Now, we need to get rid of the conflicting module, if it's there. If you are just adding a brand new module, you don't need to do this step. Otherwise, build a blacklist file for the old module. In older versions of Mythbuntu, this file should be named "blacklist-network" but in newer versions (e.g. Mythbuntu > 9.04) all blacklist files must end in the suffix ".conf". Examine the existing files in /etc/modprobe.d and see how they are named to determine how to proceed. Then, either do:

     cd /etc/modprobe.d
     sudo touch blacklist-network
     sudoedit blacklist-network

or, for later versions do:

     cd /etc/modprobe.d
     sudo touch blacklist-network.conf
     sudoedit blacklist-network.conf

Regardless of whether the blacklist file is new or if it already exists, add the following lines to it:

     # Don't load the r8169 driver. It is replaced by the r8168 driver.
     blacklist r1869

Once you've completed all of the above, you must make the changes permanent. Mythbuntu boots from a RAM image of the kernel which will still have the old driver (if any) installed and the new driver missing. You need to update this image or the conflicting driver will still get loaded and take over the show. To do so, update the RAM image:

     sudo update-initramfs -u

Reboot the machine to see if the changes are permanent and that the NIC now works:

     sudo reboot

You can use ethtool to see if the new driver is assigned:

     ethtool -i eth0

If all is working, you should be able to remove the second NIC, if you went that route, and replace it with the now-working built-in NIC.

By way of a further example of how to build and install a NIC driver, here's how to build a driver for the Atheros 8151 (and its brethren) chipset.

The first step is to see whether the Atheros drivers are already included among the kernel modules:

     find /lib -name \atl\

If you see a list that includes:

     atl1.ko
     atl1c.ko
     atl1e.ko

You've probably got the latest drivers for this chip. But, if you don't see these kernel drivers, you need to build them. As above, we'll go the second NIC route to allow us to download the needed files and get the Atheros drivers working, so see the notes above about how to do that.

Probably the biggest problem you'll face with this chip is to find the correct source needed to build the driver. Originally, the source was offered on the Atheros Web site but they have since been bought out and the Web site has disappeared. Fortunately, the Linux Wireless Web site has accumulated a lot of useful drivers for wireless chips and they have also includes drivers for a number of wired network chips like the Atheros 8151.

All of the network drivers that the Linux Wireless Web site accumulates are rolled up into a single archive file which is updated on a regular basis. You can download the latest version of this archive from the Web page:

     http://linuxwireless.org/download/compat-wireless-2.6/

There are three archives to choose from. The "-pc" version seems to be the one to choose (because it includes all of the new Atheros drivers, specifically the alx driver) so download the one that looks like this:

     compat-wireless-2012-07-03-pc.tar.bz2

Change to the directory where you downloaded the archive file and unpack it like this:

     tar-xjvf compat-wireless-2012-07-03-pc.tar.bz2

As with the r8168 above, make sure you have the driver build environment available on your system. Once you have it installed, you can build and install the Atheros drivers like this:

     cd compat-wireless*
     scripts/driver-select atl1
     make
     sudo make install
     scripts/driver-select atl1c
     make
     sudo make install
     scripts/driver-select atl1e
     make
     sudo make install
     scripts/driver-select alx
     make
     sudo make install

The install steps in the build process update the kernel RAM image so all that you need to do is reboot the machine to see that the changes are permanent and that the NIC now works:

     sudo reboot

You can use ethtool to see if the new driver is assigned:

     ethtool -i eth0

If all is working, you should be able to remove the second NIC, if you went that route, and replace it with the now-working built-in NIC.

One wrinkle though, may be that the incorrect Atheros driver is automatically chosen for the 8151 chip at boot time. There have been reports that the atl1c.ko driver works poorly with some versions of the 8151 chip (e.g. R2.0) and that the new alx.ko driver (which is meant specifically for the 8161 chip) works better. If that's the case, you will probably have to blacklist the atl1c driver.

The notes for the r8168 above describe how to edit the blacklist file so see those notes about how to add the following lines to it:

     # Don't load the atl1c driver. It is replaced by the alx driver.
     blacklist atl1c

When you reboot, the alx driver should automatically come up in place of the atl1c driver.

If you are, instead, building the latest e1000e driver, you will, as above, need to set up a build environment (i.e. second build system or second temporary NIC in the target system) and make sure that the proper kernel build environment is installed.

Once that is done, the the download location for the e1000e driver is:

     https://downloadcenter.intel.com/download/15817

Select the latest version of the e1000e driver (or the one that works for your kernel version) and download it to a local directory. Change to that directory and unpack it:

     cd .../e1000e
     tar -xvzf e1000e-3.4.2.1.tar.gz

Change to the driver source directory and build it:

     cd e1000e-3.4.2.1/src
     make

If you added a second NIC to your system and built the driver in place, you don't have to do anything else. Otherwise, you'll need to move the driver files to your target system by hook or by crook. Options include a CD, a USB stick, or booting Knoppix and using it to copy the files onto the systems disk. The files that should be included (only the ".ko" module is really important) are:

     -rw-r--r-- 1 eric eric 291295 Feb 12 16:39 e1000e.ko
     -rw-r--r-- 1 eric eric 273665 Feb 12 16:39 e1000e.o
     -rw-r--r-- 1 eric eric     56 Feb 12 16:39 modules.order
     -rw-r--r-- 1 eric eric      0 Feb 12 16:39 Module.symvers

However, if you copy the whole build tree, you can simply do what you would do if you'd built the driver on the target machine. So, whether you used a second NIC to carry out the build in place, or you've just copied the files over, switch to the source directory in the build tree and complete the install as root:

     cd .../e1000e/e1000e-3.4.2.1/src
     sudo make install

This will install the newly-built driver in:

     /lib/modules/`uname -r`/updates/drivers/net/ethernet/intel/e1000e

Apparently, Intel was at a sale on subdirectories. If you want, you can move the driver to the more conventional:

     /lib/modules/`uname -r`/kernel/drivers/net/e1000e

Or not.

If there is an existing e1000e driver, that doesn't work, loaded into memory, you should remove it. Then, you can load the new driver:

     lsmod | grep e1000e
     sudo rmmod e1000e;  (if the old driver is loaded)
     sudo modprobe e1000e

You'll probably need the information about the built-in NIC to continue with your system's set up. As soon as you do the modprobe, you can look in dmesg to get the NIC's information:

     dmesg | tail -20

Look in there for the MAC address and to see what device name udev assigned to the NIC (if you are replacing a motherboard, for example, udev will probably reassign the NIC to eth1, until you can edit its configuration and map the new NIC to eth0). You'll need these if you're going to be changing /etc/network/interfaces to use the new NIC.

Reboot the machine to see if the changes are permanent and that the NIC now works:

     sudo reboot

You can use ethtool to see if the new driver is assigned:

     ethtool -i eth0

Finally, be aware that you will need to rebuild any drivers that you build and install manually each time there is a kernel update. This may require you to get all of your ducks in a row before you do the kernel update, because the network is going to stop working again. Unless, of course the new kernel finally has the drivers installed in it, in which case, all your troubles are over.