Logitech keyboard on linux, could not set config as device or resource is busy - linux-device-driver

I have a Logitech G613 keyboard for linux. It works fine except that the G(1-6) keys are mapped to F(1-6) by default and there is no way to remap them without remapping the F keys.
So, I went through a lot of resources on the internet and found g15daemon and libg15. Unfortunately, libg15 does not support G613 but I found a way for the library to detect my keyboard by adding the following line
DEVICE("Logitech G613",0x46d,0xc53d,G15_KEYS),
The only issue now is, libg15 detaches the kernerl driver from the device with usb_detach_kernel_driver_np(), which is successful. But after that, the call to usb_set_configuration() fails with
USB error: could not set config 1: Device or resource busy
Output of hwinfo before detaching kernel driver
38: USB 00.0: 10800 Keyboard
[Created at usb.122]
Unique ID: ADDn.IsFhTXWBs20
Parent ID: k4bc.2DFUsyrieMD
SysFS ID: /devices/pci0000:00/0000:00:14.0/usb1/1-1/1-1:1.0
SysFS BusID: 1-1:1.0
Hardware Class: keyboard
Model: "Logitech USB Receiver"
Hotplug: USB
Vendor: usb 0x046d "Logitech, Inc."
Device: usb 0xc53d "USB Receiver"
Revision: "43.00"
Driver: "usbhid"
Driver Modules: "usbhid"
Speed: 12 Mbps
Module Alias: "usb:v046DpC53Dd4300dc00dsc00dp00ic03isc01ip01in00"
Driver Info #0:
XkbRules: xfree86
XkbModel: pc104
Config Status: cfg=new, avail=yes, need=no, active=unknown
Attached to: #37 (Hub)
and after detaching the kernel driver
38: USB 00.0: 10800 Keyboard
[Created at usb.122]
Unique ID: ADDn.IsFhTXWBs20
Parent ID: k4bc.2DFUsyrieMD
SysFS ID: /devices/pci0000:00/0000:00:14.0/usb1/1-1/1-1:1.0
SysFS BusID: 1-1:1.0
Hardware Class: keyboard
Model: "Logitech USB Receiver"
Hotplug: USB
Vendor: usb 0x046d "Logitech, Inc."
Device: usb 0xc53d "USB Receiver"
Revision: "43.00"
Speed: 12 Mbps
Module Alias: "usb:v046DpC53Dd4300dc00dsc00dp00ic03isc01ip01in00"
Driver Info #0:
XkbRules: xfree86
XkbModel: pc104
Config Status: cfg=new, avail=yes, need=no, active=unknown
Attached to: #37 (Hub)
Also, once the driver is detached, the keyboard stops functioning. It has to be reconnected again to be functional.
Can anyone please help me understand why usb_set_configuration() is failing?

Related

ath9k_htc (Atheros) TL-WN722N WiFi dongle on Angstrom

