You are not logged in.

#26 2012-10-16 14:32:39

plustwo
Member
From: South Africa, ZA
Registered: 2012-09-13
Posts: 32

Re: The official Arduino thread

I just received my Arduino UNO R3 kit today, and installed arduino from AUR. i just works. as always, "hello world" blink LED is the first thing everbody goes through.

will be trying a couple of other sketches ...

Arduino on ArchLinux ....!

Offline

#27 2012-10-17 09:20:36

axs
Member
Registered: 2009-01-23
Posts: 66
Website

Re: The official Arduino thread

Ok, somewhat opionated post, but still. Hope it will be useful.
It's a really good idea to ditch "arduino" package completely, or at least to know how to do it.
Your $EDITOR is likely much better for writing code and running make.
And you are also much more likely to get help from AVR guys if you speak their language (which has the word "avrdude" but lacks the word "sketch").

To run simple Arduino sketches, you need: avrdude, avr-gcc, avr-binutils (all from [community]), and hardware/arduino/{cores,variants} from arduino package (from https://github.com/arduino/Arduino/tree/hardware, or alternatively from arduino package if you have it already).
You don't need: arduino, java-runtime (that was over 100M of bloat the last time I checked it).

Rename or copy hardware/arduino to ./arduino in your working directory, and use the following Makefile:

SER = /dev/ttyUSB0
BAUD = 57600
MCU = atmega328p
CFLAGS = -g -Os -Wall -fno-exceptions -ffunction-sections -fdata-sections -mmcu=$(MCU) \
	-DF_CPU=16000000L -DUSB_VID=null -DUSB_PID=null -DARDUINO=101 \
	-Iarduino/core -Iarduino/variants/eightanaloginputs
CPPFLAGS = $(CFLAGS)
ARDOBJ = wiring_shift.o wiring.o wiring_digital.o wiring_analog.o WInterrupts.o wiring_pulse.o \
	Print.o HardwareSerial.o new.o Stream.o main.o CDC.o WString.o USBCore.o IPAddress.o \
	HID.o WMath.o Tone.o

%.o: %.c
	avr-gcc $(CFLAGS) -c -o $@ $<

%.o: %.cpp
	avr-g++ $(CPPFLAGS) -c -o $@ $<

libcore.a: $(patsubst %,arduino/core/%,$(ARDOBJ))
	avr-ar cru $@ $(filter %.o,$^)

%.elf: %.o libcore.a
	avr-gcc -Os -Wl,--gc-sections -mmcu=$(MCU) -o $@ $^ -lm

%.eep: %.elf
	avr-objcopy -O ihex -j .eeprom --set-section-flags=.eeprom=alloc,load --no-change-warnings --change-section-lma .eeprom=0 $< $@

%.hex: %.elf
	avr-objcopy -O ihex -R .eeprom $< $@

%.upload: %.hex
	avrdude -p$(MCU) -carduino -P$(SER) -b$(BAUD) -D -Uflash:w:$<:i

%.hex: %.asm
	avra $< $@

clean:
	rm -f *.o *.elf *.hex *.eep
	rm -f arduino/core/*.o
	rm -f libcore.a

Adjust device names and defines if necessary. Play with baud rate if necessary.

To build blink.cpp, run

make blink.hex

To upload it, run

make blink.upload

Check Makefile to see how it works. It's simple.
Add more libraries when/if you need them.

Arduino is also really nice for learning AVR assembler. It's basically avr328 with simple and easy usb programming.
Install avra from AUR, get some example (blink-asm.asm), get def file for you mcu (m168def.inc for most Arduinos — just google it), run

make blink-asm.hex

to build it, run

make blink-asm.upload

to upload it to the device.
You don't need arduino library to write assembler code.

Last edited by axs (2012-10-17 09:27:20)

Offline

#28 2013-05-14 19:11:00

lesto
Member
Registered: 2010-07-13
Posts: 107

Re: The official Arduino thread

next version of arduino will be command-line capable, so no more black magic!
Stay tuned

Offline

#29 2013-05-19 03:51:15

Loser777
Member
Registered: 2011-05-12
Posts: 28

Re: The official Arduino thread

Nevermind, I don't know what happened... upload using programmer clearly doesn't work, but upload does;;

The arduino IDE from the AUR was working for me about a month ago. By working, I mean at least it could at least upload my sketches--the interface is pure garbage in dwm. The AUR hasn't updated the package since then, but now I'm getting a
avrdude: usbdev_open(): did not find any USB device "usb"
My /dev/tty/ACM0 still shows up and the rx light blinks when I'm sending stuff with pyserial, so it appears to be just and issue with avrdude.

I remember avrdude being updated fairly recently... anyone else have the arduino IDE broken as a result? For the mean time, I guess back to Windows uploading it is...

Last edited by Loser777 (2013-05-19 03:58:58)

Offline

#30 2013-05-19 09:17:07

lesto
Member
Registered: 2010-07-13
Posts: 107

Re: The official Arduino thread

i can't understand if you solved the problem or what.

Offline

#31 2013-08-23 04:41:49

kuma
Member
Registered: 2013-08-23
Posts: 2

Re: The official Arduino thread

Im using arch linux 2013.08.01 in eee pc 901, I've installedo arduino from AUR but when running it I got an error saying it cannot load class  com.sun.*.GTKLookandfeel, my JAVA_HOME env var is correctly set and also my PATH. I've downloaded arduino from arduino.cc web page and installed locally in my home directory with the same result and same error.  I think it must be a problem with arduino script for launching processing main app because looking at arduino script I see it sets CLASSPATH to several directories beneath arduino installation directory including a directory named java which does not exists,  any idea?

Offline

#32 2013-08-23 17:38:48

lesto
Member
Registered: 2010-07-13
Posts: 107

Re: The official Arduino thread

the missing directory is ok, it is for boundled java. can you post the full stack trace? with the element provided we can't do anything.

Offline

#33 2013-08-24 16:12:08

kuma
Member
Registered: 2013-08-23
Posts: 2

Re: The official Arduino thread

strangely now it works, only change is I've installed ttf-dejavu package

Offline

#34 2014-01-28 12:38:37

jiyunatori
Member
Registered: 2008-07-04
Posts: 53

Re: The official Arduino thread

Hi.

When compiling a sketch, I have thie following error:

Cannot run program "/usr/share/arduino/hardware/tools/avr/bin/avr-g++" no such file or directory

I can fix this by manually adding symlinks to avr-g++, avr-gcc, avr-ar and avr-objcopy but it's clearly not a long-term solution ...

Offline

Board footer

Powered by FluxBB