OPIでFedora22のメモ

loborisさんがリリースしている、Fedora22 のMinimal がどんなものテスト。

以下、備忘録です。Cで、GPIO ピンで光らせる部分まで確認。

 

・Fedora22_Minimal.img をsdcard に dd。要注意で。

$ sudo dd bs=1m if=./Fedora22_Minimal.img of=/dev/rdisk3

・BOOT パーティションの中は、orange pi pc の用途にあったものにリネーム。

[junkhack@OrangePi ~]$ ll /media/boot/
合計 10695
-rwxr-xr-x 1 root root    35724 10月 13 14:08 script.bin
-rwxr-xr-x 1 root root 10915616 10月 13 14:08 uImage

 

・SDCard 挿入、起動

・DHCP で起動するので、IP を固定に。以下のようになじみのあるeth0 に名前変更。

[root@opi 13:35:56 network-scripts]# ll ifcfg-*
-rw-r--r-- 1 root root 364 Jan  1  1970 ifcfg-LoBoInternet
-rw-r--r-- 1 root root 389 Dec 19 13:15 ifcfg-eth0
-rw-r--r-- 1 root root 254 Apr  9  2015 ifcfg-lo
[root@opi 13:36:06 network-scripts]# 

 

・中を変更

[root@opi 13:36:07 network-scripts]# cat ifcfg-eth0 
TYPE=Ethernet
BOOTPROTO=static
DEFROUTE=yes
PEERDNS=yes
PEERROUTES=yes
IPV4_FAILURE_FATAL=no
IPV6INIT=yes
IPV6_AUTOCONF=yes
IPV6_DEFROUTE=yes
IPV6_PEERDNS=yes
IPV6_PEERROUTES=yes
IPV6_FAILURE_FATAL=no
NAME=eth0
UUID=c0a09f2a-3229-4901-9689-7deb7e356848
DEVICE=eth0
ONBOOT=yes
DOMAIN=junkhack
IPADDR=192.168.1.42
NETMASK=255.255.255.0
GATEWAY=192.168.1.1
DNS1=192.168.1.17
DNS2=192.168.1.1
[root@opi 13:36:23 network-scripts]# 

 

・root のプロンプトを変更。好みで。

[root@opi 13:35:08 ~]# tail -n 3 .bash_profile 
PS1="[\u@opi \t \W]# "
export LANG=C

[root@opi 13:35:16 ~]# 

 

・タイムゾーン設定

[root@opi 13:34:18 ~]# timedatectl set-timezone Asia/Tokyo

・後方の空きパーティション拡大。スクリプトが同梱されているので。ない場合は、git にあるので参照。

[root@opi 13:37:46 ~]# find / -name fs_resize
/usr/local/bin/fs_resize
[root@opi 13:37:59 ~]# 

[root@opi 13:39:25 ~]# fs_resize

 

リブート

・cpu周波数のツールを入れ、ポリシーを見てみる。interactiveのようです。

[root@opi 13:43:15 ~]# dnf install cpufrequtils

[root@opi 13:51:19 ~]# cpupower frequency-info
analyzing CPU 0:
  driver: cpufreq-sunxi
  CPUs which run at the same hardware frequency: 0 1 2 3
  CPUs which need to have their frequency coordinated by software: 0 1 2 3
  maximum transition latency: 2.00 ms.
  hardware limits: 480 MHz - 1.54 GHz
  available cpufreq governors: conservative, ondemand, userspace, powersave, interactive, performance
  current policy: frequency should be within 480 MHz and 1.54 GHz.
                  The governor "interactive"★ may decide which speed to use
                  within this range.
  current CPU frequency is 480 MHz (asserted by call to hardware).
  cpufreq stats: 60.0 MHz:0.00%, 120 MHz:0.00%, 240 MHz:0.00%, 312 MHz:0.00%, 408 MHz:0.00%, 480 MHz:96.37%, 504 MHz:0.00%, 600 MHz:0.00%, 648 MHz:0.00%, 720 MHz:0.00%, 816 MHz:0.01%, 912 MHz:0.00%, 1.01 GHz:0.95%, 1.10 GHz:0.06%, 1.20 GHz:0.21%, 1.34 GHz:0.17%, 1.44 GHz:0.01%, 1.54 GHz:2.21%  (173)
[root@opi 13:51:22 ~]# 

 

参考

http://oneofis05users.seesaa.net/article/288446337.html

    ■ Interactive

    より速いondemandを、ということで考案された。CPUがアイドル状態から

    抜けるとサンプリングを増やして追従を上げる。反応はondemandより良いが、

    最大クロックに上げるまでには間を取る。マルチタスクで忙しい仕事とゆっくり

    した仕事が交互にあっても、最大最小に切り替え時に一気に上下せず少し間を取って、

    中間のクロックを取る。パフォーマンス的にはondemandより良い。

    画面オンで早くトップスピードに上げるので、画面オンの時間が短く、それを

    繰り返すような使用法ではバッテリー消費が多くなる。

 

・kernel をあげてみる。上げる前は以下。

