USB download on Android (again)
glance at acc.umu.se
Tue Apr 16 13:28:43 PDT 2019
On 16 April, 2019 - Dirk Hohndel wrote:
> On the off chance that someone happens to have
> (a) a recent Android device that doesn't support FTDI downloads with Subsurface
> (b) an FTDI dive computer
Its not only FTDI computers, its also all libusb based computers
supported by libdivecomputer, like Eon Steel/Core and Atomic Aquatics
> (c) a cable to connect (b) to (a)
> (d) the ability to build for Android locally (which is really easy these
> days thanks to the container setup that I've created)
> (e) interest and time to figure this out...
The current code works on all my android devices, but I can cook a
custom fw which restricts any access to /sys for subsurface, and test
with, if I ever get around to it.
> A couple of months ago upstream libusb merged the code to wrap Android USB
> file descriptors that you can get from JNI which should allow us to work
> on recent devices that otherwise fail with libusb.
> This thread discusses the pull request that was merged
It hurts in my eyes trying to read patches in that web ui.
I'd recommend every one else to look at the PR on github instead:
> We already have a helper function to get the file descriptor (get_usb_fd()
> in core/android.c). All this should take is to replace our current hack
> which involves patching a specific version of libusb (this can be found
> in packaging/android/build.sh) with the official mechanism introduced in
> libusb master.
> Anton may have additional comments - but I know that the one thing he
> doesn't have is time...
I'm not dead yet, so I might get time =)
> I will eventually find time to work on this - but that might be a long
> while with all the OTHER things I need to work on.
> So... anyone?
I'm all for switching to mainline libusb without my patch, now when
mainline merged a solution. The way i did it was to be able to patch as
little as possible, and still get everything working. Back when I wrote
that code, ftdi_usb_open_dev didn't exist in libftdi so we would have
needed to patch libftdi to, if we went that approach back then.
Our libftdi code needs to change if we switch to this approach. Its
* Open the device in "android" with get_usb_fd
* Wrap it in libusb with libusb_wrap_sys_device
* Wrap it in libftdi with ftdi_usb_open_dev
Instead of the current ftdi_usb_open
The downside is that we need to fight libdivecomputer to get libusb
support there. In my old approach we got that for free.
Another approach is to use the new infra in libusb to disable the
stats/opens in /sys and just continue to use the current approach. This
was my previous plan, but I never got around to it, because current code
works for me<tm>.
Anton Lundin +46702-161604
More information about the subsurface