adam icon indicating copy to clipboard operation
adam copied to clipboard

Support fastboot for Adam

Open LukasAnda opened this issue 1 year ago • 7 comments

Is your feature request related to a problem? Please describe. I'd like to facilitate the installation of the whole OS on my device, therefore I also need fastboot to do so. Do you have some plans in mind to support it / can point me in a direction so I can do it myself?

Describe the solution you'd like I'd like for this library to support Fastboot commands as well to be able to flash various parts of operating system to a device

Describe alternatives you've considered Running commands manually on fastboot binary over a shell

Additional context None

LukasAnda avatar May 30 '23 06:05 LukasAnda

Hey @LukasAnda, to my knowledge adb as a protocol supports sideloading as a generic way to push packages to the device for flashing: https://malinskiy.github.io/adam/docs/package-management/sideload/

Fastboot is a complementary protocol for some Android devices and does not share any code with adb server/adbd in contrast to sideloading. I definitely think a fastboot client implementation is a good addition to adam and as a start I'd take a look at https://android.googlesource.com/platform/system/core/+/refs/heads/master/fastboot for a reference on the protocol spec.

I don't have a use-case currently for such an implementation, so would be happy to review a potential Pull Request and help guide the implementation.

Malinskiy avatar May 30 '23 08:05 Malinskiy

Perfect, thank you for your response. I'll take a look and hopefully come up with something as I'd like to use a singular library to manage my device. To give you context, it's a custom IOT device that runs Android but requires a new OS updates from time to time which I flash to the system using fastboot.

LukasAnda avatar May 30 '23 08:05 LukasAnda

@Malinskiy I see that Adam uses TCP protocol to communicate with ADB protocol. However, traditionally, fastboot is used over USB only. How would that work? It's not clear to me from that link you provided.

LukasAnda avatar Jun 01 '23 10:06 LukasAnda

I'm not a fastboot creator, but from my brief understanding the protocol for fastboot works for TCP/IP connections as well as USB

Malinskiy avatar Jun 01 '23 10:06 Malinskiy

Yes, but looking at the source of your library, correct me if I am wrong, your library works as such:

  • Start ADB server
  • Send command using protocol to that ADB server and let it return the result
  • Close ADB server

But for Fastboot, there is no such thing as running the server, especially for communication over USB, one would just need to send specific commands to the fastboot binary and parse the result. Therefore the whole protocol is not needed as there is no server running (Because usually when you want to flash some files to a device, you are connected over USB and not over TCP/IP protocol)

LukasAnda avatar Jun 01 '23 12:06 LukasAnda

But looking at the different options, I can use something like this: https://github.com/eraga/rxusb to communicate with the fastboot mode with specified protocol

LukasAnda avatar Jun 01 '23 12:06 LukasAnda

The TCP protocol is designed to be a simple way to use the fastboot protocol over ethernet if USB is not available. The device will open a TCP server on port 5554 and wait for a fastboot client to connect.

I'd probably check if any device can be used over the network instead of via USB since network communication is much easier from JVM than USB.

This library doesn't start the adb server, it's expected to work before executing requests. If one does want to start the server then the interactor is provided, but it's not a requirement to start the server by adam

For fastboot the server is implemented on the device itself without any intermediates such as adb server.

Hope this helps

Malinskiy avatar Jun 03 '23 08:06 Malinskiy

I'll close this one assuming you don't need my help here

Malinskiy avatar May 20 '24 10:05 Malinskiy