Official Arduino IDE does not agree with PI and it sucks any way.
[update] Platformio is a better way!
There are two major ways to compile and upload sketch files to Arduino: a. use IDEs (Arduino IDE, Emacs IDE, Fritzing or ArduIDE). or b. use a terminal. Arch official site explains well, however, most of it does not apply to RasPi with Arch Linux. It DOES work with regular Arch system. You can skip this section if you are using RasPI.
-
update Arch-pi and install whatever dependencies for Arduino, mine needed 3 and 4.
123sudo pacmam -Syy - arudio compile dependency
- libtinfo
-
fakeroot
123sudo pacman -S fakeroot -
install arduino IDE 1.6.4 – NOT working built on a Raspberry Pi by adding ‘armv6h’ to the arch=(‘i686’ ‘x86_64’) line like so arch=(‘i686’ ‘x86_64’ ‘armv7h’) in the PKGBUILD
Also, update replace x86-64 in the following lines with armv7h, after that it can be compiled with makepkg -s build and installed ok, but the IDE program has terminated prematurely with following error:
1234/usr/share/arduino/lib/libastylej.so: /usr/share/arduino/lib/libastylej.so: cannot open shared object file: No such file or directory (Possible cause: can't load IA 32-bit .so on a ARM-bit platform)Cannot load native library /usr/share/arduino/lib/libastylej.soPossible workaround here, I will stick with the solution below.
-
Install Python and related package
12345pacman -S python2-imagingpacman -S python2-pyserialpacman -S python2 python2-numpy openc - install arduino10 -same compile issue,
-
Download and unzip arduino-cmake
1234wget 'https://github.com/queezythegreat/arduino-cmake/archive/master.zip'unzip - Make proj folder with “build” folder and CMakeLists.txt
- CMakeLists.txt file update path and board info, fail to compile
The only way working for RasPI I figured out so far is to use arduino-mk with terminal or Emacs detailed in next section.
There are useful links: arduino-mk instruction arch AUR
-
install arduino-SDK older version, compile for armv7h and install -only working versin of arduino is this version – 1:1.5.8-4. Note: add this line arch=(‘i686’ ‘x86_64’ ‘armv7h’) to PKGBUILD file to compile, and install with following line. (please note: I discovered that arduino10 will compile, but does not work with arduino-mk).
123sudo pacman -U arduino-beta-1:1.5.8-4-armv7h.pkg.tar.xz -
compile arduino-mk and install
1234567wget 'https://aur.archlinux.org/packages/ar/arduino-mk/arduino-mk.tar.gz'tar -xvf arduino-mk.tar.gzcd arduino-mkmakepkg -ssudo pacman -U arduino-mk..tar.xz -
make project directory
123456mkdir ~/proj/sketchbookln -s /usr/share/arduino/Arduino.mkmkdir blinkcd blink12345678910111213141516sudo nano blink.ino// Blinkvoid setup(void) {pinMode(13, OUTPUT);}void loop() {digitalWrite(13, LOW);delay(1000);digitalWrite(13, HIGH);delay(1000);} -
Create Makefile for arduino >1.5 in the same folder with your ino sketch file
1234567891011121314sudo nano MakefileARDUINO_DIR = /usr/share/arduinoARDMK_DIR = /usr/share/arduinoAVR_TOOLS_DIR = /usrARDUINO_CORE_PATH = /usr/share/arduino/hardware/arduino/avr/cores/arduinoBOARDS_TXT = /usr/share/arduino/hardware/arduino/avr/boards.txtARDUINO_VAR_PATH = /usr/share/arduino/hardware/arduino/avr/variantsBOOTLOADER_PARENT = /usr/share/arduino/hardware/arduino/avr/bootloadersBOARD_TAG = uno #change accordingly e.g. megaARDUINO_LIBS =include /usr/share/arduino/Arduino.mk -
compile and upload
1234makemake upload - Other line command make – no upload make upload – compile and upload make clean – remove all our dependencies make depends – update dependencies make reset – reset the Arduino by tickling DTR on the serial port make raw_upload – upload without first resetting make show_boards – list all the boards defined in boards.txt
- Tag name is essential (uno and mega2560) tag in step 4
Emacs IDE for arduino (with arduino-beta 1.6.1 installed)
-
install arduino-mk if you did not already.
123yaourt -S arduino-mk - Get arduino-mode and CEDET if you do not have it
-
update your dot-emacs file
123456;; arduino-mode(require 'cl)(autoload 'arduino-mode "arduino-mode" "Arduino editing mode." t)(add-to-list 'auto-mode-alist '("\.ino$" . arduino-mode)) -
copy Makefile into sketch folder, this is a example working file:
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134# Arduino Make file. Refer to https://github.com/sudar/Arduino-MakefileBOARD_TAG = mega2560#include ../../Arduino.mk# --- leonardo (or pro micro w/leo bootloader)#BOARD_TAG = leonardo#MONITOR_PORT = /dev/ttyACM0#include /usr/share/arduino/Arduino.mk# --- mega2560 ide 1.0#BOARD_TAG = mega2560#ARDUINO_PORT = /dev/ttyACM0#include /usr/share/arduino/Arduino.mk# --- mega2560 ide 1.6BOARD_TAG = megaBOARD_SUB = atmega2560MONITOR_PORT = /dev/ttyACM0ARDUINO_DIR = /usr/share/arduino#ARDUINO_DIR = /where/you/installed/arduino-1.6.5include /usr/share/arduino/Arduino.mk# --- nano ide 1.0#BOARD_TAG = nano328#MONITOR_PORT = /dev/ttyUSB0#include /usr/share/arduino/Arduino.mk# --- nano ide 1.6#BOARD_TAG = nano#BOARD_SUB = atmega328#ARDUINO_DIR = /where/you/installed/arduino-1.6.5#include /usr/share/arduino/Arduino.mk# --- pro mini#BOARD_TAG = pro5v328#MONITOR_PORT = /dev/ttyUSB0#include /usr/share/arduino/Arduino.mk# --- sparkfun pro micro#BOARD_TAG = promicro16#ALTERNATE_CORE = promicro#BOARDS_TXT = $(HOME)/arduino/hardware/promicro/boards.txt#BOOTLOADER_PARENT = $(HOME)/arduino/hardware/promicro/bootloaders#BOOTLOADER_PATH = caterina#BOOTLOADER_FILE = Caterina-promicro16.hex#ISP_PROG = usbasp#AVRDUDE_OPTS = -v#include /usr/share/arduino/Arduino.mk# --- chipkit#BOARD_TAG = mega_pic32#MPIDE_DIR = /where/you/installed/mpide-0023-linux64-20130817-test#include /usr/share/arduino/chipKIT.mk# --- pinoccio#BOARD_TAG = pinoccio256#ALTERNATE_CORE = pinoccio#BOOTLOADER_PARENT = $(HOME)/arduino/hardware/pinoccio/bootloaders#BOOTLOADER_PATH = STK500RFR2/release_0.51#BOOTLOADER_FILE = boot_pinoccio.hex#CFLAGS_STD = -std=gnu99#CXXFLAGS_STD = -std=gnu++11#include /usr/share/arduino/Arduino.mk# --- fio#BOARD_TAG = fio#include /usr/share/arduino/Arduino.mk# --- atmega-ng ide 1.6#BOARD_TAG = atmegang#BOARD_SUB = atmega168#MONITOR_PORT = /dev/ttyACM0#ARDUINO_DIR = /where/you/installed/arduino-1.6.5#include /usr/share/arduino/Arduino.mk# --- arduino-tiny ide 1.0#ISP_PROG = usbasp#BOARD_TAG = attiny85at8#ALTERNATE_CORE = tiny#ARDUINO_VAR_PATH = $(HOME)/arduino/hardware/tiny/cores/tiny#ARDUINO_CORE_PATH = $(HOME)/arduino/hardware/tiny/cores/tiny#AVRDUDE_OPTS = -v#include /usr/share/arduino/Arduino.mk# --- arduino-tiny ide 1.6#ISP_PROG = usbasp#BOARD_TAG = attiny85at8#ALTERNATE_CORE = tiny#ARDUINO_DIR = /where/you/installed/arduino-1.6.5#include /usr/share/arduino/Arduino.mk# --- damellis attiny ide 1.0#ISP_PROG = usbasp#BOARD_TAG = attiny85#ALTERNATE_CORE = attiny-master#AVRDUDE_OPTS = -v#include /usr/share/arduino/Arduino.mk# --- damellis attiny ide 1.6#ISP_PROG = usbasp#BOARD_TAG = attiny#BOARD_SUB = attiny85#ALTERNATE_CORE = attiny#F_CPU = 16000000L#ARDUINO_DIR = /where/you/installed/arduino-1.6.5#include /usr/share/arduino/Arduino.mk# --- teensy3#BOARD_TAG = teensy31#ARDUINO_DIR = /where/you/installed/the/patched/teensy/arduino-1.0.6#include /usr/share/arduino/Teensy.mk# --- mighty 1284p#BOARD_TAG = mighty_opt#BOARDS_TXT = $(HOME)/arduino/hardware/mighty-1284p/boards.txt#BOOTLOADER_PARENT = $(HOME)/arduino/hardware/mighty-1284p/bootloaders#BOOTLOADER_PATH = optiboot#BOOTLOADER_FILE = optiboot_atmega1284p.hex#ISP_PROG = usbasp#AVRDUDE_OPTS = -v#include /usr/share/arduino/Arduino.mk# --- atmega328p on breadboard#BOARD_TAG = atmega328bb#ISP_PROG = usbasp#AVRDUDE_OPTS = -v#BOARDS_TXT = $(HOME)/arduino/hardware/breadboard/boards.txt#include /usr/share/arduino/Arduino.mk -
M-x compile make upload.
-
or, directly from terminal
1234make #to compilemake upload #to upload -
Note, if you encouter following error,
1234error: 'clearmessage' was not declared in this scopeclearmessage()see rational here https://www.arduino.cc/en/Tutorial/Variables and, move the function upwards until the error messages disappears. Arduino IDE tolerate this though.
MAY
About the Author:
Beyond 8 hours - Computer, Sports, Family...