Finding the source code for Ubuntu drivers

1.1k Views Asked by At

I recently installed the latest version of Ubuntu on my older macbook and it works great. I'm curious to read and understand the source of whichever drivers are installed by default.

What would be the way to go in order to be able to get to the source code from the information I have on the machine? For instance, I'm trying to find the source code for the ethernet driver I have installed on the machine.

I did an lspci, and found that I have a broadcom chip, "Broadcom Limited NetXtreme BCM57786". However, grepping through upstream kernel sources does not yield any results. How should I go about finding these drivers?

1

There are 1 best solutions below

0
Aleksey On

First of all, you need to get the kernel source code for the specific distribution and the kernel version that you're running. In your case it's Ubuntu, and there's the kernel source package called linux-source that you can install.

The command lspci | egrep -i --color 'network|ethernet' shows the list of installed network adapters in the system. Another command ip link show shows the list of network interfaces that the kernel recognizes. Using an interface name, you can easily find the name of the network driver that is responsible for that network interface, for instance: ethtool -i eth0. Finally, you can look for that network driver's source code in the kernel source tree under /drivers/net/ethernet/ (being the most popular case), or in other places, such as /drivers/net/wireless.

Please be aware, the the kernel sources for a specific distribution and kernel version are not quite the same as the kernel sources for the vanilla kernel of the same version. That's due to lots of back ports of bug fixes or features from newer kernel versions. Those back ports are different in each distribution which complicates the issue further.