[root@opi 13:55:50 src]# df -hT
Filesystem     Type      Size  Used Avail Use% Mounted on
/dev/mmcblk0p2 ext4       15G  1.1G   13G   8% /
udev           devtmpfs   10M     0   10M   0% /dev
tmpfs          tmpfs     201M  420K  201M   1% /run
tmpfs          tmpfs     502M     0  502M   0% /dev/shm
tmpfs          tmpfs     502M     0  502M   0% /sys/fs/cgroup
/dev/mmcblk0p1 vfat       63M   11M   53M  17% /media/boot
tmpfs          tmpfs     101M     0  101M   0% /run/user/0
tmpfs          tmpfs     101M     0  101M   0% /run/user/1001
[root@opi 13:55:57 src]# 
[root@opi 13:55:57 src]# ll /boot/
total 12632
-rwxr-xr-x 1 root root    32768 Oct 13 23:08 boot0_OPI.fex
-rw-r--r-- 1 root root    35724 Oct 13 23:08 script.bin
-rw-r--r-- 1 root root    35724 Oct 13 23:08 script.bin.OPI-PC_1080p50
-rw-r--r-- 1 root root    35724 Oct 13 23:08 script.bin.OPI-PC_480p
-rw-r--r-- 1 root root    35724 Oct 13 23:08 script.bin.OPI-PC_720p50
-rw-r--r-- 1 root root    35724 Oct 13 23:08 script.bin.OPI-PC_720p60
-rw-r--r-- 1 root root   901120 Oct 13 23:08 u-boot_OPI-emmc.fex
-rw-r--r-- 1 root root   901120 Oct 13 23:08 u-boot_OPI.fex
-rw-r--r-- 1 root root 10915616 Oct 13 23:08 uImage
[root@opi 13:56:16 src]# 
[root@opi 13:56:38 src]# ll /media/boot/
total 10695
-rwxr-xr-x 1 root root    35724 Oct 13 14:08 script.bin
-rwxr-xr-x 1 root root 10915616 Oct 13 14:08 uImage
[root@opi 13:56:46 src]# 

[root@opi 13:57:30 src]# uname -a
Linux OrangePi 3.4.39 #1 SMP PREEMPT Mon Oct 12 12:02:29 CEST 2015 armv7l armv7l armv7l GNU/Linux
[root@opi 13:57:34 src]# lsmod
Module                  Size  Used by
8189es                887631  0
[root@opi 13:57:41 src]# 

 

・消してしまってスクリプト上でチェックしているようで、ダミーを作成

[root@opi 14:21:02 src]# echo > /boot/uImage_OPI-2

・tar も入ってなかったのでいれておく。

[root@opi 14:25:05 src]# dnf install tar

・スクリプト実行

[root@opi 13:57:45 src]# ./update_kernel.sh 
Sat Dec 19 13:57:54 JST 2015
*********************************************************
Updating kernel, script.bin and /lib/modules for OrangePI
*********************************************************

Do you want to download script&kernel package from server, (y/N)?  y.


Unpacking ...
Files unpacked.
==============================================
Select the OrangePI board you want to upgrade:
  1   OrangePI 2
  2   OrangePI PLUS
  3   OrangePI PC
?  3
Updating OrangePI PC

===============================
Select hdmi display resolution:
  1   1080p 60Hz
  2   1080p 50Hz
  3    720p 60Hz
  4    720p 50Hz
?  1

Selected 1080p 60Hz

=====================================
Do you have HDMI->DVI adapter, (y/N)?  N
HDMI interface selected

================
CONTINUE, (y/N)?  y

kernel, script.bin and /lib/modules updated, please REBOOT.
AFTER REBOOT RUN:  sudo depmod -a
===========================================================

[root@opi 14:29:35 src]# 

 

・video 関連が新規追加されたようです。

