# Using mdev with usb keyboard [SOLVED]

## Tony0945

I've bee praising mdev but ran into a snag when implementing on my second computer. All went with a hitch, except I can't type anything! I finally realized that the first computer had a PS/2 keyboard and the second had a usb keyboard. I had run into  a problem on the first computer with the mouse which I fixed with a line in /etc/conf.d/modules *Quote:*   

> # ohci_pci and ehci_pci needed for usb mouse
> 
> modules="radeon e1000e snd_hda_intel k10temp acpi_cpufreq ohci_pci ehci_pci"
> 
> 

 

So on the second machine I changed /etc/conf.d/modules to read (eventually)  *Quote:*   

> modules="nouveau r8169 snd_hda_intel k10temp acpi_cpufreq xhci_pci ohci_pci ehci_pci  usbcore usb_common usbhid "

   But still no keyboard or mouse.

My kernel config is here: https://bpaste.net/show/7bfebb22cf0bLast edited by Tony0945 on Sat Oct 24, 2015 8:55 pm; edited 1 time in total

----------

## Roman_Gruber

does the keyboard works in grub?

Some older bios disable usb devices when the settings are wrong in teh bios.-

----------

## Roman_Gruber

https://github.com/slashbeast/mdev-like-a-boss

 *Quote:*   

> Xorg
> 
> Build xorg-server with '-udev' USEFLAG. As we no longer use udev, we can't use evdev. Install mouse and keyboard drivers, and if you use touchpad synaptics as well. The input configuration is not the same as with evdev, we will no longer use 'InputClass' but 'InputDevice' sections. You propably do not need xorg.conf at all. Create /etc/X11/xorg.conf.d/ and copy content of the /opt/mdev/xorg.conf.d/ there. Then adjust the config files as you wish.

 

well this hint is a bit bogus. my opinion is that you need at least a config file in the directory shown below with the contents of the input device sections at least. so teh Claim no xorg.conf is just a lie because you need another config file with the input section. which was basically part of the xorg.conf in the past for years.

did you create this file?

```
ls --full-time /etc/X11/xorg.conf.d/
```

 please

the x server should give you plenty of messages and warnings and plesae do not ignore those

----------

## Tony0945

Sorry to respond late. My cable modem died and my ISP just replaced it two hours ago.

Yes, keyboard works in grub. Does not work in initramfs. Doesn't work in terminal mode either if I don't launch xdm, so I doubt that the X configuration matters.

The machine is not locked up, I can ssh in to it.

----------

## geki

well, I have the same problem on console - headless system. do you already use mdev-like-a-boss?

if not, like me, I wonder if the following may help. mdev-like-a-boss parses sysfs for usb devices which busybox[mdev] init script does not.

https://github.com/slashbeast/mdev-like-a-boss/blob/master/mdev.init#L54

I do not know if I can test that anytime soon.

----------

## Tony0945

Tried lifting the code from mdev-like-a-boss. Didn't work. I see the kernel messages in the syslog but no devices are created. To do it right, I need to replace busybox with the mdev from the overlay, but I'm afraid to do that.

----------

## geki

I think I found the solution to my problem here.

I somehow thought that usb keyboards/mice need no extra kernel drivers. well, I was wrong.

I may better check kernel config: Device Drivers > HID support > Special HID drivers.

and there it was: my cherry usb keyboard driver!  :Embarassed: 

now, also seen in /proc/bus/input/devices.

lets see when I get there to actually test the keyboard.

edit #1

it actually works.

----------

## Tony0945

Well, I unemerged busybox and emerged mdev-bb which turned out to be busybox-1.21 instead of the 1.23 that i had installed. emerged mdev-like-a-boss from the overlay. no difference.

I saved copies of ls -l /dev from mdev, mdev-like-a-boss, and eudev. The only difference was that mdev-like-a-boss did not create /dev/radio1 all the major minor numbers were the same although the order of creation varied.

There is no special driver for the Microsoft keyboard unlike the Cherry keyboard.

