# Multiple USB Keyboards, devd, kbmux,  /dev/ukbd0  /dev/ukbd1



## cypher386 (Aug 20, 2019)

Simple enough, current FreeBSD 12.0
From rc.conf:

```
# a mouse
moused_enable="YES"
devfs_system_ruleset="localrules"
# devd
devd_enable="YES"       # Run devd, to trigger programs on device tree changes.
#devd_flags="-d"           # Additional flags for devd(8).
# hid support does what?
uhidd_enable="no"
#uhidd_flags="-kmohs"
kld_list="cuse nmdm vmm iicbus iic iicbb smbus coretemp aesni tpm pmc fuse"
```
Nothing significant in /boot/loader.conf
/etc/devd.conf:

```
# When a USB keyboard arrives, attach it as the console keyboard.
attach 100 {
        device-name "ukbd0";
        action "service syscons setkeyboard /dev/ukbd0";
};
detach 100 {
        device-name "ukbd0";
        action "service syscons setkeyboard /dev/kbd0";
};
```
For what its worth the computer is an old Latitude E6220.
I've got a logitech nano receiver for my mouse (Logitech trackman, old discontinued model)
It shows up like:

```
[jessica@amadala ~]$ usbconfig -d 2.3 show_ifdrv
ugen2.3: <Logitech USB Receiver> at usbus2, cfg=0 md=HOST spd=FULL (12Mbps) pwr=ON (98mA)
ugen2.3.0: ukbd0: <Logitech USB Receiver, class 0/0, rev 2.00/12.01, addr 3>
ugen2.3.1: ums0: <Logitech USB Receiver, class 0/0, rev 2.00/12.01, addr 3>
ugen2.3.2: uhid0: <Logitech USB Receiver, class 0/0, rev 2.00/12.01, addr 3>
```
The keyboard is a KeyboardIO Model 01 ( or is it 101?), it presents as a mouse, serial port, hid device and keyboard,
but keystrokes don't ever show up under the console or under X.
So Given that the default /etc/devd.conf doesn't seem to activate a second usb keyboard, (I've tried adding /dev/ukbd1 just like /dev/ukbd0, no luck).  This keyboard runs a modify ardunio (ATMega32U) firmware, so it could be something.  Keyboard works under windows.  I tried enabling HIDD (devd or devfs seems to autostart it), nothing better.

Suggestions?  I can post the usbconfig dump of the keyboard in a few hours when I get home.  Lovely $300 keyboard, but doesn't like FreeBSD.


----------



## moridin (Aug 21, 2019)

When you plug in the keyboard, are there any messages printed to console (or /var/log/messages)?


----------



## cypher386 (Aug 21, 2019)

In fact it does:

```
ugen0.8: <Keyboardio Model 01> at usbus0
ukbd1 on uhub6
ukbd1: <Keyboardio Model 01, class 239/2, rev 2.00/1.00, addr 8> on usbus0
kbd3 at ukbd1
uhid1 on uhub6
uhid1: <Keyboardio Model 01, class 239/2, rev 2.00/1.00, addr 8> on usbus0
ums1 on uhub6
ums1: <Keyboardio Model 01, class 239/2, rev 2.00/1.00, addr 8> on usbus0
ums1: 8 buttons and [XYZT] coordinates ID=1
umodem0 on uhub6
umodem0: <Keyboardio Model 01, class 239/2, rev 2.00/1.00, addr 8> on usbus0
umodem0: data interface 1, has no CM over data, has break
```
And it launches moused for the mouse function:

```
[jessica@amadala ~]$ ps ax | grep moused
2171  -  Is      0:00.02 /usr/sbin/moused -d -p /dev/psm0 -t auto
3760  -  Is      0:02.17 /usr/sbin/moused -d -p /dev/ums0 -t auto -I /var/run/m
6530  -  Is      0:00.00 /usr/sbin/moused -d -p /dev/ums1 -t auto -I /var/run/m
6609  0  S+      0:00.00 grep moused
```
And here is the usbconfig utput:

```
usbconfig -d 0.8 show_ifdrv
ugen0.8: <Keyboardio Model 01> at usbus0, cfg=0 md=HOST spd=FULL (12Mbps) pwr=ON (500mA)
ugen0.8.0: umodem0: <Keyboardio Model 01, class 239/2, rev 2.00/1.00, addr 8>
ugen0.8.2: ukbd1: <Keyboardio Model 01, class 239/2, rev 2.00/1.00, addr 8>
ugen0.8.3: uhid1: <Keyboardio Model 01, class 239/2, rev 2.00/1.00, addr 8>
ugen0.8.4: ums1: <Keyboardio Model 01, class 239/2, rev 2.00/1.00, addr 8>
```
So it shows up as a ukbd1 
I seem to have broken devd logging right now, so I don't know if its attaching:
But:

```
[jessica@amadala /var/log]$ sudo service syscons setkeyboard /dev/ukbd1
Configuring vt: keymap.
```
Still no keypresses.  Nothing I've googled has helped me monitor it.  They are mostly all older posts, etc.

Nothing on the keyboardIO forums, etc.  very frustrating.
It could be something in the firmware on the keyboard, but I just don't know and its hard to setup the keyboard firmware build environment on Freebsd.


----------



## tingo (Aug 26, 2019)

It is simple enough to test if the problem is with the keyboard: grab another usb keyboard and plug it in a free usb port. Now - does it work or not?
In general, multiple keyboards work well on FreeBSD, and has for some time now.


----------



## dch (Nov 8, 2019)

Slightly late, but I plugged in my butterfly model01 keyboard today after spilling coffee like a moron on my WASD 105. You'll notice that the butterfly works at loader time, but not after that.

TLDR, flash the firmware following this excellent guide, https://github.com/keyboardio/Kaleidoscope/wiki/Install-Arduino-support-on-FreeBSD , once with the default firmware to ensure you have that process working, and then again after applying this diff:


```
diff --git src/BootKeyboard/BootKeyboard.h src/BootKeyboard/BootKeyboard.h
index 3cfe7b1..85d077a 100644
--- src/BootKeyboard/BootKeyboard.h
+++ src/BootKeyboard/BootKeyboard.h
@@ -65,7 +65,7 @@ class BootKeyboard_ : public PluggableUSBModule {
     uint8_t getProtocol(void);
     void setProtocol(uint8_t protocol);
 
-    uint8_t default_protocol = HID_REPORT_PROTOCOL;
+    uint8_t default_protocol = HID_BOOT_PROTOCOL;
 
   protected:
     HID_BootKeyboardReport_Data_t _keyReport, _lastKeyReport;
```

This forces the keyboard to use a different, simpler, mode on startup, and then it Just Works.

Feel free to ping me (IRC or email) if you have more questions, I don't get forum updates.


----------



## graemeg (Nov 27, 2022)

I have the exact same problem using FreeBSD 12.2 and now after installing a fresh FreeBSD 13.1 [_thinking it might have better hardware support_]. Under Linux, all three programmable keyboards (Ergodox, CharaChorder One and Keyboardio Atreus) work just fine. Under FreeBSD, only the Ergodox works (based on a Teensy chip). The Atreus is based on a Arduino. I don't know the tech specs for the CharaChorder One as the hardware and firmware are more closed source at the moment.

Issue summary:
After plugging each keyboard in, the Atreus and CharaChorder One don't generate any character input when pressing keys. Interestingly enough, the CharaChorder One does work in the FreeBSD boot menu. I can press Space to stop the timer, and press Enter to start the boot process. But once FreeBSD is booted, then the keyboard doesn't work any more. 

Here is the dmesg output after plugging each keyboard in:

```
ugen2.7: <Graeme Geldenhuys Ergodox (Hacked by Graeme)> at usbus2
ukbd0 on uhub3
ukbd0: <Graeme Geldenhuys Ergodox (Hacked by Graeme), class 0/0, rev 2.00/0.01, addr 6> on usbus2
kbd2 at ukbd0
ums0 on uhub3
ums0: <Graeme Geldenhuys Ergodox (Hacked by Graeme), class 0/0, rev 2.00/0.01, addr 6> on usbus2
ums0: 8 buttons and [XYZT] coordinates ID=0
ukbd1 on uhub3
ukbd1: <Graeme Geldenhuys Ergodox (Hacked by Graeme), class 0/0, rev 2.00/0.01, addr 6> on usbus2
kbd3 at ukbd1
ugen0.2: <CharaChorder CharaChorder 1> at usbus0
umodem0 on uhub0
umodem0: <CharaChorder CharaChorder 1, class 239/2, rev 2.00/1.00, addr 1> on usbus0
umodem0: data interface 1, has no CM over data, has break
ums3 on uhub0
ums3: <CharaChorder CharaChorder 1, class 239/2, rev 2.00/1.00, addr 1> on usbus0
ums3: 3 buttons and [XYZ] coordinates ID=1
ugen0.2: <CharaChorder CharaChorder 1> at usbus0 (disconnected)
umodem0: at uhub0, port 6, addr 1 (disconnected)
umodem0: detached
ums3: at uhub0, port 6, addr 1 (disconnected)
ums3: detached
ugen0.2: <Keyboardio Atreus> at usbus0
umodem0 on uhub0
umodem0: <Keyboardio Atreus, class 239/2, rev 2.00/1.00, addr 1> on usbus0
umodem0: data interface 1, has no CM over data, has break
uhid2 on uhub0
uhid2: <Keyboardio Atreus, class 239/2, rev 2.00/1.00, addr 1> on usbus0
ums3 on uhub0
ums3: <Keyboardio Atreus, class 239/2, rev 2.00/1.00, addr 1> on usbus0
ums3: 8 buttons and [XYZT] coordinates ID=1
ukbd3 on uhub0
ukbd3: <Keyboardio Atreus, class 239/2, rev 2.00/1.00, addr 1> on usbus0
kbd5 at ukbd3
ugen0.2: <Keyboardio Atreus> at usbus0 (disconnected)
umodem0: at uhub0, port 6, addr 1 (disconnected)
umodem0: detached
uhid2: at uhub0, port 6, addr 1 (disconnected)
uhid2: detached
ums3: at uhub0, port 6, addr 1 (disconnected)
ums3: detached
ukbd3: at uhub0, port 6, addr 1 (disconnected)
ukbd3: detached
```