[root@opi 14:30:04 src]# ll /boot/
total 24220
-rwxr-xr-x 1 root root    32768 Dec 19 14:27 boot0_OPI.fex
-rw-r--r-- 1 root root    35836 Dec 19 14:27 script.bin.OPI-2_1080p50_dvi
-rw-r--r-- 1 root root    35792 Dec 19 14:27 script.bin.OPI-2_1080p50_hdmi
-rw-r--r-- 1 root root    35836 Dec 19 14:27 script.bin.OPI-2_1080p60_dvi
-rw-r--r-- 1 root root    35792 Dec 19 14:27 script.bin.OPI-2_1080p60_hdmi
-rw-r--r-- 1 root root    35836 Dec 19 14:27 script.bin.OPI-2_480p_dvi
-rw-r--r-- 1 root root    35792 Dec 19 14:27 script.bin.OPI-2_480p_hdmi
-rw-r--r-- 1 root root    35836 Dec 19 14:27 script.bin.OPI-2_720p50_dvi
-rw-r--r-- 1 root root    35792 Dec 19 14:27 script.bin.OPI-2_720p50_hdmi
-rw-r--r-- 1 root root    35836 Dec 19 14:27 script.bin.OPI-2_720p60_dvi
-rw-r--r-- 1 root root    35792 Dec 19 14:27 script.bin.OPI-2_720p60_hdmi
-rw-r--r-- 1 root root    35856 Dec 19 14:27 script.bin.OPI-PC_1080p50_dvi
-rw-r--r-- 1 root root    35812 Dec 19 14:27 script.bin.OPI-PC_1080p50_hdmi
-rw-r--r-- 1 root root    35856 Dec 19 14:27 script.bin.OPI-PC_1080p60_dvi
-rw-r--r-- 1 root root    35812 Dec 19 14:27 script.bin.OPI-PC_1080p60_hdmi
-rw-r--r-- 1 root root    35856 Dec 19 14:27 script.bin.OPI-PC_480p_dvi
-rw-r--r-- 1 root root    35812 Dec 19 14:27 script.bin.OPI-PC_480p_hdmi
-rw-r--r-- 1 root root    35856 Dec 19 14:27 script.bin.OPI-PC_720p50_dvi
-rw-r--r-- 1 root root    35812 Dec 19 14:27 script.bin.OPI-PC_720p50_hdmi
-rw-r--r-- 1 root root    35856 Dec 19 14:27 script.bin.OPI-PC_720p60_dvi
-rw-r--r-- 1 root root    35812 Dec 19 14:27 script.bin.OPI-PC_720p60_hdmi
-rw-r--r-- 1 root root    36900 Dec 19 14:27 script.bin.OPI-PLUS_1080p50_dvi
-rw-r--r-- 1 root root    36856 Dec 19 14:27 script.bin.OPI-PLUS_1080p50_hdmi
-rw-r--r-- 1 root root    36900 Dec 19 14:27 script.bin.OPI-PLUS_1080p60_dvi
-rw-r--r-- 1 root root    36856 Dec 19 14:27 script.bin.OPI-PLUS_1080p60_hdmi
-rw-r--r-- 1 root root    36900 Dec 19 14:27 script.bin.OPI-PLUS_480p_dvi
-rw-r--r-- 1 root root    36856 Dec 19 14:27 script.bin.OPI-PLUS_480p_hdmi
-rw-r--r-- 1 root root    36900 Dec 19 14:27 script.bin.OPI-PLUS_720p50_dvi
-rw-r--r-- 1 root root    36856 Dec 19 14:27 script.bin.OPI-PLUS_720p50_hdmi
-rw-r--r-- 1 root root    36900 Dec 19 14:27 script.bin.OPI-PLUS_720p60_dvi
-rw-r--r-- 1 root root    36856 Dec 19 14:27 script.bin.OPI-PLUS_720p60_hdmi
-rw-r--r-- 1 root root   901120 Dec 19 14:27 u-boot_OPI-emmc.fex
-rw-r--r-- 1 root root   901120 Dec 19 14:27 u-boot_OPI.fex
-rw-r--r-- 1 root root 10917600 Dec 19 14:27 uImage_OPI-2
-rw-r--r-- 1 root root 10917592 Dec 19 14:27 uImage_OPI-PLUS
[root@opi 14:30:08 src]# 
[root@opi 14:30:09 src]# ll /media/boot/
total 21392
-rwxr-xr-x 1 root root    35812 Dec 19 14:29 script.bin
-rwxr-xr-x 1 root root    35724 Dec 19 14:29 script.bin.bak
-rwxr-xr-x 1 root root 10917600 Dec 19 14:29 uImage
-rwxr-xr-x 1 root root 10915616 Dec 19 14:29 uImage.bak
[root@opi 14:30:14 src]# 

[root@opi 15:35:40 modules]# diff -qr 3.4.39/ 3.4.39-01-lobo/ | grep gpio
diff: 3.4.39/build: No such file or directory
diff: 3.4.39-01-lobo/build: No such file or directory
Files 3.4.39/kernel/drivers/gpio/gpio-sunxi.ko and 3.4.39-01-lobo/kernel/drivers/gpio/gpio-sunxi.ko differ
Files 3.4.39/kernel/drivers/w1/masters/w1-gpio.ko and 3.4.39-01-lobo/kernel/drivers/w1/masters/w1-gpio.ko differ
diff: 3.4.39/source: No such file or directory
diff: 3.4.39-01-lobo/source: No such file or directory
[root@opi 15:35:45 modules]# 

[root@opi 15:31:41 modules]# diff -qr 3.4.39/ 3.4.39-01-lobo/ | wc -l
diff: 3.4.39/build: No such file or directory
diff: 3.4.39-01-lobo/build: No such file or directory
diff: 3.4.39/source: No such file or directory
diff: 3.4.39-01-lobo/source: No such file or directory
197
[root@opi 15:31:54 modules]# 


