Home » mouse-free » Compiling a new kernel module to use hid-core for a Wacom Bamboo Pad

Compiling a new kernel module to use hid-core for a Wacom Bamboo Pad

I previously built a custom kernel to use my Bamboo Pad under Ubuntu via the hid driver. This has proved to be a pain, as the kernel seems to be periodically updated by Ubuntu, which renders my system unstable.

So, now, after learning about building drivers from the wacom list (unfortunately I haven’t managed to get the Bamboo working with the wacom driver), I have tried just building a custom hid driver, as follows:

Remove the wacom driver

sudo rm /lib/modules/3.8.0-35-generic/kernel/drivers/input/tablet/wacom.ko
sudo modprobe -r wacom

Build a custom hid driver

myHID=/local/myHID # directory where I will do the building
V="-34-generic"
sudo apt-get build-dep --no-install-recommends linux-image-$(uname -r)
mkdir $myHID
cd $myHID
apt-get source linux-image-$(uname -r)
cp /usr/src/linux-headers-`uname -r`/Module.symvers .
cp /boot/config-`uname -r` .config
cd linux-3.8.0/
make EXTRAVERSION=$V O=$myHID oldconfig
make EXTRAVERSION=$V O=$myHID prepare
make EXTRAVERSION=$V O=$myHID outputmakefile
make EXTRAVERSION=$V O=$myHID archprepare
make EXTRAVERSION=$V O=$myHID modules SUBDIRS=scripts
vim drivers/hid/hid-core.c
# comment out the line
#        { HID_USB_DEVICE(USB_VENDOR_ID_WACOM, HID_ANY_ID) },
make EXTRAVERSION=$V O=$myHID modules SUBDIRS=drivers/hid
sudo cp -R $myHID/drivers/hid/* /lib/modules/`uname -r`/kernel/drivers/hid
sudo depmod -a

Start monitoring usb

$ sudo cat /sys/kernel/debug/usb/devices
T:  Bus=02 Lev=02 Prnt=02 Port=06 Cnt=02 Dev#=  5 Spd=12   MxCh= 0
D:  Ver= 2.00 Cls=00(>ifc ) Sub=00 Prot=00 MxPS=64 #Cfgs=  1
P:  Vendor=056a ProdID=0318 Rev= 1.01
S:  Manufacturer=Wacom Co.,Ltd.
S:  Product=Bamboo Pad, USB
C:* #Ifs= 3 Cfg#= 1 Atr=80 MxPwr=100mA
I:* If#= 0 Alt= 0 #EPs= 1 Cls=03(HID  ) Sub=00 Prot=00 Driver=(none)
E:  Ad=81(I) Atr=03(Int.) MxPS=  64 Ivl=3ms
I:* If#= 1 Alt= 0 #EPs= 1 Cls=03(HID  ) Sub=00 Prot=00 Driver=(none)
E:  Ad=83(I) Atr=03(Int.) MxPS=  64 Ivl=8ms
I:* If#= 2 Alt= 0 #EPs= 1 Cls=03(HID  ) Sub=00 Prot=00 Driver=(none)
E:  Ad=84(I) Atr=03(Int.) MxPS=  64 Ivl=8ms
$ sudo modprobe usbmon
$ sudo cat /sys/kernel/debug/usb/usbmon/2u |grep 2:005

Reload the new hid driver, being careful not to leave myself with no hid drivers loaded, and therefore no input ability

cat > rehid <<EOF
sudo modprobe -r -a hid-multitouch hid_generic hid_microsoft usbhid hid
sudo insmod /lib/modules/`uname -r`/kernel/drivers/hid/hid.ko
sudo insmod /lib/modules/`uname -r`/kernel/drivers/hid/usbhid.ko
sudo insmod /lib/modules/`uname -r`/kernel/drivers/hid/hid-generic.ko
sudo insmod /lib/modules/`uname -r`/kernel/drivers/hid/hid-microsoft.ko
sudo insmod /lib/modules/`uname -r`/kernel/drivers/hid/hid-multitouch.ko
EOF
chmod 755 rehid
./rehid
Advertisements

26 thoughts on “Compiling a new kernel module to use hid-core for a Wacom Bamboo Pad

  1. Great. Followed this for my Bamboo Pad on Linux Mint 16 (Ubuntu 13.10) and it works. Good job.
    But can you please explain why it works? As far as I understand it I recompiled my hid drivers without that VENDOR_ID_WACOM line in hid-core.c. Why would that work?
    Anyway, thanks again.

    • Glass it worked.

      The native hid drivers work for this bamboo, but not for other models. By default, therefore, they are not loaded when the vendor id identifies something as wacom. Removing that line, they skip that check and get loaded. Does that make sense?

      • It does actually. But in that case I think recompiling isn’t necesary. There should be file in /etc where you can tell which driver goes to which product/vendor id.
        At least now I have a working touchpad and I’ll look for that file when I have some time. I’ll let you know.
        Thanks again. Cheers.

  2. Hello , and thanks!
    Some questions: does the bamboo pad function well after installation?
    For pen and touch?

    thanks for some report.

  3. Great manual. I’m so pissed off about Wacom, for not being able to get it working alright at all. It ONLY works well on Mac with pressure sensitivity. Not even Windows users can use it without problems. Such a shame,

    by the way, i tried this manual on Ubuntu Studio 12.04. Somehow, my Pc stucks at the “./rehid”, complaining about missing stuff. Which distribution are you using at the moment?

    Is pressure working on Linux then? If yes, i would try it again and give the tablet a chance.

    Thanks in advance! 🙂

    • I am running Ubuntu 13.04. I don’t have pressure working, just works like a mouse, which is a big shame and means I am not making so much use of it.

      I keep meaning to revisit it, but haven’t had time yet.

      What does it claim is missing?

  4. Hei hei!

    I’m just trying with Ubuntu 13.10, 3.11.0-19-generic.

    Could you do me a favor and explain why you are setting V to -34-generic, while you removed the driver from -35-generic – and did not use $(uname -r) there.

    Thanks a bunch!

    • Huh, good question! I had been playing around with kernels a bit, perhaps I removed the wacom.ko from one kernel, then installed in another, in which I had already removed the kernel?

      I plan to upgrade to 14.04 in a while, so after that I’ll need to redo this, on a clean kernel source, so will post a clean version there. Re your next comment, I would just undo my edits to the source, recompile etc, but you’re right, it would be easy to create a backup version to allow rollback, I’ll try and do that too when I next run this thing.

      Thanks for the suggestions!

      • Well damn – I can’t even compile the modules without errors.

        When I tried I rehid I got
        WARNING: Module hid is in use.
        Error: could not insert module /lib/modules/3.11.0-19-generic/kernel/drivers/hid/hid.ko: File exists
        Error: could not load module /lib/modules/3.11.0-19-generic/kernel/drivers/hid/usbhid.ko: No such file or directory
        Error: could not insert module /lib/modules/3.11.0-19-generic/kernel/drivers/hid/hid-microsoft.ko: Unknown symbol in module
        Error: could not insert module /lib/modules/3.11.0-19-generic/kernel/drivers/hid/hid-multitouch.ko: Unknown symbol in module

      • I just tried to find the errors that the make statements gave me, but this time everything worked fine. lol.

        I tried rehid again, and only got

        WARNING: Module hid is in use.
        Error: could not insert module /lib/modules/3.11.0-19-generic/kernel/drivers/hid/hid.ko: File exists
        Error: could not load module /lib/modules/3.11.0-19-generic/kernel/drivers/hid/usbhid.ko: No such file or directory

        My mouse and keyboard work this time, but the tablet doesn’t – neither after replugging it. /:

  5. Hey Chris. I’ve found this post to be really helpful for compiling a custom hid driver (completely unrelated to Wacom, this is for Lenovo ScrollPoint Mice).

    One issue I’m having is with the lines:
    sudo apt-get build-dep –no-install-recommends linux-image-$(uname -r)
    and
    apt-get source linux-image-$(uname -r)

    apt-get actually ends up downloading a different version of the kernel source. I.e. in my case, my version is 3.2.0-35-generic, and when I do
    apt-get source linux-image-3.2.0-35-generic

    I get:
    Picking ‘linux’ as source package instead of ‘linux-image-3.2.0-35-generic’

    And it seems to just download the 3.2.0 base and the most recent diff (3.2.0-61.91)

    So when I compile, I get symbol errors when trying to load the modules (as the symbols differ between versions, i.e.: “hid_scrollpoint: disagrees about version of symbol __hid_register_driver”)

    Do you have any tips for enforcing that apt downloads exactly the version of the source that I want?

    Thanks again, immensely useful post.

    Best,
    Chethan

    • FYI: the “proper” way to do this is to clone the ubuntu git repository, and then checkout the specific version of interest. For me, this was:

      git clone git://kernel.ubuntu.com/ubuntu/ubuntu-precise.git
      git checkout Ubuntu-3.2.0-35.55

      Just posting in case this helps anyone else stuck on the same problem.

  6. Is this right?

    Maybe you would be better-off trying a later kernel rather than compiling the hid drivers. Your at 3.13 so give 3.14.or even 3.15 a shot.

    Instructions and the upstream kernel link is located here: https://wiki.ubuntu.com/Kernel/MainlineBuilds

    Chances are support is provided for that apparatus and you’ll save yourself, and me. a lot of cursing and headaches.

  7. I found it easier to add usbhid.quirks=0x056a:0x0318:0x40000000 to the kernel commandline in /etc/default/grub.
    0x40000000 is HID_QUIRK_NO_IGNORE. The first two numbers is the device’s ID.

  8. I have tried this on 3.16.0-25-generic & 14.10 – got to the point with same errors as theonlyandy. i.e. for usbhid.ko: No such file or directory, file exists for others.

    Mouse & keyboard fine. Pad’s blue light is on. Usbmon shows action when pad is plugged in/out.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s