Ciaran McCreesh’s Blag

Now with 17% more caffeine

Posts Tagged ‘linux’

xorg-x11 hackery for a Logitech RX1000 Mouse

Posted by Ciaran McCreesh on October 23, 2008

The Logitech RX1000 mouse has a scroll wheel that can tilt left or right. This generates HWHEEL events by default, which are pretty much useless. I find it more useful to have the tilt generate WHEEL events (scroll up and down), so I can press and hold left or right rather than repeatedly spinning the mouse wheel.

The wheel can also be pressed to get a middle click, but if I don’t concentrate I end up scrolling as well as middle clicking. There’s another button with a magnifying glass icon on it just below the scroll wheel which is more useful, which usually shows up as button 8. By making this button 2 we can use that for X11 paste, open-in-new-tab in Firefox and so on.

So I don’t forget how to get this working:

Section "InputDevice"
    Identifier  "Mouse1"
    Driver      "evdev"
    Option      "Name" "Logitech USB Optical Mouse"
    Option      "HWHEELRelativeAxisButtons" "4 5"
EndSection

Unfortunately, evdev doesn’t seem to have a ButtonMapping equivalent, so we have to fall back to xmodmap to do the button remapping. Doubly unfortunately, this makes pressing the middle mouse button useless.

pointer = 1 6 3 4 5 2 7 8 9 10

Thanks Nicolas.

Posted in hardware | Tagged: , , , , , | 1 Comment »

xorg-x11 keycodes for a Logitech 350 Keyboard

Posted by Ciaran McCreesh on August 2, 2008

To save myself from having to mess around with xev again in the future: here’re the keycodes for a Logitech 350 USB keyboard with xorg-x11 on Linux:

keycode 129 = XF86AudioMedia
keycode 236 = XF86Mail
keycode 178 = XF86WWW
keycode 161 = XF86Calculator
keycode 162 = XF86AudioPlay
keycode 174 = XF86AudioLowerVolume
keycode 176 = XF86AudioRaiseVolume
keycode 160 = XF86AudioMute

These go in ~/.Xmodmap. And in ~/.fluxbox/keys, we can use:

XF86Mail                 :ExecCommand claws-mail
XF86WWW                  :ExecCommand firefox
XF86Calculator           :ExecCommand xterm
XF86AudioPlay            :ExecCommand mpc toggle
XF86AudioLowerVolume     :ExecCommand amixer set PCM 2-
XF86AudioRaiseVolume     :ExecCommand amixer set PCM 2+
XF86AudioMute            :ExecCommand amixer set Master toggle

Posted in hardware | Tagged: , , , , , , | Leave a Comment »

Edimax EW-7728In 802.11n (RaLink rt2860) with Linux 2.6.26

Posted by Ciaran McCreesh on July 14, 2008

Being sick of wireless disconnecting every time it rained, I got my hands upon a cheap Edimax EW-7728In PCI 802.11n card. This uses a RaLink rt2860 (PDF) chip, which has vendor-supplied open source drivers available. Getting it to work with Linux 2.6.26 is slightly non-trivial, however.

First, we need the drivers. At the time of writing, that means 2008_0522_RT2860_Linux_STA_v1.6.1.0.tar.bz2.

Next, we need to fix a couple of things. First, the Makefile is dumb, and tries to install into /tftpboot:

From 82dc3a8737e4f97311f4f4fccd79ea55a319f1ea Mon Sep 17 00:00:00 2001
From: Ciaran McCreesh <ciaran.mccreesh@googlemail.com>
Date: Mon, 14 Jul 2008 16:47:00 +0100
Subject: [PATCH] Get your filthy paws off my /tftpboot

---
 Makefile |    2 --
 1 files changed, 0 insertions(+), 2 deletions(-)

diff --git a/Makefile b/Makefile
index 72bc933..aed3b00 100644
--- a/Makefile
+++ b/Makefile
@@ -80,11 +80,9 @@ LINUX:
 ifneq (,$(findstring 2.4,$(LINUX_SRC)))
        cp -f os/linux/Makefile.4 $(RT28xx_DIR)/os/linux/Makefile
        make -C $(RT28xx_DIR)/os/linux/
-       cp -f $(RT28xx_DIR)/os/linux/rt$(CHIPSET)sta.o /tftpboot
 else
        cp -f os/linux/Makefile.6 $(RT28xx_DIR)/os/linux/Makefile
        make  -C  $(LINUX_SRC) SUBDIRS=$(RT28xx_DIR)/os/linux modules
-       cp -f $(RT28xx_DIR)/os/linux/rt$(CHIPSET)sta.ko /tftpboot
 endif

 clean:
--
1.5.6.2

Next, dev->nd_net should now be dev_net(dev):

From 0878b37a40e2a7f466a74938920ff3751917eec3 Mon Sep 17 00:00:00 2001
From: Ciaran McCreesh <ciaran.mccreesh@googlemail.com>
Date: Mon, 14 Jul 2008 16:48:50 +0100
Subject: [PATCH] dev->nd_net is now dev_net(dev)

---
 os/linux/rt_main_dev.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/os/linux/rt_main_dev.c b/os/linux/rt_main_dev.c
index 24604da..6a3471d 100644
--- a/os/linux/rt_main_dev.c
+++ b/os/linux/rt_main_dev.c
@@ -669,7 +669,7 @@ static NDIS_STATUS rt_ieee80211_if_setup(struct net_device *dev, PRTMP_ADAPTER p

 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,5,0)
 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,24)
-        device = dev_get_by_name(dev->nd_net, slot_name);
+        device = dev_get_by_name(dev_net(dev), slot_name);
 #else
                device = dev_get_by_name(slot_name);
 #endif
--
1.5.6.2

Finally, the driver is unusably noisy. Unless you want fifty-odd lines of kernel debug informatione every five seconds:

From 19c7a6895333624566775541fbc836e0c9208225 Mon Sep 17 00:00:00 2001
From: Ciaran McCreesh <ciaran.mccreesh@googlemail.com>
Date: Mon, 14 Jul 2008 16:47:43 +0100
Subject: [PATCH] You shut your dirty whore mouth

---
 include/rt_linux.h |    4 ----
 1 files changed, 0 insertions(+), 4 deletions(-)

diff --git a/include/rt_linux.h b/include/rt_linux.h
index dfe4ab5..079d256 100644
--- a/include/rt_linux.h
+++ b/include/rt_linux.h
@@ -325,10 +325,6 @@ extern ULONG    RTDebugLevel;

 #define DBGPRINT_RAW(Level, Fmt)    \
 {                                   \
-    if (Level <= RTDebugLevel)      \
-    {                               \
-        printk Fmt;               \
-    }                               \
 }

 #define DBGPRINT(Level, Fmt)    DBGPRINT_RAW(Level, Fmt)
--
1.5.6.2

There’s no Makefile install target, so you’ll need to sudo cp os/linux/*.ko /lib/modules/`uname -r`/kernel/ then sudo depmod -a before you can sudo modprobe rt2860sta. You’ll also need to sudo mkdir -p /etc/Wireless/RT2860STA/ then cp RT2860STA.dat /etc/Wireless/RT2860STA/, even though we’re not using that file for any configuration.

Gentoo’s init scripts, if you’re using them, try to be overly clever, and won’t be able to bring up the interface. So use something like this as your /etc/init.d/net.ra0:

#!/sbin/runscript

depend() {
    need localmount
    after bootmisc hostname net.lo net.lo0
    use isapnp isdn pcmcia usb wlan
}

start() {
    bash -x -c 'ifconfig ra0 up'
    bash -x -c 'iwconfig ra0 essid giant-space-monkey key "aa:bb:cc:dd:ee:ff:00:11:22:33:44:55:66" freq 2.417G'
    bash -x -c 'dhcpcd ra0'
}

stop() {
    :
}

restart() {
    :
}

And that appears to be sufficient.

Posted in hardware | Tagged: , , , , | 7 Comments »

Yay for git

Posted by Ciaran McCreesh on May 18, 2008

Linux 2.6.26-rc2 wouldn’t boot on my desktop. Linux 2.6.25 worked. In the good old days, tracking down why would be a major pain in the ass. But now, a quick git bisect and fifteen reboots later, I have the exact commit: 3def3d6ddf43dbe20c00c3cbc38dfacc8586998f, also known as:

Author: Yinghai Lu
Date:   Fri Feb 22 17:07:16 2008 -0800

    x86: clean up e820_reserve_resources on 64-bit

    e820_resource_resources could use insert_resource instead of request_resource
    also move code_resource, data_resource, bss_resource, and crashk_res
    out of e820_reserve_resources.

    Signed-off-by: Yinghai Lu
    Signed-off-by: Ingo Molnar

Verifying that this really is the offender is equally easy — a quick ‘git revert’ on head and another reboot and the kernel’s working again. Now, I know nothing about what an e820 is beyond what Google tells me, but hopefully someone else will.

As much as I hate to say it, if this were Subversion I’d still be tracking down the bug. And if it were CVS, I wouldn’t've bothered.

Posted in hardware, source control | Tagged: , , | 11 Comments »