All three keyboards have support for keyboard input and mouse input. I could attempt recompiling the Atreus firmware, as the previous message suggested. But that still wouldn't help me with the CharaChorder One - as the firmware is not open source.

I'm not sure if it's the n-key rollover that might be causing the issue, as I think both the Atreus and CharaChorder One have n-key rollover enabled at start-up of the device. My Ergodox, I have 6-key rollover (under FreeBSD 12.2), and have to press a key combination to enable n-key rollover. Though the Ergodox seems to have n-key rollover switched on automatically in FreeBSD 13.1.

Any thoughts on what I can try. My goal is to get the CharaChorder One working, as I just purchased it and would like to start using it on all systems I use daily (FreeBSD, Linux and MacOS).

My /var/log/messages output - in case it helps.

```
Nov 27 16:30:24 graeme-desktop kernel: ugen2.7: <Graeme Geldenhuys Ergodox (Hacked by Graeme)> at usbus2
Nov 27 16:30:24 graeme-desktop kernel: ukbd0 on uhub3
Nov 27 16:30:24 graeme-desktop kernel: ukbd0: <Graeme Geldenhuys Ergodox (Hacked by Graeme), class 0/0, rev 2.00/0.01, addr 6> on usbus2
Nov 27 16:30:24 graeme-desktop kernel: kbd2 at ukbd0
Nov 27 16:30:25 graeme-desktop kernel: ums0 on uhub3
Nov 27 16:30:25 graeme-desktop kernel: ums0: <Graeme Geldenhuys Ergodox (Hacked by Graeme), class 0/0, rev 2.00/0.01, addr 6> on usbus2
Nov 27 16:30:25 graeme-desktop kernel: ums0: 8 buttons and [XYZT] coordinates ID=0
Nov 27 16:30:25 graeme-desktop kernel: ukbd1 on uhub3
Nov 27 16:30:25 graeme-desktop kernel: ukbd1: <Graeme Geldenhuys Ergodox (Hacked by Graeme), class 0/0, rev 2.00/0.01, addr 6> on usbus2
Nov 27 16:30:25 graeme-desktop kernel: kbd3 at ukbd1
Nov 27 16:30:41 graeme-desktop kernel: ugen0.2: <CharaChorder CharaChorder 1> at usbus0
Nov 27 16:30:41 graeme-desktop kernel: umodem0 on uhub0
Nov 27 16:30:41 graeme-desktop kernel: umodem0: <CharaChorder CharaChorder 1, class 239/2, rev 2.00/1.00, addr 1> on usbus0
Nov 27 16:30:41 graeme-desktop kernel: umodem0: data interface 1, has no CM over data, has break
Nov 27 16:30:41 graeme-desktop kernel: ums3 on uhub0
Nov 27 16:30:41 graeme-desktop kernel: ums3: <CharaChorder CharaChorder 1, class 239/2, rev 2.00/1.00, addr 1> on usbus0
Nov 27 16:30:41 graeme-desktop kernel: ums3: 3 buttons and [XYZ] coordinates ID=1
Nov 27 16:30:53 graeme-desktop kernel: ugen0.2: <CharaChorder CharaChorder 1> at usbus0 (disconnected)
Nov 27 16:30:53 graeme-desktop kernel: umodem0: at uhub0, port 6, addr 1 (disconnected)
Nov 27 16:30:53 graeme-desktop kernel: umodem0: detached
Nov 27 16:30:53 graeme-desktop kernel: ums3: at uhub0, port 6, addr 1 (disconnected)
Nov 27 16:30:53 graeme-desktop kernel: ums3: detached
Nov 27 16:30:59 graeme-desktop kernel: ugen0.2: <Keyboardio Atreus> at usbus0
Nov 27 16:30:59 graeme-desktop kernel: umodem0 on uhub0
Nov 27 16:30:59 graeme-desktop kernel: umodem0: <Keyboardio Atreus, class 239/2, rev 2.00/1.00, addr 1> on usbus0
Nov 27 16:30:59 graeme-desktop kernel: umodem0: data interface 1, has no CM over data, has break
Nov 27 16:30:59 graeme-desktop kernel: uhid2 on uhub0
Nov 27 16:30:59 graeme-desktop kernel: uhid2: <Keyboardio Atreus, class 239/2, rev 2.00/1.00, addr 1> on usbus0
Nov 27 16:30:59 graeme-desktop kernel: ums3 on uhub0
Nov 27 16:30:59 graeme-desktop kernel: ums3: <Keyboardio Atreus, class 239/2, rev 2.00/1.00, addr 1> on usbus0
Nov 27 16:30:59 graeme-desktop kernel: ums3: 8 buttons and [XYZT] coordinates ID=1
Nov 27 16:30:59 graeme-desktop kernel: ukbd3 on uhub0
Nov 27 16:30:59 graeme-desktop kernel: ukbd3: <Keyboardio Atreus, class 239/2, rev 2.00/1.00, addr 1> on usbus0
Nov 27 16:30:59 graeme-desktop kernel: kbd5 at ukbd3
Nov 27 16:31:24 graeme-desktop kernel: ugen0.2: <Keyboardio Atreus> at usbus0 (disconnected)
Nov 27 16:31:24 graeme-desktop kernel: umodem0: at uhub0, port 6, addr 1 (disconnected)
Nov 27 16:31:24 graeme-desktop kernel: umodem0: detached
Nov 27 16:31:24 graeme-desktop kernel: uhid2: at uhub0, port 6, addr 1 (disconnected)
Nov 27 16:31:24 graeme-desktop kernel: uhid2: detached
Nov 27 16:31:24 graeme-desktop kernel: ums3: at uhub0, port 6, addr 1 (disconnected)
Nov 27 16:31:24 graeme-desktop kernel: ums3: detached
Nov 27 16:31:24 graeme-desktop kernel: ukbd3: at uhub0, port 6, addr 1 (disconnected)
Nov 27 16:31:24 graeme-desktop kernel: ukbd3: detached
```


