Linux USB Enumeration and uevents - linux-kernel

I read an article at http://www.technovelty.org/code/linux/plugging-in-usb.html. Its just very good.
In which function exactly the enumeration of a connected device is done by host and in which function uevent is sent ?
I introduced printks in usb_new_device etc functions and If i use "udevadm monitor --kernel", it is showing the kernel events even before the enumeration function which is called in usb_new_device in hub.c ?
Log follows
[ 110.819399] 123456 hub_irq
[ 110.824952] 123456 hub_port_connect_change
[ 110.979624] 123456 hub_port_init
[ 111.059625] usb 2-1.2: new high speed USB device using fsl-ehci and address 3
[ 111.189722] 123456 usb_new_device
[ 111.196219] usb 2-1.2: New USB device found, idVendor=05ac, idProduct=12a0
[ 111.203113] usb 2-1.2: New USB device strings: Mfr=1, Product=2, SerialNumber=3
[ 111.210438] usb 2-1.2: Product: iPhone
[ 111.214196] usb 2-1.2: Manufacturer: Apple Inc.
[ 111.218728] usb 2-1.2: SerialNumber: 9356b662a93170509226069e5adf53f2351d774e
KERNEL[110.940183] add /devices/platform/fsl-ehci.1/usb2/2-1/2-1.2 (usb)
Check the timestamps though udevadm out put is at the end(udevadm runs in user space) its actuallt got the event at [ 110.940183] where as usb_new_device was called at [ 111.189722]

I am almost Linux kernel illiterate, so not 100% sure of this info..but managed to trace the USB init with the help of http://www.cs.fsu.edu/~baker/devices/lxr/http/find?v=2.6.11.8
Here is the flow of USB Host code (Please correct me if this is wrong), on Linux 2.6.11.8 kernel
usb_init() // invoked in ../core/usb.c it initializes host, major, usbfs and usb_hub
usb_hub_init() // in core/hub.c it creates a kernel thread hub_thread()
hub_thread() // in core/hub.c
hub_events() // next this if called
hub_port_connect_change() // then this..

Related

How to disable or remove ethernet in openwrt?

