# adb: failed to read command: No error: 0



## cinux (Oct 14, 2020)

Yesterday I tried to sideload something (Custom ROM and Magisk) onto my android device and got the error messages: `adb: failed to read command: No error: 0`. First I thought this was because of the package and ROM error during download process. But it's actually not, I jumped onto another machine (Running Windows 10) with the same package and ROM I was able to sideload those without any issue. After that I think the problem is somewhat relate to the android-tools-adb itself, with both from pkg and ports, it produce the same error message. 

```
Note: The command adb devices still recognize my device every time it plugged.
```

Some information

```
FreeBSD FreeBSD 12.1-RELEASE-p10 FreeBSD 12.1-RELEASE-p10 GENERIC  amd64
android-tools-adb-29.0.6_1     Android debug bridge command line tool
```
Dmesg


----------



## mickey (Oct 16, 2020)

I did not have much luck with adb built from ports either, it did not even want to list or connect to my Android connected via USB. Installed the software on Windows 10 (some versions newer it seems) and it works without problems.


----------



## cinux (Oct 16, 2020)

mickey said:


> I did not have much luck with adb built from ports either, it did not even want to list or connect to my Android connected via USB. Installed the software on Windows 10 (some versions newer it seems) and it works without problems.


For me I have to start it as root if not it's not going to list my devices. But it's useless anyway because it can't perform other actions.
With every other linux distro I've used, I never had a problem with adb neither.


----------



## mickey (Oct 18, 2020)

cinux said:


> For me I have to start it as root if not it's not going to list my devices. But it's useless anyway because it can't perform other actions.
> With every other linux distro I've used, I never had a problem with adb neither.


I cannot say with certainty, but I think I tried running it as root. Do you use USB to connect or network? Is there some USB driver needed? I think Windows required some USB driver that presumably gets installed with Samsung Smart Smitch. In the sense of "getting the job done" I momentarily gave up on using adb on FreeBSD, but in the long run I would much prefer not having to use Windows for this.


----------



## Maxnix (Oct 18, 2020)

I experienced this myself, it seems there is a bug in version 1.0.41 of the client, and this causes attached devices to disconnect. You can use it wirelessly, this is how I worked around this, or downgrade adb like described in this blog post, paragraph 1.3: https://baohaojun.github.io/blog/2020/06/16/0-Android-App-development-under-FreeBSD.html.

HTH


----------



## mickey (Oct 18, 2020)

Maxnix said:


> I experienced this myself, it seems there is a bug in version 1.0.41 of the client, and this causes attached devices to disconnect. You can use it wirelessly, this is how I worked around this, or downgrade adb like described in this blog post, paragraph 1.3: https://baohaojun.github.io/blog/2020/06/16/0-Android-App-development-under-FreeBSD.html.


That's odd, both FreeBSD and Windows adb identify itself as version 1.0.41, but the version of devel/android-tools-adb in ports is currently 29.0.6 whereas on Windows I got:

```
Android Debug Bridge version 1.0.41
Version 30.0.4-6686687
```
If I find the time, I will try to connect over network instead of USB, but for that I will probably have to tinker with my firewall first.


----------



## Maxnix (Oct 18, 2020)

mickey said:


> If I find the time, I will try to connect over network instead of USB, but for that I will probably have to tinker with my firewall first.


AFAIK by default adb just uses TCP port 5555, but you can use whateve you want. Just open your port of choose for TCP and you're done.


----------



## mickey (Oct 21, 2020)

Turns out that `adb` actually _is_ working with my Android connected via USB cable, but for some unknown reason it takes approximately 2.5 minutes from issueing the `adb devices` command, until it starts the server and finally reacts:

```
adb D 10-21 17:17:13 44556 101024 adb_trace.cpp:192] Android Debug Bridge version 1.0.41
adb D 10-21 17:17:13 44556 101024 adb_trace.cpp:192] Version 29.0.6-FreeBSD
adb D 10-21 17:17:13 44556 101024 adb_trace.cpp:192] Installed as /usr/local/bin/adb
adb D 10-21 17:17:13 44556 101024 adb_trace.cpp:192]
adb D 10-21 17:17:13 44556 101024 adb_client.cpp:154] _adb_connect: host:version
* daemon not running; starting now at tcp:5037
adb D 10-21 17:19:43 44557 101612 adb_trace.cpp:192] Android Debug Bridge version 1.0.41
adb D 10-21 17:19:43 44557 101612 adb_trace.cpp:192] Version 29.0.6-FreeBSD
adb D 10-21 17:19:43 44557 101612 adb_trace.cpp:192] Installed as /usr/local/bin/adb
adb D 10-21 17:19:43 44557 101612 adb_trace.cpp:192]
* daemon started successfully
List of devices attached
...
```
Update: Found it. Looks like adb doesn't like it if blackhole(4) is enabled for TCP connections.


----------



## sko (Aug 14, 2021)

I just tried to use adb to install lineageOS on a galaxy tab 6 lite, but it seems this problem is still persistent:


```
% adb sideload lineage-18.1-20210812-microG-gta4xlwifi.zip
* daemon not running; starting now at tcp:5037
* daemon started successfully
adb: failed to read command: No error: 0
```

trying as root:

```
% doas adb sideload lineage-18.1-20210812-microG-gta4xlwifi.zip
serving: 'lineage-18.1-20210812-microG-gta4xlwifi.zip'  (~0%)    adb: failed to read command: No error: 0
```


```
% sysctl -a | grep blackhole
net.inet.tcp.v6pmtud_blackhole_mss: 1220
net.inet.tcp.pmtud_blackhole_mss: 1200
net.inet.tcp.pmtud_blackhole_detection: 0
net.inet.tcp.blackhole: 0
net.inet.udp.blackhole: 0
net.inet.sctp.blackhole: 0
```


Has anyone found a way to use adb on FreeBSD? I found fb-adb but that doesn't seem to support sideloading...


----------



## skunk (Mar 21, 2022)

Stumbled over this, too... 

The only thing that seems to work is `adb devices`.
But almost every "meaningful" `adb` action aside of this leads to the device "disappearing".
Luckily, my phones are all Samsung.
And, `heimdall flash --RECOVERY twrp-nnn.img --no-reboot` works just fine.

I got the phones working using TWRP and sd card for storing the LineageOS images, together with gapps and other stuff.
Because, the LineageOS recovery turned out to be useless because of a checksum failure (which is set to default off in TWRP).
The only somewhat "critical" stuff was to turn off the phone after heimall finished using VolDown+Power, and _quickly,_ when the screen got blank change to VolUp+Home+Power to initiate recovery, because otherwise another heimdall run is necessary.
Just for the record, in case the phone gets stuck in a LineageOS bootloop, reinstall LineageOS _without_ gapps.

It would be awesome if `adb` could be fixed somehow, though


----------



## bsduck (Mar 24, 2022)

I also tried to `adb sideload` a LineageOS upgrade today and couldn't make it work either. I ended up doing it from a Linux machine.


----------



## q-pa (Apr 28, 2022)

bsduck said:


> I also tried to `adb sideload` a LineageOS upgrade today and couldn't make it work either. I ended up doing it from a Linux machine.


Same here, a Linux live USB helped. On FreeBSD, the last update of android-tools-adb and -fastboot was on 2021-11-27.  There is no maintainer for this port.


----------