[root@opi 15:45:18 modules]# diff -qr 3.4.39/ 3.4.39-01-lobo/ | grep 'Only in'
::
Only in 3.4.39-01-lobo/kernel/drivers/input: serio
Only in 3.4.39-01-lobo/kernel/drivers/input: touchscreen
Only in 3.4.39-01-lobo/kernel/drivers/media: dvb
Only in 3.4.39-01-lobo/kernel/drivers/media/video/gspca: gl860
Only in 3.4.39-01-lobo/kernel/drivers/media/video/gspca: gspca_benq.ko
Only in 3.4.39-01-lobo/kernel/drivers/media/video/gspca: gspca_conex.ko
Only in 3.4.39-01-lobo/kernel/drivers/media/video/gspca: gspca_cpia1.ko
Only in 3.4.39-01-lobo/kernel/drivers/media/video/gspca: gspca_etoms.ko
Only in 3.4.39-01-lobo/kernel/drivers/media/video/gspca: gspca_finepix.ko
Only in 3.4.39-01-lobo/kernel/drivers/media/video/gspca: gspca_jeilinj.ko
Only in 3.4.39-01-lobo/kernel/drivers/media/video/gspca: gspca_jl2005bcd.ko
Only in 3.4.39-01-lobo/kernel/drivers/media/video/gspca: gspca_kinect.ko
Only in 3.4.39-01-lobo/kernel/drivers/media/video/gspca: gspca_konica.ko
Only in 3.4.39-01-lobo/kernel/drivers/media/video/gspca: gspca_mars.ko
Only in 3.4.39-01-lobo/kernel/drivers/media/video/gspca: gspca_mr97310a.ko
Only in 3.4.39-01-lobo/kernel/drivers/media/video/gspca: gspca_nw80x.ko
Only in 3.4.39-01-lobo/kernel/drivers/media/video/gspca: gspca_ov519.ko
Only in 3.4.39-01-lobo/kernel/drivers/media/video/gspca: gspca_ov534.ko
Only in 3.4.39-01-lobo/kernel/drivers/media/video/gspca: gspca_ov534_9.ko
Only in 3.4.39-01-lobo/kernel/drivers/media/video/gspca: gspca_pac207.ko
Only in 3.4.39-01-lobo/kernel/drivers/media/video/gspca: gspca_pac7302.ko
Only in 3.4.39-01-lobo/kernel/drivers/media/video/gspca: gspca_pac7311.ko
Only in 3.4.39-01-lobo/kernel/drivers/media/video/gspca: gspca_se401.ko
Only in 3.4.39-01-lobo/kernel/drivers/media/video/gspca: gspca_sn9c2028.ko
Only in 3.4.39-01-lobo/kernel/drivers/media/video/gspca: gspca_sn9c20x.ko
Only in 3.4.39-01-lobo/kernel/drivers/media/video/gspca: gspca_sonixb.ko
Only in 3.4.39-01-lobo/kernel/drivers/media/video/gspca: gspca_sonixj.ko
Only in 3.4.39-01-lobo/kernel/drivers/media/video/gspca: gspca_spca1528.ko
Only in 3.4.39-01-lobo/kernel/drivers/media/video/gspca: gspca_spca500.ko
Only in 3.4.39-01-lobo/kernel/drivers/media/video/gspca: gspca_spca501.ko
Only in 3.4.39-01-lobo/kernel/drivers/media/video/gspca: gspca_spca505.ko
Only in 3.4.39-01-lobo/kernel/drivers/media/video/gspca: gspca_spca506.ko
Only in 3.4.39-01-lobo/kernel/drivers/media/video/gspca: gspca_spca508.ko
Only in 3.4.39-01-lobo/kernel/drivers/media/video/gspca: gspca_spca561.ko
Only in 3.4.39-01-lobo/kernel/drivers/media/video/gspca: gspca_sq905.ko
Only in 3.4.39-01-lobo/kernel/drivers/media/video/gspca: gspca_sq905c.ko
Only in 3.4.39-01-lobo/kernel/drivers/media/video/gspca: gspca_sq930x.ko
Only in 3.4.39-01-lobo/kernel/drivers/media/video/gspca: gspca_stk014.ko
Only in 3.4.39-01-lobo/kernel/drivers/media/video/gspca: gspca_stv0680.ko
Only in 3.4.39-01-lobo/kernel/drivers/media/video/gspca: gspca_sunplus.ko
Only in 3.4.39-01-lobo/kernel/drivers/media/video/gspca: gspca_t613.ko
Only in 3.4.39-01-lobo/kernel/drivers/media/video/gspca: gspca_topro.ko
Only in 3.4.39-01-lobo/kernel/drivers/media/video/gspca: gspca_tv8532.ko
Only in 3.4.39-01-lobo/kernel/drivers/media/video/gspca: gspca_vc032x.ko
Only in 3.4.39-01-lobo/kernel/drivers/media/video/gspca: gspca_vicam.ko
Only in 3.4.39-01-lobo/kernel/drivers/media/video/gspca: gspca_xirlink_cit.ko
Only in 3.4.39-01-lobo/kernel/drivers/media/video/gspca: gspca_zc3xx.ko
Only in 3.4.39-01-lobo/kernel/drivers/media/video/gspca: m5602
Only in 3.4.39-01-lobo/kernel/drivers/media/video/gspca: stv06xx
diff: 3.4.39/sourceOnly in 3.4.39-01-lobo/kernel/drivers/media/video: tveeprom.ko
: No such file or directory
Only in 3.4.39-01-lobo/kernel/drivers: misc
diff: Only in 3.4.39-01-lobo/kernel/drivers/net/wireless: rtl818x
3.4.39-01-lobo/sourceOnly in 3.4.39-01-lobo/kernel/drivers/net/wireless: zd1201.ko
: No such file or directory
Only in 3.4.39-01-lobo/kernel/drivers/net/wireless: zd1211rw
Only in 3.4.39-01-lobo/kernel/net: 802
Only in 3.4.39-01-lobo/kernel/net: bridge
Only in 3.4.39-01-lobo/kernel/net: llc
[root@opi 15:45:24 modules]# 

 

・gpio_sunxi がロード

[root@opi 14:32:15 ~]# sudo depmod -a

[root@opi 14:36:36 ~]# uname -a
Linux OrangePi 3.4.39-01-lobo #1 SMP PREEMPT Sun Oct 25 14:46:41 CET 2015 armv7l armv7l armv7l GNU/Linux

[root@opi 14:33:14 ~]# ls /sys/class/gpio_sw/
ls: cannot access /sys/class/gpio_sw/: No such file or directory
[root@opi 14:33:16 ~]# 

[root@opi 14:33:17 ~]# modprobe gpio_sunxi
[root@opi 14:33:34 ~]# 
[root@opi 14:33:35 ~]# lsmod
Module                  Size  Used by
gpio_sunxi              8233  0
8189es                901572  0
[root@opi 14:33:43 ~]# 
[root@opi 14:34:04 ~]# ls /sys/class/gpio_sw/
PA10  PA13  PA14  PA15  PA21  PA3  PA6  PA7  PA8  PA9  PC3  PC4  PC7  PD14  PG6  PG7  PG8  PG9  PL10  normal_led  standby_led
[root@opi 14:34:05 ~]# 

