geekhack

geekhack Community => Keyboards => Topic started by: tex_live_utility on Mon, 04 January 2021, 02:34:10

Title: Having trouble with bootloadHID flashing on Linux
Post by: tex_live_utility on Mon, 04 January 2021, 02:34:10
I'm having trouble flashing a B.face_X2 PCB, in order to put QMK on it.

I am using Linux, so I built bootloadHID from source:

Code: [Select]
# Get prerequisites
if grep -iq opensuse /etc/issue
then
  sudo zypper install libusb-1_0-devel libusb-compat-devel
elif grep -iq debian /etc/issue; then
  sudo apt install libusb-dev
fi

# Get the bootloadHID source
wget https://www.obdev.at/downloads/vusb/bootloadHID.2012-12-08.tar.gz
tar -xf bootloadHID.2012-12-08.tar.gz

# Build bootloadHID
cd bootloadHID.2012-12-08/commandline
make
cp bootloadHID ~/bin/bootloadHID
export PATH="$HOME/bin:$PATH"

I plugged in the keyboard while holding Left Ctrl, and in the output from lsusb I see the line:

Code: [Select]
Bus 001 Device 027: ID 16c0:05df Van Ooijen Technische Informatica HID device except mice, keyboards, and joysticks

I tried flashing with:


and in all cases I get the following error:

Code: [Select]
Warning: could not set configuration: Device or resource busy
Warning: could not claim interface
Error sending message: Input/output error
Error reading page size: Communication error with device

And I get the following output from dmesg:

Code: [Select]
[62368.440698] usb 1-7: new low-speed USB device number 30 using xhci_hcd
[62368.635193] usb 1-7: New USB device found, idVendor=16c0, idProduct=05df, bcdDevice= 1.00
[62368.635200] usb 1-7: New USB device strings: Mfr=1, Product=2, SerialNumber=0
[62368.635204] usb 1-7: Product: HIDBoot
[62368.635207] usb 1-7: Manufacturer: obdev.at
[62368.655898] hid-generic 0003:16C0:05DF.0022: hiddev98,hidraw5: USB HID v1.01 Device [obdev.at HIDBoot] on usb-0000:00:14.0-7/input0
[62395.584140] usb 1-7: usbfs: interface 0 claimed by usbhid while 'bootloadHID' sets config #1
[62395.584168] usb 1-7: usbfs: process 10226 (bootloadHID) did not claim interface 0 before use

I double-checked that the following lines are present in /etc/udev/rules.d/50-qmk.rules:

Code: [Select]
# BootloadHID
SUBSYSTEMS=="usb", ATTRS{idVendor}=="16c0", ATTRS{idProduct}=="05df", TAG+="uaccess"

I also tried logging in on a different TTY just in case the Udev rules needed a new login session to take effect.

How do I figure this out? What additional debugging steps can I take?
Title: Re: Having trouble with bootloadHID flashing on Linux
Post by: yui on Mon, 04 January 2021, 03:06:39
a google search of that "usbfs: interface 0 claimed by usbhid while 'bootloadHID' sets config #1" (line that seemed to me to contain the problem, it tells you that usbhid "stole" the interface before bootloadHID could get it) gave that stack exchange article:
https://unix.stackexchange.com/questions/55495/prevent-usbhid-from-claiming-usb-device
although you will need to know the usb vendor and product id of your keyboard (i think 16c0:05df from your lsusb but not 100% sure)
Title: Re: Having trouble with bootloadHID flashing on Linux
Post by: tex_live_utility on Mon, 04 January 2021, 05:17:25
a google search of that "usbfs: interface 0 claimed by usbhid while 'bootloadHID' sets config #1" (line that seemed to me to contain the problem, it tells you that usbhid "stole" the interface before bootloadHID could get it) gave that stack exchange article:
https://unix.stackexchange.com/questions/55495/prevent-usbhid-from-claiming-usb-device
although you will need to know the usb vendor and product id of your keyboard (i think 16c0:05df from your lsusb but not 100% sure)

Aha, thank you!

I added the following to /etc/modprobe.d/98-usbhid_bootloadHID.conf:

Code: [Select]
options usbhid quirks=0x16c0:0x05df:0x4

and bootloadHID worked perfectly.

For anyone reading who doesn't understand what this does: 0x16c0:0x05df correspond to the vendor and device IDs shown by lsusb, and the 0x4 is just a magic number that everyone else on the Web said to use :))

Edit: unfortunately, Via does not recognize the keyboard after flashing the Via hex, but at least I got the flashing part working.
Title: Re: Having trouble with bootloadHID flashing on Linux
Post by: yui on Mon, 04 January 2021, 05:30:57
well you maybe need to remove the usbhid quirk so that it can start communicating normally with it again, i do not know how via works on linux, or on windows to be honest, still having trouble with making it work at all.
Title: Re: Having trouble with bootloadHID flashing on Linux
Post by: tex_live_utility on Mon, 04 January 2021, 13:47:08
well you maybe need to remove the usbhid quirk so that it can start communicating normally with it again, i do not know how via works on linux, or on windows to be honest, still having trouble with making it work at all.

I see. I commented out the line in my modprobe.d conf file, but Via still does not recognize the Bface_X2 board.

It works fine on my OK60 though (which has the standard Atmega32u4), so I know Via itself is working.
Title: Re: Having trouble with bootloadHID flashing on Linux
Post by: tex_live_utility on Tue, 05 January 2021, 09:47:48
Update: apparently Via doesn't actually have a JSON file for the Bface_X2 :)) I will try to put one together and see if I can get it working.