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 26, 2012

Hacking Bluetooth Modules in Fedora 17 Linux

Having figured out how to successfully build the original source package of the Bluetooth modules downloaded online (see my older post on how to build), now we can head to hack those modules in order to customize certain Bluetooth functionalities on demand (as is actually, at least one of many others, the reason why we wanted to build the source package instead of downloading the executable in the first place).

To hack the Bluetooth modules and make it really effect for ordinary users, we need both categories of module - the kernel module and the user module. While the tricks required to build the kernel modules ca be found in the older post on how to build, building the latter on the same platform (AMD64, Fedora 17 Linux) has been straightforward at least for myself(your report of troubles in building the user space modules of Bluetooth, i.e. as downloaded from bluez.org, is welcome to be put into the comments of this post). Remember, however, as was somehow seemingly required, you need to "sudo" the execution of the common sequence of "./configure" -> "make" -> "make install" if you are not logged in as the root directly.

Now following things to be followed, no big deal, just the below listed,

1. Having successfully built the kernel modules should have given you a group of module binaries (.ko files) that has been moved ("installed") to the directory of "/lib/modules/`uname -r`/updates" by default, where subdirectories include the following together with example, but not all, enclosed files :
driver[/btusb.ko],  net[/bluetooth/{rfcomm.ko, bnep.ko}], and net/[bluetooth.ko]. 

* if you have not yet successfully got these files, you have not yet successfully built the kernel module then. Check again you have really followed and went through successfully the following steps before getting back again to the older post on how to build:
under the top source directory, do
"make clean" -> "scripts/selectdriver bt" -> "make install-modules"

2. before you can "mount" the newly built kernel module for bluetooth above, make sure you "dismount" the currently mounted one as the system has done while booting the kernel by default. Do these:
"killall -9 bluetoothd" -> "sudo modprobe -r bnep" -> "sudo modprobe -r rfcomm" -> "sudo modprobe -r btusb" -> "sudo modprobe -r bluetooth". An alternative to "modprobe -r" could be "rmmod".

* note if the bluetoothd (see below for more about it) is still running, you will get "cannot remove module xxx, xxx is busy/in use" when you are doing the aforementioned "dismounting" steps.

* note that the btusb.ko module is directly associated with the "bluetooth icon" on the toolbar of the desktop , which is presented there by default. So when you killed this module, that icon disappeared. In return, you can use the disappearance of that icon as a simple flag that this module has been removed successfully.

* If you still had trouble removing them, play the trump now:
"sudo init 3" -> "log in a root" -> "do the same series of modprobe -r"

3. Having successfully built the user space module should have given you a set of binary executables and objects (lib files) besides documentation related files to the directory you have indicated when doing "./configure" before. Check the installation directory for such subdirectories as that includes the following together with example, but not all, enclosed files :
bin[/hcitools], sbin[/bluetoothd], ....

Here we actually are concerned about the bluetooth daemon server bluetoothd only, as is to be running in the user space to bridge the bluetooth applications and the underlying bluetooth kernel modules.

4. Now start mounting your own hacked modules and make them effect by following steps:

  1. "sudo mv /sbin/bluetoothd /sbin/bluetoothd.org" (just back up the original one in any way you prefer)
  2. "sudo cp $installDir/sbin/bluetoothd /sbin/" (this is critical, directly running this daemon from the $installDir", at least when the "installDir" is not the one taken as default, has fallen to failure for me)
  3. "sudo /sbin/bluetoothd [-n] [-d]"
  4. "sudo modprobe bluetooth,bnep,rfcomm,btusb"


Now you should have been working with your hacked bluetooth modules.

* using "-n" to run bluetoothd in a non-daemon will show you the running log that can give you a sense of how the user modules get loaded and run; further, the addition of "-d" to the command line can provide you even more details of the internal dynamics of the user space code.

* "dmesg -T | grep "bluetooth" can give you running logs of the kernel module, about their being loaded and run.

Enjoy hacking!

Nikon D5100 16.2MP Digital SLR Camera with AF-S DX Nikkor 18-55mm f/3. (Google Affiliate Ad)

2 comments:

Anonymous said...

Write more, thats all I have to say. Literally,
it seems as though you relied on the video to make your point.
You definitely know what youre talking about, why waste your
intelligence on just posting videos to your weblog when you could be giving us
something informative to read?

Stop by my weblog how much should you weigh

ianthyahvalcarcel said...

Best games from Casinodaddy Casino - DrmCD
Top rated casino for 용인 출장샵 slots ✓ 공주 출장안마 Play 화성 출장안마 online slots for real money ✓ No download ✓ Huge progressive 하남 출장안마 jackpot slots ✓ Play for free. 전라북도 출장샵 Rating: 5 · ‎1 vote