7,166
edits
(36 intermediate revisions by the same user not shown) | |||
Line 47: | Line 47: | ||
ソフトウェアの情報は LLC に合わせている。 | ソフトウェアの情報は LLC に合わせている。 | ||
Arduino Yun の面白さ(逆に難しさ) | Arduino Yun の面白さ(逆に難しさ)はマイコン屋の知識と、UNIX屋・ネットワーク屋の知識と、Web屋の知識がすべて必要なところ。それぞれの専門家からみたら他方はブラックボックスに見えて理解の妨げになっているようだ。Arduino Yun の使い方・付き合い方は多方面から見てあげることが大切だ。 | ||
= 導入 = | = 導入 = | ||
Line 140: | Line 140: | ||
</syntaxhighlight> | </syntaxhighlight> | ||
'''注意''' : '''すべての設定やデータが消えます。''' | '''注意''' : '''すべての設定やデータが消えます。'''(luci の backup / restore を使う方法もあり) | ||
'''注意''' : '''アップデート後、もういちどWiFiの設定を最初からやり直す事。''' | '''注意''' : '''アップデート後、もういちどWiFiの設定を最初からやり直す事。''' | ||
Line 197: | Line 197: | ||
(echo o; echo n; echo p; echo 1; echo; echo +15G; echo n; echo p; echo 2; echo; echo; echo t; echo 1; echo c; echo w) | fdisk /dev/sda | (echo o; echo n; echo p; echo 1; echo; echo +15G; echo n; echo p; echo 2; echo; echo; echo t; echo 1; echo c; echo w) | fdisk /dev/sda | ||
mkfs.vfat /dev/sda1 | mkfs.vfat /dev/sda1 | ||
# mkfs.fat /dev/sda1 | |||
mkfs.ext4 /dev/sda2 | mkfs.ext4 /dev/sda2 | ||
mkdir -p /mnt/sda2 | mkdir -p /mnt/sda2 | ||
Line 527: | Line 528: | ||
[http://xx-prime.hatenablog.com/entry/2015/04/26/224618 Arduino yunで放射線センサのデータをxivelyとM2Xにアップロードする - XX-Prime's blog] | [http://xx-prime.hatenablog.com/entry/2015/04/26/224618 Arduino yunで放射線センサのデータをxivelyとM2Xにアップロードする - XX-Prime's blog] | ||
[http://qiita.com/kassy_kz/items/ebeda9bcda444cf401a0 IFTTTを用いてArduinoからツイートする | [http://qiita.com/kassy_kz/items/ebeda9bcda444cf401a0 IFTTTを用いてArduinoからツイートする] | ||
[https://github.com/itman83/ArduinoYun https://github.com/itman83/ArduinoYun] | [https://github.com/itman83/ArduinoYun https://github.com/itman83/ArduinoYun] | ||
Line 574: | Line 575: | ||
{ | { | ||
uint8_t sreg = SREG; | uint8_t sreg = SREG; | ||
noInterrupts(); // Protect from a scheduler and prevent transactionBegin | noInterrupts(); // Protect from a scheduler and prevent transactionBegin | ||
if (!initialized) { | if (!initialized) { | ||
// Set SS to high so a connected chip will be "deselected" by default | // Set SS to high so a connected chip will be "deselected" by default | ||
uint8_t port = digitalPinToPort(SS); | uint8_t port = digitalPinToPort(SS); | ||
uint8_t bit = digitalPinToBitMask(SS); | uint8_t bit = digitalPinToBitMask(SS); | ||
volatile uint8_t *reg = portModeRegister(port); | volatile uint8_t *reg = portModeRegister(port); | ||
// if the SS pin is not already configured as an output | // if the SS pin is not already configured as an output | ||
// then set it high (to enable the internal pull-up resistor) | // then set it high (to enable the internal pull-up resistor) | ||
if(!(*reg & bit)){ | if(!(*reg & bit)){ | ||
digitalWrite(SS, HIGH); | digitalWrite(SS, HIGH); | ||
} | } | ||
// When the SS pin is set as OUTPUT, it can be used as | // When the SS pin is set as OUTPUT, it can be used as | ||
// a general purpose output port (it doesn't influence | // a general purpose output port (it doesn't influence | ||
// SPI operations). | // SPI operations). | ||
pinMode(SS, OUTPUT); | pinMode(SS, OUTPUT); | ||
// Warning: if the SS pin ever becomes a LOW INPUT then SPI | // Warning: if the SS pin ever becomes a LOW INPUT then SPI | ||
// automatically switches to Slave, so the data direction of | // automatically switches to Slave, so the data direction of | ||
// the SS pin MUST be kept as OUTPUT. | // the SS pin MUST be kept as OUTPUT. | ||
SPCR |= _BV(MSTR); | SPCR |= _BV(MSTR); | ||
SPCR |= _BV(SPE); | SPCR |= _BV(SPE); | ||
Line 606: | Line 607: | ||
</syntaxhighlight> | </syntaxhighlight> | ||
で RX LED が付きっぱなしの条件でも RX LED は消灯することができる。 | で RX LED が付きっぱなしの条件でも RX LED は消灯することができる。 | ||
ちなみに、複数の SPI デバイスを使う場合は、SPI Library で初期化する前に、すべての SPI デバイスの CS を必ず HIGH にしておくこと。 | |||
<syntaxhighlight lang="cpp" enclose="div"> | |||
/* Prepare for using multiple SPI devices */ | |||
pinMode(SPI1_CS, OUTPUT); | |||
digitalWrite(SPI1_CS, HIGH); | |||
pinMode(SPI2_CS, OUTPUT); | |||
digitalWrite(SPI2_CS, HIGH); | |||
/* Init SPI lib */ | |||
SPI.begin(); | |||
</syntaxhighlight> | |||
== DS3234 の SQW と Alarm == | == DS3234 の SQW と Alarm == | ||
Line 816: | Line 829: | ||
<syntaxhighlight lang="bash" enclose="div"> | <syntaxhighlight lang="bash" enclose="div"> | ||
opkg install dosfsck | opkg install dosfsck | ||
# opkg install dosfstools | |||
umount /dev/sdb1 | umount /dev/sdb1 | ||
dosfsck -t -a -w /dev/sdb1 | dosfsck -t -a -w /dev/sdb1 | ||
# fsck.fat -t -a -w /dev/sda1 | |||
/sbin/block mount | /sbin/block mount | ||
</syntaxhighlight> | </syntaxhighlight> | ||
Line 1,011: | Line 1,026: | ||
= Yun を 無線(Wi-Fi) 有線(Ethernet) コンバータとして使う = | = Yun を 無線(Wi-Fi) 有線(Ethernet) コンバータとして使う = | ||
[https://lede-project.org/docs/user-guide/relay_configuration Wifi Extender or Repeater or Bridge Configuration] | |||
[https://wiki.openwrt.org/doc/recipes/relayclient Routed Client with relayd (Pseudobridge)] | |||
[http://ultimania.org/trac/yuna/wiki/linux/OpenWrt2 http://ultimania.org/trac/yuna/wiki/linux/OpenWrt2] | [http://ultimania.org/trac/yuna/wiki/linux/OpenWrt2 http://ultimania.org/trac/yuna/wiki/linux/OpenWrt2] | ||
<syntaxhighlight lang="bash" enclose="div"> | <syntaxhighlight lang="bash" enclose="div"> | ||
Line 1,018: | Line 1,034: | ||
opkg install relayd | opkg install relayd | ||
opkg install luci-proto-relay | opkg install luci-proto-relay | ||
/etc/init.d/relayd enable | |||
/etc/init.d/relayd start | |||
</syntaxhighlight> | </syntaxhighlight> | ||
Luci 使えば簡単だった。 | Luci 使えば簡単だった。 | ||
↓は LEDE 公式資料なので IF 名が Yun と違うので注意。(Yun は wan が eth1、lan が wifi) | |||
[https://lede-project.org/_media/docs/guide-user/wifirepeater_interfaces_lan.png https://lede-project.org/_media/docs/user-guide/wifirepeater_interfaces_lan.png] | |||
[https://lede-project.org/_media/docs/guide-user/wifirepeater_newinterface.png https://lede-project.org/_media/docs/user-guide/wifirepeater_newinterface.png] | |||
[https://lede-project.org/_media/docs/guide-user/wifirepeater_relaybridge1.png https://lede-project.org/_media/docs/user-guide/wifirepeater_relaybridge1.png] | |||
[https://lede-project.org/_media/docs/guide-user/wifirepeater_relaybridge2.png https://lede-project.org/_media/docs/user-guide/wifirepeater_relaybridge2.png] | |||
[https://lede-project.org/_media/docs/guide-user/wifirepeater_firewall.png https://lede-project.org/_media/docs/user-guide/wifirepeater_firewall.png] | |||
↓を再度確認のこと。(Yun は wan が eth1) | |||
eth1 に ダミーの IP を振る。 | |||
<syntaxhighlight lang="text" enclose="div"> | |||
config interface 'wan' | |||
option ifname 'eth1' | |||
option proto 'static' | |||
option ipaddr '192.168.2.1' | |||
option netmask '255.255.255.0' | |||
config interface 'repeater_bridge' | |||
option proto 'relay' | |||
list network 'lan' | |||
list network 'wan' | |||
</syntaxhighlight> | |||
最後に relayd を restart | |||
<syntaxhighlight lang="bash" enclose="div"> | |||
/etc/init.d/relayd restart | |||
</syntaxhighlight> | |||
relayd の '-I' オプションは ARP cache を頻繁に行うようで気持ち悪い '-i' に変えてみた。が、動かなかった。'-I' に戻した。 | |||
最終的に ARP storm 問題が気になったので、いろいろ試したが解決せず、relayd を使わずに、静的な bridge 構成にした。 | |||
bridge しているインターフェースには proxy_arp を有効にすること。 | |||
= Security = | = Security = | ||
Line 1,062: | Line 1,114: | ||
= Arduino Yún LininoOS 差分 = | = Arduino Yún LininoOS 差分 = | ||
* Arduino LLC 版 Arduino IDE で「ライブラリを管理...」から MCU 側の Ciao Library がインストールできるようになっていた。 | *Arduino LLC 版 Arduino IDE で「ライブラリを管理...」から MCU 側の Ciao Library がインストールできるようになっていた。 | ||
* Bridge Library か Ciao Library かは選択可能のように記述されている。(どちらか推奨があるわけではないみたい) | *Bridge Library か Ciao Library かは選択可能のように記述されている。(どちらか推奨があるわけではないみたい) | ||
* luci-app-arduino-webpanel (Linino 版) と Arduino-OS (arduinoos) かはこれも様子見っぽい。Arduino-OS は野心的なので安定するまでは様子見したほうがよさげ。 | *luci-app-arduino-webpanel (Linino 版) と Arduino-OS (arduinoos) かはこれも様子見っぽい。Arduino-OS は野心的なので安定するまでは様子見したほうがよさげ。 | ||
* LininoIO はまだ水面下っぽい。(MCUIO driver 系) コンセプトは素晴らしいが、vanilla kernel に取り込まれる勢いで OpenWrt / LEDE に入らないと将来はあやしい。 | *LininoIO はまだ水面下っぽい。(MCUIO driver 系) コンセプトは素晴らしいが、vanilla kernel に取り込まれる勢いで OpenWrt / LEDE に入らないと将来はあやしい。 | ||
**こんなのあるんだ。これを拡張するのかな [https://www.kernel.org/doc/html/latest/driver-api/iio/index.html Industrial I/O (IIO)] | |||
* 公式版 LininoOS (LininoIO 版) は Barrier Breaker(14.07) ベース。 (/etc/linino_version には attitude_adjustment とあるが)(あかん..) | *公式版 LininoOS (LininoIO 版) は Barrier Breaker(14.07) ベース。 (/etc/linino_version には attitude_adjustment とあるが)(あかん..) | ||
* Chaos Calmer(15.05) ベースの LininoOS もあることはある。 | *Chaos Calmer(15.05) ベースの LininoOS もあることはある。 | ||
= link = | = link = |