Is it possible to run
fastboot commands using Termux terminal emulator? I am wanting to run commands from one Huawei T3 7 to another using USB/OTG cable. Need to unlock bootloader but have no access to a PC or laptop.
This question is nearly a duplicate of this which has a detailed answer by @Firelord, except the Termux part. As mention by @DeathMaskSalesman in comment, Termux is more like a Linux environment, but so far it doesn't have
fastboot in repositories, though proposed. Most probably because they are meant for rooted devices. But you can use static binaries (e.g. this or this) on Termux like on usual Terminal emulator app. Make sure to set proper environment variables (
However you won't be able to run each of them without root because only members of
AID_USB group are able to read devices in
/dev/bus/usb/ (1). Furthermore SELinux restricts unprivileged apps' access to
adb there's a workaround if both devices are connected to same network e.g. Wi-Fi or hotspot.
adbd can be run to listen on TCP socket instead of USB. It's possible if before turning on "USB Debugging" property
service.adb.tcp.port (2) is set to some port (first default is
5555). Apps can't set properties, so to do this using
adb shell or by simply executing
adb tcpip 5555, you need to connect the target device to a PC over USB. Then all you have to do from Termux before sending commands is:
~$ adb connect <IP>:5555
service.adb.tcp.port is reset on reboots and you have to set it again. There is another property
persist.adb.tcp.port which persists across reboots but it's meant only for testing and SELinux won't let you set this without root or some system app running with UID
Some custom ROMs have built-in toggle to set
service.adb.tcp.port. But for
fastboot root is must. However it's possible on Android to access USB OTG devices through
fastboot-mobile is an unofficial library from Google to send
fastboot commands over OTG. This app (I have no affiliation) also provides similar limited functionality.