What I haven't tried is unplugging and replugging the mouse and keyboard at the xdm login screen to see if they hotplug. Going to try that now.

----------

## Tony0945

Interestingly enough, the Microsoft keyboard is identified as a LITEON. I was wrong, there is a CONFIG_USB_MICROSOFT and it's set to y. 

Anyway hotplugging didn't work but I have a log with two fatal errors:https://bpaste.net/show/8d247d6dac9f however, I have no idea what they mean.

I've spent the weekend reading Kay Siever's documentation, various google results, the www.kernel.org documentation, and Linux Device Drivers 3rd edition, and the mdev/udev code (ugh!). This seems like a straightforward mechanism, I can't imagine why the code and rules are so complex.

I'm kind of tempted to copy the /dev from eudev to the hard drive, remove devtmpfs from /etc/fstab, remove all &dev from rc-update levels, boot the sysrecuecd and copy that saved /dev to /dev on the root drive and just use it as a fixed /dev. But if that would work, why didn't mdev?

I reiterate, mdev (not like a boss) working fine on the system with PS/2 keyboard and usb wireless mouse, although I thing Xorg is activating the mouse.

----------

## geki

do you see your keyboard in /proc/bus/input/devices with mdev?

I wonder if that is an indication of its working state.

----------

## Tony0945

 *geki wrote:*   

> do you see your keyboard in /proc/bus/input/devices with mdev?
> 
> I wonder if that is an indication of its working state.

 

Yes, I do.

I added "modules" to the depend line of /etc/init.d/mdev. Apparently modules were being loaded later because now the keyboard works in the consoles. However when I manually launch xdm, there is no input any more. I removed evdev and rebuilt xord and modules but the keyboard still isn't recognized in X. 

At least there is some progress.

----------

## khayyam

 *Tony0945 wrote:*   

> I added "modules" to the depend line of /etc/init.d/mdev. Apparently modules were being loaded later because now the keyboard works in the consoles.

 

Tony ... you shouldn't need to do that, once mdev is in /proc/sys/kernel/hotplug any subsequent module load will trigger mdev and so the device nodes created. In my case, in case it matters, 'mdev' is in the sysinit runlevel, and 'modules' in the boot runlevel. Both of these are well before default, so any issue with the required modules, and/or device nodes, shouldn't have any effect on your having kbd at the login (or xorg) stage.

 *Tony0945 wrote:*   

> However when I manually launch xdm, there is no input any more. I removed evdev and rebuilt xord and modules but the keyboard still isn't recognized in X.

 

You mention above that you're using mdev-like-a-boss, did you copy the contents of /opt/mdev/xorg.conf.d/ to /etc/X11/xorg.conf.d?

HTH & best ... khay

----------

## Tony0945

FINALLY SOLVED!   

Found in the xorg log that because hotplug was enabled, the keyboard and mouse were shut off.(????) The solution was to change "udev" to "-udev" in the xorg-server use flags.

System boots MUCH faster. Thanks to all! And thanks user chithanh in another thread who introduced me to the Magic SysRQ which I use to get to a virtual terminal to examine the Xorg log.

----------

## khayyam

 *Tony0945 wrote:*   

> Found in the xorg log that because hotplug was enabled, the keyboard and mouse were shut off.(????) The solution was to change "udev" to "-udev" in the xorg-server use flags.

 

Tony ... its odd you should mention this because sometime back I has a discussion with krinn on this very subject, the upshot of which (as I remember) was that udev could be left enabled. I was fairly sure I'd tried this but had a similar issue to yours ... 

 *Tony0945 wrote:*   

> System boots MUCH faster. Thanks to all! And thanks user chithanh in another thread who introduced me to the Magic SysRQ which I use to get to a virtual terminal to examine the Xorg log.

 

Yes, that was my experience also ... btw, I'd also recommend switching /bin/sh to /bin/dash (if you haven't already). Instructions are here if you search for my name and dash.

best ... khay

----------