I am trying to interface the TL-WN722N to a Altera Cyclone SoC. I have taken the following approach:
Downloaded the open firmware ath9k_htc and try integrating it to my linux kernel image to be loaded.
a. https://wiki.debian.org/ath9k_htc/open_firmware: The steps here mention to build the toolchain and the firmware and then place it in /lib/firmware.
b. Built the linux kernel using the steps mentioned here : https://rocketboards.org/foswiki/Documentation/GSRDCompilingLinux
The firmware obtained in step a. was placed into /linux-socfpga/firmware , since there was no firmware folder in directory /lib/.
c. The image created was flashed and the wifi dongle was plugged in.
2.Here is a dmesg output for the cyclone board :
[ 2.223039] usb 1-1: New USB device found, idVendor=0cf3, idProduct=9271
[ 2.229735] usb 1-1: New USB device strings: Mfr=16, Product=32, SerialNumber=48
[ 2.237129] usb 1-1: Product: USB2.0 WLAN
[ 2.241124] usb 1-1: Manufacturer: ATHEROS
[ 2.245215] usb 1-1: SerialNumber: 12345
[ 5.351145] EXT4-fs (mmcblk0p2): recovery complete
[ 5.359958] EXT4-fs (mmcblk0p2): mounted filesystem with ordered data mode. Opts: (null)
[ 5.368058] VFS: Mounted root (ext3 filesystem) on device 179:2.
[ 5.375560] devtmpfs: mounted
[ 5.379310] Freeing unused kernel memory: 1024K (c0900000 - c0a00000)
**[ 5.670820] systemd[1]: Failed to insert module 'autofs4': No such file or directory**
[ 5.722709] systemd[1]: systemd 226 running in system mode. (+PAM -AUDIT -SELINUX +IMA -APPARMOR +SMACK +SYSVINIT +UTMP -LIBCRYPTSETUP -GCRYPT +GNUTLS +ACL +XZ -LZ4 -SECCOMP +BLKID -ELFUTILS +KMOD +IDN)
The linux is able to identify the Atheros usb device. However the driver module is not loaded. I have verified this using lsmod and it returns nothing. The commands ifconfig and ip a also returns no wireless connection.
Also when I see the path /lib/modules/.../kernel/drivers/net I observe only 2 modules ethernet and mdio.ko
Kernel version : 4.1.33-ltsi-altera
Does that mean that my driver is missing in the image? What could be the possible reasons for this issue? Does anyone have any other solution to this issue?
Edit:
I could find the linux drivers in /sys/bus/usb/drivers/ath9k_htc and the corresponding modules in /sys/module/ath9k_htc
So basically, the modules are configured static.
Now when I boot up the system, I find an error saying that the requested firmware is not found.
I have already placed the required firmware(htc_9271-1.4.0.fw & htc_9271.fw) in /lib/firmware/ath9k_htc
Here is the error :
[ 2.002205] usb 1-1: new high-speed USB device number 2 using dwc2
[ 2.262666] usb 1-1: New USB device found, idVendor=0cf3, idProduct=9271
[ 2.269348] usb 1-1: New USB device strings: Mfr=16, Product=32, SerialNumber=48
[ 2.276730] usb 1-1: Product: USB2.0 WLAN
[ 2.280724] usb 1-1: Manufacturer: ATHEROS
[ 2.284815] usb 1-1: SerialNumber: 12345
[ 2.289370] usb 1-1: ath9k_htc: Firmware ath9k_htc/htc_9271-1.4.0.fw requested
[ 2.297203] usb 1-1: Direct firmware load for ath9k_htc/htc_9271-1.4.0.fw failed with error -2
[ 2.305811] usb 1-1: ath9k_htc: Firmware htc_9271.fw requested
[ 2.311658] usb 1-1: Direct firmware load for htc_9271.fw failed with error -2
[ 2.318867] usb 1-1: no suitable firmware found!
[ 2.323478] usb 1-1: ath9k_htc: Failed to get firmware htc_9271.fw
[ 2.329951] usb 1-1: ath9k_htc: USB layer deinitialized
I have also followed the steps mentioned here :
https://unix.stackexchange.com/questions/21903/custom-kernel-fails-to-load-firmware-when-module-built-in
which explains how to provide configuration for the path for loading the firmware.
A quick grep for /proc/config.gz reveals this:
$zcat /proc/config.gz | grep CONFIG_ATH
CONFIG_ATH_COMMON=y
#CONFIG_ATH_DEBUG is not set
#CONFIG_ATH5K is not set
#CONFIG_ATH5K_PCI is not set
CONFIG_ATH9K_HW=y
CONFIG_ATH9K_COMMON=y
CONFIG_ATH9K_BTCOEX_SUPPORT=y
CONFIG_ATH9K=y
CONFIG_ATH9K_PCI=y
CONFIG_ATH9K_AHB=y
#CONFIG_ATH9K_DEBUGFS is not set
#CONFIG_ATH9K_DYNACK is not set
CONFIG_ATH9K_WOW=y
#CONFIG_ATH9K_CHANNEL_CONTEXT is not set
CONFIG_ATH9K_PCOEM=y
CONFIG_ATH9K_HTC=y
CONFIG_ATH9K_HTC_DEBUGFS=y
#CONFIG_ATH6KL is not set
#CONFIG_ATH10K is not set
$zcat /proc/config.gz | grep CONFIG_EXT
CONFIG_EXTRA_FIRMWARE="htc_9271-1.4.0.fw"
CONFIG_EXTRA_FIRMWARE_DIR="/lib/firmware/ath9k_htc"
#CONFIG_EXTCON is not set
zcat /proc/config.gz | grep CONFIG_FIRMW
CONFIG_FIRMWARE_IN_KERNEL=y
# CONFIG_FIRMWARE_MEMMAP is not set
Is there any other way to notify the kernel to load the firmware? I think I might be missing out some configuration.
Edit 2 :
I resolved the issue of firmware load failure by enabling the option Fallback user-help invocation for firmware loading. Now the device is initialised, but the driver seems to not support the device. Here is the dmesg log :
[ 14.568484] usb 1-1: ath9k_htc: Transferred FW: ath9k_htc/htc_9271-1.4.0.fw, size: 51008
[ 14.820407] ath9k_htc 1-1:1.0: ath9k_htc: HTC initialized with 33 credits
[ 15.852173] ath: phy0: Mac Chip Rev 0x0f.3 is not supported by this driver
[ 15.859064] ath: phy0: Unable to initialize hardware; initialization status: -95
[ 15.866512] ath: phy0: Unable to initialize hardware; initialization status: -95
[ 15.873973] ath9k_htc: Failed to initialize the device
A quick research on the device, I found that the official website of TP-Link states that the linux drivers are available for version 2, and not for version 1. My device is a version 1 device and I think because of this the driver does not support.