・基板上の電源LED の隣の緑LED が点灯、消灯

[root@opi 14:34:58 ~]# echo 1 > /sys/class/gpio_sw/standby_led/data
[root@opi 14:35:13 ~]# echo 0 > /sys/class/gpio_sw/standby_led/data

・WiringOP を入れる準備。c関連を面倒なのでグループインストール

[root@opi 14:41:48 WiringOP]# dnf group list
Last metadata expiration check performed 1:47:22 ago on Sat Dec 19 12:56:05 2015.
Available environment groups:
   Minimal Install
   Fedora Server
   Fedora Workstation
   Fedora Cloud Server
   KDE Plasma Workspaces
   Xfce Desktop
   LXDE Desktop
   LXQt Desktop
   Cinnamon Desktop
   MATE Desktop
   Sugar Desktop Environment
   Development and Creative Workstation
   Web Server
   Infrastructure Server
   Basic Desktop
Available groups:
   3D Printing
   Administration Tools
   Audio Production
   Authoring and Publishing
   Books and Guides
   C Development Tools and Libraries★
   Cloud Infrastructure
   Cloud Management Tools
   Container Management
   D Development Tools and Libraries
   Design Suite
   Development Tools
   Domain Membership
   Fedora Eclipse
   Editors
   Educational Software
   Electronic Lab
   Engineering and Scientific
   FreeIPA Server
   Games and Entertainment
   Headless Management
   LibreOffice
   MATE Applications
   MATE Compiz
   Medical Applications
   Milkymist
   Network Servers
   Office/Productivity
   Robotics
   RPM Development Tools
   Security Lab
   Sound and Video
   System Tools
   Text-based Internet
   Window Managers
[root@opi 14:43:30 WiringOP]# dnf group install "C Development Tools and Libraries"

 

・WiringOP ビルド

[root@opi 14:50:36 WiringOP]# ./build 
wiringPi Build script
=====================


WiringPi Library
[UnInstall]
[Compile] wiringPi.c
[Compile] wiringSerial.c
[Compile] wiringShift.c
[Compile] piHiPri.c
[Compile] piThread.c
[Compile] wiringPiSPI.c
[Compile] wiringPiI2C.c
[Compile] softPwm.c
[Compile] softTone.c
[Compile] softServo.c
[Compile] mcp23008.c
[Compile] mcp23016.c
[Compile] mcp23017.c
[Compile] mcp23s08.c
[Compile] mcp23s17.c
[Compile] sr595.c
[Compile] pcf8574.c
[Compile] pcf8591.c
[Compile] mcp3002.c
[Compile] mcp3004.c
[Compile] mcp4802.c
[Compile] mcp3422.c
[Compile] max31855.c
[Compile] max5322.c
[Compile] sn3218.c
[Compile] drcSerial.c
[Link (Dynamic)]
[Install Headers]
[Install Dynamic Lib]

WiringPi Devices Library
[UnInstall]
[Compile] ds1302.c
[Compile] maxdetect.c
[Compile] piNes.c
[Compile] gertboard.c
[Compile] piFace.c
[Compile] lcd128x64.c
[Compile] lcd.c
[Compile] piGlow.c
[Link (Dynamic)]
[Install Headers]
[Install Dynamic Lib]

GPIO Utility
[Compile] gpio.c
gpio.c:801:13: warning: 'doPadDrive' defined but not used [-Wunused-function]
 static void doPadDrive (int argc, char *argv [])
             ^
gpio.c:889:13: warning: 'doGbw' defined but not used [-Wunused-function]
 static void doGbw (int argc, char *argv [])
             ^
gpio.c:931:13: warning: 'doGbr' defined but not used [-Wunused-function]
 static void doGbr (int argc, char *argv [])
             ^
[Compile] extensions.c
[Compile] readall.c
[Compile] pins.c
[Link]
[Install]

All Done.

NOTE: To compile programs with wiringBP v2, you need to add:
    -lwiringPi
  to your compile line(s) To use the Gertboard, MaxDetect, etc.
  code (the devLib), you need to also add:
    -lwiringPiDev
  to your compile line(s).

[root@opi 14:50:59 WiringOP]# 

 

・テストソース

[root@opi 14:54:54 gpio]# cat blink.c 
#include <wiringPi.h>

// Define GPIO Pin number wPi
#define LED 16
// delay 1 = 2msec
#define MSEC 500
// blink count 100 = 1sec
#define LOOP 100

// Main function
int main(void) {
        int i;

        // Initialize WiringPi
        wiringPiSetup ();

        // Set GPIO pin to output mode
        pinMode(LED, OUTPUT);

        // Repeat LED blinking 10 times
        for(i=0; i<LOOP; i++){
                digitalWrite(LED, LOW);
                delay(MSEC);
                digitalWrite(LED, HIGH);
                delay(MSEC);
        }

        // Turn off LED
        digitalWrite(LED, LOW);

        return 0;
}

 

・ビルド、実行

[root@opi 14:55:01 gpio]# gcc -o blink blink.c -lwiringPi -lpthread
[root@opi 14:55:26 gpio]# 
[root@opi 14:55:27 gpio]# ll
total 12
-rwxr-xr-x 1 root root 6592 Dec 19 14:55 blink
-rw-r--r-- 1 root root  624 Dec 19 14:54 blink.c
[root@opi 14:55:30 gpio]# ./blink 
^C
[root@opi 14:55:53 gpio]# 

