Embedded Linux Wifi Driver
Hello everybody. Here is the video Part 5 in this training series. It demonstrates how to locate a device driver in the kernel source code. In the previous videos, we learned about the kernel logging API and the how to use it to get the kernel debug logs. But the question is, the kernel has a tens of thousands of files- how can I find where is the one for the peripheral on my board which I need to debug? This video will teach you the solution.
In this video, we first look at the kernel device driver architecture to understand word or platform-dependent device drivers are, then learn how the kernel locates the driver for a given device at runtime, so we can use the same method to find the device driver we are interested in in the kernel source code. After that, we use the AM335x I2C as an example to show how to locate the device driver. We have seen this diagram in the very first video of this training series. Linux has a user space and kernel space. Device driver is one of the frameworks in the kernel space.
The device driver framework can be divided into three layers. The application driver layer is on the top to implement the functions which the module can do, or to interface for other modules to use their services. The module core layer- in the middle- implements the common platform independent functions to control the hardware.
The controller driver layer at the bottom directly operates the hardware. This diagram shows the structure of the UART module. Marjoe The application layer is the TTY/Console Driver, and the controller driver layer has the UART device drivers to operate many UART controllers. This diagram shows the structure of the SDIO module. The application layer is the kernel virtual file system, and the controller driver layer has SD device drivers to operate many SD controllers. This diagram shows the structure of the I2C module. The application layer provides the I2C dev interface, but the controller driver layer is slightly different.
Because of the master/slave architecture, the controller driver layer encloses I2C adapter drivers to operate the I2C master controllers and I2C client drivers to operate the I2C slave controllers. Here's our problem- we just learned that each driver module has and application driver and a core driver, which are platform independent. It also has a many controller drivers to support many platforms. But only one controller device driver is used in one module for a specific system.
How do I find the controller device driver for my platform in the kernel source code? When discovering a new device, the kernel will try to locate its driver and load it into the memory. So first, let's see how the kernel finds the device driver for a specific device. How does the kernel find a driver for a device? The tie compatible.
Both the drivers and the device tree nodes define the compatible property. The kernel binds a driver to device if their compatible value matches. Let's look at the example of AM335x. The left side of the table shows that the USB node, which defines the compatible property to be ti,am33xx-usb.
To the right side of the table is the USB driver for AM335x, which also defines the same compatible value. When parsing the device tree, the kernel discovers the USB node. It will load this USB driver and bind it to the device, because their compatible value matches.
So how can we find a device driver for a given device? The same as what the kernel does- find the matching compatible string. We first look at the device tree file for a given platform. Find the compatible property value of the device node, then search the same incompatible value in the kernel source code to find its the driver. Let's use AM335x I2C subsystem as example to see how we can do it. Most I2C related code is located under drivers/I2C the directory in the kernel code. If you recall the driver architecture diagram we showed early in this video, the middle layer is the core, and the upper layer is the i2c-dev.
From the file names, you can see their drivers are all in here. Here, also, has a folder called buses, which has all the drivers for I2C master controllers. But it seems like the S2C slave drivers are not here. We will see where we can find them. AM335x has three I2C modules, called I2C0, I2C1, and then I2C2.
The I2C device tree file- am33xx.dtsi- defines the nodes for the three masters, which have the same compatible property value- ti,omap4-i2c. Each platform might have different I2C slaves. So the nodes for I2C slaves are defined in each board device tree file. The AM335x GP VM device tree file is called a am335x-evm.dts. Here's those old I2C slaves on the I2C1 bus. Each one defines their compatible property. We will use them to find their device driver.
Let's firstly try to find the drivers for the I2C masters. All three masters use the same compatible property value- ti,omap4-i2c. Now, in the top directory of the kernel tree, run this find command to search for the I2C master driver. The name pattern is a start LC, because we know the driver should a C file.
Please see the GREP pattern in the find command. We know the driver should define the compatible.
It has to be an assignment in the code. So we use an assignment with omap4-i2c as the GREP pattern. It is a little restrictive, because we want to limit the search result to only have the file we are interested in. Instead, if we only searched for omap4-i2c, we may get many files. Then we have to check each one to find which one is the driver.
Nothing fancy here, we just want to be a little efficient. Here are the search results. It only shows one file- drivers/i2c/busses/i2c-omap.c. It must be the driver for the I2C master on AM335x. Now you can open it up to check what debug you can turn on to get its debug log. Now we look at the I2C slaves.
Here is the node for tlv320aic2106 on bus I1C1, defined in AM335x-evm.dts. We used a similar find command as we did it for searching the I2C master driver. The only change is the compatible property value. Here is the search result.
We show the one file- sound/soc/codecs/tlv320asc3x.c. It must be the driver for this I2C slave. Please note, this driver is not under drivers/I2C. It has the drivers for I2C application layer, core layer, and then master devices. So basically, the I2C slave drivers can be anywhere in the kernel tree. Here's another I2C slave on bus I2C1- ls331dlh.
Please note, it has two values in it's compatible property. We still used a similar find command. But because the device compatible property has two values, we have to search for both to ensure we find its driver. The GREP pattern you'll see in this find command uses a regular expression to include both values. Here is our search result. It shows the device driver is drivers/misc/lis3lv02d/lis3lv02di2c.c. So far, so good.
We don't have any issue, yet, in finding device drivers are using this method. Here is another I2C slave on bus I2C1- tsl2550. We still use the same find command, but change the GREP pattern to have to tsl2550, which is a compatible property value defined in its device trait node. Oops, we found nothing. Now we loosen the GREP pattern a little bit.
Only search for the string tsl2550. Please note that we still include the double quotes in the search pattern, so it is still relatively restrictive. If we only searched for tsl2550 without the double quotes, we might get to many instances in the search result. It would take us a little more time to find the device driver.
Now we've found something. It has two instances.
But luckily, both point to the same file- drivers/misc/tsl2550.c. Let's try to figure out why our first find command didn't get anything, and also ensure that this is the driver for this I2C slave. We use this GREP command to see the context of the string tsl2550 in this file. Now we see the driver doesn't use that assignment when defining the compatible property.
The string tsl2550 in line 441 is used to in the I2C device ID struct, which is a tsl2550id. And then tsl2550id is used in line 444 to create the module device table, which is where kernel builds the driver lookup table. So now we know this the file is the I2C slave driver we are looking for. Why our first find command didn't find anything? It is only because this driver uses a different way to define the compatible property. It uses the struct defined the I2C core driver. To summarize this video, the link between a device and its driver is a compatible property.
So to find the device driver, we can search in kernel source code for the compatible value, which is defined in the device node in the device tree file. This is all for this video, and here are some links for more information. If you have any questions, please let us know.
Thanks for watching.
In this video I go through the steps required to build the Linux kernel for the Beaglebone and show the steps that are required to deploy the kernel to an existing distribution. I download the Ubuntu Arm minimal distribution and deploy it and the kernel together.
I then show how we can get Wi-Fi working using two small USB Wifi adapters that are based on the Realtek RTL8192CU chipset. Both of these adapters are less than €10 ($13 USD) in price and can be bought directly from suppliers such as Amazon: The “Edimax EW-7811” and the “Duronic IR786” are the two devices that are tested in this video.
Finally, I demonstrate how I would compile and deploy a custom driver using the 8192CU driver that is available from the Realtek website. Thanks to Robert C Nelson solved my issue. The trick is to delete some unnecessary files form the /boot partition of the angstrom build such as drivers directory and then copy over to the SD card using the script. If you do a df -k, you’ll notice that your /sdb1 is mounted to a directory on the Linux-dev directory. Go to this directory, delete some of the junk and then all works well.
Simple trick, had me going for days. Another note from Robert, recommended that I pull 3.8. Or 3.12 from the Linux-dev environment as 3.2 will not boot on BBB anyway. You live, you learn.
Hello, I followed your explanations and got WiFi to run with my Samsung BluRay Player WiFi stick, because it also used the RT8192 chip. It worked fine with the built-in driver. Later I switched to the Medimax WiFi stick and ran into several problems (including not being able to boot some times). Finally I rebuild the driver as you showed and replaced the built-in one with the newly built one.
This made the stick work better, but not reliable. I saw a lot of USB failures in dmesg. After some further research I found out that ESD could be an issue so I used a USB extension cable and plugged the stick in there approx 1m away from the BB.
From that point on it worked fine and my bone now also runs as a WiFi Access point. Maybe the use of the own-built module and the use of a USB extension cable is something you want to mention in your tutorial (I am using a BB Rev A6).
Really great blog! Regards, Thomas. Howya Derek, thanks for taking the time to share so much good stuff. I keep swearing to myself that I will give back something in the way of a web site one of these days. A quick question for you. I’m using a BBB as an “intelligent node” with an arduino attached for switching how water and measuring energy.
The BBB sends and receives info using MQTT to / from an MQTT broker. I’ve all but given up on getting reliable WiFi comms on the BBB.
(I’m currently using a Rasp Pi). Since I’m using Ubuntu 13.1, I downloaded the back level Linux kernel headers, and built the Realtek driver as described in many places on the net. It builds, and works for a little while, but is very flaky. I’ve tried many adapters. So do you have a solid reliable WiFi setup on your BBB? If so, could you tell me what router you are using?
I’m using Apple base stations, and the 2.4Ghz network is on channel 11, I wonder whether that might be the problem. Cheers, Con.
Install Usb Wifi Driver Linux
I have a Rev C Beaglebone Black with the Debian 3.8.13 distribution. I bought the Edimax wireless adapter and have it working without much trouble. The problem I’m seeing however, is when I log in with putty, the command line is very slow and sporadic when accepting keystrokes and displaying results. Ie, I can type ls -ltr and it may take 3-4 sec just for the command to show in the putty window. At times it gets slower and slower the longer i have the putty session going.
Thanks in advance Derek. I’m having Beaglebone Black, Angstrom 3.8.13.
Linux Wifi Drivers Download
I could successfully build and boot up with 3.8.13-bone47 by following your steps. However, after that I can’t boot up without SD card and it seemed to try to reflash MMC everytime booting up with SD. So I left SD card in there for about half an hour to let it finishing reflashing MMC. But when I booted up with MMC, it’s still 3.8.13.
It didn’t reflash it with 3.8.13-bone47. How do I boot up with SD card without reflashing MMC? How to reflash it with 3.8.13-bone47 on SD? PLease advise. Hi Derek, I just completed my beagle bone project based on android accessory but i am facing one last problem, Beagle-bone USB Host port becomes unresponsive if I connect Android Device having USB-OTG.
But after resetting Beagle-bone it works fine on both devices i.e. Android Device with USB-OTG and without USB-OTG.
But again if I disconnect and try to reconnect, it won’t work. Also the power supply on USB-Host of Beagle-bone seems unavailable. At the back-end, my script is executing continuously, there is no problem on script, as I checked my script on Linux too, and it also works fine on all Android Device(.with & without USB-OTG facility). Also there is no problem on multiple connects and disconnects with different devices. Please, let me know where i’m wrong. The 'monster' image that is associated with your comment is auto-generated - it makes it easier to follow the conversation threads. If you wish to replace this image with a less (or perhaps more) monstrous version, add an image at against the e-mail address that you use to submit your comment.
Your image will henceforth be used on most WordPress sites. Please note that I will remove any messages that contain blatant advertisement or that refer to illegal software, content etc. I may tidy up some messages if they contain code dumps etc. E-mail addresses are used only to notify you of any responses, and to authenticate your future comments on this website - they are not made public nor used for any other purpose.
Ubuntu Linux Wifi Drivers
See the for a full description. I manually approve all new posts in order to keep the website spam free, but once your post is approved, all future posts should be automatically approved. Please let me know if your messages do not appear.
I really appreciate it when you answer the questions of others on the page, as it is difficult for me to do so and continue to produce new content. Thanks for your understanding, Derek. Current ye@r. Leave this field empty.