ラベル Arch Linux の投稿を表示しています。 すべての投稿を表示
ラベル Arch Linux の投稿を表示しています。 すべての投稿を表示

2013年1月28日月曜日

Xtion Pro and OpenNI2 on Raspberry Pi

OpenNI2のversion up が去年の12月にありました。
暫く移行を躊躇していました。しかし、そろそろ考えないとならないので検証しました。
Raspberry PiへのOpenNI2のインストール方法は、---> Here click!

      Xtion Pro-->  Raspberry Pi  > Arch Linux  >  OpenNI2  >  LXDE  >  AP

本日テストをして、その結果から、OpenNI2に移行する事に決めました。
写真は、Color stream と Depth steam テストのsnap shotです。
上のDepth画像と、下のVideo画像は、対象は違います。
Depth Stream  (snap shot)
Video Stream (snap shot)
LXDE上で、それぞれOpenCVを使ってストリームを表示しましたが、スムーズに表示できました。十分使える範囲だと思います。
これで、懸案の、OpenNI2への移行もなんとかなりそうです。
ただし、コンパイル&リンクの時間は、以前より長いかもしれません。

このような検証をする為に、LXDEの環境も作ってありますが、やはり使っているとフラストレーションが溜ります。
今回も、実行モジュールができるまでは、MacからSSH接続をして、画面表示の状態を確認するときだけLXDEで画面を見ます。

PCLの入力システムとしてのRaspberry Pi + Xtionは、なかなかの組合せです。
ただし、NITEは、考えてはなりませぬ。

今回のOpenNI2も、Kinectを公式にはサポートできない。
だんだんと、Raspberry PiでKinectを使う事が難しくなってきた。

いよいよ、Kinect 2台は、農場の監視カメラか。。。。。

peace!

2013年1月24日木曜日

Configure a GPU memory size of a Raspberry Pi

RDCS機能強化の一環としてRamDiskとして使える容量を増やす為、BCM2835に割当てられているGPUメモリーを小さくしました。
「Raspberry Pi User Guide」や、ネットで調べてもArch Linuxでのやり方が出ていなかったでのRaspbianをdownloadして、SDカードから起動してraspi-configで設定。その後、raspi-configの内容を確認したら、/boot/config.txt に書き込んでいるようなので、/boot/config.txtを見てみたら、あら簡単。
gpu_mem=16

BEFORE
[root@rcmp-r03 ~]# free
                         total       used       free     shared    buffers     cached
Mem:         446772      52796      393976          0       8336      24740
-/+ buffers/cache:      19720     427052
Swap:       524284                0     524284
[root@rcmp-r03 ~]# vi  /boot/config.txt

gpu_mem=16                                                   add

[root@rcmp-r03 ~]# reboot

AFTER
[root@rcmp-r03 ~]# free
                       total       used       free     shared    buffers     cached
Mem:        495444       52256      443188          0       7896      24684
-/+ buffers/cache:      19676     475768
Swap:       524284                0      524284

peace!

2013年1月22日火曜日

An Installation of a Monkey http server (1.1.1) on a Raspberry Pi

Raspberry PiにHttp Serverを構築する必要がありました。
ロボット間通信は、いくつかの方法で実装していますが、その一部をHTTPに変える事にしました。その為に、軽量なhttp serverが必要です。NginXも試しましたが、cgiを動かす仕組みがなくadd onのソフトが必要なのであきらめました。robotのコントローラとして使っているのでRaspberry Piには、いろいろなソフトを入れたくない
消去法で Monkey http server 1.1.1 にしました。結果的には、Monkeyで良かった。

私の様な用途、つまり”公開”用でなく内部システムのHTTP Serverとして使うには、このようなLightweightで、Simpleなソフトが必要である。大きな収穫でした。
http://monkey-project.com/
Monkeyは、ネットにも情報がありませんでした。手探りでインストールしてみました。Apacheと同じ感じです。結果は、perlのCGI も動かせる様になりました。
I found a report about the Monkey http server performance.

Monkey v/s NginX on a Raspberry PI - Monkey Project

