Hi,
I was succesfull to install all needed tools on my Google Nexus 7 to write and upload/flash Arduino Sketches.
Here I will try to get you going, please be kind if I make some errors, I tried quite a bit to get here so there may be quirks
I will update this thread as needed.
What do we need:
- Android device with Android >= 4.0 (I use a Nexus 7 with 4.1.1 stock ROM)
- device needs to be rooted (Nexus Toolkit to do that)
- USB Host port on the device (often called USB OTG (on the go))
- the right module for your FTDI and your android architecture (ftdt_sio.ko I compiled it myself on a Ubuntu Linux) (see attachments for two versions, need to match your kernel)
- USB OTG Cable
- Arduino UNO, Diecemilla or Pro Mini with FTDI Adapter
- [1] AVR Toolchain Google Code Archive - Long-term storage for Google Code Project Hosting.
- busybox for Android (common Unix commands, see Market)
- [2] an Makefile: ::[ edam ]:: » Arduino Makefile
- terminal Emulator App
- text editor (with c++ syntax highliting)
- Hackers Keyboard App (recommended!)
How it works
Software
- install busybox
- install terminal app
From now on we use the terminal app. You can/should use the "su" command to make you work as root, there is no real user we can work as, so be carefull not to mess your device!
- make an directory on your sdcard, I used "arduino/"
- put the avr folder from [1] with the tools and includes there (delete bin/su here or it will clash with your system su!)
- put the folders "hardware" and "libraries" from Arduino 1.0.1 here
- make a directory with an example sketch, I uses "Blink/" with Blink.ino in it
- copy the arduino.mk from [2] to the "arduino/" folder, it will be our template
- we need now to make some changes to the makefile.mk
- add the line SHELL:=/system/bin/sh in the beginning
- define the defaults as on [2] documented
- The busybox rm command don’t know the -f param, so I deleted this param (search for "-f ").
- The check for stty came up with “-f” but the system stty still wants -F, change the second echo also to "-f"
- copy the makefile.mk to you example folder and rename it to Makefile
- call make boards, it is in the avr/bin/ folder (e.g. /sdcard/arduino/avr/bin/make or ../avr/bin/make)
- there should be now some output like this:
root@android:/sdcard/arduino/Blink # ../avr/bin/make boards
Available values for BOARD:
uno Arduino Uno
atmega328 Arduino Duemilanove w/ ATmega328
diecimila Arduino Diecimila or Duemilanove w/ ATmega168
nano328 Arduino Nano w/ ATmega328
nano Arduino Nano w/ ATmega168
mega2560 Arduino Mega 2560 or Mega ADK
mega Arduino Mega (ATmega1280)
leonardo Arduino Leonardo
mini328 Arduino Mini w/ ATmega328
mini Arduino Mini w/ ATmega168
ethernet Arduino Ethernet
fio Arduino Fio
bt328 Arduino BT w/ ATmega328
bt Arduino BT w/ ATmega168
lilypad328 LilyPad Arduino w/ ATmega328
lilypad LilyPad Arduino w/ ATmega168
pro5v328 Arduino Pro or Pro Mini (5V, 16 MHz) w/ ATmega328
pro5v Arduino Pro or Pro Mini (5V, 16 MHz) w/ ATmega168
pro328 Arduino Pro or Pro Mini (3.3V, 8 MHz) w/ ATmega328
pro Arduino Pro or Pro Mini (3.3V, 8 MHz) w/ ATmega168
atmega168 Arduino NG or older w/ ATmega168
atmega8 Arduino NG or older w/ ATmega8
root@android:/sdcard/arduino/Blink #
-
we now set the board we like to use: # export BOARD=atmega328
-
Now call make with no target
../avr/bin/make
A big stream of compile output should now fill your stream. If it ends with something like
/sdcard/arduino/avr/bin/avr-objcopy -O ihex -R .eeprom Blink.elf Blink.hex
rm Blink.elf
You are lucky
- Fixing things up
- most likely you (because of my bad description) forget to set some defaults in the Makefile -> fix it, see [2]
- an error in util/delay.h about ceil etc can be fixed by adding a #include <math.h> in that file
- Flashing the .hex
- remember that ftdi_sio.ko? Do a "insmod ftdi_sio.ko" command (root needed here absolutely). Then connect your FTDI or your Arduino. Check if there is a "/dev/ttyUSB0" device file now!
- do a "make upload" (should work if you did your homework from [2])
root@android:/sdcard/arduino/Blink # ../avr/bin/make upload
Uploading to board...
stty -F /dev/ttyUSB0 hupcl
/sdcard/arduino/avr/bin/avrdude -C /sdcard/arduino/avr/bin/avrdude.conf -DV -p atmega328p -P /dev/ttyUSB0 -c arduino -b 57600 -U flash:w:Blink.hex:i
avrdude: AVR device initialized and ready to accept instructions
Reading | ################################################## | 100% 0.01s
avrdude: Device signature = 0x1e950f
avrdude: reading input file "Blink.hex"
avrdude: writing flash (1106 bytes):
Writing | ################################################## | 100% 0.33s
avrdude: 1106 bytes of flash written
avrdude: safemode: Fuses OK
avrdude done. Thank you.
root@android:/sdcard/arduino/Blink #
Hope this gets you started! This is far from beeing error prone so far, test it and give feedback.
Todo/remarks:
- the Makefile uses the gnu screen command to mimic the serial monitor, however I could not find a android port working for me
- you put the avr toolchain in the PATH variable (also from the Terminal App Preferences)
- you can work without beeing root after installation. Upload will not work, you can however change the permission for /dev/ttyUSB to "666" (this can be a security risk, and lasts only until the Board is removed)
- Adroid and Linux makes a different in the Case, so a EtherCard.h will only be found in EtherCard/ not in ethercard like on Windows
- it is not possible (as in the IDE, which seems to do some magic) to access a function before it was declared. Maybe you need to reshuffle your functions in the source
- to check the size use "make size", however it seems to differ a bit from the IDE, maybe some gcc optimisations could be used?
- a problem with using float math occured, somehow we need to convince the linker to use c math (http://arduino.cc/forum/index.php/topic,40215.0.html) we need to add that (my Makefile attached, you need to be logged in to get it)
Greetings,
Carsten
Makefile (13.4 KB)
ftdi_sio_4.1.1_Nexus7Tegra.zip (95.2 KB)
ftdi_sio_4.1.2_tegra.zip (95.2 KB)