Getting Hotplug react when plugging 3G netstick (with mdev) - usb

I'm trying to get a device running embedded linux V-2.6.31 to automatically recognize when a Huawei 3G usb stick is plugged to it, run usb_modeswitch, and communicate with the module.
it seems that usb_modeswitch doesn't work well in a system that has mdev, since the path /dev/bus/usb is only being created with udev.
I found a script that create this path and enable usb_modeswitch to work properly.
now, all i need is automation of this process, e.g., when plugging the 3G module, hotplug will first call my script, and then usb_modeswitch.
the problem is that when plugging the 3G module nothing happens when the enumeration is done (the hotplug wont run), see trace:
[83175.520000] usb 2-1: new full speed USB device using bcm5892-ohci:PORT-2 and address 3
[83175.730000] usb 2-1: not running at top speed; connect to a high speed hub
[83175.750000] usb 2-1: New USB device found, idVendor=12d1, idProduct=1f1c
[83175.760000] usb 2-1: New USB device strings: Mfr=1, Product=2, SerialNumber=3
[83175.770000] usb 2-1: Product: HUAWEI Mobile
[83175.770000] usb 2-1: Manufacturer: Vodafone(Huawei)
[83175.780000] usb 2-1: SerialNumber: FFFFFFFFFFFFFFFF
[83175.800000] usb 2-1: configuration #1 chosen from 2 choices
[83175.870000] scsi1 : SCSI emulation for USB Mass Storage devices
[83180.910000] scsi 1:0:0:0: CD-ROM HUAWEI Mass Storage 2.31 PQ: 0 ANSI: 2
I'm not sure what is wrong, is there something i didn't enable? is there a KO that i need to load in order for it to work?
Thank you in advance!

Related

STM32H743 with USB HS, FUSB2805 not detected

I have a custom board with STM32H743VIT6 connected to an external USB HS PHY, the FUSB2805MLX.
I am trying to run a bare minimum example setup in STM32CubeMx. Just including a USB HS connection and the device in USB VCP mode.
The pin setup is correct, and the external clocks on the PHY are correct (26MHz in, generates 60MHz on CLK line between MCU and PHY).
I can see that the 60Mhz line is shut down after the call to USBD_Start(&hUsbDeviceHs)
The data lines are pulled high at the same time.
The relevant pinout is:
PA3 -> USB_OTG_HS_ULPI_DO
PA5 -> USB_OTG_HS_ULPI_CK
PB0 -> USB_OTG_HS_ULPI_D1
PB1 -> USB_OTG_HS_ULPI_D2
PB5 -> USB_OTG_HS_ULPI_D7
PB10 -> USB_OTG_HS_ULPI_D3
PB11 -> USB_OTG_HS_ULPI_D4
PB12 -> USB_OTG_HS_ULPI_D5
PB13 -> USB_OTG_HS_ULPI_D6
PC0 -> USB_OTG_HS_ULPI_STP
PC2_C -> USB_OTG_HS_ULPI_DIR
PC3_C -> USB_OTG_HS_ULPI_NXT
However, i cannot get this to work.
The code runs without errors and debugging through it doesn't give me any idea of what might be wrong. All functions return with HAL_OK
The computer does not detect the USB device.
sudo dmesg | grep usb gives the following output
[27482.966148] usb usb3-port7: attempt power cycle
[27483.622018] usb 3-7: new low-speed USB device number 32 using xhci_hcd
[27483.622532] usb 3-7: Device not responding to setup address.
[27483.830337] usb 3-7: Device not responding to setup address.
[27484.041933] usb 3-7: device not accepting address 32, error -71
[27484.173925] usb 3-7: new low-speed USB device number 33 using xhci_hcd
[27484.174414] usb 3-7: Device not responding to setup address.
[27484.382364] usb 3-7: Device not responding to setup address.
[27484.589893] usb 3-7: device not accepting address 33, error -71
[27484.590002] usb usb3-port7: unable to enumerate USB device
[81863.025532] usb 3-3: reset full-speed USB device number 3 using xhci_hcd
[82185.873876] usb 3-3: reset full-speed USB device number 3 using xhci_hcd
[82306.336339] usb 3-3: reset full-speed USB device number 3 using xhci_hcd
[82758.471075] usb 3-3: reset full-speed USB device number 3 using xhci_hcd
It's the same using the USB_DEVICE Middleware in Mass Storace Class mode.
Are there any tricks to getting ULPI USB HS to work on this MCU?