I'm using vocore2, and present the boot time of my vocore2 running OpenWrt 19.07.3 is 30seconds, I want to decrease it by 10 seconds, while going through dmesg log I found starting ethernet takes around 7sec, so disabling ethernet will decrease boottime by 7sec.
[ 15.022570] kmodloader: done loading kernel modules from /etc/modules.d/*
[ 22.710060] br-lan: port 1(eth0.1) entered blocking state
[ 22.715623] br-lan: port 1(eth0.1) entered disabled state
[ 22.721459] device eth0.1 entered promiscuous mode
[ 22.726517] device eth0 entered promiscuous mode
[ 22.751465] br-lan: port 1(eth0.1) entered blocking state
[ 22.757014] br-lan: port 1(eth0.1) entered forwarding state
[ 22.762876] IPv6: ADDRCONF(NETDEV_UP): br-lan: link is not ready
[ 23.722126] efuse_probe: efuse = 10000012
[ 23.899450] tssi_1_target_pwr_g_band = 25
[ 29.820162] <==== rt28xx_init, Status=0
[ 29.844215] IPv6: ADDRCONF(NETDEV_CHANGE): br-lan: link becomes ready
[ 32.083358] br-lan: port 2(ra0) entered blocking state
[ 32.088656] br-lan: port 2(ra0) entered disabled state
[ 32.094226] device ra0 entered promiscuous mode
[ 32.098903] br-lan: port 2(ra0) entered blocking state
[ 32.104169] br-lan: port 2(ra0) entered forwarding state
So how to remove ethernet in openwrt?
Change your board config to delete those ethernet port.
From the result I found in google. This board is coming from this patch
From the boardconfig patch, it seems that the esw block is the ethernet config for this board. Remove it could work. I didn't tried any board from vocore2. Please take your own risk if there is no other recovery method than the ethernet port.

Linux serial port console input, framebuffer console output

I have an embedded Linux system (i.e just Busybox) with a framebuffer (/dev/fb0) and a serial port (/dev/hvc0).
The serial port is the only method of console input currently.
My Kernel has;
CONFIG_FB=y
CONFIG_FB_SIMPLE=y
CONFIG_VGA_CONSOLE=y
CONFIG_DUMMY_CONSOLE=y
CONFIG_DUMMY_CONSOLE_COLUMNS=80
CONFIG_DUMMY_CONSOLE_ROWS=25
CONFIG_FRAMEBUFFER_CONSOLE=y
CONFIG_FRAMEBUFFER_CONSOLE_DETECT_PRIMARY=y
My bootargs are currently;
bootargs = "console=hvc0 earlycon=sbi debug";
What I would like to do is use the frame-buffer to display the console output (login terminal, printk output), but with input coming from the serial port (/dev/hvc0).
Can you be more specific regarding the Hw and the OS and u-boot?
You need something like this:
setenv bootargs console=ttyO2,115200n8 vram=16M root=/dev/ram0 rw ramdisk_size=16384 initrd=0x83000000,16M rootfstype=ext2
or this:
setenv bootargs 'console=ttymxc0,115200 root=/dev/mmcblk2p1 rootwait rw video=mxcfb0:dev=hdmi,1920x1080M#60,if=RGB24'
You see, you need to specify the tty = serial port configuration (speed, parity and so on). Also the type of file system ext2, ext4, ... the above are just examples and you need to base yours according to your system.

Can't format a usb volume using fdisk

I tried to format a usb flash disk to FAT32 using fdisk /dev/sdb(I created a new partition and saved changes with w) and mkfs.vfat -F 32 /dev/sdb but when i eject and mount the volume again,it looks like it's empty.
dmesg | tail
outputs:
[ 8583.830684] usb-storage 3-2:1.0: USB Mass Storage device detected
[ 8583.830801] scsi host5: usb-storage 3-2:1.0
[ 8584.864614] scsi 5:0:0:0: Direct-Access Generic Flash Disk 5.00 PQ: 0 ANSI: 2
[ 8584.865005] sd 5:0:0:0: Attached scsi generic sg1 type 0
[ 8584.865070] sd 5:0:0:0: [sdb] 31283200 512-byte logical blocks: (16.0 GB/14.9 GiB)
[ 8584.865194] sd 5:0:0:0: [sdb] Write Protect is off
[ 8584.865196] sd 5:0:0:0: [sdb] Mode Sense: 0b 00 00 08
[ 8584.865314] sd 5:0:0:0: [sdb] No Caching mode page found
[ 8584.865318] sd 5:0:0:0: [sdb] Assuming drive cache: write through
[ 8584.870170] sd 5:0:0:0: [sdb] Attached SCSI removable disk
mkfs.vfat -F 32 /dev/sdb
Running this command overwrites any partitioning of the disk. You should have used
mkfs.vfat -F 32 /dev/sdb1
instead. This will create the filesystem on the first partition of sdb.

Win32_PnPEntity not getting hidden devices

I'm using the Win32_PnPEntity class to get all the devices in a computer, but the Win32_PnPEntity class does not list the hidden devices. Hidden devices in the Windows device manager have a status "Currently, this hardware device is not connected to the computer. (Code 45)" and can be shown by clicking the menu option in Device Manager: View > Show hidden devices (Windows 10).
Does anyone know how to get the hidden devices?
You can do it using the command:
Get-PnpDevice -class "Ports"
Status Class FriendlyName
------ ----- ------------
OK Ports Communications Port (COM1)
Unknown Ports Silicon Labs Dual CP2105 USB to UART Bridge: Enhanced
Unknown Ports Arduino Uno (COM5)
Unknown Ports Silicon Labs Dual CP2105 USB to UART Bridge: Standard
OK Ports Prolific USB-to-Serial Comm Port (COM6)
Here you can see my COM ports that have been disconnected (status: unknown)
You can make use of ConfigManagerErrorCode. Refer Win32_PnPEntity and Win32_PnPEntity MSDN. You have not mentioned if you are using powershell or C# for scripting, i am assuming powershell.
$result = #{Expression = {$_.Name}; Label = "Device Name"},
#{Expression = {$_.ConfigManagerErrorCode} ; Label = "Status Code" }
Get-WmiObject -Class Win32_PnpEntity -ComputerName localhost -Namespace Root\CIMV2 | Where-Object {$_.ConfigManagerErrorCode -gt 0 } | Format-Table $result

XFCE 4.12: desktop taking ages to appear when dual monitor is on

i'm using an Gentoo (3.18.9 / Graphic card: ATI Trinity Radeon HD 7660D, details below) with XFCE 4.12 on top. Note that i'm to help isolate the problem, i'm not using any login manager, i'm logging from console and then running "startx".
If i start with one monitor, then log in and add the second, XFCE does a great job at configuring it, deciding which one is primary, and everything works fine.
However, if I then restart (with both monitor on), they both start in mirror mode up to the login, i login ok, then "startx", and i'm then seeing a sort of white screen with the cursor waiting, for nearly 2 minutes. Ultimately the desktop appears on both screen with the correct dual monitor setting. But there's obviously something wrong happening during those 2 minutes every time I open start XFCE.
Unfortunately I don't have many logs. The /var/log/* don't log anything, just the fact that I correctly logged in.
the Xorg in my home directory have a bit more stuff but no obvious error message. In a nutshell, if I try to compare those between a start with one screen, and a start with 2 screens, i have similar sequence, with one extra section when starting with 2 screens:
[ 94.961] (II) RADEON(0): EDID for output HDMI-0
[ 94.961] (II) RADEON(0): Manufacturer: ACI Model: 2493 Serial#: 16843009
[ 94.961] (II) RADEON(0): Year: 2014 Week: 50
[ 94.961] (II) RADEON(0): EDID Version: 1.3
(...)
The two outputs identified as follow:
[ 95.049] (II) RADEON(0): Output HDMI-0 using initial mode 1920x1080
[ 95.049] (II) RADEON(0): Output DVI-0 using initial mode 1920x1080
Then here is the big timelag (see the timestamps jump):
[ 95.290] (II) XINPUT: Adding extended input device "KB USB Keyboard" (type: KEYBOARD, id 9)
[ 95.290] (**) Option "xkb_rules" "evdev"
[ 95.290] (**) Option "xkb_model" "pc104"
[ 95.290] (**) Option "xkb_layout" "us"
[ 153.096] (II) RADEON(0): EDID vendor "ACI", prod id 9363
[ 153.096] (II) RADEON(0): Using EDID range info for horizontal sync
[ 153.096] (II) RADEON(0): Using EDID range info for vertical refresh
[ 153.096] (II) RADEON(0): Printing DDC gathered Modelines:
[ 153.096] (II) RADEON(0): Modeline "1920x1080"x0.0 148.50 1920 2008 2052 2200 1080 1084 1089 1125 +hsync +vsync (67.5 kHz eP)
While in with one screen I have:
[ 147.475] (II) XINPUT: Adding extended input device "KB USB Keyboard" (type: KEYBOARD, id 9)
[ 147.475] (**) Option "xkb_rules" "evdev"
[ 147.475] (**) Option "xkb_model" "pc104"
[ 147.475] (**) Option "xkb_layout" "us"
[ 148.151] (II) RADEON(0): EDID vendor "ACI", prod id 9363
[ 148.151] (II) RADEON(0): Using EDID range info for horizontal sync
[ 148.151] (II) RADEON(0): Using EDID range info for vertical refresh
I have tried asking on the XFCE forum and elsewhere and couldn't find any help... so this is pretty much my last try before I need to do more drastic changes (like moving to Gnome)...
So any help is appreciated (maybe even just to add extra-logging if that's feasible).
Config:
(--) RADEON(0): Chipset: "ARUBA" (ChipID = 0x9901)
...
(II) Module exa: vendor="X.Org Foundation"
[ 94.757] compiled for 1.16.4, module version = 2.6.0
[ 94.757] ABI class: X.Org Video Driver, version 18.0

Resources