LinuxQuestions.org
Register a domain and help support LQ
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Slackware
User Name
Password
Slackware This Forum is for the discussion of Slackware Linux.

Notices

Reply
 
LinkBack Search this Thread
Old 11-05-2010, 04:14 PM   #1
Laodiceans
Member
 
Registered: Jan 2006
Distribution: Slackware
Posts: 188

Rep: Reputation: 18
Arduino Slackbuild Problem


Hello!

I'm trying to change this SlackBuild script to work with my new Arduino Uno that have the ATmega8U2 for USB-serial conversion and in linux uses /dev/ttyACM0

And the problem is that I have to do always chmod 666 /dev/ttyACM0 when I try to use de Arduino IDE to write (upload) on the device. And in most cases it fails.
I keep trying until it works...
I dont know if is a problem of the Arduino or if is a problem of the SlackBuild script that build the IDE.
I tested in ubuntu and it works also with some difficulties but less that in Slackware (some times the upload fail too).

And the script only works on 32 bits...
But in Ubuntu the IDE works on 64 bits!!!

This is arduino.SlackBuild:
Code:
#!/bin/sh

# Slackware build script for Arduino IDE
# Written by Diogo Leal (diogo@diogoleal.com)

PRGNAM=arduino
VERSION=${VERSION:-0021}
BUILD=${BUILD:-1}
TAG=${TAG:-_SBo}
CWD=$(pwd)

TMP=${TMP:-/tmp/SBo}
PKG=$TMP/package-$PRGNAM
OUTPUT=${OUTPUT:-/tmp}

ARCH=i486

set -e 

rm -rf $PKG 
mkdir -p $TMP $PKG $OUTPUT
rm -rf $TMP/$PRGNAM-$VERSION
cd $TMP
tar xvf $CWD/$PRGNAM-$VERSION.tgz
cd $PKG
chown -R root:root . 
find . \
 \( -perm 777 -o -perm 775 -o -perm 711 -o -perm 555 -o -perm 511 \) \
 -exec chmod 755 {} \; -o \
 \( -perm 666 -o -perm 664 -o -perm 600 -o -perm 444 -o -perm 440 -o -perm 400 \) \
 -exec chmod 644 {} \;

mkdir -p $PKG/opt
cp -a ../$PRGNAM-$VERSION $PKG/opt/arduino

install -D -m 644 $CWD/arduino.desktop $PKG/usr/share/applications/arduino.desktop
install -D -m 644 $CWD/arduino.png $PKG/usr/share/pixmaps/arduino.png

find $PKG | xargs file | grep -e "executable" -e "shared object" | grep ELF \
  | cut -f 1 -d : | xargs strip --strip-unneeded 2> /dev/null || true


mkdir -p $PKG/install
cat $CWD/slack-desc > $PKG/install/slack-desc
cat $CWD/doinst.sh > $PKG/install/doinst.sh
mkdir -p $PKG/etc/udev/rules.d/

#echo $CWD
#echo $PWD
#echo $PKG
#exit 0
cat $CWD/09-arduino.rules >  $PKG/etc/udev/rules.d/09-arduino.rules 

cd $PKG
/sbin/makepkg -l y -c n $OUTPUT/$PRGNAM-$VERSION-$ARCH-$BUILD$TAG.${PKGTYPE:-tgz}
And this is 09-arduino.rules:
Code:
SUBSYSTEMS=="usb", ATTRS{product}=="FT232R USB UART", ATTRS{idProduct}=="6001", ATTRS{idVendor}=="0403", SYMLINK+="arduino arduino_$attr{serial}"
SUBSYSTEMS=="usb", ATTRS{product}=="ARDUINO NANO",    ATTRS{idProduct}=="6001", ATTRS{idVendor}=="0403", SYMLINK+="arduino arduino_nano_$attr{serial}"
All credits to Diogo Leal.


I will test it also in windows 7 to see how it works.

Last edited by Laodiceans; 11-05-2010 at 04:50 PM.
 