List UART -> COM converter in Windows Device Portal

I have Raspberry Pi 3 plate with connected USB to UART (COM) converter.
The power led on the USB stick is ON.
I can not find the converter in Windows Device Portal.
In both: connected and disconnected states I see just two UART related records in Device Manager:
(ID:ACPI\BCM2835\0, Class:System, Manufacturer:Microsoft, StatusCode:25165834)
>BCM283x Mini UART Serial Device
(ID:ACPI\BCM2836\0, Class:Ports, Manufacturer:Microsoft, StatusCode:25182218)
>ARM PL011 UART Device Driver
(ID:ACPI\BCM2837\4, Class:System, Manufacturer:Microsoft, StatusCode:25165834)
Also I use git diff between saved device lists and there is no difference between the case I connect USB stick and disconnect it.
Where can I see the device in the list?
UPDATE
Here I print all found devices:
First you need make sure your USB to UART (COM) converter is supported on Windows IoT Core. Please check the hardware compatibility list. The CP2102 USB 2.0 to TTL Module Serial Converter is supported.
I use CP2102 USB to UART Bridge Converter and it also works. Use the SerialUART sample can list two device: one is on-board PL011 UART Device and the other is mine.
From device portal:

Android Things: ADB over USB on Raspberry Pi

I'm playing with Raspberry Pi 3 Model B and Android Things. I was able to configure everything (connect Pi over Ethernet, then reconnect over Wi-Fi with Android.local) and debug the app. However it's not convenient sometimes to debug over Wi-Fi when I travel and I have to change Wi-Fi networks or don't have Wi-Fi connection at all.
I know there is serial debug console, but it seems to be for getting logs and shell commands, not for debugging.
Any chance to have direct debugging over USB cable just like any other Android device like smartphone/tablet?
How to debug Android Things device over USB?
Briefly: you can't do it with Raspberry Pi.
Why not?
Let's look at the pin specification of Raspberry Pi micro USB (J1):
where
1: power
2: D- (data out), not connected
3: D+ (data in), not connected
4: NC, not connected
5: GND (ground)
So summing up the above said: no data pin connection - no adb. You can only power your RPi over micro USB.
Any chance to have direct debugging over USB cable just like any other Android device like smartphone/tablet?
Use another board. In fact, any board that has USB OTG and is supported by Android Things would allow debugging over USB, just as a "regular" smartphone/tablet.
And ironically, by the time of this writing, all the supported hardware platforms would fit except for Raspberry Pi :)
The NXP i.MX7D development board has the same pins as the Raspberry Pi for development, however it uses USB-C for power and ADB.
Highly recommend it over the Raspberry Pi
https://developer.android.com/things/hardware/imx7d.html
(source: android.com)
Another option is to setup Wi-Fi access point on your laptop and allow the Pi to connect to it. I have not tested it but it should work.

USB WebCamera protocol

When I plug a USB web Camera into a PC via USB, what communications is used? I know each device COULD have its own uniques driver, but it seems as though 99% use a common built in driver now. Where is it spec'd and how do you get a linux embedded device to act like a webcam?
What you're looking for is the USB Video Class and you can download the specification for this and other standard USB device classes here:
http://www.usb.org/developers/docs/devclass_docs/
The Linux USB gadget framework has code to emulate such a device:
https://github.com/torvalds/linux/blob/master/drivers/usb/gadget/function/f_uvc.c

emulating usb device with another PC

Task: Testing production software on PC notebook without production unit attached via USB and without changing prodcution software.
Goal: Emulate production device with another PC. The test application runs on the second PC to emulate our device commands/responses.
Challenge: Using a USB bridge cable or other device requires that we can change the PID/VID to look like our device.
Suggestions?
You need a hardware device on the second PC to do this type of emulation.
USB ports on a normal PC are USB host ports. Two such ports cannot be connected with each other directly. USB device (or USB OTG - switchable) ports can be found on programmable smartphones (Android, maybe others) and some developer boards like these. I think you probably need to use a smartphone or developer board rather than ordinary PC as the your USB device emulator.