Difference between revisions of "Arduino"
m (→gcc-avr-4.6.1-1 results to compilation errors)
|Line 123:||Line 123:|
In order to bypass this problem downgrade to previous gcc-avr-4.6.0-3.
In order to bypass this problem downgrade to previous gcc-avr-4.6.0-3.
You can grab it from
You can grab it from http://arm.konnichi.com/community/os/i686/gcc-avr-4.6.0-3-i686.pkg.tar.xz
Revision as of 09:03, 23 August 2011
Arduino is an open-source electronics prototyping platform based on flexible, easy-to-use hardware and software. It's intended for artists, designers, hobbyists, and anyone interested in creating interactive objects or environments. More information is availible on the Arduino HomePage.
- 1 Installation
- 2 Configuration
- 3 Working with Uno/Mega2560
- 4 Running Arduino Uno
- 5 Alternatives for IDE
- 6 Troubleshooting
- 7 64-bit
- 8 See also
Add the following modules to your /etc/rc.conf file.
Load them manually with modprobe so you don't have to reboot:
# modprobe --all cdc-acm ftdi_sio
Running arduino for the first time
If the file /usr/share/arduino/lib/targets/libraries/Wire/utility/twi.o does not exist arduino will try and create it. Normal users don't have permission to write there so this will fail. Run arduino as root so it can create the file, after the file has been created it can be run under a normal user.
The arduino board communicates with the PC via a serial connection or a serial over USB connection. So the user needs read/write access to the serial device file. Udev creates files in /dev/tts/ owned by group uucp so adding the user to the uucp group gives the required read/write access.
gpasswd -a <user> uucp
Change serial port from COM1 to your serial port. You can find out what your serial port is with:
ls /dev/ | grep "USB"
This is the line to change in ~/.arduino/preferences.txt:
Associate .pde files with the Arduino IDE
edit /usr/bin/arduino so it looks like this:
Then change the last line in /usr/share/arduino/arduino to look like this:
java -Dswing.defaultlaf=com.sun.java.swing.plaf.gtk.GTKLookAndFeel processing.app.Base "$*"
Now you can run "arduino /some/path/sketch.pde and it should open instead of a blank sketch
Working with Uno/Mega2560
The Arduino Uno and Mega2560 have an onboard USB interface (an Atmel 8U2) that accepts serial data, so they are accessed through /dev/ttyACM0 created by the cdc-acm kernel module when it is plugged in.
The 8U2 firmware may need an update to ease serial communications. See  for more details and reply #11 for a fix. The original arduino bbs, where you can find an image explaining how to get your Uno into DFU, is now in a read-only state. If you don't have an account to view the image, see .
You can perform a general function test of the Uno by putting it in loopback mode and typing characters into the arduino serial monitor at 115200 baud. It should echo the characters back to you. To put it in loopback, short pins 0 -> 1 on the digital side and either hold the reset button or short the GND -> RESET pins while you type.
Running Arduino Uno
Once Arduino is running you must ensure you have selected the correct board from the Tools->Boards menu item:
Secondly you must ensure you have selected the correct serial port from the Tools->Serial Port menu item:
Once these are done you should be able to write and upload sketches to your Arduino Uno without any issues.
Alternatives for IDE
If you prefer working from terminal there are some other options to choose from.
Using scons together with arscons it is very easy to use to compile and upload Arduino projects from the command line. Scons is based on python and you will need python-pyserial to use the serial interface. Install everything with
# pacman -S python-pyserial scons
That will get the dependencies you need too. You will also need Arduino itself so install it as described above. Create project directory (eg. test), then create a arduino project file in your new directory. Use the same name as the directory and add .pde (eg. test.pde). Get the SConstruct script from arscons and put it in your directory. Have a peek in it and, if necessary, edit it. It's a python script. Edit your project as you please, then run
$ scons # This will build the project $ scons upload # This will upload the project to your Arduino
Update 2011-03-12. Arduino Is not shipping a Makefile with version (22). The Makefile from the dogm128 project works for me though.
Instead of using the arduino IDE it's possible to use another editor and a Makefile.
Set up a directory to program your Arduino and copy the Makefile into this directory. A copy of the Makefile can be obtained from arduino website or from /usr/share/arduino/hardware/cores/arduino/Makefile
You will have to modify this a little bit to reflect your settings. The makefile should be pretty self explainatory. Here are some lines you may have to edit.
PORT = usually /dev/ttyUSBx, where x is the usb serial port your arduino is plugged into TARGET = your sketch's name ARDUINO = /usr/share/arduino/lib/targets/arduino
Depending on which library functions you call in your sketch, you may need to compile parts of the library. To do that you need to edit your SRC and CXXSRC to include the required libraries.
Now you should be able to make && make upload to your board to execute your sketch.
Using arduino-cmake and CMake you can build Arduino firmware from the command line using multiple build systems. CMake lets you generate the build system that fits your needs, using the tools you like. It can generate any type of build system, from simple Makefiles, to complete projects for Eclipse, Visual Studio, XCode, etc.
gcc-avr-4.6.1-1 results to compilation errors
Current gcc-avr-4.6.1-1 results to compilation errors such as
In file included from /usr/share/arduino/hardware/arduino/cores/arduino/Tone.cpp:37:0: /usr/share/arduino/hardware/arduino/cores/arduino/pins_arduino.h:66:48: error: variable 'port_to_mode_PGM' must be const in order to be put into read-only section by means of '__attribute__((progmem))'
In order to bypass this problem downgrade to previous gcc-avr-4.6.0-3. You can grab it from here.
When building with pacman, gcc-multilib and binutils-multilib were installed. However testing has revealed that the multilib versions are not required and the Arduino Uno works fine with the regular 64 bit versions of these programs.
delay() doesn't work
There are some cases where the delay() function doesn't work, causing programs such as the example "Blink" program to malfunction. See http://arduino.cc/forum/index.php/topic,56841.msg410902.html#msg410902 and http://arduino.cc/forum/index.php?topic=59409.0 Fedora has the same problem with binutils 2.21 https://bugzilla.redhat.com/show_bug.cgi?id=688645 Downgraded packages that work are binutils-avr 2.20.1-3 and gcc-avr 4.5.1-2. Unknown whether there is an upstream bug report.
Adruino Mega2560 and new gcc-avr
If you are using gcc-avr >= 4.3.5 then there is a C++ bug in the gcc-avr toolchain which builds bad firmware for the Atmel2560 processors. gcc-avr must be rebuilt using a patch found at . You can read more about the problems at .
Here is the patch for gcc:
--- gcc-4.5.1.orig/gcc/config/avr/libgcc.S 2009-05-23 17:16:07 +1000 +++ gcc-4.5.1/gcc/config/avr/libgcc.S 2010-08-12 09:38:05 +1000 @@ -802,7 +802,9 @@ mov_h r31, r29 mov_l r30, r28 out __RAMPZ__, r20 + push r20 XCALL __tablejump_elpm__ + pop r20 .L__do_global_ctors_start: cpi r28, lo8(__ctors_start) cpc r29, r17 @@ -843,7 +845,9 @@ mov_h r31, r29 mov_l r30, r28 out __RAMPZ__, r20 + push r20 XCALL __tablejump_elpm__ + pop r20 .L__do_global_dtors_start: cpi r28, lo8(__dtors_end) cpc r29, r17
The easiest way to rebuild gcc-avr is using ABS and makepkg.