Old 11-05-2010, 05:03 PM   #2
D1ver
Member
 
Registered: Jan 2010
Distribution: Slackware 13.37
Posts: 527
Blog Entries: 3

Rep: Reputation: 126Reputation: 126
Hey mate, I had the same issue with permission denied errors, but after issuing the 'chmod 666 /dev/USB0' (in my case it was the older arduino Duemilanove) things would start to work..

What is the error your getting when you try to upload code to the device? Also could you try hitting the reset button on the board half a second before clicking upload?

Also, if your unaware there's a way (IIRC its shift+click) when uploading that will print verbose debug errors which is pretty helpful.

Last edited by D1ver; 11-05-2010 at 05:08 PM.
 
Old 11-05-2010, 06:28 PM   #3
Laodiceans
Member
 
Registered: Jan 2006
Distribution: Slackware
Posts: 188

Original Poster
Rep: Reputation: 18
In my case I do the chmod 666 /dev/ttyACM0 and in 32 bits I have error like /dev/ttyACM0 not found or /dev/ttyACM0 in use. That kind of errors, I keep doing chmod 666 /dev/ttyACM0 and trying to upload, sometimes it works sometimes don't work. This happens in Slackware 13.1 32bits and in Ubuntu 10.10 with the last Arduino IDE but in ubuntu it fails less to upload then in slackware.

In 64 bits I receive this message when uploading:

Code:

java.io.IOException: Cannot run program "/opt/arduino/hardware/tools/avrdude": java.io.IOException: error=2, No such file or directory
     at java.lang.ProcessBuilder.start(Unknown Source)
     at java.lang.Runtime.exec(Unknown Source)
     at java.lang.Runtime.exec(Unknown Source)
     at processing.app.debug.Uploader.executeUploadCommand(Unknown Source)
     at processing.app.debug.AvrdudeUploader.avrdude(Unknown Source)
     at processing.app.debug.AvrdudeUploader.uploadViaBootloader(Unknown Source)
     at processing.app.debug.AvrdudeUploader.uploadUsingPreferences(Unknown Source)
     at processing.app.Sketch.upload(Unknown Source)
     at processing.app.Sketch.exportApplet(Unknown Source)
     at processing.app.Sketch.exportApplet(Unknown Source)
     at processing.app.Editor$DefaultExportHandler.run(Unknown Source)
     at java.lang.Thread.run(Unknown Source)
Caused by: java.io.IOException: java.io.IOException: error=2, No such file or directory
     at java.lang.UNIXProcess.<init>(Unknown Source)
     at java.lang.ProcessImpl.start(Unknown Source)
     ... 12 more

I tested in windows 7 32 bits and works fine so is a problem with linux not with the hardware itself.

Last edited by Laodiceans; 11-05-2010 at 06:33 PM.
 
Old 11-05-2010, 06:47 PM   #4
D1ver
Member
 
Registered: Jan 2010
Distribution: Slackware 13.37
Posts: 527
Blog Entries: 3

Rep: Reputation: 126Reputation: 126
Have you had a look in /dev/ and made sure ttyACM0 exists? are there any options to change to a different device?

In 32 bit linux does resetting the board with the reset button just as your uploading get rid of the 'line in use' errors?

I Don't know what your proficiency in C is, but I did all the work on my arduino using avrgcc and avrdude writing in pure C. I didn't like the arduino language..

Last edited by D1ver; 11-05-2010 at 07:01 PM.
 
Old 11-05-2010, 08:01 PM   #5
Laodiceans
Member
 
Registered: Jan 2006
Distribution: Slackware
Posts: 188

Original Poster
Rep: Reputation: 18
Some commands and results in Ubuntu 10.10 and Slackware 13.1

Ubuntu:

