Welcome

Troves being gleaned while surfing on the Internet mostly about computer/IT/system skills and tricks, Welcome here ...
Powered By Blogger

Disclaimer

This blog is written by the owner with real practices and tests and intended to hold all original posts except there is a clear declaration for referencing from others. Thanks for tagging with the source link or other tips for reference from here if you would like to quote partial or full text from posts in this blog.

Monday, November 19, 2012

Build Bluetooth Kernel Module in Fedora Linux

Prelude:
If you do not encounter issues like one of the following, you are free to leave now so as to avoid a waster of time reading more below.

Download  Linux Bluetooth kernel module source code

Can not compile Linux Bluetooth kernel module
/sbin/modprobe: invalid option -- 'l'


========================== Start =====================================

Although this practice was with Fedora Linux 17, the following instructions should still do the tricks for building the Compat bluetooth kernel module for Linux with kernel version of 2.6.x or above.

NOTE: this post is not about playing with the user space code that you may find on the bluez.org official site http://www.bluez.org/download/

1. download kernel code for the bluetooth module
This should be ported together with the kernel itself, but in case you have not yet had it on hand or been unable to find the source code, download from the site below

https://gforge.ti.com/gf/download/frsrelease/802/5435/ti-compat-bluetooth-2012-02-20.tar.gz

2. now once your followed the steps indicated on http://processors.wiki.ti.com/index.php/Open_source_Wireless_Connectivity_Bluetooth_components#Bluetooth_Modules, you will probably get stuck by the compilation with
 
make KLIB_BUILD=<Path To Linux> KLIB=${ROOTFS} install-modules

(Equivalence of it is to run "make bt" under the top source code directory.)

Error might be like some syntactical faults in the kernel headers this module depends on, and you may find you have no luck by applying the patch provided in the above site (http://processors.wiki.ti.com/images/8/8e/Compat-patch-zip.zip) , the only cure I had got that really was efficacious is to apply the following patch instead (thanks to the guy who posted it)
http://marc.info/?l=linux-wireless&m=132760196131230&w=2 (in case this link may be expired or moved away, I have pasted below)

This file was introduced in commit 2a11c8ea20bf850b3a2c60db8c2e7497d28aba99
and included in 3.1 and later kernels.  It includes <generated/autoconf.h>
itself, as well as some other definitions that are used elsewhere.

Signed-off-by: John W. Linville <linville@tuxdriver.com>
---
 include/linux/compat-2.6.h |    4 +++-
 1 files changed, 3 insertions(+), 1 deletions(-)

diff --git a/include/linux/compat-2.6.h b/include/linux/compat-2.6.h
index c23e94a..3ccd051 100644
--- a/include/linux/compat-2.6.h
+++ b/include/linux/compat-2.6.h
@@ -2,7 +2,9 @@
 #define LINUX_26_COMPAT_H
 
 #include <linux/version.h>
-#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,33))
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,1,0))
+#include <linux/kconfig.h>
+#elif (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,33))
 #include <generated/autoconf.h>
 #else
 #include <linux/autoconf.h>
-- 
1.7.4.4

(Copy it into a file named newpatch, say, and then apply it by "patch -p1 newpatch")

Thereafter, you should be able to get through "make bt" successfully".

3.  However, when you get to "make btinstall" or later "make btuninstall" to toy around the Bluetooth loading or unloading, you can get more annoying warnings like:
 
/sbin/modprobe: invalid option -- 'l'

It seems not critical but will block the normal process of "installation" from being complete hence unsuccessfully installation of the new Bluetooth module you just made.

To get rid of them (I am showing you the reasons behind it since you may be interested more in the solutions right now, please Google that if you are indeed intrigued with that),  use the following trick
(this is came up with on the basis of what was earlier posted by Artem Chekunov on http://comments.gmane.org/gmane.linux.kernel.wireless.general/87040)

touch /sbin/modprobe.sh
and then put the following into it and save.
--------------------------------------------------------------------------
#!/bin/bash

if [[ $1 == -l ]]
then

if [ -z $2 ]    
then
 find /lib/modules/$(uname -r) -name '*.ko' | \
 sed -e "s#\/lib\/modules\/$(uname -r)\/##g"
else 
 find /lib/modules/$(uname -r) -name '*.ko' | \ 
 sed -e "s#\/lib\/modules\/$(uname -r)\/##g" | grep $2
fi

else
/sbin/modprobe $@
fi
 
exit 0 
---------------------------------------------------------------------------
Note the last line I added (besides changes made somewhere else) is important to make sure that "make" can run completely through all expected steps.

Then do the following more steps:

chmod +x /sbin/modprobe.sh
alias modprobe=/sbin/modprobe.sh
echo "alias modprobe=/sbin/modprobe.sh" >> /etc/bashrc

cp Makefile Makefile.save
sed -i -e 's/^MODPROBE.*/MODPROBE := \/sbin\/modprobe.sh/g' Makefile
 
Now do what you like.

========================== End =====================================

4 comments:

Anonymous said...

Blue Martini ' 949-2583 Open: 4pm No Cover Happy Hour: 4pm-8pm. That is why it's especially important to command professionalism from the start.
Iba ang pulitika at iba ang boxing (We don't need mudslinging, just present your good intentions.

Here is my web blog :: Tao of Badass Review

Anonymous said...

I blog often and I seriously appreciate your content.
This article has truly peaked my interest. I am going to take a note of your
website and keep checking for new information about once per week.

I subscribed to your RSS feed as well.

Look at my web blog; Click here

Anonymous said...

When we do not understand things we tend to make assumptions that are
not always correct. He also stated that he knew of many instances of corruption but he feared for his life if he came forward.
The meaning of "tajweed' is to make perfect or proficient.

Here is my blog post :: islamic education foundation

Anonymous said...

Losing fat and gaining muscles at the same time is quite tricky thing
to do without the guidance of an expert. With
that being said, it is vital to understand the benefit of staying fit and not being
superficial. Many people suffer with a belly fat problem, the
problem range from mild to severe.

Feel free to visit my website - how to lose belly fat fast