3

Hi members of stackoverflow.com!

I try to build an app in Android that can upload HEX file generated by avr-gcc. I installed the AndAVR this chaintool http://code.google.com/p/andavr/

to run avrdude (in root devices with USB-OTG cable) I use this command in mobile terminal:

/data/data/jackpal.androidterm/local/bin/avrdude -F -V -c arduino -p m2560 -P /dev/bus/usb/002/001  -b 115200 -C /data/data/jackpal.androidterm/local/etc/avrdude.conf -U flash:w:/sdcard/megademo/Blink1.cpp.hex

and after Read this post Android cannot talk to Arduino using AVRDUDE I try the solution and change the /dev/bus/usb/002/002 by /dev/ttyACM0.

/data/data/jackpal.androidterm/local/bin/avrdude -F -V -c arduino -p m2560 -P /dev/ttyACM0  -b 115200 -C /data/data/jackpal.androidterm/local/etc/avrdude.conf -U flash:w:/sdcard/megademo/Blink1.cpp.hex

But avrdude answer me with:

avrdude: ser_open(): can't open device "unkown". No such file or directory. 

I have a Arduino Mega 2560 and Mega ADK 2560 R3, both boards have a ATmega2560 microcontollers and I have a:

  • Samsumg Galaxy S2 run Android 4.1.2 stock with root
  • Samsumg Galaxy S3 run Android 4.1.2 stock with root
  • Samsumg Galaxy Tab Note 10.1 run Android 4.1.2 stock without root
  • Asus Transfomer Pad TF700T run Android 4.2.1 stock without root

the problem is that Samsung devices doesn't enumerate the Arduino board and the Asus tab yes.

In all devices I run the command in mobile terminal:

cat /proc/tty/drivers

and Asus present the specific driver:

ACM /dev/ttyACM 166 0-31 serial

this driver doesn't show in Samsung devices, well this driver is essential to upload the hex file to Arduino board, so How can I install this driver in Samsung devices? or how can I upload the hex file?

Android in all devices create a file in /dev/bus/USB/002/xxx where xxx is the Arduino board or other USB device.

Best regards!

Community
  • 1
  • 1

1 Answers1

1

If you want to use this method, you need to load the cdc_acm kernel module - which probably was not supplied with your device, so you will have to build it. And then create the corresponding /dev/ttyACM0 device node, since the daemon that would do that on a desktop linux probably isn't there. You will need root to do these things, and moderately close kernel sources to compile from.

Another approach might be to implement CDC_ACM type communication in user mode from an Android app using the Android USB Host APIs if those are supported on your device. This would be a more "android style" solution, but would require some changes to avrdude, since it will have to do communication via an Android-aware backend service packaged in an app.

Also note that CDC_ACM is used by the recent arduinos (Uno, etc) and a minority of clones; older Arduino boards and the majority of clones use FTDI USB-serial converters and require ftdi driver modules or protocols.

Chris Stratton
  • 39,853
  • 6
  • 84
  • 117
  • I found a driver called cdc_acm.ko for S3 in this page: http://www.draisberghof.de/usb_modeswitch/bb/viewtopic.php?f=6&t=1113&sid=8a884c8da0544520e912d4e3aa94351b I installed and this works, how I use this driver in other device? is it possible? I installed with the command with super user: # insmod /sdcard/cdc-acm.ko – Miguel Tres Patines May 31 '13 at 15:59
  • Kernel modules tend to only work on the same/very close kernel builds. Even it if works, to use it you will need to create a device node. You can probably get the major/minor numbers with ls -l /dev/ttyACM0 from your tablet where it works (probably 166 and 0 based on your above). First read a linux man page for `mknod` then realize that Android's `mknod` may be weird but you can likely see comparable example of using it in the startup scripts on your device. – Chris Stratton May 31 '13 at 16:02
  • I will implement the STK500V2 protocol in java to upload hex file to Arduino Mega 2560 with the USB-Serial API for Android to make my application "general" and without access root thanks for help me! Best regards! – Miguel Tres Patines Jun 04 '13 at 12:13
  • @MiguelTresPatines, did you end up implementing this in java? – Scampbell Sep 05 '18 at 00:51