Code:
dmesg 
....
[   22.808517] EXT4-fs (sda6): re-mounted. Opts: errors=remount-ro,commit=0
[   22.822822] EXT4-fs (sdb2): re-mounted. Opts: commit=0
[   28.104896] EXT4-fs (sda6): re-mounted. Opts: errors=remount-ro,commit=0
[   28.107339] EXT4-fs (sdb2): re-mounted. Opts: commit=0
[   31.520039] eth0: no IPv6 routers present
[  173.370334] usb 4-2: new full speed USB device using uhci_hcd and address 2
[  173.610148] cdc_acm 4-2:1.0: ttyACM0: USB ACM device
[  173.612881] usbcore: registered new interface driver cdc_acm
[  173.612885] cdc_acm: v0.26:USB Abstract Control Model driver for USB modems and ISDN adapters


ls -lh /dev/ttyACM0
crw-rw---- 1 root dialout 166, 0 2010-11-06 00:32 /dev/ttyACM0

uname -r
2.6.35-22-generic
Slackware:
Code:
dmesg
...
usb 4-2: new full speed USB device using uhci_hcd and address 9
usb 4-2: New USB device found, idVendor=2341, idProduct=0001
usb 4-2: New USB device strings: Mfr=1, Product=2, SerialNumber=220
usb 4-2: Product: Arduino Uno
usb 4-2: Manufacturer: Arduino (www.arduino.cc)
usb 4-2: SerialNumber: 6493832313135191D0B0
cdc_acm 4-2:1.0: ttyACM0: USB ACM device


ls -lh /dev/ttyACM0
crw-rw---- 1 root dialout 166, 0 2010-11-05 23:47 /dev/ttyACM0

uname -r
2.6.33.4
 
Old 11-05-2010, 11:50 PM   #6
Lirey
Member
 
Registered: Sep 2009
Distribution: Slackware
Posts: 32

Rep: Reputation: 5
Hi Laodiceans,

I think that you have two separate problems.

First, the issue with the permissions for ttyACM0 can be solved by adding yourself to the "dialout" group. You'll need to logout and log back in before the group change is recognized.

On my system (Slackware-current, 64bit), /dev/ttyACM0 has rw permissions for the owner (root) and group (dialout). You can change the permissions, but I expect that they will revert to the default once the board (and ttyACM0) goes away and returns.

