3. MacからSSHで作業をします。
3-1 まずは、更新
ssh root@192.168.11.13
vi /etc/pacman.d/mi*
で、サーバを近そうな所に変更してから、、、
pacman -Syu
10分くらいね。
3-2 Ethernet接続を固定アドレスにする。
cd /etc/netctl
cp examples/ethernet-static ./eth0Static
vi eth0Static
この部分を、
Address=('192.168.1.23/24' '192.168.1.87/24')
#Routes=('192.168.0.0/24 via 192.168.1.2')
Gateway='192.168.1.1'
DNS=('192.168.1.1')
自分の開発環境に合わせて、アドレスを設定します。
Address=('192.168.11.131/24')
#Routes=('192.168.0.0/24 via 192.168.1.2')
Gateway='192.168.11.1'
DNS=('192.168.11.1')
netctl enable eth0Static
3-3 ホスト名を、自分のルールに合わせて変更します。
hostnamectl set-hostname rcmp-r31
vi /etc/hosts
cat /etc/hosts
#
# /etc/hosts: static lookup table for host names
#
#<ip-address> <hostname.domain.org> <hostname>
127.0.0.1 localhost.localdomain localhost rcmp-r31
::1 localhost.localdomain localhost rcmp-r31
# End of file
3-4 ユーザの追加
以後は、このユーザで作業をします。sudoを使えるようにwheelグループに登録します。
useradd -m rbt
passwd rbt
Enter new UNIX password:
Retype new UNIX password:
passwd: password updated successfully
gpasswd -a rbt wheel
gpasswd -a rbt video (option)
gpasswd -a rbt audio (option)
gpasswd -a rbt power (option)
gpasswd -a rbt uucp (option)
gpasswd -a rbt dialout (option)
pacman -S sudo
visudo
wheelがコメントになっているので、下記のように変更する
## Uncomment to allow members of group wheel to execute any command
%wheel ALL=(ALL) ALL
reboot
参考: useradd -m -g users -G wheel -s /bin/bash rbt
4.再度、SSHでログイン
ssh rbt@192.168.11.131
rbt@192.168.11.131's password:
Welcome to Arch Linux ARM
Website: http://archlinuxarm.org
Forum: http://archlinuxarm.org/forum
IRC: #archlinux-arm on irc.Freenode.net
[rbt@rcmp-r31 ~]$
こんな感じで、ちゃんとログインができればよいです。
その後は、sudoで作業ができます。
でも、最初は、ちょっとビックリかも、、、
4-1 SDカード目一杯使います。
sudo fdisk /dev/mmcblk0
Welcome to fdisk (util-linux 2.27.1).
Changes will remain in memory only, until you decide to write them.
Be careful before using the write command.
Command (m for help): p
Disk /dev/mmcblk0: 14.7 GiB, 15804137472 bytes, 30867456 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: dos
Disk identifier: 0x4bce3dec
Device Boot Start End Sectors Size Id Type
/dev/mmcblk0p1 2048 206847 204800 100M c W95 FAT32 (LBA)
/dev/mmcblk0p2 206848 7000000 6793153 3.2G 83 Linux
Command (m for help): d
Partition number (1,2, default 2):
Partition 2 has been deleted.
Command (m for help): n
Partition type
p primary (1 primary, 0 extended, 3 free)
e extended (container for logical partitions)
Select (default p): p
Partition number (2-4, default 2):
First sector (206848-30867455, default 206848):
Last sector, +sectors or +size{K,M,G,T,P} (206848-30867455, default 30867455):
Created a new partition 2 of type 'Linux' and of size 14.6 GiB.
Command (m for help): p
Disk /dev/mmcblk0: 14.7 GiB, 15804137472 bytes, 30867456 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: dos
Disk identifier: 0x4bce3dec
Device Boot Start End Sectors Size Id Type
/dev/mmcblk0p1 2048 206847 204800 100M c W95 FAT32 (LBA)
/dev/mmcblk0p2 206848 30867455 30660608 14.6G 83 Linux
Command (m for help): w
The partition table has been altered.
Calling ioctl() to re-read partition table.
Re-reading the partition table failed.: Device or resource busy
The kernel still uses the old table. The new table will be used at the next reboot or after you run partprobe(8) or kpartx(8).
sudo reboot
[rbt@rcmp-r31 ~]$ sudo resize2fs /dev/mmcblk0p2
[sudo] password for rbt:
resize2fs 1.42.13 (17-May-2015)
Filesystem at /dev/mmcblk0p2 is mounted on /; on-line resizing required
old_desc_blocks = 1, new_desc_blocks = 2
The filesystem on /dev/mmcblk0p2 is now 3832576 (4k) blocks long.
[rbt@rcmp-r31 ~]$ df -h
Filesystem Size Used Avail Use% Mounted on
/dev/root 15G 2.1G 12G 15% /
devtmpfs 458M 0 458M 0% /dev
tmpfs 462M 0 462M 0% /dev/shm
tmpfs 462M 388K 462M 1% /run
tmpfs 462M 0 462M 0% /sys/fs/cgroup
tmpfs 462M 0 462M 0% /tmp
/dev/mmcblk0p1 100M 19M 82M 19% /boot
tmpfs 93M 0 93M 0% /run/user/1000
SDカード、前部使えます。(^^)
4-2 タイムゾーン、時刻設定
sudo timedatectl set-timezone Asia/Tokyo
We trust you have received the usual lecture from the local System
Administrator. It usually boils down to these three things:
#1) Respect the privacy of others.
#2) Think before you type.
#3) With great power comes great responsibility.
[sudo] password for rbt:
sudo timedatectl set-timezone Asia/Tokyo
sudo pacman -S ntp
resolving dependencies...
looking for conflicting packages...
Packages (1) ntp-4.2.8.p4-1
Total Download Size: 1.62 MiB
Total Installed Size: 3.92 MiB
:: Proceed with installation? [Y/n] y
:: Retrieving packages ...
ntp-4.2.8.p4-1-armv7h 1657.7 KiB 3.68M/s 00:00 [######################] 100%
(1/1) checking keys in keyring [######################] 100%
(1/1) checking package integrity [######################] 100%
(1/1) loading package files [######################] 100%
(1/1) checking for file conflicts [######################] 100%
(1/1) checking available disk space [######################] 100%
(1/1) installing ntp [######################] 100%
sudo vi /etc/ntp.conf
cat /etc/ntp.conf
# Please consider joining the pool:
#
# http://www.pool.ntp.org/join.html
#
# For additional information see:
# - https://wiki.archlinux.org/index.php/Network_Time_Protocol_daemon
# - http://support.ntp.org/bin/view/Support/GettingStarted
# - the ntp.conf man page
# Associate to Arch's NTP pool
#server 0.arch.pool.ntp.org
#server 1.arch.pool.ntp.org
#server 2.arch.pool.ntp.org
#server 3.arch.pool.ntp.org
server ntp.nict.jp iburst (追加)
# By default, the server allows:
# - all queries from the local host
# - only time queries from remote hosts, protected by rate limiting and kod
restrict default kod limited nomodify nopeer noquery notrap
restrict 127.0.0.1
restrict ::1
# Location of drift file
driftfile /var/lib/ntp/ntp.drift
sudo ntpd -qg
27 Dec 16:39:25 ntpd[344]: ntpd 4.2.8p4@1.3265-o Thu Oct 22 09:48:17 UTC 2015 (1): Starting
27 Dec 16:39:25 ntpd[344]: Command line: ntpd -qg
27 Dec 16:39:25 ntpd[344]: proto: precision = 1.667 usec (-19)
27 Dec 16:39:25 ntpd[344]: Listen and drop on 0 v6wildcard [::]:123
27 Dec 16:39:25 ntpd[344]: Listen and drop on 1 v4wildcard 0.0.0.0:123
27 Dec 16:39:25 ntpd[344]: Listen normally on 2 lo 127.0.0.1:123
27 Dec 16:39:25 ntpd[344]: Listen normally on 3 eth0 192.168.11.13:123
27 Dec 16:39:25 ntpd[344]: Listen normally on 4 eth0 192.168.11.131:123
27 Dec 16:39:25 ntpd[344]: Listen normally on 5 lo [::1]:123
27 Dec 16:39:25 ntpd[344]: Listen normally on 6 eth0 [fe80::ba27:ebff:fe08:daac%2]:123
27 Dec 16:39:25 ntpd[344]: Listening on routing socket on fd #23 for interface updates
27 Dec 16:39:28 ntpd[344]: ntpd: time slew -0.000270 s
ntpd: time slew -0.000270s
sudo timedatectl set-ntp 1
4-3 追加のソフトインストール
sudo pacman -S git fcrontab
sudo pacman -S --needed base-devel
sudo pacman -S vim htop screen tree picocom git rsync ftp gawk
sudo shutdown -h now
4-4 swap
sudo dd if=/dev/zero of=/swapfile.img bs=1M count=1024
[sudo] password for rbt:
1024+0 records in
1024+0 records out
1073741824 bytes (1.1 GB) copied, 58.9933 s, 18.2 MB/s
sudo mkswap /swapfile.img
Setting up swapspace version 1, size = 1024 MiB (1073737728 bytes)
no label, UUID=b753579a-6c58-4733-a80f-13f95adc39c5
sudo swapon /swapfile.img
swapon: /swapfile.img: insecure permissions 0644, 0600 suggested.
sudo vi /etc/fstab
cat /etc/fstab
#
# /etc/fstab: static file system information
#
# <file system> <dir> <type> <options> <dump> <pass>
/dev/mmcblk0p1 /boot vfat defaults 0 0
/swapfile.img none swap sw 0 0
4-5 環境設定
cat .bashrc
#
# ~/.bashrc
#
# If not running interactively, don't do anything
[[ $- != *i* ]] && return
alias ls='ls --color=auto'
PS1='[\u@\h \W]\$ '
export LANG=ja_JP.UTF-8
alias ll='ls -al'
alias l=ls
alias h=history
PATH=~/bin:"$PATH"
vi .exrc
cat .exrc
set tabstop=2
set showmode
set autoindent
set nonumber
set showmatch
4-6 無線LAN
飛躍的に設定が楽になりましたーーー
sudo pacman -S wpa_supplicant wireless_tools dialog
sudo wifi-menu wlan0
あとは、画面の指示に従って、変更です。
で、おまじないの文言を追加します。
sudo vi wlan0SSID
sudo cat wlan0SSID
[sudo] password for rbt:
Description='Automatically generated profile by wifi-menu'
Interface=wlan0
Connection=wireless
Security=wpa
ESSID=SSID
Key=自分ちのpskだよ
IP=static
Address='192.168.11.130/24'
Gateway='192.168.11.1'
DNS=('192.168.11.1')
sudo netctl enable wlan0SSID
sudo netctl list
で、ダメだったら、、おまじない、やってみてね。
sudo ip link set wlan0 up
か、、、
sudo ip link set wlan0 down
それと、プロファイルの名称に - (ハイフォン)が入るのはダメらしい??
CRDAのエラーが出た時は、
sudo pacman -S crda
イーサネットケーブルを抜きます。
reboot
5. /boot/config.txt
次の設定をする。
(1) 900MHzを選択(コメントを外す)
##Medium
arm_freq=900
core_freq=333
sdram_freq=450
over_voltage=2
(2) オーバースキャンの設定
disable_overscan=1
(3) i2c設定
dtparam=i2c_arm=on
6. i2c設定
sudo pacman -S i2c-tools lm_sensors
sudo vi /etc/modules-load.d/raspberrypi.conf
cat /etc/modules-load.d/raspberrypi.conf
bcm2708-rng
snd-bcm2835
i2c-dev
reboot
sudo i2cdetect -y 1
0 1 2 3 4 5 6 7 8 9 a b c d e f
00: -- -- -- -- -- -- -- -- -- -- -- -- --
10: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
20: -- -- -- -- -- -- -- -- -- 29 -- -- -- -- -- --
30: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
40: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
50: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
60: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
70: -- -- -- -- -- -- -- --
下記の写真のTSL2591の、アドレスは0x29です。
バッチリ(^^)
7. lighttpd
sudo pacman -S lighttpd
cd /etc/lighttpd
sudo vi /etc/lighttpd/lighttpd.conf
cat /etc/lighttpd/lighttpd.conf
# This is a minimal example config
# See /usr/share/doc/lighttpd
# and http://redmine.lighttpd.net/projects/lighttpd/wiki/Docs:ConfigurationOptio
ns
server.port = 80
server.username = "http"
server.groupname = "http"
server.document-root = "/srv/http"
server.errorlog = "/var/log/lighttpd/error.log"
dir-listing.activate = "enable"
index-file.names = ( "index.html" )
mimetype.assign = (
".html" => "text/html",
".txt" => "text/plain",
".css" => "text/css",
".js" => "application/x-javascript",
".jpg" => "image/jpeg",
".jpeg" => "image/jpeg",
".gif" => "image/gif",
".png" => "image/png",
"" => "application/octet-stream"
)
server.modules = (
"mod_access",
"mod_cgi",
"mod_alias",
"mod_accesslog",
"mod_compress",
)
$HTTP["url"] =~ "/cgi-bin/" {
cgi.assign = ( "" => "" )
}
cgi.assign = (
".cgi" => ""
)
sudo lighttpd -t -f /etc/lighttpd/lighttpd.conf
sudo mkdir conf.d
sudo vi cgi.conf
cat cgi.conf
server.modules += ( "mod_cgi" )
cgi.assign = ( ".bin" => "",
".pl" => "/usr/bin/perl",
".cgi" => "/usr/bin/perl",
".rb" => "/usr/bin/ruby",
".erb" => "/usr/bin/eruby",
".py" => "/usr/bin/python",
".php" => "/usr/bin/php-cgi" )
index-file.names += ( "index.pl", "default.pl",
"index.rb", "default.rb",
"index.erb", "default.erb",
"index.py", "default.py",
"index.php", "default.php" )
sudo systemctl start lighttpd.service
sudo systemctl enable lighttpd.service
cd /srv/http
sudo mkdir cgi-bin
cd cgi-bin
vi hello.c
cat hello.c
#include "stdio.h"
int main(void) {
printf( "Content-Type: text/plain\n\n" );
printf("Hello world !\n");
return 0;
}
sudo gcc hello.c -o hello.bin
sudo co hello.bin hello
このサーバにアクセス
192.168.11.100/cgi-bin/hello
ブラウザーに、次の文字がでればOk(^^)
Hello World!
って事で、基本的なRESTの環境構築終了(^^)/
だから、、、
curl http://192.168.11.100/cgi-bin/hello
Hello world !
8. OpenCV
OpenCV 2.4です。
sudo pacman -S opencv
9. WiringPi
なんということでしょうか!!
よかったです。
sudo pacman -S wiringpi
10. MACで16GBのイメージファイルをつくる
sudo diskutil unmount /dev/disk2s1
sudo dd if=/dev/rdisk2 of=./archlinux-151227.img
でおしまいです。
って、感じでギャオです。
Peace!!