2
votes

I have a custom build of AOSP (based on kitkat 4.4). I am controlling an arduino board via Android's USB Host API. I also am running a kernel that supports the CDC-ACM module.

I want to be able to flash new hex files onto the board. I have seen ArduinoDroid do this in his app. I have been able to flash using avrdude and the /dev/ttyACM* file that is created using the CDC-ACM driver.

However, when I grant permission for my app to communicate with the arduino board, the /dev/ttyACM* file disappears. Which makes sense because I am now controlling it via Android's USB host api. I am looking for either a way to restore the /dev/ttyACM* file or allow avrdude to use the /dev/bus/usb/#/# file in order to flash a new hex file onto the board. It doesn't appear that there is a revokePermission method in the USBManager.

The /dev/ttyACM* device file does not appear even after closing the device. I am running the following code to close the device.

connection.releaseInterface(device.getInterface(1));

connection.close();

I guess my real question is that there a way to get the kernel driver back after releasing the USB connection.

Because I am using a custom build of AOSP, I do not have google play and I cannot install ArduinoDroid on the tablet. However, I can run my app as a system level app if needed.

1
I've tried to call connection.claimInterface(device.getInterface(1), false) to keep the /dev/ttyACM0 file around, but for some reason the tablet reboots when I try to claim it this way.scheibk
The reason for the reboot is because the claimInterface call failed when I passed in false for force.scheibk

1 Answers

0
votes

Ultimately I solved this, but it does seem like a bit of a hack.

Before taking control of the device (on a reboot of the tablet), I checked to see if any /dev/ttyACM* files existed. If they did, I then checked the /sys/ file system to check to see they were the correct device. I essentially checked the vendor of the usb device and matched it against the known device. Once that was confirmed, I knew it was safe to try and upload a new hex file to the device.