Android Things: ADB over USB on Raspberry Pi - usb

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.

Related

ToupTek XCAM4K8MPA camera connection to Linux computer

I'm trying to connect a ToupTek XCAM4K8MPA camera to a Linux Ubuntu 20.04 64-bit computer to use with their provided ToupLite software for microscopy image capturing. The camera comes with a USB 3.0 cable, HDMI cable and USB WLAN adapter.
I have managed to set up the ToupTek ToupLite software (Link to manual, Link to download page) which, as far as I understand, comes with the SDK included. I have then connected the camera via USB 3.0 and HDMI cable to the computer, but ToupLite shows No device as in, the camera is not recognized or connected. I have tested the camera by simply connecting it to a computer monitor via HDMI cable and it works, but for capture I would like it to be connected to a computer and the WLAN or Wi-Fi connection solution is not really a good option.
Perhaps someone has some ideas of what I am missing.
Note: Relevant tags include touptek, touplite, microscopy
I ended up using the WLAN connection. Made a non-changing IP address for the camera and the ToupLite software recognizes that it is on the local network.

STM32F04 in DFU mode recognized only when powered from battery (Win10)

I made a STM32F042k6, battery powered device, that I would to flash vi DFU protocol.
In order to do so I disconnect the battery, I pull BOOT0 to VCC, and then plug the device in USB3 port of PC (no USB2 available). The device is not recognized and showed
VID:0000 PID:0002 (case I)
However, when I first connect battery, and then connect the device to PC it is recognized without a fuss (case II).
The problem I face is that I would like to initiate jump to bootloader program by command in software - but then I reach exactly the same condition as in case I.
Could you help me to identify what conditions for proper boot I am violating?
EDIT:
The way I have discovered the problem was when I implemented software jump to bootloader. It seemed not to work at all (VCP device dissapeared, and erroreous <> device appeard in system PID:0002 VID:0000).
I wanted to enter bootloader by pulling up BOOT0 pin, but I could see that I sucseed only when battery-power cycled. USB power cyccle resulted in the same "failed descriptor" device.
I suspect that when powered on via USB, the booloader has som ecommunication problems and cannot establish proper PID and VID. When powered via battery - this problem is not existing.
Do you have a discovery board?
I read in the STM32F042x4/x6 Reference Manual (DocID025832 Rev 5):
The STM32F042x4/x6 embeds a full-speed USB device peripheral compliant
with the USB specification version 2.0.
(part 3.19, p.27).
In the AN2606 (Rev 33), a table shows the USB configuration which is used by the DFU Bottolader in USB FS (Full-speed):
I assume that the USB in the bootloader is the 2.0, but USB 3.0 must be USB 2.0 compliant. So it is possible to use an USB 3.0 port.
I suggest you use the DfUSe Demo from ST. Its interface consists of a tab where the DFU devices available are displayed when detected. I try it on another STM32x by following these steps:
Open DfuSe Demo software.
Plug BOOT0 to Vdd to put the micro on DFU mode.
Plug the USER USB to your computer port.
The name of your device should appear in “Available DFU Devices” field.
You could try to use directly PA11 and PA12 as well (according to Table 12) instead of the USB port of your board.
EDIT:
Another solution to upgrade your firmware without driving boot0 is to jump directly into the DFU bootloader of ST inside your firmware. Else you could design your own IAP bootloader (In-Application Programming).
I hope that helps.
I faced this same issue with the STM32 Mini F401 and dug into it for several days. Unlike the OP I was unable to find any electrical conditions which reliably got the bootloader to do the right thing. I was able to program my board maybe once every 20 tries, which was really slowing down my process.
In the end I discovered that I can go to the Windows device manager, show hidden devices, and there will be an entry in Universal Serial Bus Devices called STM32 BOOTLOADER. When the issue is happening the board is connected in dfu mode but that device is not marked active in the device manager.
To resolve the issue consistently, you can manually delete the hidden STM32 BOOTLOADER entry, uninstalling the device (no need to delete the driver, just uninstall the device). Then reboot your board in DFU mode and it should connect as expected every time. Unfortunately I need to do this process every time I want to program, but that's far better than the inconsistent/intermittent failures before.

USB HID Keyboard emulator

I want to make hardware keylogger from my Raspberry Pi model B. I think that I can connect keyboard to raspberry and connect raspberry to computer, but how I can emulate keyboard output?
I consider that here must be some low-level libraries for this purpose, but I can't find someone.
Thanks!
You need to implement HID device emulator on Pi in order to act like keyboard. But it seems impossible because Pi hasn't separate USB port.
No, on the Raspberry PI model B the USB hardware is actually connected to a built in Hub, this fixes the USB format as master, there is no way a model B can be a "slave device". Thats said, the SoC of the Raspberry PI is actually capable as being used for both a master and a slave USB device, so theoretically when using a model-A it could be possible to program it to behave as a slave device. Obviously its against the USB specification for a slave device to have a type-A connector, but with some soldering you could connect a type-B or even an USB-on-the-go connector.
source

Raspberry pi freezed on wifi adapter

I have a type B Raspberry Pi running perfectly with USB keyboard and USB mouse both plugged in.
However pi freeze in all the following combinations,
USB keyboard + USB wifi adapter (CUI)
USB mouse + USB wifi adapter (GUI)
In CUI, pi reboots every time I hot plugged in the adapter, and freezes on asking for login id.
If I boot pi with wifi preplugged in, pi also freeze on asking for login id.
In GUI, it does not reboot but freeze when I hot plugged in the adapter.
It is true when I boot pi with preplugged in.
Could someone please advise me how to fix this?
Your raspberry pi does not have beefy enough USB ports to power the wifi adaptor. Get a powered USB hub.

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.