Arduino cheat sheet
Jump to navigation
Jump to search
Arduino + cygwin + ino (ano) ハマりどころメモ
Without Arduino IDE
- arduino を cygwin 環境内で build, upload したい。
arduino.cc の情報
Arduino from the Command Line
- によると
Arturo
- Arturo (a.k.a ano) というのがある。(ググったら ino というのがみつかるが、これがメンテされてないので ino のメンテナンス引き継ぎ版が ano のようだ)
- しかし cygwin で Windows 版 Arduino IDE のコンパイラーや avrdude を起動したばあい、(cygwin からは正しく見えるのに)パスの問題があるようだ。さっくり cygwin 環境で AVR toolchain を作ることにする。
- ano build のエラー
fatal error: Arduino.h: No such file or directory #include <Arduino.h>
- ano upload のエラー
avrdude: can't open config file "/usr/share/arduino/hardware/tools/avr/etc/avrdude.conf": No such file or directory avrdude: error reading system wide configuration file "/usr/share/arduino/hardware/tools/avr/etc/avrdude.conf"
cygwin 環境で AVR toolchain をビルド
cygwin 準備
Installing and Updating Cygwin for 32-bit versions of Windows
- 32bit バージョンをインストールする。(64bit バージョンは AVR toolchain のコンパイルに不具合あり)
- cygwin のパッケージは以下のものを入れる。
git wget unzip zip gperf bison flex make patch autoconf gcc-g++ libncurses-devel pkg-config python-setuptools
libusb問題
- cygwin のパッケージで libusb をインストールしている場合は avrdude の build で不具合があるので、あれば削除しておく。(もし必要なら avrdude の build で static link をやめる逃げ道はある)
FTDI USB serial driver (メモ書き)
- arduino のパッケージには FTDI 社のドライバが梱包されてる
http://www.ftdichip.com/Drivers/VCP.htm
arduino IDE 配置
- 先ほど arduino.cc の記述によると ano は arduino IDE versions 1.6.1 は動くとのこと。
Arduino 1.6.x, 1.5.x BETA
arduino-1.6.1-windows.exe
- をとってきてインストールする。
- Windows 版の IDE は最新をつかいたいので、version 1.6.1 は /Program Files/Arduino を /cygwin/usr/share 配下にコピーする。
- 名前は Arduino から arduino に変える。(たんなる趣味)
- Windows の権限管理の問題があるので arduino フォルダーのプロパティを開き、セキュリティ タブで *適切な設定* にしておく。
- Windows 版 IDE を最新したいなら、1.6.1 を uninstall して、再度最新版をインストールする。
AVR toolchain 配置
The AVR toolchain used by the Arduino IDE
- arduino IDE 1.6.1 の場合は release 3.4.5 である。tag を指定して git clone する。
git clone --depth=1 --branch 3.4.5 --single-branch https://github.com/arduino/toolchain-avr.git
- Readme.md にあるように texinfo の指定バージョン 4.13 は cygwin にないので、自分でコンパイルして配置する。
- ついでに automake-1.11.1 も cygwin のパッケージつかわないで自分でコンパイルして配置する。
texinfo-4.13.tar.gz
automake-1.11.1.tar.bz2
- arch.win32.build.bash はつかわない。なので MinGW 環境は不要。
- sourceforge の ごたごたで URL がかわってしまってソースが取れない。 build がコケるので事前にとって配置しておく。
wget http://distribute.atmel.no/tools/opensource/Atmel-AVR-GNU-Toolchain/3.4.5/avr8-headers-6.2.0.469.zip wget http://download.savannah.gnu.org/releases/avr-libc/avr-libc-1.8.0.tar.bz2 wget http://download.savannah.gnu.org/releases/avrdude/avrdude-6.0.1.tar.gz wget http://mirror.switch.ch/ftp/mirror/gnu/autoconf/autoconf-2.64.tar.bz2 wget http://mirror.switch.ch/ftp/mirror/gnu/automake/automake-1.11.1.tar.bz2 wget http://mirror.switch.ch/ftp/mirror/gnu/binutils/binutils-2.24.tar.bz2 wget http://mirror.switch.ch/ftp/mirror/gnu/gcc/gcc-4.8.1/gcc-4.8.1.tar.bz2 wget http://mirror.switch.ch/ftp/mirror/gnu/gdb/gdb-7.8.tar.xz wget http://mirror.switch.ch/ftp/mirror/gnu/gmp/gmp-5.0.2.tar.bz2 wget http://mirror.switch.ch/ftp/mirror/gnu/mpfr/mpfr-3.0.0.tar.bz2 wget http://download.sourceforge.net/project/libusb-win32/libusb-win32-releases/1.2.6.0/libusb-win32-bin-1.2.6.0.zip wget http://download.sourceforge.net/project/libusb/libusb-1.0/libusb-1.0.18/libusb-1.0.18.tar.bz2 wget http://download.sourceforge.net/project/libusb/libusb-compat-0.1/libusb-compat-0.1.5/libusb-compat-0.1.5.tar.bz2 wget http://www.multiprecision.org/mpc/download/mpc-0.9.tar.gz
bash build.all.bash
- 数時間コンパイルにかかる。
gdb でエラー
build.all.bash でなぜか以下のエラー
fhandler_disk_file::fixup_mmap_after_fork: requested 0xFFFA0000 != 0x0 mem alloc base 0xFFEB0000, state 0x2000, size 65536, Win32 error 487
- gdb.build.bash 単体なら出ない
- どうも cygwin 固有の問題らしい
- .bashrc に
export LANG=C export LC_ALL=C
- で解決。
- ちなみに cygwin terminal の locale は ja_JP.SJIS が良い。
avrdude.exe
- avrdude の serial port の指定は(もし Windows で認識しているポートが 'COM5' なら) /dev/ttyS4 が動かず '\\.\com5' で動く。
- COM ポートを指定したい場合は、Windows で
デバイスマネージャ -> ポート (COM と LPT) -> Arduino Uno (COM?) -> プロパティ -> ポートの設定 -> 詳細設定 -> COM ポート番号
- で変える。
giveio services
- これが起動しない。32bit only とのこと。あと giveio はいろいろ評判わるそう。
- パラレルポートの場合に必要とのこと。なので今回は無視。
libusb-win32 問題
- cygwin でコンパイルした avrdude.exe がいろいろ win32 系の dll を見るのでうざい
arduino usb serial の windows OS での初期化
- arduino の usb を刺しただけでは cygwin から serial device (COM5) としてみえてなので、windows OS で認識させる。
シリアルポートの使い方@windows
#!/bin/sh mode.com $1: BAUD=115200 PARITY=N DATA=8 STOP=1 to=off xon=off odsr=off octs=on dtr=off rts=on idsr=off
- このスクリプト動かす。
配置
- objdir を /usr/share/arduino/hardware/tools/ 配下にコピーし、tools ディレクトリの avr ディレクトリを avr.org にリネームして、objdir を avr にリネームする。
avrdude build メモメモ
- もし、libusb-win32 をつかわないで build する場合は libusb-1.0.18 にパッチを当てる。
diff -urN libusb-1.0.18.orig/libusb/os/windows_usb.h libusb-1.0.18/libusb/os/windows_usb.h --- libusb-1.0.18.orig/libusb/os/windows_usb.h 2014-01-09 08:55:51.000000000 +0900 +++ libusb-1.0.18/libusb/os/windows_usb.h 2015-08-27 12:55:34.000000000 +0900 @@ -46,7 +46,7 @@ #endif #if defined(__CYGWIN__ ) -#define _stricmp stricmp +#define _stricmp strcasecmp // cygwin produces a warning unless these prototypes are defined extern int _snprintf(char *buffer, size_t count, const char *format, ...); extern char *_strdup(const char *strSource);
- ややこしいので AVR toolchain を fork してパッチあてたので、これ使ってください
avr toolchain cygwin only
git clone -b cygwin_only https://github.com/nxhack/toolchain-avr.git cd toolchain-avr ./arch.cygwin.build.bash
Arturo (ano)
ano
Arturo
git clone https://github.com/scottdarch/Arturo.git
stty 周りのパッチをあてる。(かなり強引に)
- fork してパッチあてたもの
fork scottdarch/Arturo (for cygwin only)
git clone -b cygwin_only https://github.com/nxhack/Arturo.git cd Arturo make install
picocom
picocom
- picocom をインストール
ano の環境
- /etc/ano.ini or ~/.anorc
[build] board-model = uno cpu = 8MHzatmega328p arduino-dist = /usr/share/arduino [upload] board-model = uno cpu = 8MHzatmega328p arduino-dist = /usr/share/arduino serial-port = /dev/ttyS4 com-port = '\\.\com5' [serial] serial-port = /dev/ttyS4
ano の使い方
- ino と同じなので、arduino ino build とかでググってください
cygwin メモ
cygwin terminalのロケール
- ja_JP.SJIS がよさげ。
- かつ .bashrc に
export LANG=C export LC_ALL=C
- 矛盾してる設定だが、MS-DOS 的な SJIS の世界と Windows+cygwin の世界の落としどころかも。
cygwin terminalのショートカット
Mouse -> (ON) Clicks place command line cursor Mouse -> Right click action -> Paste
apt-cyg
apt-cyg
emacs
- .emacs
; Emacs 2x (cond ((> emacs-major-version 19) (progn (set-language-environment "Japanese") (setq default-enable-multibyte-characters t) (setq auto-coding-functions nil) (set-default-coding-systems 'sjis ) (set-buffer-file-coding-system 'sjis ) (set-terminal-coding-system 'sjis ) (setq default-buffer-file-coding-system 'sjis ) (setq default-terminal-coding-system 'sjis ) (set-keyboard-coding-system 'sjis) (set-clipboard-coding-system 'sjis) (setq inhibit-startup-message t) (setq initial-scratch-message nil) ;;(global-font-lock-mode nil) (require 'jka-compr) (auto-compression-mode 1) ))) ;; ;; whitespace ;; (require 'whitespace) (setq whitespace-style '(face ; faceで可視化 trailing ; 行末 tabs ; タブ empty ; 先頭/末尾の空行 space-mark ; 表示のマッピング tab-mark )) (setq whitespace-display-mappings '((tab-mark ?\t [? ?\t] [?\\ ?\t]))) (global-whitespace-mode 1) ; (setq-default scroll-step 1) (line-number-mode t) (column-number-mode t) (setq visible-bell t) (setq-default truncate-lines nil) (setq next-line-add-newlines nil) (setq minibuffer-max-depth nil) (setq initial-scratch-message nil) (setq inhibit-startup-message t) (setq-default c-basic-offset 4 ;;基本インデント量4 tab-width 4 ;;タブ幅4 indent-tabs-mode nil) ;;インデントをタブでするかスペースでするか