The second problem is that the version of avrdude that is included in the 64b version of the Arduino software (I'm using arduino-0021) appears to be for a 32b (or multilib) system. I had the same errors as in post #3 when I first installed the Arduino software on my system.

The solution is to install avrdude from source. The slackbuild script works with avrdude-5.10. Unfortunately, there are some minor issues with using the Arduino software with a different version of avrdude than what was included in the distribution.

First, the Arduino software expects avrdude to be in the "arduino/hardware/tools" folder. Delete both the avrdude program and the avrdude.conf file in this directory and replace them with soft links to the version compiled from the source (if you use the slackbuild, avrdude will be in /usr/bin and avrdude.conf will be in /etc. If avrdude can't find the latest avrdude.conf, the next step will not work...

Second, the Arduino version of avrdude has been patched in some way. A version of avrdude that is installed from source won't recognize the arduino and will generate an error that starts with "Yikes...". To fix this you will need to edit the boards.txt file in the arduino/hardware/arduino folder. You will need to find your board and change the upload protocol from "stk500" to "arduino".

The uno should be the first board listed and the fixed line should read:

uno.upload.protocol=arduino

This should be, approximately, the fourth line in the file.

Those fixes seemed to solve all my problems related to the arduino software.

Hope this helps. Now I'm going back to trying to figure out how to get my uno to log temperature readings.

Mike R.
 
Old 11-06-2010, 06:45 AM   #7
Laodiceans
Member
 
Registered: Jan 2006
Distribution: Slackware
Posts: 188

Original Poster
Rep: Reputation: 18
I did what you wrote and it solved the problems of java and avrdude in 64 bits when uploading to arduino.
But when uploading I still receive in (all) most of the times the message of /dev/ttyACM0 not found or in use. I had my user to the group dialout. I even run arduino as root and receive that message. Its strange!

In 32 bits I receive the same message of /dev/ttyACM0 not found or in use in most of the case to not say almost all.

Last edited by Laodiceans; 11-06-2010 at 11:38 AM.
 
Old 11-07-2010, 09:20 AM   #8
Laodiceans
Member
 
Registered: Jan 2006
Distribution: Slackware
Posts: 188

Original Poster
Rep: Reputation: 18
I did find this http://arduino.cc/blog/2010/10/02/ar...wm-bug-on-uno/

Appears there is a problem with the new USB->serial chip ATMega8U2 in linux.

Lirey, you don't have problems at all in slackware using a new Uno?
 
Old 11-07-2010, 09:55 PM   #9
Lirey
Member
 
Registered: Sep 2009
Distribution: Slackware
Posts: 32

Rep: Reputation: 5
Hi Laodiceans,

That blog posting was a great find!

Two days ago I hadn't seen any problems. Once I was able to get my workstation and my uno to talk to one another the first time, everything seemed to be working perfectly.

Unfortunately, that changed when I started experimenting with some new sketches that are making heavy use of the serial communications. The weirdness started after I unplugged the arduino while the serial monitor was still open. I had a few cases where the board showed up on a different port, ttyACM1 or ttyACM2. Then the software started to refuse to upload anything to the board. When I tried to upload an updated sketch it was failing with an error that the serial port could not be found.

I read the blog posting that you found and it confirmed my suspicions that the data being transmitted from the arduino board is confusing the software. Although from the blog it sounds like the problem is in Linux rather than the arduino software.

I followed the combined suggestions of the arduino blog comments from x64 (post from Oct 6th) and tony (post from Oct 7th), and I have been able to re-establish communications with the board. The trick is to unplug the board, hold down the reset button, and start to upload the new sketch while the button is still held down. You have to release the reset button while the RX light is flashing, otherwise the arduino software will time out and abort the transfer.

My permanent (sort-of) solution to the problem is to add a 10 second delay in the setup() function before I call Serial.begin. This seems to give me plenty of time after a reset to start the serial monitor or upload a new sketch. Incidentally, when the serial monitor is open I don't seem to have problems, but the software starts acting funny if there is a large amount of data from the arduino board with nothing to receive it.

Mike R.
 
Old 11-12-2010, 11:16 PM   #10
Laodiceans
Member
 
Registered: Jan 2006
Distribution: Slackware
Posts: 188

Original Poster
Rep: Reputation: 18
I bought a Duemilanove and no problems at all with the slackbuild of Arduino IDE. But I did the changes in avrdude e avrdude.conf in /opt/arduino/hardware/tools and had my user to the group dialout. I'm using Slackware 13.1 64 bits stable and not having problems at all until now.
I hope that the problems with the new Uno and the new Mega will be solved very soon. Maybe with a new version of the IDE. I don't know... it seams to be a problem with linux too!
 
Old 11-14-2010, 03:52 PM   #11
Laodiceans
Member
 
Registered: Jan 2006
Distribution: Slackware
Posts: 188

Original Poster
Rep: Reputation: 18
Today I did make the following experience. Compile various kernels and test the Arduino IDE (the made by the Slackbuild script that works without problems on 2.6.33.4 with Arduino Duemilanove). I make tests with kernels 2.6.33.7, 2.6.35.7, 2.6.36 (and even with others) and it seams that Arduino IDE have problems with serial communications (even with Duemilanove) in other kernels beside 2.6.33.4 (or others close to it, that I didn't test).
I don't know if this make sense to anybody but I'm going to stay with 2.6.33.4 for now.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Arduino on Bluewhite64 - 13 DEA Bluewhite64 4 01-30-2010 02:42 AM
Arduino carbonfiber General 3 01-18-2010 01:05 PM
Trying to Program the Arduino oakmanor1 Linux - Newbie 2 07-02-2009 11:15 PM
Problem with yafray.SlackBuild brianL Slackware 7 10-30-2008 12:57 PM
Slackbuild problem http:// Slackware 11 04-07-2008 10:46 PM


All times are GMT -5. The time now is 05:01 PM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration