3

I am using AVRDUDE for Android (http://code.google.com/p/andavr/). I can compile the C code. I can run

$ avr-gcc -Os -DF_CPU=16000000UL -mmcu=atmega328p -c -o led.o led.c
$ avr-gcc -mmcu=atmega328p led.o -o led
$ avr-objcopy -O ihex -R .eeprom led led.hex

all without issues. Then I try to run:

avrdude -F -V -c arduino -p ATMEGA328P -P /dev/bus/usb/002/002  -b 115200 -C /data/data/jackpal.androidterm/local/etc/avrdude.conf -U flash:w:led.hex

The result is:

avrdude: ser_open(): can't open device "/dev/bus/usb/002/002"; Permission denied
loctl("TIOCMGET"): Invalid argument

avrdude done. Thank you.

The situation is similar when I run:

avrdude -F -V -c arduino -p ATMEGA328P -P /dev/bus/usb/002/001  -b 115200 -C /data/data/jackpal.androidterm/local/etc/avrdude.conf -U flash:w:led.hex

I can confirm that /dev/bus/usb/002/002 is the Arduino device connected with the OTG cable. Before connecting, I run

ls -l /dev/bus/usb/002/

and I get:

total 0

After I connect the Arduino via USB to my tablet I run the command:

ls -l /dev/bus/usb/002

and I get

crw-rw----   1 0   1018  180,128 Mar 24 07:53 001
crw-rw----   1 0   1018  180,129 Mar 24 07:53 002

This clearly shows me that the Arduino is connected. I would love to know if anyone can see what I am doing wrong.

PS: I am trying to create an Android application that allows Arduino programming directly from an Android tablet.

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
HansStam
  • 509
  • 2
  • 9
  • 22

2 Answers2

3

It says 'permission denied' and you do not seem to be using a root shell. Try 'su' and then the command that failed. If your phone is not rooted, I don't think it could work.

I'm not even sure if it will work right when you are root, so please post the result! My guess is that it won't if your phone does not act as usb host (only some can)

nspo
  • 1,488
  • 16
  • 21
  • Thanks but, So here is what I have done: I have rooted my nexus7, which supports OTG. I can succesfully control is using a mouse/keyboard over OTG. I can also use it to control my arduino over OTG. I assume this means OTG is working 100% ok. Also, I have rooted my phone, and I have root access to it. I also installed Ubuntu Touch on it, and I am running a number of apps that require root succesful. I have also granted root permission to the Terminal Emulator. I cannot do su, this is not supported. I have found a way to connect the adb over wireless via an app called adbwireless. – HansStam Mar 24 '13 at 11:28
  • Continuation: I am now able to control the nexus7 adb shell via wifi, while having the arduino plugged into the usbport of the nexus7. On the adb shell, you automaticly get su access, so this should definately give me su permissions. End of story, it still does not work, even if I have su permision. I have also tried giving the arduino chmod 777 access, but that did not work either. It just does not want to be controlled by my nexus 7. – HansStam Mar 24 '13 at 11:36
  • I do not give up yet though. It SHOULD be possible – HansStam Mar 24 '13 at 11:37
  • Sorry, but after all that, it turns out I still did not have enough root permissions. I do however have root permissions, by running: /system/xbin/su. Now I finally have root permision, and I get another error, which I will describe somewhere else. I will post the link here soon. – HansStam Mar 24 '13 at 11:50
  • Follow-up question can be found here: http://stackoverflow.com/questions/15598179/avrdude-android-arduino-ioctl-error – HansStam Mar 24 '13 at 12:00
-1

I'm not expert. But don't you need a USB shield for communicating with Arduino - Android via cables? Both are slaves (so when Android/Arduino are plugged into the PC, the PC controls it). Try USB Host Shield 2.0 For Arduino.

Again, I could be wrong. I hope this helps.

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
Colum
  • 1
  • Yep, I am not using a shield. All I am using is an android tablet (nexus7) with an OTG cable which connects to an arduino uno. Next step: try to do it without any cables, but with a bluetooth shield. – HansStam Mar 25 '13 at 01:14
  • 1
    Here's my blogpost on how I did it. thanks for the help!! http://www.hstam.com/blog/?p=29 – HansStam Mar 25 '13 at 01:42
  • No, because using Android OTG cables, the mobile phone will actually be a host device, and the Arduino will be a slave. So in this setup a USB shield for Arduino should not be used. – David Refoua Dec 09 '17 at 05:21