Issue with binding platform driver to the platform device - linux

I want to make work mt7622 soc's ethernet controller and faced with this issue. I've compiled mtk_soc_eth driver as mkt_eth module and I have an entry in mt7622-bananapi-bpi-r64.dts device tree for device, compatible with driver.
During boot this module is loaded into system automatically (I think after mounting rootfs):
[root#nixos:~]# lsmod | grep mtk_eth
mtk_eth 69632 0
dsa_core 98304 1 mtk_eth
And it seems registered as platform driver:
[root#nixos:~]# ls /sys/bus/platform/drivers/mtk_soc_eth
bind module uevent unbind
Also after boot I have an platform device:
[root#nixos:~]# ls /sys/bus/platform/devices/1b100000.ethernet
driver_override
modalias
of_node
power
subsystem
supplier:platform:10006000.power-controller
supplier:platform:10209000.apmixedsys
supplier:platform:10210000.topckgen
supplier:platform:10211000.pinctrl
supplier:platform:1b000000.syscon
supplier:platform:1b128000.sgmiisys
uevent
waiting_for_supplier
However they are not binded for some reason. Moreover, when I try to bind them manually, I get an error:
[root#nixos:~]# echo '1b100000.ethernet' > /sys/bus/platform/drivers/mtk_soc_eth/bind
-bash: echo: write error: Resource temporarily unavailable
How can I understand why ethernet device doesn't bind with driver?

Well, it seems that I figured out where is the problem. It seems that linux kernel have rich debug options) I've enabled dynamic debug to track which happens inside __driver_probe_device https://github.com/torvalds/linux/blob/master/drivers/base/dd.c#L730 function:
[root#nixos:~]# echo 'file dd.c +p'>/sys/kernel/debug/dynamic_debug/control
[root#nixos:~]# echo 'file core.c +p'>/sys/kernel/debug/dynamic_debug/control
And then tried to bind device driver and device:
[root#nixos:~]# echo '1b100000.ethernet' >/sys/bus/platform/drivers/mtk_soc_eth/bind
-bash: echo: write error: Resource temporarily unavailable
[root#nixos:~]# dmesg -T | tail
...
[Sat Jan 1 00:03:27 2000] bus: 'platform': __driver_probe_device: matched device 1b100000.ethernet with driver mtk_soc_eth
[Sat Jan 1 00:03:27 2000] platform 1b100000.ethernet: error -EPROBE_DEFER: supplier 1b000000.syscon not ready
It seems that one of the dependent devices (1b000000.syscon) is not ready (at the same time /sys/bus/platform/devices/1b100000.ethernet/waiting_for_supplier was still 0 for some reason). I need to load clk-mt7622-eth driver as well.

Related

DPDK Error: "Cause: No Ethernet ports - bye"

The title is the last line of an error while trying to run a sample application of dpdk, named l2fwd. When I run the app by ./build/l2fwd -l 0-3 -n 4 -- -q 8 -p ffff but at last lines this error occurs:
EAL: Error - exiting with code: 1
Cause: No Ethernet ports - bye
According to dpdk documentation before running app I must execute a command: modprobe ixgbe max_vfs=2,2
I also have a problem with this command, but I'm not sure this is the main reason of failing app execution.
Error of modprobe command relates to ixgbe driver which I can't install it. The error after make of ixgbe is
cc1: error: code model kernel does not support PIC mode
Makefile:197: * * Aborting the build. *** This driver is not supported on kernel versions older than 2.4.0. Stop.
To you a NIC with DPDK we need to bind it to UIO or VFIO driver.
Please have a look at Binding and Unbinding Network Ports to/from the Kernel Modules in DPDK's getting started guide.

No userspace chardev available when using pwm-ir-tx module

I'm attempted to use a pwm output pin as a IR transmitter using a RAMIPS SoC and the PWM IR TX kernel module. I'm running linux 4.14.37 and have added the following entry to the dts file:
pwm_ir_tx1: pwm-ir-transmitter1 {
compatible = "pwm-ir-tx";
pwms = <&pwm 1 100>;
};
I'm loading the rc-core and pwm-ir-tx kernel modules:
lsmod | grep pwm
pwm_ir_tx 2032 0
pwm_mediatek_ramips 1744 1
rc_core 19348 2 pwm_ir_tx
When the pwm-ir-tx module loads, the kernel logs:
[ 3754.108259] rc rc0: PWM IR Transmitter as /devices/platform/pwm-ir-transmitter1/rc/rc0
The sysfs nodes appear to be loaded correctly:
ls -la /sys/class/rc/
drwxr-xr-x 2 root root 0 May 29 00:18 .
drwxr-xr-x 23 root root 0 Jan 1 1970 ..
lrwxrwxrwx 1 root root 0 May 29 01:16 rc0 -> ../../devices/platform/pwm-ir-transmitter1/rc/rc0
But there is no userspace (chardev) lirc device listed in /dev so I'm not sure how I'm supposed to interact with the device. Ideally I'd like to use the Remote Controller API but this requires a chardev to be present in /dev.
ls /dev
autofs mtd2ro network_throughput
console mtd3 null
cpu_dma_latency mtd3ro port
full mtd4 ptmx
gpiochip0 mtd4ro pts
gpiochip1 mtd5 random
gpiochip2 mtd5ro shm
gpiochip3 mtd6 tty
i2c-0 mtd6ro ttyS0
kmsg mtdblock0 ttyS1
log mtdblock1 ttyS2
memory_bandwidth mtdblock2 urandom
mtd0 mtdblock3 watchdog
mtd0ro mtdblock4 watchdog0
mtd1 mtdblock5 zero
mtd1ro mtdblock6
mtd2 network_latency
I've tried loading the lirc_dev module before and after the pwm-ir-tx module, but nothing appears in /dev still, the following output appears when I load the lirc_dev module:
[ 4775.367966] lirc_dev: IR Remote Control driver registered, major 251
But still no lirc userspace device in /dev... I'm thinking the lirc_dev module is required since it provides the lirc userspace api but there doesn't appear to be any connection between it and the pwm-ir-tx module, and it's not creating any lirc chardevs in /dev.
The pwm_ir_tx module seems to be more or less a piggy-back to the pwm driver. And the pwm driver seems to be available at /sys/class/pwm/. See https://www.kernel.org/doc/Documentation/pwm.txt.
BTW, not having a lirc link in rc0/ is not uncommon - not all drivers implements this.
After reading some of rc source files in the kernel, it became obvious the ir-lirc-codec module was also required.
Basically, the pwm-ir-tx driver is defined as a type of RC_DRIVER_IR_RAW_TX. When the rc-core module registers a driver with a type of RC_DRIVER_IR_RAW or RC_DRIVER_IR_RAW_TX it calls the ir_raw_event_prepare function which in turn tries to load the ir-lirc-codec module. Once this module was available the following kernel logs appear:
[ 10.004460] lirc_dev: IR Remote Control driver registered, major 251
[ 10.131011] IR LIRC bridge handler initialized
[ 10.471561] rc rc0: PWM IR Transmitter as /devices/platform/pwm-ir-transmitter1/rc/rc0
[ 10.487456] rc rc0: lirc_dev: driver ir-lirc-codec (pwm-ir-tx) registered at minor = 0
And in /dev there is a lirc chardev device available:
ls /dev/li*
/dev/lirc0

Minicom is not starting

I am trying to run NuttX on STM32f429I. I have build nuttX and flashed the nuttx to the device. But after flashing when i am trying to start minicom, it showing this problem
minicom: cannot open /dev/ttyUSB0: No such file or directory
I already followed all the steps given in this How to connect to a terminal to Serial-USB device on Ubuntu 10.10? post.
I am getting this after Serial Post setup from minicom.
Checking with lsusb
Checking with dmesg | grep tty
I have also checked with ttyUSB1,ttyUSB2, ttyACM1,ttyACM0 etc.
result of sudo lsusb -v
I am following this tutorial. My machine is Ubuntu 16.04LTE
Edit:
~/nuttxworkspace/nuttx$ dmesg | grep tty
[ 0.000000] console [tty0] enabled
[ 0.888895] 00:04: ttyS0 at I/O 0x3f8 (irq = 4, base_baud = 115200) is a 16550A
[25292.460385] cdc_acm 2-1.5:1.1: ttyACM0: USB ACM device
Is there some reason that you would expect to see /dev/ttyUSB0? Do you have CDC/ACM device class configured? What does your configuration use for a serial console? I would expect it would use the STLink-VCOM port. There won't be any USB connection unless you have full configured it that way.

CentOS 7 USB. Connect to Wi-Fi using CLI only

I just installed CentOS 7 [Kernel 3.10.0-514] on my USB stick.
Operating system works fine but I had some problems with my Broadcom 43227 wireless card.
I downloaded driver, patched it, changed code a bit according to the instruction here: https://wiki.centos.org/HowTos/Laptops/Wireless/Broadcom and after many attempts it finally compilled and after loading the driver module into kernel led turned on.
Now I need to connect to my Wi-Fi.
What am I trying to do:
Get wireless interface name using iw dev:
phy#0
Interface wlp2s0
Scan to find WiFi Network using iw wlp2s0 scan | grep SSID
SSID: MyNetworkName
Generate a WPA/WPA2 configuration file using wpa_passphrase MyNetworkName >> /etc/wpa_supplicant.conf
MyNetworkPassword
Connect to WPA/WPA2 WiFi network using wpa_supplicant -B -D wext -i wlp2s0 -c /etc/wpa_supplicant.conf
Successfylly initialized wpa_supplicant
[and in some cases after few minutes]
ERROR #wl_cfg80211_scan: WLC_SCAN error (-22)
Get an IP using dhclient using dhclient wlp2s0
But nohing happens
Ping command : Name or sarvice not known
If I run wpa_supplicant without -B I get some repeating errors:
Device or resource busy
wlp2s0: Failed to initiate AP scan
wlp2s0: Trying to associate with [MAC] (SSID='MyNetName' freq=2462 MHz)
Operation not supported
wlp2s0: Association request to the driver failed
....
if I add -D nl80211 to wpa_supplicant call I get same errors without "Device or resource busy"
What I am doing wrong?

Debugging cdc-acm kernel module

I am trying to fix a problem I am having on Ubuntu (tried different versions including the latest 13.10) with a USB device talking CDC/ACM on one of its interfaces. The kernel module handling this kind of devices only reports
cdc_acm 6-2:1.1: This device cannot do calls on its own. It is not a modem.
cdc_acm: probe of 6-2:1.1 failed with error -22
in dmesg and that is it. Nothing about "Zero length descriptor references" or similar stuff that other people report on the web. So I wanted to find out what the problem might be. I followed the description in http://www.silly-science.co.uk/2012/06/23/lenovo-usb-modem-in-linux-ubuntu-10-04 to compile and load a custom cdc-acm module. First, I changed the two #undefs for debug to #defines in cdc-acm.c, but I am still not getting any additional output in dmesg.
Changing the version string in cdc-acm.c's DRIVER_VERSION define to something else, I can verify that my modified module is indeed loaded. Am I looking for the debug output in the wrong place?
I managed to get debug info from cdc_acm in dmesg, and even though I don't have something special to share, these were my steps, using latest kernel as of today 4.2-rc5:
Change DEBUG and VERBOSE_DEBUG #undefs to #defines in cdc-acm.c.
make -C /lib/modules/$(uname -r)/build M=$(pwd)/drivers/usb/class modules
modprobe -r cdc_acm; insmod $(pwd)/drivers/usb/class/cdc-acm.ko
dmesg after plugging a compatible device
[...]
[14035.355036] cdc_acm 2-2:1.1: acm_tty_write - write 1
[14035.368040] cdc_acm 2-2:1.1: acm_softint
[14038.156445] cdc_acm 2-2:1.0: acm_tty_close
[14038.173054] cdc_acm 2-2:1.0: acm_ctrl_msg - rq 0x22, val 0x0, len 0x0, result 0
[14038.173059] cdc_acm 2-2:1.0: acm_port_shutdown
[14038.173640] cdc_acm 2-2:1.0: acm_ctrl_irq - urb shutting down with status: -2
[14038.174636] cdc_acm 2-2:1.1: acm_read_bulk_callback - urb 0, len 0
[...]

Resources