インストール後、この画面がでればOK
Monkey http server(1.1.1-5)に関する感想や、注意事項
1) 設定ファイル編集
/etc/monkey/sites/defaultなどの編集ではtab送りをしない。
起動できないなどのエラーになる。
2) perl cgi の実行は、不安定な感じ? 大丈夫
CGI moduleをload するが、そのmoduleの問題かなぁ。perl cgi自体はコンソールで動くし、MacやISPのサーバで動いている。
発見!ちゃんと動きます。試しにやったら動きました。
perl
print "Content-Type: text/html\r\n\r\n";
sh
/bin/echo -e "Content-Type: text/html\r\n\r\n"
CプログラムをCGI経由で試したがperlと比較にならないくらい早い。やはりSDカードからのloadが大きい。CGI機能の確認の為にperlを使っただけです。
3) 感覚的には、静的なページは、NginXや、Apacheよりも早いかもしれない。
ただし、Raspberry PiはI/O系が少し弱いので、http serverはどれでも良いかも
僕は、通常のWebサーバーとしては使わないので影響はないですが。。。
4) Monkey についての基本的な情報がない
EQ(Emotional Intelligence)の低いソフトなので、推奨するソフトではありません。EQの低さは、Windowsにはかわなないけど。開発者自身の解説本も充実しているRaspberry Piは最高ランクです。EQを考えるとIT業界は成り立たないですが、、、
5) CUI開発に於ける、ArchLinuxの利便性(Monkeyとは、関係ないが。。。)
このような情報の少ないソフトを導入するときは、サービス起動、停止、rebootなどを繰り返しますが、Arch Linuxは爆速なので作業が早く進みます。何たって、rebootしても15秒以内で戻ってきます。コーヒを入れる間もない。(笑
GUIが必要なソフトは、Macで開発して、CUIベースでできる物は、Raspberry Piで十分です。ただ、くれぐれもRaspberry Piは、それなりに使うのが良いのです。

ところで、Web Server なのか? HTTP Server なのか?
私の場合は、ロボットシステムの通信手段として使うので、HTTP Serverです。

 Monkey自体の問題ではありませんが、注意点が一つあります。pacmanでアップグレードすると設定ファイルが上書きされます。必ず、/etc/monkeyの設定はコピーしておいて下さい。ただし、upgradeにより設定方法の変更があるかもしれませんので、上書きされた内容の確認は必要です。(2013/03/25)

------------------------------------------------------------------------------------------------
(1) Install packages
(2) Configure files
(3) Make directories and files
(4) Run (manual)
(5) Configure the systemd

(1) Install packages
[root@rcmp-r03 ~]# pacman -Syu
[root@rcmp-r03 ~]# pacman -S perl perl-archive-zip if you need...
[root@rcmp-r03 ~]# pacman -S monkey


(2) Configure files
[root@rcmp-r03 ~]# vi /etc/monkey/monkey.conf

    "port 2001"         to    "port 80"            change  a port number you want

    "User nobody"    to    "User root"          change   your root group user
    "UserDir public_html"    to   "UserDir /home/nao/public_html  
    "PidFile /var/run/monkey/monkey.pid" ->
                                  "PidFile /var/log/monkey/monkey.pid"
                '/var/run' is a link to '/run'.   '/run' is a ramdisk on Arch Linux

[root@rcmp-r03 ~]# vi /etc/monkey/plugins.load
# CGI
 ===
# This plugin enable the CGI support in Monkey. CGI is an old
# interface and not recommended for production enviroments, due
# to it nature, it lack of performance.
#
Load /usr/lib/monkey/monkey-cgi.so                           enable
[root@rcmp-r03 ~]# vi /etc/monkey/sites/default
[HOST]
    # DocumentRoot :
    DocumentRoot /var/http                                         enable & set
[CGI]                                                                             enable
    # Per-vhost CGI matching, same rules as with the global match
    Match /cgi-bin/.*\.cgi                                               enable  
[root@rcmp-r03 ~]# vi /etc/monkey/plugins/cgi/cgi.conf
[CGI]
     Match /cgi-bin/.*\.cgi .*\.sh .*\.pl                            add extensions  

(3) Make directories and files
[root@rcmp-r03 ~]# touch /var/log/monkey/access.log
[root@rcmp-r03 ~]# touch /var/log/monkey/error.log
[root@rcmp-r03 ~]# chmod +w /var/log/monkey/access.log
[root@rcmp-r03 ~]# chmod +w /var/log/monkey/error.log
[root@rcmp-r03 ~]# mv /srv/http /var
[root@rcmp-r03 ~]# mkdir /var/http/cgi-bin
[root@rcmp-r03 ~]# rm -r /srv
[root@rcmp-r03 ~]# mkdir /var/run/monkey

(4) Run (Manual)
[root@rcmp-r03 ~]# monkey -D 
Monkey HTTP Daemon 1.1.1
Built : Dec 14 2012 14:16:18 (gcc 4.7.2)
Home  : http://monkey-project.com
* Process ID is 1677
* Server socket listening on Port 80 
* 5 threads, 101 client connections per thread, total 505
* Transport layer by liana in http mode
[2013/01/22 12:55:33] [   Info] HTTP Server started

(5) Configure a systemd service
[root@rcmp-r03 ~]# vi /etc/systemd/system/monkey.service
[root@rcmp-r03 ~]# cat /etc/systemd/system/monkey.service
[Unit]
Description=Monkey http server deamon
Required=network.target
After=network.target
[Service]
Type=forking
ExecStart=/usr/bin/monkey -D
ExecStop=/bin/kill $MAINPID
ExecReload=/bin/kill $MAINPID ; /usr/bin/monkey -D
PIDFile=/var/log/monkey/monkey.pid.80
PIDFile=/var/run/monkey.pid.80
[Install]
WantedBy=multi-user.target
[root@rcmp-r03 ~]# systemctl enable monkey.service
ln -s '/etc/systemd/system/monkey.service' '/etc/systemd/system/multi-user.target.wants/monkey.service'
[root@rcmp-r03 ~]# reboot


peace!

2013年1月19日土曜日

インストール / 設定関連のまとめ(自分用)

This post is a collection of posts to refer when I install  and configure software.

1st Oct. 2013 
HTTP サーバを、monkey よりlighttpd に変更
理由は、cgi系の処理が不安定なため。また、lighttpd関連の資料が多い。
gpasswd -a http root 本来は、設定してはいけない。
ただし、本ロボットシステムは閉じているので、ちょっと、暫定処置として。
基本的には、設定しなくなります。

4th Aug. 2013 
当初のSD-CARDイメージは、primary partition 上にOSイメージを展開していました。
従って、fdiskで、SD-Card全域利用の拡張操作が容易にできました。しかしながら、
新しいSDカード上のOS展開方法では、コマンドライン操作のSD-Card拡張は不可能です。従って、ubuntu の GPartedで拡張を行いました。
その方法を、下記のpostに記載しました。この処理の後に、これまでのpostに記述したようにOS環境構築を行ってください。

Raspberry Pi [実用]入門」 技術評論社刊 読者の方へ
上記 "4 Aug. 2013"のメッセージ内容は、
技術評論社のサポートサイトからダウンロードしたPDFファイル 「Chap 12-13補足」の、
”1.2 Arch Linux の起動とSDカード拡張” の内容に該当します。
下記post内容で、1.2項の処理を行ってください。1.3項 以降は変更ありません
よろしくお願いいたします。

Ubuntu 上のGPartedを使って、SDカード拡張をする方法

-----------------------------------------------------------------------------------------------

1. Design Philosoph and Concept 

(1) Design Philosoph and Concept of may robots
  Design Philosoph and Concept of may robots 設計思想、デザインについて

2. An installation manual (Arch Linux)

(1) ロボット開発用 ArchLinuxインストール(最初から固定IPアドレスなど)
    archlinux-hf-2013-07-22.img

(2) 忘備録用に、詳しく記述したインストール方法
    archlinux-hf-2013-02-11.img
    ウィンドシステムは、LXDE

(3) Old install manual            インストール説明書 (参考まで)

3. Arch Linux system software

(1) ネットワーク設定
  固定IPアドレスを、有線、無線LANに設定する方法 
   wpa_supplicant設定は, 上記(1)ArchLinux インストール(4.2)を参照

(2) ハード設定
  GPU memory size  変更方法

(3) Systemd関連
  systemd    説明 (Arch Linux HP)
  systemctl  コマンド簡易説明

(4) Mac から、Raspberry Pi のX Window Client を使う方法
  SHH Tunnel  X11 Client  (Raspberry Pi)とX11 Server (Mac)

(5) pacman
  Performance up pacman.d/mirrorlist変更

4. Packages for development 

(1) OpenNI2    2.1.0
  Arch Linux on Raspberry Pi :  Build & install

(2) OpenCV
  ArchLinux: pacman -S opencv
      OSX: sudo port install opencv  -> /opt/local/include/opencv2, /opt/local/lib

(2) HTTP Server
  Monkey http server インストール print "Content-Type: text/html\r\n\r\n";
  NginX http server インストール   (今は使っていない)
  Apache 2.4.3  (OSX 10.8.2) インストール


5. Others

(1) pacman error
  下記のエラーメッセージがでた時の対応
  “ error: failed to commit transaction (conflicting files) "
  > pacman -Syuf

(2) Sambaのインストール
    http://robot009.blogspot.jp/2013/08/an-installation-of-samba-on-raspberry.html

(3) Libre Office
  これは、OSXでの話です。writerで、文字入力が大変遅い時の対応というか
  基本的な設定かもしれなし。

  Preferences
        (1) Java
             check out -> java  "use a Java runtime environment"
        (2) Memory
             Undo                                       20-30

             Graphic cache           Libre   128
             per object                               20

peace!
-------------------------------------------------------------------

sudo diskutil unmount /dev/disk2s1
sudo dd bs=1M if=~/Downloads/rapi/archlinux-hf-2012-09-18.img of=/dev/rdisk2
/sbin/ip addr add local 192.168.11.70/24 dev wlan0 label wlan0:1
ip addr add 192.168.1.1/24 brd 192.168.1.255 dev eth1   ip addr show dev eth1
ip addr add 192.168.1.3/24 brd 192.168.1.255 dev eth1 label eth1:0
ip addr del 192.168.1.3 dev eth1
ip addr list   ip route   ip -s link   ifcong netstat ethtool
pacman -S ttf-dejavu ttf-bitstream-vera
find . -name \*.cgi -print0 | xargs -0 grep print /dev/null

ffmpeg -i aa.WMA -ar 16000 aa.wav
./julius/julius -C fast.jconf -input file -charconv EUC-JP UTF-8



[root@alarmpi ~]# dd if=/dev/zero of=/swapfile.img bs=1M count=512
512+0 records in
512+0 records out
536870912 bytes (537 MB) copied, 26.3849 s, 20.3 MB/s

------------------------------------------------------------------
Debian
(1) suto run # runlevel
# insserv
# update-rc.d -f exim4 remove
# update-rc.d exim4 defaults
   update-rc.d: using dependency based boot sequencing  このメッセージは無視
# insserv apache2
# sysv-rc-conf --list

(2) USB truble
libv4l2: error turning on stream: No space left on device
VIDIOC_STREAMON: No space left on device
---> separate USB BUS
lsusb -t
v4l2-ctl -d /dev/video0 --list-formats
sudo rmmod uvcvideo

sudo modprobe uvcvideo quirks=128

(3) wifi
mac address -> wifi wlanx

------------------------------------------------------------------
dd if=/dev/zero of=/swapfile.img bs=1M count=512; mkswap /swapfile.img; swapon /swapfile.img; cat /proc/swaps
vi /etc/fstab
/swapfile.img none swap sw 0 0
vi /etc/pacman.d/m*
hostnamectl set-hostname rcmp-r13; timedatectl set-timezone Japan; pacman -Syu wpa_supplicant wireless_tools
#edit /boot/config.txt
reboot

##-------------------------------------------------------
## configure network
## PC->target    FTP Tool
#copy   /root/*
#copy   /etc/conf.d
#change /etc/conf.d/network  (change static ip address)
#copy   /etc/wpa_supplicant/wap_sulicant.conf
#copy   /etc/systemd/system/network.service
systemctl disable dhcpcd@eth0.service
systemctl disable dhcpcd;systemctl enable network.service
reboot

##-------------------------------------------------------
ip addr
vi /etc/resolv.conf
pacman -S gcc make cmake pkg-config libtool git python2  glut  doxygen graphviz opencv ttf-bitstream-vera ttf-dejavu fswebcam unzip php opencv-samples eigen2 python2-numpy lighttpd lua51

#copy   /srv/http/*
systemctl enable lighttpd
systemctl start lighttpd
pacman -S lxde xorg-xinit xf86-video-fbdev  leafpad obconf gpicview gedit
mkdir ~/.config
mkdir  ~/.config/openbox
cp /etc/xdg/openbox/menu.xml /etc/xdg/openbox/rc.xml /etc/xdg/openbox/autostart ~/.config/openbox
xinit /usr/bin/lxsession

vi /etc/ssh/sshd_config
AllowTcpForwarding yes
X11Forwarding yes
X11DisplayOffset 10
X11UseLocalhost yes

#copy developping environement

reboot

##-END------------------------------------------------------




2013年1月16日水曜日

An Installation of OpenNI2 on Raspberry Pi. To use a Xtion.


An Installation of OpenNI2.2 on Raspberry Pi ---> Please see a new post.


New Release OpenNI2 (2.1.0.4 branch:develop)
I've built new OpenNI2 driver and modules as following.
This installation time is an hour.

a Xion, a Webcam, and a Webcam on the Raspberry Pi

(1) Buliding Prerequisites
[root@rcmp-r03 ~]# pacman -Syu
[root@rcmp-r03 ~]# pacman -S gcc
[root@rcmp-r03 ~]# pacman -S make cmake pkg-config
[root@rcmp-r03 ~]# pacman -S libusb
[root@rcmp-r03 ~]# pacman -S python2
[root@rcmp-r03 ~]# pacman -S freeglut
[root@rcmp-r03 ~]# pacman -S doxygen
[root@rcmp-r03 ~]# pacman -S graphviz
or
pacman -S gcc make cmake pkg-config 
pacman -S libusb python2 freeglut doxygen graphviz 

(2) Download  & uncompress OpenNI2 source. (branch:develop 2.1.0.4)
(26 Jan, 2013 : Both the 'master' and 'develop' were up-to-date.
It's necessary to confirm the version of  branches.) 
Please download a source zip file form Here.
  Download > OpenNI 2.0 source code is available on GitHub > branch develop
Assuming an installation directory "~/OpenNI2-develop".

(3) Set  compiler options for the ARM1176JZF-S
ARM compiler option web-site. HERE 

[root@rcmp-r03 ~]# cd OpenNI2-develop/ThirdParty/PSCommon/BuildSystem
[root@rcmp-r03 BuildSystem]# vi Platform.Arm
[root@rcmp-r03 BuildSystem]# cat Platform.Arm

ifeq "$(CFG)" "Release"
    # Hardware specifying flags
    #CFLAGS += -march=armv7-a -mtune=cortex-a8 -mfpu=neon -mfloat-abi=softfp #-mcpu=cortex-a8
  CFLAGS += -mtune=arm1176jzf-s -mfloat-abi=hard
    # Optimization level, minus currently buggy optimizing methods (which break bit-exact)
    #CFLAGS += -O3 -fno-tree-pre -fno-strict-aliasing
    # More optimization flags
   # CFLAGS += -ftree-vectorize -ffast-math -funsafe-math-optimizations -fsingle-precision-constant
endif

(4) Build
[root@rcmp-r03 OpenNI2-BuildSystem]# cd ../../..
[root@rcmp-r03 OpenNI2-develop]# make                             20-30 minites

(5) Packaging 
[root@rcmp-r03 OpenNI2-develop]# cd Redist
[root@rcmp-r03 Redist]# vi Redist.py
Line : 534
before
compilation_cmd = "make -j" + calc_jobs_number() + " CFG=" + configuration + " PLATFORM=" + platform + " > " + outfile + " 2>&1"
        if compilationMode == 'Rebuild':
after
compilation_cmd = "make -j1" + " CFG=" + configuration + " PLATFORM=" + platform + " > " + outfile + " 2>&1"
        if compilationMode == 'Rebuild':

[root@rcmp-r03 Redist]# ln -s /usr/bin/python2 /usr/bin/python
[root@rcmp-r03 Redist]# python ReleaseVersion.py arm      3 -5 minites
[root@rcmp-r03 Redist]# cd Final
[root@rcmp-r03 Final]# ls
OpenNI-Linux-Arm-2.1.0.tar.bz2

(6) Installation
[root@rcmp-r03 Final]# tar -jxvf OpenNI-Linux-Arm-2.1.0.tar.bz2
[root@rcmp-r03 Final]# cd OpenNI-2.1.0-arm
[root@rcmp-r03 Final]# sh install.sh


(7) Environment variable

[root@rcmp-r03 Final]# export OPENNI_DIR=/root/OpenNI2-develop
[root@rcmp-r03 Final]# export OPENNI2_INCLUDE=$OPENNI_DIR/Include
[root@rcmp-r03 Final]# export OPENNI2_REDIST=$OPENNI_DIR/Redist


(8) Testing
[root@rcmp-r03 Final]# cd Samples/Bin
[root@rcmp-r03 Bin]# SimpleRead
[00000000]        0
[00033369]        0
[00066738]        0
[00100107]        0
[00133477]        0
[00166846]        0
[00200215]        0
[00233584]        0
[00266954]        0
[00300323]        0
[00333692]        0

Success!

peace!

2013年1月11日金曜日

An installation of Arch Linux on Raspberry Pi : assign static IP (wired and wireless)

How to assign static IP addresses to  a wireless device and a wired device.

Raspberry Piで、有線/無線LANに、それぞれ固定IPアドレスを設定する方法。
13台のRaspberry Piで、問題なく稼動しています。
Please refer https://wiki.archlinux.org/index.php/Static_IP_and_DHCP
少し、なやんだ事があります。
両方とも固定にすると、立上げ時にデバイス認識できず起動せず。
起動後、再度sysmtectlでunitをstart させると正常に起動する。
結論から言うと、USBハブとの相性が悪かったみたい。その場合は、 (6) 2項を実施すると、問題なく動きます。boot時の様に、負荷が比較的高い状態で、かつ起動後最初のUSBハブ経由のwifi USB dongle認識に少し時間が必要な様です。他のデバイスでも発生する可能性がありますが、確かめてはいません。

Wifi dongle     : BUFFALO WLI-UC-GNM
Wired LAN      : 192.168.11.10
Wireless LAN  : 192.168.11.11
DNS             :  192.168.11.1  -> (4)

無線LANを使うには、wpa_supplicantパッケージのインストールと、
/etc/wpa_supplicant.confの設定が必要です。
Arch Linux installのページを参照して下さい。section 4.2 です。
手動で確認する手順も記述してあります。その後、下記手順をどうぞ

(1) Create the file /etc/conf.d/network
(2) Create the file /etc/systemd/system/network.service
(3) Run systemcrl
(4) Edit /etc/resolv.conf & reboot
(5) Check
(6) If you have  errors

設定が終わったら、Design Philosoph and Concept of my robots も見てね!

-------------------------------------------------------------------------------------------------
(1) Create the file /etc/conf.d/network
[root@rcmp-sv01 ~]# vi /etc/conf.d/network
[root@rcmp-sv01 ~]# cat /etc/conf.d/network
interfacew=wlan0
interface=eth0
addressw=192.168.11.10
address=192.168.11.11
netmask=24
broadcast=192.168.11.255
gateway=192.168.11.1

(2) Create the file /etc/systemd/system/network.service
 この設定は、無線LAN子機接続を優先して設定し、有線LANを補助として使う設定方法です。従って、起動時に無線LAN子機が取り外れている時には、エラーになります。そのような運用に問題がある場合には、serviceをそれぞれ作る事が必要です。

[root@rcmp-sv01 ~]# vi /etc/systemd/system/network.service
[root@rcmp-sv01 ~]# cat /etc/systemd/system/network.service
[Unit]
Description=Network Connectivity (Static IP wlan0 eth0)
Wants=network.target
Before=network.target
[Service]
Type=oneshot
RemainAfterExit=yes
EnvironmentFile=/etc/conf.d/network
ExecStart=/sbin/ip link set dev ${interfacew} up
ExecStart=/sbin/ip link set dev ${interface} up
ExecStart=/usr/sbin/wpa_supplicant -B -D wext -i ${interfacew} -c /etc/wpa_supplicant/wpa_supplicant.conf
ExecStart=/sbin/ip addr add ${addressw}/${netmask} broadcast ${broadcast} dev ${interfacew}
ExecStart=/sbin/ip addr add ${address}/${netmask} broadcast ${broadcast} dev ${interface}
ExecStart=/sbin/ip route add default via ${gateway}
ExecStop=/sbin/ip addr flush dev ${interfacew}
ExecStop=/sbin/ip addr flush dev ${interface}
ExecStop=/sbin/ip link set dev ${interfacew} down
ExecStop=/sbin/ip link set dev ${interface} down
[Install]
WantedBy=multi-user.target

(3) Run systemcrl
[root@rcmp-sv01 ~]# systemctl disable dhcpcd@eth0.service
rm '/etc/systemd/system/multi-user.target.wants/dhcpcd@eth0.service'
[root@rcmp-sv01 ~]# systemctl enable network.service
ln -s '/etc/systemd/system/network.service' '/etc/systemd/system/multi-user.target.wants/network.service'

(4) Edit /etc/resolv.conf & reboot
After a static IP address set on your Raspberry Pi, you  need to assign a  DNS address (nameserver) into /etc/resolv.conf.
If you are able to ping the following  address, you may try adding this nameserver to your /etc/resolv.conf file. It is the address of Google's primary DNS server.

[root@rcmp-sv01 ~]# ping -c 3 8.8.8.8
PING 8.8.8.8 (8.8.8.8) 56(84) bytes of data.
64 bytes from 8.8.8.8: icmp_seq=1 ttl=46 time=46.4 ms
64 bytes from 8.8.8.8: icmp_seq=2 ttl=46 time=50.1 ms
64 bytes from 8.8.8.8: icmp_seq=3 ttl=46 time=50.2 ms
--- 8.8.8.8 ping statistics ---
3 packets transmitted, 3 received, 0% packet loss, time 2003ms
rtt min/avg/max/mdev = 46.446/48.952/50.259/1.791 ms
[root@rcmp-sv01 ~]# vi /etc/resolv.conf
[root@rcmp-sv01 ~]# cat /etc/resolv.conf
# Generated by dhcpcd
# /etc/resolv.conf.head can replace this line
# /etc/resolv.conf.tail can replace this line
#nameserver 192.168.11.1                      # your DNS 
nameserver 8.8.8.8                            # 8.8.8.8 ping OK
nameserver 8.8.8.4

Insert a wifi dongle to your Raspberry Pi.

[root@rcmp-sv01 ~]# reboot

(5) Check
[root@rcmp-sv01 ~]# dmesg | grep eth0
[    2.326344] smsc95xx 1-1.1:1.0: eth0: register 'smsc95xx' at usb-bcm2708_usb-1.1, smsc95xx
USB 2.0 Ethernet, b8:27:eb:7a:da:c6
[   17.464573] IPv6: ADDRCONF(NETDEV_UP): eth0: link is not ready
[   18.971807] IPv6: ADDRCONF(NETDEV_CHANGE): eth0: link becomes ready
[   18.974373] smsc95xx 1-1.1:1.0: eth0: link up, 100Mbps, full-duplex, lpa 0x45E1
[root@rcmp-sv01 ~]# dmesg | grep wlan0
[   17.471293] IPv6: ADDRCONF(NETDEV_UP): wlan0: link is not ready
[   20.137110] wlan0: authenticate with xx:xx:xx:xx:44:74
[   20.282721] wlan0: send auth to xx:xx:xx:xx:44:74 (try 1/3)
[   20.284445] wlan0: authenticated
[   20.361233] wlan0: associate with xx:xx:xx:xx:44:74 (try 1/3)
[   20.365241] wlan0: RX AssocResp from xx:xx:xx:xx:44:74 (capab=0x431 status=0 aid=7)
[   20.381284] wlan0: associated
[   20.381465] IPv6: ADDRCONF(NETDEV_CHANGE): wlan0: link becomes ready
[root@rcmp-sv01 ~]# ip addr
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 16436 qdisc noqueue state UNKNOWN     link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
    inet 127.0.0.1/8 scope host lo
    inet6 ::1/128 scope host valid_lft forever preferred_lft forever
4: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP qlen 1000
    link/ether xx:xx:xx:xx:da:c6 brd ff:ff:ff:ff:ff:ff
    inet 192.168.11.11/24 brd 192.168.11.255 scope global eth0
    inet6 fe80::ba27:ebff:fe7a:dac6/64 scope link valid_lft forever preferred_lft forever
5: wlan0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq state UP qlen 100
    link/ether xx:xx:xx:xx:95:f4 brd ff:ff:ff:ff:ff:ff
    inet 192.168.11.10/24 brd 192.168.11.255 scope global wlan0
    inet6 fe80::126f:3fff:fe5b:95f4/64 scope link valid_lft forever preferred_lft forever

(6) If you have errors.
-   Check below files
     network, network.service, resolv.conf

-  Insert a sleep command
[Service]
Type=oneshot
RemainAfterExit=yes
EnvironmentFile=/etc/conf.d/network
ExecStart=/usr/bin/sleep 2
ExecStart=/sbin/ip link set dev ${interface} up

-  Last challenge.
It's a good luck charm   maybe.
[root@rcmp-sv01 ~]# ip addr add  local <ip address>/<mask> brd <broadcast>
                                      dev wlan0 label wlan0:0
[root@rcmp-sv01 ~]# reboot

peace!

pacman download performance up

(1) Change a mirror site
I changed the download mirror site from the default  to California US.
I got the high performance!

[root@rcmp-sv01 ~]# vi /etc/pacman.d/mirrorlist 
[root@rcmp-sv01 ~]# cat    etc/pacman.d/mirrorlist
#
# Arch Linux ARM repository mirrorlist
# Generated on 2013-01-02
#
## Geo-IP based mirror selection and load balancing
#Server = http://mirror.archlinuxarm.org/armv6h/$repo           ADD '#"

### United States
## Delaware
# Server = http://de.us.mirror.archlinuxarm.org/armv6h/$repo
## California
 Server = http://ca.us.mirror.archlinuxarm.org/armv6h/$repo    Delete '#'
## Nebraska
# Server = http://ne.us.mirror.archlinuxarm.org/armv6h/$repo
## New York
# Server = http://us.mirror.archlinuxarm.org/armv6h/$repo
## Virginia
# Server = http://va.us.mirror.archlinuxarm.org/armv6h/$repo

peace!

An installation of a nginx on Arch Linux , Raspberry Pi

I installed a nginx web server on Arch Linux, Raspberry PI.

(1) Installation
[root@rcmp-sv01 ~]# pacman -S nginx
resolving dependencies...
looking for inter-conflicts...
Targets (3): geoip-1.4.8-2  geoip-database-20121207-1  nginx-1.2.6-1
Total Download Size:    1.11 MiB
Total Installed Size:   3.80 MiB
Proceed with installation? [Y/n] y
:: Retrieving packages from extra...
 geoip-database-2012...   715.0 KiB  13.4K/s 00:54 [######################] 100%
 geoip-1.4.8-2-armv6h     115.5 KiB  2.42K/s 00:48 [######################] 100%
:: Retrieving packages from community...
 nginx-1.2.6-1-armv6h     309.0 KiB  9.40K/s 00:33 [######################] 100%
(3/3) checking package integrity                   [######################] 100%
(3/3) loading package files                        [######################] 100%
(3/3) checking for file conflicts                  [######################] 100%
(3/3) checking available disk space                [######################] 100%
(1/3) installing geoip-database                    [######################] 100%
(2/3) installing geoip                             [######################] 100%
(3/3) installing nginx                             [######################] 100%

(2) Create a unit file of nginx
[root@rcmp-sv01 ~]# vi /etc/systemd/system/nginx.service
[root@rcmp-sv01 ~]# cat /etc/systemd/system/nginx.service
[[Unit]
Description=The nginx HTTP and reverse proxy server
After=syslog.target network.target remote-fs.target nss-lookup.target

[Service]
Type=forking
PIDFile=/run/nginx.pid
ExecStartPre=/usr/sbin/nginx -t
ExecStart=/usr/sbin/nginx
ExecReload=/bin/kill -s HUP $MAINPID
ExecStop=/bin/kill -s QUIT $MAINPID
PrivateTmp=true

[Install]
WantedBy=multi-user.target

(3) RUN
[root@rcmp-sv01 ~]# systemctl enable /etc/systemd/system/nginx.service
ln -s '/etc/systemd/system/nginx.service' '/etc/systemd/system/multi-user.target.wants/nginx.service'
[root@rcmp-sv01 ~]# systemctl start /etc/systemd/system/nginx.service

(4) configuration
[root@rcmp-sv01 ~]# cat /etc/nginx/nginx.conf
#user html;
worker_processes  1;
#error_log  logs/error.log;
#error_log  logs/error.log  notice;
#error_log  logs/error.log  info;
#pid        logs/nginx.pid;
events {
    worker_connections  1024;
}
http {
    include       mime.types;
    default_type  application/octet-stream;
    #log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '
    #                  '$status $body_bytes_sent "$http_referer" '
    #                  '"$http_user_agent" "$http_x_forwarded_for"';
    #access_log  logs/access.log  main;
    sendfile        on;
    #tcp_nopush     on;
    #keepalive_timeout  0;
    keepalive_timeout  65;
    #gzip  on;
    server {
        listen       80;
        server_name  localhost;
        #charset koi8-r;
        #access_log  logs/host.access.log  main;
        location / {
            root   /usr/share/nginx/html;
            index  index.html index.htm;
        }
        #error_page  404              /404.html;
        # redirect server error pages to the static page /50x.html
        #
        error_page   500 502 503 504  /50x.html;
        location = /50x.html {
            root   /usr/share/nginx/html;
        }
    }
}

peace!

2013年1月10日木曜日

Memo : Arch Linux systemd & Raspberry Pi weak

systemdでは、制御対象をunit ( = daemon) と言う。
systemctl コマンドを使って管理する。その途中で、Raspberry Piならではの発見!
抜群のコストパフォーマンスなので気にしないが全て外部電源に依存しているので、
どっきり!43 years and 0 months ago なんて表示  (3)を参照。
こういう所も、分かって"良い道具"として使います。

最近は、PC、スマートフォンどんどん、性能が良くなっても、性能・機能の1割も使いこなしていないのでは無いでしょうか?
しかし、Raspberry Piは、自分の創造力次第で、性能以上の事ができるコンピュータだ。
創造力の無い人には、単なる「ちょっと、試してみたいデバイス」だが。

しかし、最近の人の歩く姿を見ていると、つくづく思う。 人間は、前を見定めて生きるもの、下(スマホ)をみながら生きるべきではない。

本題のsystemdですが、、、結局 man systemdが一番詳しいので訳しています。
私の場合、ロボットのservice nodeのコンピュターの為に、ちゃんと理解しないとならない。とりあえず、systemctl について簡単に!

(1) UNIT 一覧 
(2) UNIT 一覧 error 表示
(3) UNIT 状態表示
(4) UNIT 開始(start),  停止(stop)
(5) UNIT 自動起動(enable)、停止(disable)

-------------------------------------------------------------------------------------------------
(1) UNIT の一覧  (赤字は、自分の設定)
[root@rcmp-sv01 ~]# systemctl      or     systemdctl --all
UNIT                        LOAD   ACTIVE SUB       DESCRIPTION
proc-sys...t_misc.automount   loaded active waiting   Arbitrary Executable File Fo
sys-devi...y-ttyAMA0.device   loaded active plugged   /sys/devices/dev:f1/tty/ttyA
sys-devi...-net-eth0.device     loaded active plugged   ec00
sys-devi...net-wlan0.device    loaded active plugged   802.11_n_WLAN
<略>
dhcpcd@eth0.service             loaded active running   dhcpcd on eth0
getty@tty1.service                  loaded active running   Getty on tty1
<略>
netwifistaticip.service              loaded active exited    Network Connectivity
openntpd.service                     loaded active running   OpenNTP Daemon
sshd.service                            loaded active running   OpenSSH Daemon
<略>
rdcs-crd.service                      loaded active running  RDCS Coordinator service
rdcs-cpr.service                      loaded active running  RDCS Cooperative service
rdcs-img.service                      loaded active running  RDCS Imaging service
rdcs-wcs.service                     loaded active running  RDCS Work Control Schedule service
rdcs-fr.service                          loaded active running  RDCS Fail safe Recovery service
rdcs-rc.service                         loaded active running  RDCS Resource Control service
rdcs-sd.service                        loaded active running  RDCS Space Database service
rdcs-log.service                        loaded active running  RDCS Log service
rdcs-rs.service                         loaded active running  RDCS Recognize ing  service
syslog.target                             loaded active active    Syslog
systemd-...iles-clean.timer loaded active waiting   Daily Cleanup of Temporary D
LOAD   = Reflects whether the unit definition was properly loaded.

ACTIVE = The high-level unit activation state, i.e. generalization of SUB.

SUB    = The low-level unit activation state, values depend on unit type.

62 loaded units listed. Pass --all to see loaded but inactive units, too.

To show all installed unit files use 'systemctl list-unit-files'.



(2) UNIT の一覧 error 表示
SSH接続なので、下記のエラーが発生しています。


<略>
auditd.service                     error  inactive dead      auditd.service
cronie.service                     loaded active   running   Periodic Command Scheduler
dbus.service                       loaded active   running   D-Bus System Message Bus
dhcpcd@eth0.service        loaded active   running   dhcpcd on eth0
display-manager.service    error  inactive dead      display-manager.service
emergency.service             loaded inactive dead      Emergency Shell
getty@tty1.service             loaded active   running   Getty on tty1
netwifistaticip.service         loaded active   exited    Network Connectivity
openntpd.service                loaded active   running   OpenNTP Daemon
plymouth-quit-wait.service  error  inactive dead      plymouth-quit-wait.service
plymouth-start.service        error  inactive dead      plymouth-start.service
rc-local.service                    error  inactive dead      rc-local.service
<略>

(3) UNITの状態表示 Weakness of Raspberry Pi
ちゃんと、動いています。やっぱり、サーバはstatic IPにしておかないといろいろ大変
下記の表示は、すごく面白い事があります。
何と、43年前から動いている事になっています。 (-_-)???
Raspberry Piは、電源を全て外部電源に依存しています。従って、通常のコンピュータであれば可能な、タイマーの保持ができません。下記のUNITは、固定アドレスでwifiを立上げるUNITの情報です。当然、wifiでネットが立上がってから、ntpdの同期ですから、このような事が発生します。RaspberryPiのコストパフォーマンスを考えれば、ご愛嬌です。その為に、RDCSのシステムでは、対策を実装しました。

[root@rcmp-sv01 ~]# systemctl  status netwifistaticip.service
netwifistaticip.service - Network Connectivity
 Loaded: loaded (/etc/systemd/system/netwifistaticip.service; enabled)
 Active: active (exited) since Thu, 1970-01-01 09:00:08 JST; 43 years and 0 months ago
Process: 155 ExecStart=/sbin/ip route add default via ${gateway} (code=exited, status=0/SUCCESS)
Process: 152 ExecStart=/sbin/ip addr add ${address}/${netmask} broadcast ${broadcast} dev ${interface} (code=exited, status=0/SUCCESS)
Process: 126 ExecStart=/usr/sbin/wpa_supplicant -B -Dwext -i${interface} -c/etc/wpa_supplicant/wpa_supplicant.conf (code=exited, status=0/SUCCESS)
Process: 111 ExecStart=/sbin/ip link set dev ${interface} up (code=exited, status=0/SUCCESS)
 CGroup: name=systemd:/system/netwifistaticip.service
 └─151 /usr/sbin/wpa_supplicant -B -Dwext -iwlan0 -c/etc/wpa...
Jan 01 09:00:08 cmp-sv01 systemd[1]: Started Network Connectivity.

(4) UNITの開始(start), 停止(stop)
[root@rcmp-sv01 ~]# systemctl  start netwifistaticip.service
[root@rcmp-sv01 ~]# systemctl  stop netwifistaticip.service

(5) UNITの自動起動(enable)と、停止(disable)
[root@rcmp-sv01 ~]# systemctl  enable  netwifistaticip.service
[root@rcmp-sv01 ~]# systemctl  disable netwifistaticip.service

peace!