RPi3 with SenseHat and Yocto

I am currently working with building a Yocto Image for the RPi3 with the SenseHat installed.
The Yocto image consist of the following layers:
meta
meta-poky
meta-oe
meta-networking
meta-python
meta-raspberrypi
meta-java
an application-specific layer.
The application-specific layer is mainly tasked with loading the following kernel-modules:
i2c-dev
fb_sys_fops
syscopyarea
sysfillrect
sysimgblt
rpisense_core
rpisense_js
rpisense_fb
It also contains openssh, psplash, gcc, make, libiio, rtimulib and some other misc. packages.
My image boots nicely without the SenseHat mounted, but the boot-process stops before reaching the UART shell when it is mounted. It stays frozen until the system is reset by the watchdog.
Following is the last part of the UART output before the system freezes.
{...}
Populating dev cache
ALSA: Restoring mixer settings...
/usr/sbin/alsactl: load_state:1735: No soundcards found...
Tue Nov 1 10:01:54 UTC 2016
INIT: Entering runlevel: 5
Configuring network interfaces... [ 5.130327] smsc95xx 1-1.1:1.0 eth0: hardware isn't capable of remote wakeup
udhcpc (v1.24.1) started
Sending discover...
[ 6.662428] smsc95xx 1-1.1:1.0 eth0: link up, 100Mbps, full-duplex, lpa 0x4DE1
[ 6.688217] cfg80211: Calling CRDA to update world regulatory domain
Sending discover...
Sending select for 192.168.0.106...
Lease of 192.168.0.106 obtained, lease time 3600
/etc/udhcpc.d/50default: Adding DNS 192.168.0.20
/etc/udhcpc.d/50default: Adding DNS 192.168.0.40
done.
Starting system message bus: dbus.
Starting OpenBSD Secure Shell server: sshd
[ 9.034713] NET: Registered protocol family 10
done.
Starting rpcbind daemon...done.
Starting advanced power management daemon: No APM support in kernel
(failed.)
Starting bluetooth
bluetoothd
Starting syslogd/klogd: done
* Starting Avahi mDNS/DNS-SD Daemon: avahi-daemon
[ 9.401783] Bluetooth: Core ver 2.20
[ 9.405528] NET: Registered protocol family 31
[ 9.410088] Bluetooth: HCI device and connection manager initialized
[ 9.416576] Bluetooth: HCI socket layer initialized
[ 9.421576] Bluetooth: L2CAP socket layer initialized
[ 9.426747] Bluetooth: SCO socket layer initialized
...done.
Starting Telephony daemon
[ 9.507315] Bluetooth: BNEP (Ethernet Emulation) ver 1.3
[ 9.512765] Bluetooth: BNEP filters: protocol multicast
[ 9.518098] Bluetooth: BNEP socket layer initialized
Starting Linux NFC daemon
[ 9.624816] nfc: nfc_init: NFC Core ver 0.1
[ 9.629241] NET: Registered protocol family 39
I shoould note that I have soldered three wires onto the UART pins:
RPi3 UART pins http://www.embeddedforu.com/wp-content/uploads/2015/06/Raspberry-pi-UART-connections_thumb.png
When the system is frozen, I can still ping the device, but SSH does not work.
Any idea what might be causing this behavior?
It turned out that the problem lay within the yocto local.conf-file. The following line was set:
ENABLE_I2C = "1"
This created a second i2c-driver, which lead to one of the crashing on boot.
For any googlers out there: This flag does not need to be set. Instead make sure that the i2c-dev kernel driver is loaded at boot.
I never used the bluetooth, but it seems the system doesn't freeze, you just lose UART data when Bluetooth connects.
From here:
On the rpi3, it is normal since the BCM2837 on the Raspberry Pi3 has 2 UARTs (as did its predecessors), however to support the Bluetooth functionality the fully featured PL011 UART was moved from the header pins to the Bluetooth chip and the mini UART made available on header pins 8 & 10.
This has a number of consequences for users of the serial interface.
The /dev/ttyAMA0 previously used to access the UART now connects to Bluetooth.
I would advise you to try again having in config.txt
dtoverlay=pi3-disable-bt
enable_uart=1
And if you really need bluetooth, use
dtoverlay=pi3-miniuart-bt
And for the ssh, add "openssh" in your image recipe, and dependencies to connect like wpa-supplicant (don't forget to configure it)

Accessing real frame buffer of PCI card

I am trying to access the framebuffer on my systems VGA controller card.
lscpi -vn gives:
00:02.0 0300: 8086:2a02 (rev 0c) (prog-if 00 [VGA controller])
Subsystem: 1028:022f
Flags: bus master, fast devsel, latency 0, IRQ 45
Memory at fea00000 (64-bit, non-prefetchable) [size=1M]
Memory at e0000000 (64-bit, prefetchable) [size=256M]
I/O ports at eff8 [size=8]
Expansion ROM at <unassigned> [disabled]
Capabilities: [90] MSI: Enable+ Count=1/1 Maskable- 64bit-
Capabilities: [d0] Power Management version 3
Kernel driver in use: i915
Now, I access the device and I get:
fb_base = pci_resource_start( devp, 0 ); **output: FEA00000**
fb_size = pci_resource_len( devp, 0 ); **output: 1MB**
So the range of framebuffer is FEA00000 - FEB00000
But from the lspci -vn output This region is non prefetchable.
Does that mean I am not pointing to the frame buffer at all.
Is my framebuffer at address E0000000:
The driver currently using the resource is the Intel i915
So maybe when I request region or IRQ it can clash if not shared by that driver.
If I remove the i915 rmmod it to insmod my driver, will my screen go blank.
Please help.
Thanks.

Can't register rteth0 for FEC Ethernet card on SabreLite iMX6Q

I'm a new user on RTnet and try to make Rtnet work on Freescale Sabre Lite iMX6Q board. But I got an issue, RTnet can't use rt_fec.ko module driver to register rt_eth0 even though non real time driver is disable.
I'm using:
Linux kernel 3.0.43 download from Xenomai git://git.xenomai.org/ipipe-gch.git/?h=ipipe-3.0-imx6q
Xenomai 2.6 download from git.xenomai.org/xenomai-2.6.git/
RTnet 0.9.13 download from rtnet.org/download.html
Please see my kernel configuration and boot log in attached link.
Xenomai is loaded:
"*I-pipe: Domain Xenomai registered.
Xenomai: hal/arm started.
Xenomai: scheduling class idle registered.
Xenomai: scheduling class rt registered.
Xenomai: real-time nucleus v2.6.3 (Lies and Truths) loaded.
Xenomai: debug mode enabled.
Xenomai: starting native API services.
Xenomai: starting POSIX services.
Xenomai: starting RTDM services.* "
And FEC ethernet driver (non real-time driver) is loaded when kernel is booting
*"FEC Ethernet Driver
fec_enet_mii_bus: probed "*
Xenomai is built following install guideline for ARM platform from Xenomai:
http://xenomai.org/installing-xenomai-2-x/
RTnet is built by below command, because SABRE Lite use FEC ethernet card with Micrel KSZ9021 Gigabit chip so I put "--enable-fec" in configure command to build real-time driver for FEC ethernet card:
"./configure --host=armv7l-timesys-linux-gnueabi --with-rtext-config=/home/sonnguyen/rtnet-xenomai-rootfs/usr/xenomai/bin/xeno-config --with-linux=/home/sonnguyen/build/rtnet-xenomai-ipipe-imx6q --enable-rtcfg-dbg --enable-rtwlan --enable-net-routing --enable-router --enable-nomac --enable-rtcap --enable-proxy --enable-checks --enable-fec "
Then
"make DESTDIR=/home/sonnguyen/rtnet-xenomai-rootfs install"
I also changed RT_DRIVER from default value to "rt_fec" in rtnet.conf.
After kernel is booted, I ran "./rtnet start" and got this:
"RTnet: initialising real-time networking
RT FEC Ethernet Driver
./rtnet: line 385: can't create /sys/bus/pci/drivers/rt_fec/bind: nonexistent directory
initializing loopback...
RTnet: registered rtlo
RTcap: real-time capturing interface
ifconfig: SIOCGIFFLAGS: No such device
ifconfig: SIOCGIFFLAGS: No such device
RTcfg: init real-time configuration distribution protocol
RTmac: init realtime media access control
RTmac/TDMA: init time division multiple access control mechanism
ioctl: No such device
ioctl: No such device
ioctl: No such device
ioctl: No such device
ioctl (add): No such device
ioctl (add): No such device
ioctl (add): No such device
ifconfig: SIOCGIFFLAGS: No such device
Waiting for all slaves...ioctl: No such device
ioctl: No such device "
Then I tried:
"# lspci
lspci: /sys/bus/pci/devices: No such file or directory
ls /sys/bus/
ac97 hid mdio_bus platform sdio spi
event_source i2c mmc scsi serio usb "
No pci directory under /sys/bus/. Then I thought because the script can't find the ethernet physical bus, it can't register rteth0.
Then I looked into rtnet script and did some minor change. In the script it requires physical ethernet device ID (mentioned in REBIND_RT_NICS), so I tried to find out what it is and got this when make eth0 up with non real-time driver:
"eth0: Freescale FEC PHY driver [Micrel KSZ9021 Gigabit PHY] (mii_bus:phy_addr=1:06, irq=-1)
PHY: 1:06 - Link is Up - 1000/Full "
I think 1:06 is my physical bus ID, then I change the code in rtnet from:
for dev in $REBIND_RT_NICS; do
if [ -d /sys/bus/pci/devices/$dev/driver ]; then
echo $dev > /sys/bus/pci/devices/$dev/driver/unbind
fi
echo $dev > /sys/bus/pci/drivers/$RT_DRIVER/bind
done
To
echo 1:06 > /sys/bus/mdio_bus/drivers/Micrel\ KSZ9021\ Gigabit\ PHY/unbind
echo 1:06 > /sys/bus/platform/drivers/rt_fec/bind
And I tried again with "./rtnet start", this time I got this:
RTnet: initialising real-time networking
RT FEC Ethernet Driver
sh: write error: No such device
initializing loopback...
RTnet: registered rtlo
RTcap: real-time capturing interface
ifconfig: SIOCGIFFLAGS: No such device
ifconfig: SIOCGIFFLAGS: No such device
RTcfg: init real-time configuration distribution protocol
RTmac: init realtime media access control
RTmac/TDMA: init time division multiple access control mechanism
ioctl: No such device
ioctl: No such device
ioctl: No such device
ioctl: No such device
ioctl (add): No such device
ioctl (add): No such device
ioctl (add): No such device
ifconfig: SIOCGIFFLAGS: No such device
Waiting for all slaves...ioctl: No such device
ioctl: No such device
But it still said "No such device"
This is lsmod after I ran ./rtnet start
lsmod
Module Size Used by Not tainted
tdma 25691 0
rtmac 9724 1 tdma
rtcfg 58071 0
rtcap 7151 0
rt_loopback 1279 2
rtpacket 6365 0
rtudp 10738 0
rt_fec 12742 0
rtipv4 29987 2 rtcfg,rtudp
rtnet 40746 9 tdma,rtmac,rtcfg,rtcap,rt_loopback,rtpacket,rtudp,rt_fec,rtipv4
./rtifconfig
rtlo Medium: Local Loopback
IP address: 127.0.0.1
UP LOOPBACK RUNNING MTU: 1500
Only rtlo is registered.
I also tried with kernel linux without non real-time FEC driver (please refer in another config file in attached Skydrive link), but still the same issue happened.
Do you have any idea how to solve this issue? I did many search but still can not figure out how to fix it.
Because I can't attach the files to my post, so I put all of my configuration files in the link below:
https://onedrive.live.com/redir?resid=162EDF85AEBD2EFE!717&authkey=!AJ1Fjd_XiohUwes&ithint=file%2czip
Best Regards,
Nguyen Hung Son

“RAM check failed” when using j-Link to erase chip or readback

I closed SWD and JTAG by acident so that I can't download new program into developboard by j-Link.Then I try using j-flash ARM to erase chip, and error comes like this:
Connecting ...
- Connecting via USB to J-Link device 0
- J-Link firmware: V1.20 (J-Link ARM V8 compiled Dec 1 2009 11:42:48)
- JTAG speed: 2000 kHz (Auto)
- Initializing CPU core (Init sequence) ...
- Executing Reset (0, 0 ms)
- Initialized successfully
- JTAG speed: 2000 kHz (Auto)
- Connected successfully
Reading entire flash chip ...
- 64 sectors, 1 range, 0x8000000 - 0x800FFFF
- ERROR: RAM check failed # address 0x20000000.
- ERROR: Write: 0x03020100 07060504
- ERROR: Read: 0xAAAAAAAA AAAAAAAA
- ERROR: (0 bytes of RAM have been checked successfully)
- ERROR: Failed to read back target memory
Disconnecting ...
- Disconnected
I don't know how to use BOOT0 and BOOT1 to get into ISP mode. BOOT0 is connected to GND.
Post some information about your environment.
Are you using IAR EWARM? If you're not, you should download the size-limited trial version. Then, load one of the basic program examples, and try to flash it to your board.
What board are you using? And what do you mean you "closed" SWD and JTAG? I'm not sure what that refers to...jumpers? options window?
Help us out here.