# usb disconnets with android tethering



## kisscool-fr (Feb 5, 2021)

Hello,

First I'm not sure it is the right place here for this thing. Let me know if it is not the case. 

So, I have an older android phone I downgraded from android 7 to android 4. Before the downgrade I used it as a backup phone and as a 4g router for my home installation. The router part was working ok via usb tethering. Usage as a backup phone was not so good. More recent android versions are ressource consumer so the phone was too slow. 

Now, once downgraded, phone usage is very good but I have trouble to make tethering work. 

When I plug the phone to the computer, from logs I have this:


> Feb  5 21:35:26 host kernel: ugen3.2: <Android Android> at usbus3
> Feb  5 21:35:26 host root: Unknown USB device: vendor 0x18d1 product 0xd002 bus uhub5



And once I enable tethering on phone, it disconnets instantly and reconnects:


> Feb  5 21:35:33 host kernel: ugen3.2: <Android Android> at usbus3 (disconnected)
> Feb  5 21:35:35 host kernel: ugen3.2: <Android Android> at usbus3
> Feb  5 21:35:35 host root: Unknown USB device: vendor 0x18d1 product 0xd002 bus uhub5



I don't have this problem when I connect the phone to my laptop with Slackware. After enabling tethering, interface is created correctly. 

I don't really know where to check, so maybe someone has any idea where to look. 

Thanks,


----------



## obsigna (Feb 6, 2021)

USB devices which draw too much current may be disconnected.

USB2 ports are specified to provide 500 mA, while USB3.x ports may provide 900 mA and newer ports may provide upto 1500 mA for charging batteries. Perhaps your laptop is equipped with USB3 ports or even with BC capable ones, and on your FreeBSD system you connected your phone to an USB2 port.

Try to fully charge your phone before connecting it to your FreeBSD system, then the charging current for the battery would be negligable.

Alternatively, find a self powered USB-Hub which is capable of battery charging, then no current would be drawn from your FreeBSD system and there would be no over current, which would lead to a shutdown of the USB power.


----------



## kisscool-fr (Feb 6, 2021)

I don't have usb3 ports nor on the problematic pc nor on the laptop but what you say may be an explanation once added to what I found after posting yesterday. 

To try to identify where the problem could come from, I restored the Android version I had before the downgrade and retested tethering. And this is a bit tricky. 
If I connect the phone to the pc/router, and try to enable tethering, I have the same behaviour as after downgrade. So that disconnects the device from the router and tethering is not seen.

Because I had this working, I had to remember exactly how I enabled tethering before and here it is. Android version I had before downgrade, has a way (in fact two) to enable tethering mode before connecting phone to computer and this is what I used I presume. This way, once the phone is connected, it is detected as a usb modem and his interface is created correctly on pc/router. 

So, it may be something related to the moment the phone is switching from charge/mtp/mass storage mode to tethering mode and possibly related to power given by usb ports, even if I tried front ports and ports directly from motherboard. 

I have now to find a way, on downgraded version, to enable tethering before pluging the phone to computer, as the only way it has for that, is to enable switcher once phone is plugged. 

Thanks,


----------



## obsigna (Feb 6, 2021)

I solved a problem with limited USB2 power of a BeagleBone Black. For this I bought a cheap (ca. US$6) USB2-Hub.



This, I modified modified from bus-powered to self-powered. This is very easy. Disconnect the red cable and solder a 5 V plug-in power supply (5 V, 5 A, US$5) to the solder point of the red cable (+) and the solder point of the black cable (-). I added even a tiny relay in the line, so the BBB can switch the hub on and off on demand. The relay is optional, however.

Anyway, I now can connect many bus-powered devices to the Beaglebone at the same time, and it won’t anymore disconnect them in the middle of the operation. For example in the picture below, a 1 TByte bus-powered-USB3 drive (left, 1000 mA), a 11n-USB-WLAN-Dongle (middle, 500 mA) and a 8 GB USB-Memory-Chip (right, 200 mA), are all operating perfectly at the same time. Without the Hub, the BBB would disconnect the disk drive on some heavy write operations. And the WLAN-Dongle also would be disconnected this and then.


----------



## Snurg (Feb 6, 2021)

obsigna Great idea... will use this together with an amperemeter (with peaks function) to check out USB devices, just to make sure the function test doesn't fail just due to a few milliamperes.

kisscool-fr iirc it was necessary to enable "programmer mode" to use USB for tethering. But I might mistake this with other things around messing with (old) android.


----------



## kisscool-fr (Feb 6, 2021)

obsigna Thanks for the details. It for sure may be usefull for someone in the futur, maybe for me too 

For my problem, I found an app that provides a toggle, in dowgraded phone, to enable tethering before plugging the phone to pc (action widgets via xposed). It make it works like I want. I have gone even further, with "automate" I have usb tethering activated automatically when I plug the phone and it is correctly seen on the pc. I have still to see what will happen after a reboot or a powerloss.

I'm still curious, if it is really a usb power problem, why it doesn't work on pc's motherboard back usb ports, as it is a server motherboard, and there is not so much devices connected. In fact just the phone and a little usb sound card. For front ports, depending on case and cables quality, that might happen.

For now, I'm happy with the conf, so it will stay like that for a moment.

Snurg By "programmer" you mean "developper" maybe ? Before the downgrade, in Android 7, there was an option for that, but I'm not sure why, it was not persistant. That worked just once for me and reverts to charge. It is one of the two ways I talked above. The other way is via quick settings in 7. There is a toggle that let to enable tether before plugging. 
From what I have read, via developper mode, that's more reliable in later versions. Maybe a bug in 7. I don't know. It's an option that is not avaliable on 4 (kitkat). For the moment I have what I want 

Thanks guys.


----------



## Snurg (Feb 6, 2021)

Yes it was "developer mode", and it was for Kitkat or even its predecessor. Long ago...
I remember well that it was not simple.
Are you sure you have ADB up and running?
The message "Unknown device" looks to me like ADB could be missing...
So I wonder whether that app is actually some "USB server"... which one is it?


----------



## kisscool-fr (Feb 7, 2021)

Snurg said:


> Are you sure you have ADB up and running?


I don't think adb has anything to do with usb tethering. The same applies for developper mode in my opinion. I don't have adb installed on the FreeBSD host and tethering is working. It's just this trick on how you enable it and how the switch is managed.
I'll probably do more testing for that later, I don't like having something unresolved in my head.



Snurg said:


> So I wonder whether that app is actually some "USB server"... which one is it?


I'm not sure I understand this part. Can you rephrase please ?


----------



## Snurg (Feb 7, 2021)

kisscool-fr said:


> I'm not sure I understand this part. Can you rephrase please ?


I have an old smartphone too, which I want to repurpose as backup internet connection during occasional DSL maintenance downtimes.
So I wanted to know which android app you used to make USB tethering easy.
This might save me much time finding an app that works.
Can you please tell the name of the app?


----------



## kisscool-fr (Feb 7, 2021)

Ok, actually i had understood correctly but as I gave the name before I was not sure. 

I used an app/plugin for xposed framework, it's called "action widgets". This is for the manual activation. There are certainly others, the idea is to have a toggle usable before the cable is connected. 

To enable tethering automatically, I have installed "automate" because I did not found anything simpler that is working, but in fact "automate" is not so complicated. I tried "auto usb tethering" from play store without success. I have just a little gap, after some time, if I disconnect the cable and reconnect it when screen is locked, tethering is not started. A second connect/disconnect solve this. I don't remember having a need for a third operation.That may be a problem in case of reboot/powerloss.


----------