[root@opi 14:56:19 gpio]# gpio readall
 +-----+-----+----------+------+---+--OrangePiPC--+---+------+---------+-----+--+
 | BCM | wPi |   Name   | Mode | V | Physical | V | Mode | Name     | wPi | BCM |
 +-----+-----+----------+------+---+----++----+---+------+----------+-----+-----+
 |     |     |     3.3v |      |   |  1 || 2  |   |      | 5v       |     |     |
 |   2 |  -1 |    SDA.0 |      |   |  3 || 4  |   |      | 5V       |     |     |
 |   3 |  -1 |    SCL.0 |      |   |  5 || 6  |   |      | 0v       |     |     |
 |   4 |   6 | IO6 PA06 |  OUT | 0 |  7 || 8  |   |      | TxD3     |     |     |
 |     |     |       0v |      |   |  9 || 10 |   |      | RxD3     |     |     |
 |  17 |  -1 |     RxD2 |      |   | 11 || 12 | 0 | OUT  | IO1 PD14 | 1   | 18  |
 |  27 |  -1 |     TxD2 |      |   | 13 || 14 |   |      | 0v       |     |     |
 |  22 |  -1 |     CTS2 |      |   | 15 || 16 | 0 | OUT  | IO4 PC04 | 4   | 23  |
 |     |     |     3.3v |      |   | 17 || 18 | 0 | OUT  | IO5 PC07 | 5   | 24  |
 |  10 |  -1 |     MOSI |      |   | 19 || 20 |   |      | 0v       |     |     |
 |   9 |  -1 |     MISO |      |   | 21 || 22 |   |      | RTS2     |     |     |
 |  11 |  -1 |     SCLK |      |   | 23 || 24 |   |      | SPI-CE0  |     |     |
 |     |     |       0v |      |   | 25 || 26 |   |      | CE1      |     |     |
 |   0 |  -1 |    SDA.1 |      |   | 27 || 28 |   |      | SCL.1    |     |     |
 |   5 |   7 |  IO7 PA7 |  OUT | 0 | 29 || 30 |   |      | 0v       |     |     |
 |   6 |   8 |  IO8 PA8 |  OUT | 0 | 31 || 32 | 0 | OUT  | IO9 PG08 | 9   | 12  |
 |  13 |  10 | IO10 PA9 |  OUT | 0 | 33 || 34 |   |      | 0v       |     |     |
 |  19 |  12 | IO12PA10 |  OUT | 0 | 35 || 36 | 0 | OUT  | IO13PG09 | 13  | 16  |
 |  26 |  14 | IO14PA20 | ALT3 | 0 | 37 || 38 | 0 | OUT  | IO15PG06 | 15  | 20  |
 |     |     |       0v |      |   | 39 || 40 | 0 | OUT  | IO16PG07 | 16  | 21  |
 +-----+-----+----------+------+---+----++----+---+------+----------+-----+-----+
 | BCM | wPi |   Name   | Mode | V | Physical | V | Mode | Name     | wPi | BCM |
 +-----+-----+----------+------+---+--OrangePIPC--+------+----------+-----+-----+
[root@opi 14:56:27 gpio]# 

OPIでLチカ GPIOをC で

前回、RasPi2 でWiringPiを使ってGPIO の制御をしました。

RasPi2 でCの王道? WiringPi

OrangePi でも同様に無いか探したところ、Forkしたものがありました。

WiringOP
https://github.com/zhaolei/WiringOP

サンプルソース

#include <wiringPi.h>

#define LED 16
#define MSEC 50

int main (void)
{
  wiringPiSetup () ;
  pinMode (LED, OUTPUT) ;
  for (;;)
  {
    digitalWrite (LED, HIGH) ; delay (MSEC) ;
    digitalWrite (LED,  LOW) ; delay (MSEC) ;
  }
  return 0 ;
}

GPIO

ビルド方法は以下のようにしました。

# gcc -o blink blink.c -lwiringPi -lpthread

ピンの指定が、以下で出てくる wPi の番号のようでした。

root@opi:~# gpio readall
 +-----+-----+----------+------+---+--OrangePiPC--+---+------+---------+-----+--+
 | BCM | wPi |   Name   | Mode | V | Physical | V | Mode | Name     | wPi | BCM |
 +-----+-----+----------+------+---+----++----+---+------+----------+-----+-----+
 |     |     |     3.3v |      |   |  1 || 2  |   |      | 5v       |     |     |
 |   2 |  -1 |    SDA.0 |      |   |  3 || 4  |   |      | 5V       |     |     |
 |   3 |  -1 |    SCL.0 |      |   |  5 || 6  |   |      | 0v       |     |     |
 |   4 |   6 | IO6 PA06 |  OUT | 0 |  7 || 8  |   |      | TxD3     |     |     |
 |     |     |       0v |      |   |  9 || 10 |   |      | RxD3     |     |     |
 |  17 |  -1 |     RxD2 |      |   | 11 || 12 | 0 | OUT  | IO1 PD14 | 1   | 18  |
 |  27 |  -1 |     TxD2 |      |   | 13 || 14 |   |      | 0v       |     |     |
 |  22 |  -1 |     CTS2 |      |   | 15 || 16 | 0 | OUT  | IO4 PC04 | 4   | 23  |
 |     |     |     3.3v |      |   | 17 || 18 | 0 | OUT  | IO5 PC07 | 5   | 24  |
 |  10 |  -1 |     MOSI |      |   | 19 || 20 |   |      | 0v       |     |     |
 |   9 |  -1 |     MISO |      |   | 21 || 22 |   |      | RTS2     |     |     |
 |  11 |  -1 |     SCLK |      |   | 23 || 24 |   |      | SPI-CE0  |     |     |
 |     |     |       0v |      |   | 25 || 26 |   |      | CE1      |     |     |
 |   0 |  -1 |    SDA.1 |      |   | 27 || 28 |   |      | SCL.1    |     |     |
 |   5 |   7 |  IO7 PA7 |  OUT | 0 | 29 || 30 |   |      | 0v       |     |     |
 |   6 |   8 |  IO8 PA8 |  OUT | 0 | 31 || 32 | 0 | OUT  | IO9 PG08 | 9   | 12  |
 |  13 |  10 | IO10 PA9 |  OUT | 0 | 33 || 34 |   |      | 0v       |     |     |
 |  19 |  12 | IO12PA10 |  OUT | 0 | 35 || 36 | 0 | OUT  | IO13PG09 | 13  | 16  |
 |  26 |  14 | IO14PA20 | ALT3 | 0 | 37 || 38 | 0 | OUT  | IO15PG06 | 15  | 20  |
 |     |     |       0v |      |   | 39 || 40 | 1 | OUT  | IO16PG07 | 16  | 21  |
 +-----+-----+----------+------+---+----++----+---+------+----------+-----+-----+
 | BCM | wPi |   Name   | Mode | V | Physical | V | Mode | Name     | wPi | BCM |
 +-----+-----+----------+------+---+--OrangePIPC--+------+----------+-----+-----+

とりあえず動きました。関数の扱いがちょっと?な部分もあり、完全に互換ソースで動くというわけじゃなさそうです。

root@opi:~# ls /sys/class/gpio_sw/
normal_led  PA10  PA13  PA14  PA15  PA21  PA3  PA6  PA7  PA8  PA9  PC3  PC4  PC7  PD14  PG6  PG7  PG8  PG9  PL10  standby_led
root@opi:~# lsmod
Module                  Size  Used by
gpio_sunxi              8233  0 
8189es                901572  0 
root@opi:~# modprobe gpio_sunxi
root@opi:~# modprobe gpio-sunxi
root@opi:~# modprobe gpio
modprobe: FATAL: Module gpio not found.
root@opi:~# echo 1 > /sys/class/gpio_sw/standby_led/data
root@opi:~# echo 0 > /sys/class/gpio_sw/standby_led/data
root@opi:~# gpio -g write 16 1
pin number error
root@opi:~# gpio -g write 21 1
pin number error
root@opi:~# gpio -g write IO16PG07 1
pin number error
root@opi:~# gpio -g write PG7 1
pin number error
root@opi:~# gpio -g write 0 1
pin number error
root@opi:~# 

もう少し、手入れが必要ですね。sysfs に直接書くと以下のように光ります。gpio のマッピングがうまく機能していないようですね。

gpio_stanby_led

15ドルのOrange Piで遊び倒す

遊びがいがありそうなので、ポチりました! 動機としては、OpenStack のARMビルド版を動かすのを目標にしています。

 

CPU には、allwinner のH3 というアーキテクチャーネームはsun8iw7p1 というものが載っています。

4K に対応した H.265/HEVC 4K@30fps のデコードが出来るんですよ。そして、4コアですよ。1.6Ghz で動作して、こんなのが2300円で買えてしまうなんて。もう驚きです。!!!どうやら、これは30ドル~50ドルくらいのSTBを対象に開発されたようで、価格は6ドルとのこと。

H3_Allwinner_TechnologyH3_Allwinner_Technology 2

Allwinner_H3_Datasheetv1.1

UnixBench ではRasPi(2じゃないやつ)よりも速いはずです。到着したら、自身で計測してみますが、他者の結果は以下のようです。RasPi2 より速ければ、うれしいですね。スペック的には速いはずです。以下のベンチマークは、Orange Pi(AllWinner A20)のもの。

参考ソース

http://pastebin.com/chsgAxw2

========================================================================
   BYTE UNIX Benchmarks (Version 5.1.3)
 
   System: OrangePI: GNU/Linux
   OS: GNU/Linux -- 3.4.39 -- #1 SMP PREEMPT Wed Sep 16 13:39:07 CEST 2015
   Machine: armv7l (unknown)
   Language: en_US.utf8 (charmap="UTF-8", collate="UTF-8")
   16:00:08 up 31 min,  1 user,  load average: 3.00, 3.09, 2.76; runlevel 2
 
------------------------------------------------------------------------
Benchmark Run: Sat Sep 19 2015 16:00:08 - 16:28:23
0 CPUs in system; running 1 parallel copy of tests
 
Dhrystone 2 using register variables        5193714.8 lps   (10.0 s, 7 samples)
Double-Precision Whetstone                      791.3 MWIPS (10.1 s, 7 samples)
Execl Throughput                                349.9 lps   (29.9 s, 2 samples)
File Copy 1024 bufsize 2000 maxblocks        121696.0 KBps  (30.0 s, 2 samples)
File Copy 256 bufsize 500 maxblocks           36652.0 KBps  (30.0 s, 2 samples)
File Copy 4096 bufsize 8000 maxblocks        277558.9 KBps  (30.0 s, 2 samples)
Pipe Throughput                              323747.0 lps   (10.0 s, 7 samples)
Pipe-based Context Switching                  12225.1 lps   (10.0 s, 7 samples)
Process Creation                               1044.4 lps   (30.0 s, 2 samples)
Shell Scripts (1 concurrent)                   1433.6 lpm   (60.0 s, 2 samples)
Shell Scripts (8 concurrent)                    472.1 lpm   (60.0 s, 2 samples)
System Call Overhead                         854375.1 lps   (10.0 s, 7 samples)
 
System Benchmarks Index Values               BASELINE       RESULT    INDEX
Dhrystone 2 using register variables         116700.0    5193714.8    445.0
Double-Precision Whetstone                       55.0        791.3    143.9
Execl Throughput                                 43.0        349.9     81.4
File Copy 1024 bufsize 2000 maxblocks          3960.0     121696.0    307.3
File Copy 256 bufsize 500 maxblocks            1655.0      36652.0    221.5
File Copy 4096 bufsize 8000 maxblocks          5800.0     277558.9    478.5
Pipe Throughput                               12440.0     323747.0    260.2
Pipe-based Context Switching                   4000.0      12225.1     30.6
Process Creation                                126.0       1044.4     82.9
Shell Scripts (1 concurrent)                     42.4       1433.6    338.1
Shell Scripts (8 concurrent)                      6.0        472.1    786.9
System Call Overhead                          15000.0     854375.1    569.6
                                                                   ========
System Benchmarks Index Score                                         225.1

 

-c 4 のオプションをつけてないようなので、おそらくRasPi2 よりも速いはず。

 

orangepipc_info オフィシャルサイトには、サポートOSは以下のようです。

orange_pi_homepage_-_Orangepi

www_orangepi_org_downloadresources_ ラインナップは以下のようです。最初の1つを選ぶとしたら、一番安いものでとりあえずいいかなと思ったので、15ドルのOrange Pi PC にしました。大きな違いは、NIC がGB対応にするか、WiFi 付きを選ぶか、SATA も付くのを選ぶか、eMMC8GB のストレージ付きを選ぶかです。

  Orange Pi Orange Pi Plus Orange Pi 2 Orange Pi PC Raspberry Pi 2 Model B
Processor AllWinner A20 Allwinner H3 Allwinner H3 Allwinner H3 Broadcom BCM2836
CPU cores 4x Cortex-A7 @ 1GHz 4x Cortex-A7 @ 1.6GHz 4x Cortex-A7 @ 1.6GHz 4x Cortex-A7 @ 1.6GHz 4x Cortex-A7 @ 900MHz
GPU PowerVR SGX544MP2 ARM Mali-400 MP2 ARM Mali-400 MP2 ARM Mali-400 MP2 Broadcom VideoCore IV
RAM 1GB 1GB 1GB 1GB 1GB
Storage microSD, SATA 2.0 microSD, SATA 2.0, 8GB eMMC microSD microSD microSD
Wireless WiFi WiFI WiFi
Ethernet Gigabit Gigabit 10/100 10/100 10/100
A/V I/O HDMI, composite, LVDS, VGA HDMI, composite HDMI, composite HDMI, composite HDMI, composite
Camera CSI CSI CSI CSI CSI
USB ports 4x USB 2.0; 1x USB OTG 4x USB 2.0; 1x USB OTG 4x USB 2.0; 1x USB OTG 3x USB 2.0; 1x USB OTG 4x USB 2.0
Power +5V via micro-USB or barrel jack +5V via micro-USB or barrel jack +5V via barrel jack +5V via barrel jack +5V via micro-USB
Expansion 26-pin Pi-style; 18-pin 40-pin Pi-style 40-pin Pi-style 40-pin Pi-style 40-pin
Dimensions 112 x 60mm 112 x 60mm 93 x 60mm 85 x 55mm 85 x 56mm
Price (less shipping) $49 $59 $30 $15 $35

オリジナルソース

http://linuxgizmos.com/15-dollar-orange-pi-pc-hacker-sbc-packs-quad-core-soc/

価格のバランスから言って、まずは表中の赤いものでいいかなと思いました。

2300円(15ドル+送料)くらいなので、ちょっと遊んでみようかと思います。目標は、オリジナルなOSビルドです。

野良なイメージはあるけれども、ちょっと心配だし、1からCentOS とかのarm 版を作ってみようかと。目標は、OpenStack のARMビルドを走らせること。そして、検証用のOpenStack 環境を作ってみたいなと。

 

アプリケーションであれば、クロスコンパイル環境を作ればARM版のアプリケーションはビルド出来るのでしょうが、OS自体を1からARM ビルドするにはどうしたらいいのでしょうか? このあたりのノウハウも勉強になると思いますので、やってみたいと思います。

 

オリジナルなブートローダーや、セットアップを簡単にするインストーラなども作れたら面白いなと思っていますが、いろいろスキルが必要になりそうですので、勉強しながらやっていきたいです。

 

それにしても、この部品構成でどやったら、15ドルで出せるのかが不思議です。

CPU は6ドルとのことで、大量に買えば安くはなるのであろうけども、中国のパワーはすごいですね。脅威を通りこして畏敬を感じます。安いのはパワーだと!

 

とりあえず、年末年始はこれで楽しめそうです。SUNXIのマニュアルにH3 とか基本的なマニュアルビルドの手順が載っていたのでメモ。

 

sunxi

Manual build howto

H3 Manual build howto