----------



## Andriy (Nov 28, 2022)

graemeg maybe try with `hw.usb.usbhid.enable=1` in loader.conf.


----------



## graemeg (Nov 28, 2022)

Thanks for your reply. I tried that and rebooted with the CharaChorder One (CC1) keyboard plugged in. Again, during the FreeBSD boot menu it works just fine. During the boot process, I see the following output (see below). The `uhid0` is new in the logs [instead of the previous `ums3`], but unfortunately the CC1 still doesn't generate keyboard input after FreeBSD has booted.


```
umodem0 on uhub0
umodem0: <CharaChorder CharaChorder 1, class 239/2, rev 2.00/1.00, addr 1> on usbus1
umodem0: data interface 1, has no CM over data, has break
uhid0 on uhub0
uhid0: <CharaChorder CharaChorder 1, class 239/2, rev 2.00/1.00, addr 1> on usbus1
```


----------



## SirDice (Nov 28, 2022)

Andriy said:


> @graemeg  maybe try with `hw.usb.usbhid.enable=1` in loader.conf.


Don't you also need add `usbhid` to `kld_list` for this to work? `sysrc kld_list+="usbhid"`


----------



## graemeg (Nov 28, 2022)

`kldstat` shows that `uhid` and `usbhid` are already loaded.


----------



## Andriy (Nov 30, 2022)

If the new-style hid-related drivers are not in kernel configuration trhen you need more drivers than just usbhid(4). However, most of them should be automatically loaded.
I have drivers like hidbus(4), hkbd(4), hidmap(4) and a few others.
But, as I mentioned, only usbhid(4) is explicitly loaded, the rest are auto-loaded.

Also, I think that there was a bug that caused old-style hid drivers to attach despite hw.usb.usbhid.enable=1.
Maybe try to block-list (or move away) drivers like uhid(4) and ukbd(4).


----------



## graemeg (Dec 4, 2022)

Andriy said:


> graemeg maybe try with `hw.usb.usbhid.enable=1` in loader.conf.


I was so stupid, I did the above, but typed `enabled=1` instead of `enable=1`. After fixing my spelling mistake, my CharaChorder started to work (after a reboot). Thank you so much for helping with this.

There is still one small issue. If I unplug my keyboard, and then plug it back in, it doesn't work (it only works from boot). But that's something I can live with for now, as I don't really unplug the keyboard much.


----------

