2015/01/26

ZYBOの収納ケースとACアダプタ

ZYBOの収納ケース

購入時の紙箱のままでは頼りないので,ZYBOを収納するためのケースを準備しました. そんな機会があるのかはともかくとして,持ち運びにも便利です.


ZYBOの収納ケース(蓋を閉じた状態)

ZYBOの収納ケース(蓋を開けた状態)

100円ショップで購入した,プラスチックの葉書ケースです. ZYBOは葉書よりも一回り小さい程度なので,サイズ的にピッタリでした. 葉書ケースの蓋側にドリルで穴を開け,M3ネジでZYBOの足を固定しています.


ZYBOの収納ケース(蓋側)

蓋側にZYBOを固定した理由は,各種コネクタへのアクセスのしやすさを重視したためです. この葉書ケースは,簡単に蓋と本体を分離・連結することができます. 本体側を取り払ってしまえば,ZYBOを葉書ケースの蓋に固定していることをほとんど意識しなくて良くなります. 100円ショップを何件か回り,いくつか候補を見つけましたが,最終的にこの葉書ケースにした理由はここです.


ZYBOの収納ケース(蓋と本体が分離・連結可能)

安価かつ簡単に収納ケースを作ることができますので,是非お試しください.

ZYBOのACアダプタ

年末に大阪日本橋のデジットに立ち寄った際,ちょうど良いACアダプタを見つけました. 出力はDC5V,1A,プラグ規格はφ2.1のセンタープラスですから,ZYBOに適合しています. コンセント形状が海外規格ですが,ちゃんと国内規格に変換するアダプタが付属しています. 価格は180円でした. 良い買い物ができました…これで海外出張対策も万全!?

[追記 2015/02/25] DC4.5V~5.5V出力で最低でも2.5A供給可能な外部電源が必要であると,「ZYBO FPGA Board Reference Manual」の4ページに記載されていることを教えていただきました. 私がちゃんとリファレンスマニュアルを読んでいないのがバレバレですね…. 現在のところ電源不足に陥ったような症状には遭遇していませんが,これから購入される方は,DC5V出力で2.5A以上供給できるACアダプタを探したほうが良いと思います.


ACアダプタ
2015/01/25

ZYBOでUbuntuのルートファイルシステムを使用する

はじめに

前回記事「Embedded Linux Hands-on Tutorial for the ZYBOをやってみました」で,ZYBO上でのLinux起動に成功しましたので,使用するルートファイルシステムをUbuntuのものに変更してみました. そもそも,私はまだLinuxやルートファイルシステム自体をよく理解していません. 本記事のタイトルからして適切なのか不安ですが,追々勉強して,理解しながら訂正や追記をしていきたいと思います.

下記記事を参考に作業しました.

開発環境

仮想マシン上のUbuntu 14.04 LTS 32bitで作業しました.

OS Ubuntu 14.04 LTS 32bit
作業ログ
1. microSDHCのフォーマット

前回記事「Embedded Linux Hands-on Tutorial for the ZYBOをやってみました」の内容を終えていることが前提となっています. ディレクトリ構造については,各自の環境に置き換えて読み進めてください.

microSDHC内のデータは,バックアップしておいてください. Ubuntuであれば,microSDHCを挿入すると,自動認識してファイルマネージャが開くのではないかと思います. 特に使用しませんので,ファイルマネージャは閉じても大丈夫です(下図は,Mac OS Xライクな外観にしたUbuntuのウィンドウです).


microSDHC (フォーマット前)

lsblkコマンドでmicroSDHCのマウント位置を調べました. 私の環境では,/dev/sdbでした. fdiskを開始し,pコマンドで既存パーティションを表示した後,dコマンドで既存パーティションを削除しました.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
~$ lsblk
NAME   MAJ:MIN RM   SIZE RO TYPE MOUNTPOINT
sda      8:0    0    80G  0 disk
├─sda1   8:1    0    78G  0 part /
├─sda2   8:2    0     1K  0 part
└─sda5   8:5    0     2G  0 part [SWAP]
sdb      8:16   1   7.5G  0 disk
└─sdb1   8:17   1   7.5G  0 part /media/省略/4097-E642
sr0     11:0    1  1024M  0 rom 
~$ sudo fdisk /dev/sdb
[sudo] password for 省略:
 
コマンド (m でヘルプ): p
 
ディスク /dev/sdb: 8001 MB, 8001683456 バイト
ヘッド 209, セクタ 4, シリンダ 18694, 合計 15628288 セクタ
Units = セクタ数 of 1 * 512 = 512 バイト
セクタサイズ (論理 / 物理): 512 バイト / 512 バイト
I/O サイズ (最小 / 推奨): 512 バイト / 512 バイト
ディスク識別子: 0x00000000
 
デバイス ブート      始点        終点     ブロック   Id  システム
/dev/sdb1            8192    15628287     7810048    b  W95 FAT32
 
コマンド (m でヘルプ): d
選択したパーティション 1
 
コマンド (m でヘルプ): p
 
ディスク /dev/sdb: 8001 MB, 8001683456 バイト
ヘッド 209, セクタ 4, シリンダ 18694, 合計 15628288 セクタ
Units = セクタ数 of 1 * 512 = 512 バイト
セクタサイズ (論理 / 物理): 512 バイト / 512 バイト
I/O サイズ (最小 / 推奨): 512 バイト / 512 バイト
ディスク識別子: 0x00000000
 
デバイス ブート      始点        終点     ブロック   Id  システム

第1パーティション(プライマリ,64MByte)を作成しました. nコマンドで新規パーティションの作成を開始し,'p'でパーティションタイプをプライマリに,'1'でパーティション番号を1に設定しました. 最初セクタは入力せず,Lastセクタは'+64M'としました.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
コマンド (m でヘルプ): n
Partition type:
   p   primary (0 primary, 0 extended, 4 free)
   e   extended
Select (default p): p
パーティション番号 (1-4, 初期値 1): 1
最初 セクタ (2048-15628287, 初期値 2048):
初期値 2048 を使います
Last セクタ, +セクタ数 or +size{K,M,G} (2048-15628287, 初期値 15628287): +64M
 
コマンド (m でヘルプ): p
 
ディスク /dev/sdb: 8001 MB, 8001683456 バイト
ヘッド 209, セクタ 4, シリンダ 18694, 合計 15628288 セクタ
Units = セクタ数 of 1 * 512 = 512 バイト
セクタサイズ (論理 / 物理): 512 バイト / 512 バイト
I/O サイズ (最小 / 推奨): 512 バイト / 512 バイト
ディスク識別子: 0x00000000
 
デバイス ブート      始点        終点     ブロック   Id  システム
/dev/sdb1            2048      133119       65536   83  Linux

第2パーティション(プライマリ,残りの領域)を作成しました. nコマンドで新規パーティションの作成を開始し,'p'でパーティションタイプをプライマリに,'2'でパーティション番号を2に設定しました. 最初セクタとLastセクタは入力しませんでした.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
コマンド (m でヘルプ): n
Partition type:
   p   primary (1 primary, 0 extended, 3 free)
   e   extended
Select (default p): p
パーティション番号 (1-4, 初期値 2): 2
最初 セクタ (133120-15628287, 初期値 133120):
初期値 133120 を使います
Last セクタ, +セクタ数 or +size{K,M,G} (133120-15628287, 初期値 15628287):
初期値 15628287 を使います
 
コマンド (m でヘルプ): p
 
ディスク /dev/sdb: 8001 MB, 8001683456 バイト
ヘッド 209, セクタ 4, シリンダ 18694, 合計 15628288 セクタ
Units = セクタ数 of 1 * 512 = 512 バイト
セクタサイズ (論理 / 物理): 512 バイト / 512 バイト
I/O サイズ (最小 / 推奨): 512 バイト / 512 バイト
ディスク識別子: 0x00000000
 
デバイス ブート      始点        終点     ブロック   Id  システム
/dev/sdb1            2048      133119       65536   83  Linux
/dev/sdb2          133120    15628287     7747584   83  Linux

第1パーティションのシステムタイプをFAT32に変更し(tコマンド),ブート可能フラグを付加しました(aコマンド).

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
コマンド (m でヘルプ): t
パーティション番号 (1-4): 1
16進数コード (L コマンドでコードリスト表示): L
 
 0  空              24  NEC DOS         81  Minix / 古い Li bf  Solaris       
 1  FAT12           27  Hidden NTFS Win 82  Linux スワップ  c1  DRDOS/sec (FAT-
 2  XENIX root      39  Plan 9          83  Linux           c4  DRDOS/sec (FAT-
 3  XENIX usr       3c  PartitionMagic  84  OS/2 隠し C: ド c6  DRDOS/sec (FAT-
 4  FAT16 <32M      40  Venix 80286     85  Linux 拡張領域  c7  Syrinx        
 5  拡張領域        41  PPC PReP Boot   86  NTFS ボリューム da  非 FS データ  
 6  FAT16           42  SFS             87  NTFS ボリューム db  CP/M / CTOS / .
 7  HPFS/NTFS/exFAT 4d  QNX4.x          88  Linux プレーン  de  Dell ユーティリ
 8  AIX             4e  QNX4.x 2nd part 8e  Linux LVM       df  BootIt        
 9  AIX ブート可能  4f  QNX4.x 3rd part 93  Amoeba          e1  DOS access    
 a  OS/2 ブートマネ 50  OnTrack DM      94  Amoeba BBT      e3  DOS R/O       
 b  W95 FAT32       51  OnTrack DM6 Aux 9f  BSD/OS          e4  SpeedStor     
 c  W95 FAT32 (LBA) 52  CP/M            a0  IBM Thinkpad ハ eb  BeOS fs       
 e  W95 FAT16 (LBA) 53  OnTrack DM6 Aux a5  FreeBSD         ee  GPT           
 f  W95 拡張領域 (L 54  OnTrackDM6      a6  OpenBSD         ef  EFI (FAT-12/16/
10  OPUS            55  EZ-Drive        a7  NeXTSTEP        f0  Linux/PA-RISC 
11  隠し FAT12      56  Golden Bow      a8  Darwin UFS      f1  SpeedStor     
12  Compaq 診断     5c  Priam Edisk     a9  NetBSD          f4  SpeedStor     
14  隠し FAT16 <32M 61  SpeedStor       ab  Darwin ブート   f2  DOS セカンダリ
16  隠し FAT16      63  GNU HURD または af  HFS / HFS+      fb  VMware VMFS   
17  隠し HPFS/NTFS  64  Novell Netware  b7  BSDI fs         fc  VMware VMKCORE
18  AST SmartSleep  65  Novell Netware  b8  BSDI スワップ   fd  Linux raid 自動
1b  隠し W95 FAT32  70  DiskSecure Mult bb  隠し Boot Wizar fe  LANstep       
1c  隠し W95 FAT32  75  PC/IX           be  Solaris ブート  ff  BBT           
1e  隠し W95 FAT16  80  古い Minix    
16進数コード (L コマンドでコードリスト表示): b
パーティションのシステムタイプを 1 から b (W95 FAT32) に変更しました
 
コマンド (m でヘルプ): a
パーティション番号 (1-4): 1
 
コマンド (m でヘルプ): p
 
ディスク /dev/sdb: 8001 MB, 8001683456 バイト
ヘッド 209, セクタ 4, シリンダ 18694, 合計 15628288 セクタ
Units = セクタ数 of 1 * 512 = 512 バイト
セクタサイズ (論理 / 物理): 512 バイト / 512 バイト
I/O サイズ (最小 / 推奨): 512 バイト / 512 バイト
ディスク識別子: 0x00000000
 
デバイス ブート      始点        終点     ブロック   Id  システム
/dev/sdb1   *        2048      133119       65536    b  W95 FAT32
/dev/sdb2          133120    15628287     7747584   83  Linux

パーティションテーブルの書込みを実行しました. 書込み後,パーティションテーブルの再読込みでエラーが発生しました. partprobeコマンドを実行しても駄目でした.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
コマンド (m でヘルプ): w
パーティションテーブルは変更されました!
 
ioctl() を呼び出してパーティションテーブルを再読込みします。
 
警告: パーティションテーブルの再読込みがエラー 16 で失敗しました: デバイスもしくはリソースがビジー状態です。
カーネルはまだ古いテーブルを使っています。新しいテーブルは
次回リブート時か、partprobe(8)またはkpartx(8)を実行した後に
使えるようになるでしょう
 
警告: DOS 6.x パーティションを作成、または変更してしまった場合は、
fdisk マニュアルの追加情報ページを参照してください。
ディスクを同期しています。
~$ partprobe
~$ lsblk
NAME   MAJ:MIN RM   SIZE RO TYPE MOUNTPOINT
sda      8:0    0    80G  0 disk
├─sda1   8:1    0    78G  0 part /
├─sda2   8:2    0     1K  0 part
└─sda5   8:5    0     2G  0 part [SWAP]
sdb      8:16   1   7.5G  0 disk
└─sdb1   8:17   1   7.5G  0 part /media/省略/4097-E642
sr0     11:0    1  1024M  0 rom

一度,microSDHCをアンマウント(取り外し)し,再度挿入することで解決しました. 一応,再度パーティションテーブルを書込みしました.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
~$ lsblk
NAME   MAJ:MIN RM   SIZE RO TYPE MOUNTPOINT
sda      8:0    0    80G  0 disk
├─sda1   8:1    0    78G  0 part /
├─sda2   8:2    0     1K  0 part
└─sda5   8:5    0     2G  0 part [SWAP]
sdb      8:16   1   7.5G  0 disk
├─sdb1   8:17   1    64M  0 part
└─sdb2   8:18   1   7.4G  0 part
sr0     11:0    1  1024M  0 rom 
~$ sudo fdisk /dev/sdb
 
コマンド (m でヘルプ): p
 
ディスク /dev/sdb: 8001 MB, 8001683456 バイト
ヘッド 247, セクタ 62, シリンダ 1020, 合計 15628288 セクタ
Units = セクタ数 of 1 * 512 = 512 バイト
セクタサイズ (論理 / 物理): 512 バイト / 512 バイト
I/O サイズ (最小 / 推奨): 512 バイト / 512 バイト
ディスク識別子: 0x00000000
 
デバイス ブート      始点        終点     ブロック   Id  システム
/dev/sdb1   *        2048      133119       65536    b  W95 FAT32
/dev/sdb2          133120    15628287     7747584   83  Linux
 
コマンド (m でヘルプ): w
パーティションテーブルは変更されました!
 
ioctl() を呼び出してパーティションテーブルを再読込みします。
ディスクを同期しています。

パーティション名を設定し,ファイルシステムを作成しました.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
~$ sudo mkfs.msdos -n ZYBO_BOOT /dev/sdb1
mkfs.fat 3.0.26 (2014-03-07)
~$ sudo mkfs.ext4 -L ROOT_FS /dev/sdb2
mke2fs 1.42.9 (4-Feb-2014)
Filesystem label=ROOT_FS
OS type: Linux
Block size=4096 (log=2)
Fragment size=4096 (log=2)
Stride=0 blocks, Stripe width=0 blocks
484800 inodes, 1936896 blocks
96844 blocks (5.00%) reserved for the super user
First data block=0
Maximum filesystem blocks=1983905792
60 block groups
32768 blocks per group, 32768 fragments per group
8080 inodes per group
Superblock backups stored on blocks:
 32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632
 
Allocating group tables: done                           
Writing inode tables: done                           
Creating journal (32768 blocks): done
Writing superblocks and filesystem accounting information: done
2. ルートファイルシステムの書込み

ルートファイルシステムの書込みを行いました. 下記はコマンド実行ログです. 事前に,ディレクトリ「zybo_ubuntu」を作成し,前回記事「Embedded Linux Hands-on Tutorial for the ZYBOをやってみました」内で作成した「BOOT.bin」をコピーしておきました. tarコマンドは,実行に6分程度かかりました.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
~$ lsblk
NAME   MAJ:MIN RM   SIZE RO TYPE MOUNTPOINT
sda      8:0    0    80G  0 disk
├─sda1   8:1    0    78G  0 part /
├─sda2   8:2    0     1K  0 part
└─sda5   8:5    0     2G  0 part [SWAP]
sdb      8:16   1   7.5G  0 disk
├─sdb1   8:17   1    64M  0 part /media/省略/ZYBO_BOOT
└─sdb2   8:18   1   7.4G  0 part /media/省略/ROOT_FS
sr0     11:0    1  1024M  0 rom 
~$ cd zybo_ubuntu/
# 出力メッセージ省略
~/zybo_ubuntu$ ls
BOOT.bin  linaro-precise-ubuntu-desktop-20121124-560.tar.gz
~/zybo_ubuntu$ sudo tar --strip-components=3 -C /media/省略/ROOT_FS/ -xzpf linaro-precise-ubuntu-desktop-20121124-560.tar.gz binary/boot/filesystem.dir
~/zybo_ubuntu$ ls /media/省略/ROOT_FS/
bin   dev  home  lost+found  mnt  proc  run   selinux  sys  usr
boot  etc  lib   media       opt  root  sbin  srv      tmp  var
3. BOOT.binとuImageの書込み

BOOT.binとuImage(前回記事「Embedded Linux Hands-on Tutorial for the ZYBOをやってみました」内で作成)をZYBO_BOOTに書き込みました.

1
2
3
4
~/zybo_ubuntu$ ls
BOOT.bin  linaro-precise-ubuntu-desktop-20121124-560.tar.gz
~/zybo_ubuntu$ cp BOOT.bin /media/省略/ZYBO_BOOT/
~/zybo_ubuntu$ cp ~/zybo_bsd_linux/Linux-Digilent-Dev/arch/arm/boot/uImage /media/省略/ZYBO_BOOT/

4. devicetree.dtbの書込み

前回記事「Embedded Linux Hands-on Tutorial for the ZYBOをやってみました」内で使用した「zynq-zybo.dts」をコピーし,編集しました.

1
2
3
4
5
6
7
8
9
10
~/zybo_ubuntu$ cp ~/zybo_bsd_linux/drivers/zynq-zybo.dts .
~/zybo_ubuntu$ ls
BOOT.bin  linaro-precise-ubuntu-desktop-20121124-560.tar.gz  zynq-zybo.dts
~/zybo_ubuntu$ vi zynq-zybo.dts
# 編集内容は別記
~/zybo_ubuntu$ ../zybo_bsd_linux/Linux-Digilent-Dev/scripts/dtc/dtc -I dts -O dtb -o devicetree.dtb zynq-zybo.dts
~/zybo_ubuntu$ ls
BOOT.bin        linaro-precise-ubuntu-desktop-20121124-560.tar.gz
devicetree.dtb  zynq-zybo.dts
~/zybo_ubuntu$ cp devicetree.dtb /media/省略/ZYBO_BOOT/

「zynq-zybo.dts」の変更箇所は42行目と55行目の計2箇所です.

42
bootargs = "console=ttyPS0,115200 root=/dev/mmcblk0p2 rw earlyprintk rootfstype=ext4 rootwait devtmpfs.mount=1";
55
operating-points = <650000 1000000>;
5. uEnv.txtの書込み

「uEnv.txt」を作成し,ZYBO_BOOTにコピーしました.

1
2
3
4
5
6
7
8
9
10
11
12
13
~/zybo_ubuntu$ vi uEnv.txt
# 編集内容は別記
~/zybo_ubuntu$ cp uEnv.txt /media/省略/ZYBO_BOOT/
~/zybo_ubuntu$ ls /media/省略/ZYBO_BOOT/
BOOT.bin  devicetree.dtb  uEnv.txt  uImage
~/zybo_ubuntu$ ls /media/省略/ROOT_FS/var/log/
ConsoleKit         boot           dmesg.0         lastlog   speech-dispatcher
Xorg.0.log         boot.log       dpkg.log        lightdm   syslog
Xorg.0.log.old     bootstrap.log  faillog         mail.err  udev
Xorg.failsafe.log  btmp           fontconfig.log  mail.log  unattended-upgrades
alternatives.log   cups           fsck            news      upstart
apt                dist-upgrade   hp              ntpstats  wtmp
auth.log           dmesg          kern.log        samba

「uEnv.txt」の内容は下記のとおりです.

1
uenvcmd=fatload mmc 0 0x03000000 uImage && fatload mmc 0 0x02A00000 devicetree.dtb && bootm 0x03000000 - 0x02A00000
6. 実機テスト

Linuxが起動しました!下記はTera Term上のログです.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
0
Device: zynq_sdhci
Manufacturer ID: 74
OEM: 4a45
Name: USD
Tran Speed: 50000000
Rd Block Len: 512
SD version 3.0
High Capacity: Yes
Capacity: 7.5 GiB
Bus Width: 4-bit
reading uEnv.txt
117 bytes read in 9 ms (12.7 KiB/s)
Loaded environment from uEnv.txt
Importing environment from SD ...
Running uenvcmd ...
reading uImage
3819360 bytes read in 337 ms (10.8 MiB/s)
reading devicetree.dtb
7474 bytes read in 15 ms (486.3 KiB/s)
## Booting kernel from Legacy Image at 03000000 ...
   Image Name:   Linux-3.14.0-xilinx-13567-g906a2
   Image Type:   ARM Linux Kernel Image (uncompressed)
   Data Size:    3819296 Bytes = 3.6 MiB
   Load Address: 00008000
   Entry Point:  00008000
   Verifying Checksum ... OK
## Flattened Device Tree blob at 02a00000
   Booting using the fdt blob at 0x2a00000
   Loading Kernel Image ... OK
   Loading Device Tree to 1fb2a000, end 1fb2ed31 ... OK
 
Starting kernel ...
 
Uncompressing Linux... done, booting the kernel.
[    0.000000] Booting Linux on physical CPU 0x0
[    0.000000] Linux version 3.14.0-xilinx-13567-g906a2c9 (省略) (gcc version 4.8.3 20140320 (prerelease) (Sourcery CodeBench Lite 2014.05-23) ) #1 SMP PREEMPT Thu Jan 22 20:59:00 JST 2015
[    0.000000] CPU: ARMv7 Processor [413fc090] revision 0 (ARMv7), cr=18c5387d
[    0.000000] CPU: PIPT / VIPT nonaliasing data cache, VIPT aliasing instruction cache
[    0.000000] Machine model: Xilinx Zynq
[    0.000000] bootconsole [earlycon0] enabled
[    0.000000] cma: CMA: reserved 128 MiB at 17800000
[    0.000000] Memory policy: Data cache writealloc
[    0.000000] PERCPU: Embedded 8 pages/cpu @dfb9e000 s10752 r8192 d13824 u32768
[    0.000000] Built 1 zonelists in Zone order, mobility grouping on.  Total pages: 130048
[    0.000000] Kernel command line: console=ttyPS0,115200 root=/dev/mmcblk0p2 rw earlyprintk rootfstype=ext4 rootwait devtmpfs.mount=1
[    0.000000] PID hash table entries: 2048 (order: 1, 8192 bytes)
[    0.000000] Dentry cache hash table entries: 65536 (order: 6, 262144 bytes)
[    0.000000] Inode-cache hash table entries: 32768 (order: 5, 131072 bytes)
[    0.000000] Memory: 375412K/524288K available (5133K kernel code, 319K rwdata, 1888K rodata, 206K init, 5339K bss, 148876K reserved, 0K highmem)
[    0.000000] Virtual kernel memory layout:
[    0.000000]     vector  : 0xffff0000 - 0xffff1000   (   4 kB)
[    0.000000]     fixmap  : 0xfff00000 - 0xfffe0000   ( 896 kB)
[    0.000000]     vmalloc : 0xe0800000 - 0xff000000   ( 488 MB)
[    0.000000]     lowmem  : 0xc0000000 - 0xe0000000   ( 512 MB)
[    0.000000]     pkmap   : 0xbfe00000 - 0xc0000000   (   2 MB)
[    0.000000]     modules : 0xbf000000 - 0xbfe00000   (  14 MB)
[    0.000000]       .text : 0xc0008000 - 0xc06e3a0c   (7023 kB)
[    0.000000]       .init : 0xc06e4000 - 0xc0717a00   ( 207 kB)
[    0.000000]       .data : 0xc0718000 - 0xc0767d40   ( 320 kB)
[    0.000000]        .bss : 0xc0767d4c - 0xc0c9eb88   (5340 kB)
[    0.000000] Preemptible hierarchical RCU implementation.
[    0.000000]  RCU lockdep checking is enabled.
[    0.000000]  Dump stacks of tasks blocking RCU-preempt GP.
[    0.000000]  RCU restricting CPUs from NR_CPUS=4 to nr_cpu_ids=2.
[    0.000000] RCU: Adjusting geometry for rcu_fanout_leaf=16, nr_cpu_ids=2
[    0.000000] NR_IRQS:16 nr_irqs:16 16
[    0.000000] ps7-slcr mapped to e0802000
[    0.000000] zynq_clock_init: clkc starts at e0802100
[    0.000000] Zynq clock init
[    0.000017] sched_clock: 64 bits at 325MHz, resolution 3ns, wraps every 3383112499200ns
[    0.008511] ps7-ttc #0 at e0804000, irq=43
[    0.013577] Console: colour dummy device 80x30
[    0.017922] Lock dependency validator: Copyright (c) 2006 Red Hat, Inc., Ingo Molnar
[    0.026003] ... MAX_LOCKDEP_SUBCLASSES:  8
[    0.030025] ... MAX_LOCK_DEPTH:          48
[    0.034199] ... MAX_LOCKDEP_KEYS:        8191
[    0.038617] ... CLASSHASH_SIZE:          4096
[    0.042971] ... MAX_LOCKDEP_ENTRIES:     16384
[    0.047442] ... MAX_LOCKDEP_CHAINS:      32768
[    0.051944] ... CHAINHASH_SIZE:          16384
[    0.056388]  memory used by lock dependency info: 3695 kB
[    0.061833]  per task-struct memory footprint: 1152 bytes
[    0.067282] Calibrating delay loop... 1292.69 BogoMIPS (lpj=6463488)
[    0.110958] pid_max: default: 32768 minimum: 301
[    0.116261] Mount-cache hash table entries: 1024 (order: 0, 4096 bytes)
[    0.122802] Mountpoint-cache hash table entries: 1024 (order: 0, 4096 bytes)
[    0.137445] CPU: Testing write buffer coherency: ok
[    0.143744] CPU0: thread -1, cpu 0, socket 0, mpidr 80000000
[    0.149387] Setting up static identity map for 0x4deb20 - 0x4deb78
[    0.155758] L310 cache controller enabled
[    0.159717] l2x0: 8 ways, CACHE_ID 0x410000c8, AUX_CTRL 0x72760000, Cache size: 512 kB
[    0.240369] CPU1: Booted secondary processor
[    0.328288] CPU1: thread -1, cpu 1, socket 0, mpidr 80000001
[    0.329308] Brought up 2 CPUs
[    0.342171] SMP: Total of 2 processors activated.
[    0.346871] CPU: All CPU(s) started in SVC mode.
[    0.354972] devtmpfs: initialized
[    0.365822] VFP support v0.3: implementor 41 architecture 3 part 30 variant 9 rev 4
[    0.380157] regulator-dummy: no parameters
[    0.393328] NET: Registered protocol family 16
[    0.402174] DMA: preallocated 256 KiB pool for atomic coherent allocations
[    0.415804] cpuidle: using governor ladder
[    0.419786] cpuidle: using governor menu
[    0.446885] syscon f8000000.ps7-slcr: regmap [mem 0xf8000000-0xf8000fff] registered
[    0.459375] hw-breakpoint: found 5 (+1 reserved) breakpoint and 1 watchpoint registers.
[    0.467326] hw-breakpoint: maximum watchpoint size is 4 bytes.
[    0.473663] zynq-ocm f800c000.ps7-ocmc: ZYNQ OCM pool: 256 KiB @ 0xe0880000
[    0.544842] bio: create slab <bio-0> at 0
[    0.554333] vgaarb: loaded
[    0.558897] SCSI subsystem initialized
[    0.565022] usbcore: registered new interface driver usbfs
[    0.570942] usbcore: registered new interface driver hub
[    0.576688] usbcore: registered new device driver usb
[    0.583439] media: Linux media interface: v0.10
[    0.588270] Linux video capture interface: v2.00
[    0.593477] pps_core: LinuxPPS API ver. 1 registered
[    0.598318] pps_core: Software ver. 5.3.6 - Copyright 2005-2007 Rodolfo Giometti <giometti@linux.it>
[    0.607868] PTP clock support registered
[    0.612798] EDAC MC: Ver: 3.0.0
[    0.619064] Advanced Linux Sound Architecture Driver Initialized.
[    0.635421] DMA-API: preallocated 4096 debug entries
[    0.640258] DMA-API: debugging enabled by kernel config
[    0.646111] Switched to clocksource arm_global_timer
[    0.708767] NET: Registered protocol family 2
[    0.715648] TCP established hash table entries: 4096 (order: 2, 16384 bytes)
[    0.723127] TCP bind hash table entries: 4096 (order: 5, 147456 bytes)
[    0.731631] TCP: Hash tables configured (established 4096 bind 4096)
[    0.738216] TCP: reno registered
[    0.741353] UDP hash table entries: 256 (order: 2, 20480 bytes)
[    0.747543] UDP-Lite hash table entries: 256 (order: 2, 20480 bytes)
[    0.755037] NET: Registered protocol family 1
[    0.761102] RPC: Registered named UNIX socket transport module.
[    0.766958] RPC: Registered udp transport module.
[    0.771617] RPC: Registered tcp transport module.
[    0.776377] RPC: Registered tcp NFSv4.1 backchannel transport module.
[    0.784151] hw perfevents: enabled with ARMv7 Cortex-A9 PMU driver, 7 counters available
[    0.798040] futex hash table entries: 512 (order: 3, 32768 bytes)
[    0.811973] jffs2: version 2.2. (NAND) (SUMMARY)  c 2001-2006 Red Hat, Inc.
[    0.819531] msgmni has been set to 989
[    0.824784] io scheduler noop registered
[    0.828720] io scheduler deadline registered
[    0.832990] io scheduler cfq registered (default)
[    0.854020] dma-pl330 f8003000.ps7-dma: Loaded driver for PL330 DMAC-2364208
[    0.861114] dma-pl330 f8003000.ps7-dma:      DBUFF-128x8bytes Num_Chans-8 Num_Peri-4 Num_Events-16
[    0.873119] e0001000.serial: ttyPS0 at MMIO 0xe0001000 (irq = 82, base_baud = 3125000) is a xuartps
[    0.882609] console [ttyPS0] enabled
[    0.882609] console [ttyPS0] enabled
[    0.889720] bootconsole [earlycon0] disabled
[    0.889720] bootconsole [earlycon0] disabled
[    0.900963] xdevcfg f8007000.ps7-dev-cfg: ioremap 0xf8007000 to e0866000
[    0.910749] [drm] Initialized drm 1.1.0 20060810
[    0.948927] brd: module loaded
[    0.971194] loop: module loaded
[    0.987544] m25p80 spi0.0: found s25fl128s1, expected n25q128
[    0.993254] m25p80 spi0.0: s25fl128s1 (16384 Kbytes)
[    0.998533] 4 ofpart partitions found on MTD device spi0.0
[    1.003944] Creating 4 MTD partitions on "spi0.0":
[    1.008790] 0x000000000000-0x000000400000 : "qspi-fsbl-uboot"
[    1.022201] 0x000000400000-0x000000900000 : "qspi-linux"
[    1.032171] 0x000000900000-0x000000920000 : "qspi-device-tree"
[    1.042738] 0x000000920000-0x000001000000 : "qspi-user"
[    1.061998] e1000e: Intel(R) PRO/1000 Network Driver - 2.3.2-k
[    1.067811] e1000e: Copyright(c) 1999 - 2013 Intel Corporation.
[    1.079450] libphy: XEMACPS mii bus: probed
[    1.085789] xemacps e000b000.ps7-ethernet: pdev->id -1, baseaddr 0xe000b000, irq 54
[    1.096547] ehci_hcd: USB 2.0 'Enhanced' Host Controller (EHCI) Driver
[    1.103482] ehci-pci: EHCI PCI platform driver
[    1.108862] ULPI transceiver vendor/product ID 0x0424/0x0007
[    1.114439] Found SMSC USB3320 ULPI transceiver.
[    1.119121] ULPI integrity check: passed.
[    1.123934] zynq-ehci zynq-ehci.0: Xilinx Zynq USB EHCI Host Controller
[    1.131470] zynq-ehci zynq-ehci.0: new USB bus registered, assigned bus number 1
[    1.166236] zynq-ehci zynq-ehci.0: irq 53, io mem 0x00000000
[    1.186203] zynq-ehci zynq-ehci.0: USB 2.0 started, EHCI 1.00
[    1.198978] hub 1-0:1.0: USB hub found
[    1.202958] hub 1-0:1.0: 1 port detected
[    1.210998] usbcore: registered new interface driver usb-storage
[    1.219863] mousedev: PS/2 mouse device common for all mice
[    1.227572] i2c /dev entries driver
[    1.240037] zynq-edac f8006000.ps7-ddrc: ecc not enabled
[    1.246337] cpufreq_cpu0: failed to get cpu0 regulator: -19
[    1.254729] Xilinx Zynq CpuIdle Driver started
[    1.261042] sdhci: Secure Digital Host Controller Interface driver
[    1.267337] sdhci: Copyright(c) Pierre Ossman
[    1.271615] sdhci-pltfm: SDHCI platform and OF driver helper
[    1.277861] mmc0: no vqmmc regulator found
[    1.281885] mmc0: no vmmc regulator found
[    1.326174] mmc0: SDHCI controller on e0100000.ps7-sdio [e0100000.ps7-sdio] using ADMA
[    1.338604] usbcore: registered new interface driver usbhid
[    1.346315] usbhid: USB HID core driver
[    1.360976] TCP: cubic registered
[    1.364224] NET: Registered protocol family 17
[    1.369165] Registering SWP/SWPB emulation handler
[    1.376606] regulator-dummy: disabling
[    1.380902] drivers/rtc/hctosys.c: unable to open rtc device (rtc0)
[    1.390048] mmc0: new high speed SDHC card at address b368
[    1.398339] mmcblk0: mmc0:b368 USD   7.45 GiB
[    1.408886]  mmcblk0: p1 p2
[    1.414716] ALSA device list:
[    1.417776]   No soundcards found.
[    1.455616] EXT4-fs (mmcblk0p2): mounted filesystem with ordered data mode. Opts: (null)
[    1.463821] VFS: Mounted root (ext4 filesystem) on device 179:2.
[    1.481760] devtmpfs: mounted
[    1.485007] Freeing unused kernel memory: 204K (c06e4000 - c0717000)
。+HH2.035133] init: ureadahead main process (585) terminated with status 5
cat: /var/lib/update-notifier/fsck-at-reboot: No such file or directory
run-parts: /etc/update-motd.d/98-fsck-at-reboot exited with return code 1
Welcome to Linaro 12.11 (GNU/Linux 3.14.0-xilinx-13567-g906a2c9 armv7l)
 
 * Documentation:  https://wiki.linaro.org/
 
0 packages can be updated.
0 updates are security updates.
 
root@linaro-ubuntu-desktop:~#
7. apt-get

ZYBO用のEmbedded Linux をブートするSDカードの作り方」にしたがい,Tera Term上で下記コマンドを実行しておきました.

1
2
3
root@linaro-ubuntu-desktop:~# apt-get update
root@linaro-ubuntu-desktop:~# apt-get upgrade
root@linaro-ubuntu-desktop:~# apt-get install ntp

ZYBOのFile System (ramdisk)を修正してみました

はじめに

前回の記事で,ZYBO上でのLinux起動に成功しました. しかし,ZedBoardのデザインからramdisk8M.image.gzを流用したため,Linux起動時に下記のような警告が発生しています. そこで,この問題を修正するとともに,myled.koをLinux起動時にinsmodするようにramdiskを修正してみました. 初心者ですので,非効率だったり,不可解だったりする操作をしている可能性があります. その場合は,コメントなどでご指摘いただければ幸いです….

218
219
220
221
222
223
224
225
226
227
228
229
230
Starting rcS...
++ Mounting filesystem
++ Setting up mdev
++ Configure static IP 192.168.1.10
++ Starting telnet daemon
++ Starting http daemon
++ Starting ftp daemon
++ Starting dropbear (ssh) daemon
[    2.676499] random: dropbear urandom read with 7 bits of entropy available
++ Starting OLED Display
insmod: can't read '/lib/modules/3.14.0-xilinx-13567-g906a2c9/pmodoled-gpio.ko': No such file or directory
++ Exporting LEDs & SWs
rcS Complete

下記の記事が参考になりました.ありがとうございます.

作業ログ
  1. microSDHCカードとramdiskをマウントする
  2. ZYBOでLinuxを起動し,作業開始しました. 下記は,Tera Term上でのコマンド実行ログです.

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    zynq> mkdir -p /mnt/sd_card
    zynq> mkdir -p /mnt/ramdisk
    zynq> mount /dev/mmcblk0p1 /mnt/sd_card/
    zynq> ls /mnt/sd_card/
    BOOT.bin           led_blink          uImage
    devicetree.dtb     myled.ko           uramdisk.image.gz
    zynq> cp /mnt/sd_card/uramdisk.image.gz /tmp/
    zynq> cd /tmp/
    zynq> ls
    uramdisk.image.gz
    zynq> dd if=uramdisk.image.gz of=ramdisk.image.gz bs=64 skip=1
    57720+1 records in
    57720+1 records out
    3694108 bytes (3.5MB) copied, 1.784584 seconds, 2.0MB/s
    zynq> ls
    ramdisk.image.gz   uramdisk.image.gz
    zynq> gunzip ramdisk.image.gz
    zynq> ls
    ramdisk.image      uramdisk.image.gz
    zynq> mount -o loop /tmp/ramdisk.image /mnt/ramdisk/
    [  196.002988] EXT2-fs (loop0): warning: mounting unchecked fs, running e2fsck is recommended
    zynq> ls /mnt/ramdisk/
    bin         lib         lost+found  proc        sys         var
    dev         licenses    mnt         root        tmp
    etc         linuxrc     opt         sbin        usr
  3. ramdiskの編集:/lib/modules以下の編集
  4. /mnt/ramdisk/lib/modules以下を編集し,myled.koを追加しました.

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    zynq> cd /mnt/ramdisk/
    zynq> ls
    bin         lib         lost+found  proc        sys         var
    dev         licenses    mnt         root        tmp
    etc         linuxrc     opt         sbin        usr
    zynq> mkdir -p /mnt/ramdisk/lib/modules/`uname -r`
    zynq> ls /mnt/ramdisk/lib/modules/
    3.14.0-xilinx-13567-g906a2c9   3.3.0-digilent-12.07-zed-beta
    zynq> cp /mnt/sd_card/myled.ko /mnt/ramdisk/lib/modules/`uname -r`
    zynq> ls /mnt/ramdisk/lib/modules/`uname -r`
    myled.ko
  5. ramdiskの編集:/etc/init.d/rcSと/usr/bin以下の編集
  6. /mnt/ramdisk/etc/init.d/rcSと/usr/bin以下を編集し,Linux起動時にmyled.koがinsmodされるようにしました.

    1
    2
    3
    4
    5
    6
    zynq> cd /mnt/ramdisk/
    zynq> ls
    bin         lib         lost+found  proc        sys         var
    dev         licenses    mnt         root        tmp
    etc         linuxrc     opt         sbin        usr
    zynq> vi ./etc/init.d/rcS

    rcSは,「echo "++ Starting OLED Display"」より下部を下記のように変更しました. 既存記述をコメントアウトし,2行を追加記述しています.

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    echo "++ Starting dropbear (ssh) daemon"
    dropbear
     
    #echo "++ Starting OLED Display"
    #load_oled
     
    #echo "++ Exporting LEDs & SWs"
    #for i in 0 1 2 3 4 5 6 7;
    #do
    #       sw=$(($i+69));
    #       led=$(($i+61));
    #       echo $sw > /sys/class/gpio/export;
    #       echo $led > /sys/class/gpio/export;
    #       echo out > /sys/class/gpio/gpio$led/direction;
    #done;
     
    echo "++ Starting myLed"
    load_myLed
     
    export PATH=$PATH:/usr/local/bin
     
    echo "rcS Complete"

    rcSから実行される,load_myledを作成しました.

    1
    2
    zynq> mv ./usr/bin/load_oled ./usr/bin/load_myled
    zynq> vi ./usr/bin/load_myled

    load_myledの内容は,下記の通りです.

    1
    2
    #!/bin/sh
    insmod /lib/modules/`uname -r`/myled.ko;
  7. ramdiskとmicroSDHCカードをアンマウントする
  8. microSDHCカードに編集済みのramdisk.image.gzをコピーします.

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    zynq> cd /tmp
    zynq> umount /mnt/ramdisk/
    zynq> ls
    ramdisk.image      uramdisk.image.gz
    zynq> gzip ramdisk.image
    zynq> ls
    ramdisk.image.gz   uramdisk.image.gz
    zynq> cp /tmp/ramdisk.image.gz /mnt/sd_card/
    zynq> ls /mnt/sd_card/
    BOOT.bin           led_blink          ramdisk.image.gz   uramdisk.image.gz
    devicetree.dtb     myled.ko           uImage
    zynq> umount /mnt/sd_card/
  9. ramdisk.image.gzをuramdisk.image.gzに変換する
  10. ZYBO上のLinuxにはmkimageコマンドがないようでしたので,これ以降はPCのUbuntu上で作業を行います. microSDHC上のramdisk.image.gzをUbuntu上の任意の作業ディレクトリにコピーし,下記コマンドを実行します. 生成されたuramdisk.image.gzをmicroSDHCカードに上書きして,作業は完了です.

    1
    modified_ramdisk$ mkimage -A arm -T ramdisk -C gzip -d ramdisk.image.gz uramdisk.image.gz
編集後のLinux起動ログ

myled.koがLinux起動時にinsmodされるようになりました.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
0
Device: zynq_sdhci
Manufacturer ID: 74
OEM: 4a45
Name: USD
Tran Speed: 50000000
Rd Block Len: 512
SD version 3.0
High Capacity: Yes
Capacity: 7.5 GiB
Bus Width: 4-bit
reading uEnv.txt
** Unable to read file uEnv.txt **
Copying Linux from SD to RAM...
reading uImage
3819360 bytes read in 334 ms (10.9 MiB/s)
reading devicetree.dtb
7442 bytes read in 16 ms (454.1 KiB/s)
reading uramdisk.image.gz
3678760 bytes read in 323 ms (10.9 MiB/s)
## Booting kernel from Legacy Image at 03000000 ...
   Image Name:   Linux-3.14.0-xilinx-13567-g906a2
   Image Type:   ARM Linux Kernel Image (uncompressed)
   Data Size:    3819296 Bytes = 3.6 MiB
   Load Address: 00008000
   Entry Point:  00008000
   Verifying Checksum ... OK
## Loading init Ramdisk from Legacy Image at 02000000 ...
   Image Name:
   Image Type:   ARM Linux RAMDisk Image (gzip compressed)
   Data Size:    3678696 Bytes = 3.5 MiB
   Load Address: 00000000
   Entry Point:  00000000
   Verifying Checksum ... OK
## Flattened Device Tree blob at 02a00000
   Booting using the fdt blob at 0x2a00000
   Loading Kernel Image ... OK
   Loading Ramdisk to 1f7ad000, end 1fb2f1e8 ... OK
   Loading Device Tree to 1f7a8000, end 1f7acd11 ... OK
 
Starting kernel ...
 
Uncompressing Linux... done, booting the kernel.
[    0.000000] Booting Linux on physical CPU 0x0
[    0.000000] Linux version 3.14.0-xilinx-13567-g906a2c9 (省略) (gcc version 4.8.3 20140320 (prerelease) (Sourcery CodeBench Lite 2014.05-23) ) #1 SMP PREEMPT Thu Jan 22 20:59:00 JST 2015
[    0.000000] CPU: ARMv7 Processor [413fc090] revision 0 (ARMv7), cr=18c5387d
[    0.000000] CPU: PIPT / VIPT nonaliasing data cache, VIPT aliasing instruction cache
[    0.000000] Machine model: Xilinx Zynq
[    0.000000] bootconsole [earlycon0] enabled
[    0.000000] cma: CMA: reserved 128 MiB at 17400000
[    0.000000] Memory policy: Data cache writealloc
[    0.000000] PERCPU: Embedded 8 pages/cpu @dfb9e000 s10752 r8192 d13824 u32768
[    0.000000] Built 1 zonelists in Zone order, mobility grouping on.  Total pages: 130048
[    0.000000] Kernel command line: console=ttyPS0,115200 root=/dev/ram rw earlyprintk
[    0.000000] PID hash table entries: 2048 (order: 1, 8192 bytes)
[    0.000000] Dentry cache hash table entries: 65536 (order: 6, 262144 bytes)
[    0.000000] Inode-cache hash table entries: 32768 (order: 5, 131072 bytes)
[    0.000000] Memory: 371812K/524288K available (5133K kernel code, 319K rwdata, 1888K rodata, 206K init, 5339K bss, 152476K reserved, 0K highmem)
[    0.000000] Virtual kernel memory layout:
[    0.000000]     vector  : 0xffff0000 - 0xffff1000   (   4 kB)
[    0.000000]     fixmap  : 0xfff00000 - 0xfffe0000   ( 896 kB)
[    0.000000]     vmalloc : 0xe0800000 - 0xff000000   ( 488 MB)
[    0.000000]     lowmem  : 0xc0000000 - 0xe0000000   ( 512 MB)
[    0.000000]     pkmap   : 0xbfe00000 - 0xc0000000   (   2 MB)
[    0.000000]     modules : 0xbf000000 - 0xbfe00000   (  14 MB)
[    0.000000]       .text : 0xc0008000 - 0xc06e3a0c   (7023 kB)
[    0.000000]       .init : 0xc06e4000 - 0xc0717a00   ( 207 kB)
[    0.000000]       .data : 0xc0718000 - 0xc0767d40   ( 320 kB)
[    0.000000]        .bss : 0xc0767d4c - 0xc0c9eb88   (5340 kB)
[    0.000000] Preemptible hierarchical RCU implementation.
[    0.000000]  RCU lockdep checking is enabled.
[    0.000000]  Dump stacks of tasks blocking RCU-preempt GP.
[    0.000000]  RCU restricting CPUs from NR_CPUS=4 to nr_cpu_ids=2.
[    0.000000] RCU: Adjusting geometry for rcu_fanout_leaf=16, nr_cpu_ids=2
[    0.000000] NR_IRQS:16 nr_irqs:16 16
[    0.000000] ps7-slcr mapped to e0802000
[    0.000000] zynq_clock_init: clkc starts at e0802100
[    0.000000] Zynq clock init
[    0.000016] sched_clock: 64 bits at 325MHz, resolution 3ns, wraps every 3383112499200ns
[    0.008513] ps7-ttc #0 at e0804000, irq=43
[    0.013585] Console: colour dummy device 80x30
[    0.017925] Lock dependency validator: Copyright (c) 2006 Red Hat, Inc., Ingo Molnar
[    0.026005] ... MAX_LOCKDEP_SUBCLASSES:  8
[    0.030021] ... MAX_LOCK_DEPTH:          48
[    0.034195] ... MAX_LOCKDEP_KEYS:        8191
[    0.038612] ... CLASSHASH_SIZE:          4096
[    0.042966] ... MAX_LOCKDEP_ENTRIES:     16384
[    0.047437] ... MAX_LOCKDEP_CHAINS:      32768
[    0.051937] ... CHAINHASH_SIZE:          16384
[    0.056382]  memory used by lock dependency info: 3695 kB
[    0.061827]  per task-struct memory footprint: 1152 bytes
[    0.067276] Calibrating delay loop... 1292.69 BogoMIPS (lpj=6463488)
[    0.110961] pid_max: default: 32768 minimum: 301
[    0.116266] Mount-cache hash table entries: 1024 (order: 0, 4096 bytes)
[    0.122805] Mountpoint-cache hash table entries: 1024 (order: 0, 4096 bytes)
[    0.137446] CPU: Testing write buffer coherency: ok
[    0.143748] CPU0: thread -1, cpu 0, socket 0, mpidr 80000000
[    0.149391] Setting up static identity map for 0x4deb20 - 0x4deb78
[    0.155764] L310 cache controller enabled
[    0.159720] l2x0: 8 ways, CACHE_ID 0x410000c8, AUX_CTRL 0x72760000, Cache size: 512 kB
[    0.240372] CPU1: Booted secondary processor
[    0.328289] CPU1: thread -1, cpu 1, socket 0, mpidr 80000001
[    0.329292] Brought up 2 CPUs
[    0.342156] SMP: Total of 2 processors activated.
[    0.346857] CPU: All CPU(s) started in SVC mode.
[    0.354960] devtmpfs: initialized
[    0.365694] VFP support v0.3: implementor 41 architecture 3 part 30 variant 9 rev 4
[    0.380025] regulator-dummy: no parameters
[    0.393200] NET: Registered protocol family 16
[    0.401996] DMA: preallocated 256 KiB pool for atomic coherent allocations
[    0.415591] cpuidle: using governor ladder
[    0.419573] cpuidle: using governor menu
[    0.446584] syscon f8000000.ps7-slcr: regmap [mem 0xf8000000-0xf8000fff] registered
[    0.459105] hw-breakpoint: found 5 (+1 reserved) breakpoint and 1 watchpoint registers.
[    0.467059] hw-breakpoint: maximum watchpoint size is 4 bytes.
[    0.473396] zynq-ocm f800c000.ps7-ocmc: ZYNQ OCM pool: 256 KiB @ 0xe0880000
[    0.544551] bio: create slab <bio-0> at 0
[    0.554073] vgaarb: loaded
[    0.558669] SCSI subsystem initialized
[    0.564786] usbcore: registered new interface driver usbfs
[    0.571458] usbcore: registered new interface driver hub
[    0.577203] usbcore: registered new device driver usb
[    0.583722] media: Linux media interface: v0.10
[    0.589081] Linux video capture interface: v2.00
[    0.594308] pps_core: LinuxPPS API ver. 1 registered
[    0.599146] pps_core: Software ver. 5.3.6 - Copyright 2005-2007 Rodolfo Giometti <giometti@linux.it>
[    0.608666] PTP clock support registered
[    0.613529] EDAC MC: Ver: 3.0.0
[    0.619871] Advanced Linux Sound Architecture Driver Initialized.
[    0.635714] DMA-API: preallocated 4096 debug entries
[    0.640817] DMA-API: debugging enabled by kernel config
[    0.646463] Switched to clocksource arm_global_timer
[    0.709368] NET: Registered protocol family 2
[    0.716229] TCP established hash table entries: 4096 (order: 2, 16384 bytes)
[    0.723679] TCP bind hash table entries: 4096 (order: 5, 147456 bytes)
[    0.731674] TCP: Hash tables configured (established 4096 bind 4096)
[    0.738174] TCP: reno registered
[    0.741311] UDP hash table entries: 256 (order: 2, 20480 bytes)
[    0.747679] UDP-Lite hash table entries: 256 (order: 2, 20480 bytes)
[    0.755204] NET: Registered protocol family 1
[    0.761154] RPC: Registered named UNIX socket transport module.
[    0.767008] RPC: Registered udp transport module.
[    0.771671] RPC: Registered tcp transport module.
[    0.776429] RPC: Registered tcp NFSv4.1 backchannel transport module.
[    0.783935] Trying to unpack rootfs image as initramfs...
[    0.790821] rootfs image is not initramfs (no cpio magic); looks like an initrd
[    0.822200] Freeing initrd memory: 3592K (df7ad000 - dfb2f000)
[    0.828366] hw perfevents: enabled with ARMv7 Cortex-A9 PMU driver, 7 counters available
[    0.842320] futex hash table entries: 512 (order: 3, 32768 bytes)
[    0.855927] jffs2: version 2.2. (NAND) (SUMMARY)  c 2001-2006 Red Hat, Inc.
[    0.863480] msgmni has been set to 989
[    0.868816] io scheduler noop registered
[    0.872628] io scheduler deadline registered
[    0.877164] io scheduler cfq registered (default)
[    0.903391] dma-pl330 f8003000.ps7-dma: Loaded driver for PL330 DMAC-2364208
[    0.910360] dma-pl330 f8003000.ps7-dma:      DBUFF-128x8bytes Num_Chans-8 Num_Peri-4 Num_Events-16
[    0.922509] e0001000.serial: ttyPS0 at MMIO 0xe0001000 (irq = 82, base_baud = 3125000) is a xuartps
[    0.931977] console [ttyPS0] enabled
[    0.931977] console [ttyPS0] enabled
[    0.939085] bootconsole [earlycon0] disabled
[    0.939085] bootconsole [earlycon0] disabled
[    0.950278] xdevcfg f8007000.ps7-dev-cfg: ioremap 0xf8007000 to e0866000
[    0.960077] [drm] Initialized drm 1.1.0 20060810
[    0.998317] brd: module loaded
[    1.020791] loop: module loaded
[    1.037001] m25p80 spi0.0: found s25fl128s1, expected n25q128
[    1.042712] m25p80 spi0.0: s25fl128s1 (16384 Kbytes)
[    1.048102] 4 ofpart partitions found on MTD device spi0.0
[    1.053505] Creating 4 MTD partitions on "spi0.0":
[    1.058370] 0x000000000000-0x000000400000 : "qspi-fsbl-uboot"
[    1.071620] 0x000000400000-0x000000900000 : "qspi-linux"
[    1.081695] 0x000000900000-0x000000920000 : "qspi-device-tree"
[    1.092290] 0x000000920000-0x000001000000 : "qspi-user"
[    1.111564] e1000e: Intel(R) PRO/1000 Network Driver - 2.3.2-k
[    1.117381] e1000e: Copyright(c) 1999 - 2013 Intel Corporation.
[    1.129061] libphy: XEMACPS mii bus: probed
[    1.135400] xemacps e000b000.ps7-ethernet: pdev->id -1, baseaddr 0xe000b000, irq 54
[    1.146094] ehci_hcd: USB 2.0 'Enhanced' Host Controller (EHCI) Driver
[    1.153483] ehci-pci: EHCI PCI platform driver
[    1.158650] ULPI transceiver vendor/product ID 0x0424/0x0007
[    1.164226] Found SMSC USB3320 ULPI transceiver.
[    1.168954] ULPI integrity check: passed.
[    1.173775] zynq-ehci zynq-ehci.0: Xilinx Zynq USB EHCI Host Controller
[    1.181170] zynq-ehci zynq-ehci.0: new USB bus registered, assigned bus number 1
[    1.216566] zynq-ehci zynq-ehci.0: irq 53, io mem 0x00000000
[    1.236544] zynq-ehci zynq-ehci.0: USB 2.0 started, EHCI 1.00
[    1.249258] hub 1-0:1.0: USB hub found
[    1.253254] hub 1-0:1.0: 1 port detected
[    1.261273] usbcore: registered new interface driver usb-storage
[    1.270141] mousedev: PS/2 mouse device common for all mice
[    1.277842] i2c /dev entries driver
[    1.290334] zynq-edac f8006000.ps7-ddrc: ecc not enabled
[    1.296578] cpufreq_cpu0: failed to get cpu0 regulator: -19
[    1.305008] Xilinx Zynq CpuIdle Driver started
[    1.311471] sdhci: Secure Digital Host Controller Interface driver
[    1.317632] sdhci: Copyright(c) Pierre Ossman
[    1.321914] sdhci-pltfm: SDHCI platform and OF driver helper
[    1.328223] mmc0: no vqmmc regulator found
[    1.332245] mmc0: no vmmc regulator found
[    1.376466] mmc0: SDHCI controller on e0100000.ps7-sdio [e0100000.ps7-sdio] using ADMA
[    1.391761] usbcore: registered new interface driver usbhid
[    1.397382] usbhid: USB HID core driver
[    1.413032] TCP: cubic registered
[    1.416321] NET: Registered protocol family 17
[    1.421207] Registering SWP/SWPB emulation handler
[    1.428537] regulator-dummy: disabling
[    1.432746] drivers/rtc/hctosys.c: unable to open rtc device (rtc0)
[    1.449239] mmc0: new high speed SDHC card at address b368
[    1.457706] mmcblk0: mmc0:b368 USD   7.45 GiB
[    1.466956] ALSA device list:
[    1.470202]   No soundcards found.
[    1.470412]  mmcblk0: p1
[    1.478273] RAMDISK: gzip image found at block 0
[    1.898859] EXT2-fs (ram0): warning: mounting unchecked fs, running e2fsck is recommended
[    1.907329] VFS: Mounted root (ext2 filesystem) on device 1:0.
[    1.914020] devtmpfs: mounted
[    1.917408] Freeing unused kernel memory: 204K (c06e4000 - c0717000)
Starting rcS...
++ Mounting filesystem
++ Setting up mdev
++ Configure static IP 192.168.1.10
++ Starting telnet daemon
++ Starting http daemon
++ Starting ftp daemon
++ Starting dropbear (ssh) daemon
[    2.688942] random: dropbear urandom read with 7 bits of entropy available
++ Starting myLed
[    2.747360] myled probed at VA 0xe08e0000
rcS Complete
zynq> ls
bin         lib         lost+found  proc        sys         var
dev         licenses    mnt         root        tmp
etc         linuxrc     opt         sbin        usr
zynq> echo 0xa > /proc/myled
zynq> echo 0xf > /proc/myled
zynq> echo 0x5 > /proc/myled
zynq> rmmod myled
製品紹介

Embedded Linux Hands-on Tutorial for the ZYBOをやってみました

はじめに

Digilentが提供している,Embedded Linux Hands-on Tutorial for the ZYBOをやってみました.

日本語情報としては,下記記事を参考にさせていただきました. Hands-on Tutorialだけでは初心者の私にはわかりづらい箇所は,ほとんど下記記事で補完されていました. 大変助かりました.

開発環境
Hardware Customization, Generate BOOT.BIN

ZYBO Base System Designのカスタマイズ関係(1. Hardware Customization, 3. Generate BOOT.BIN)は,Windows環境で行いました.

OS Microsoft Windows 7 Professional x64 Service Pack 1
Vivado Vivado 2014.4 WebPACK Edition (Windows)
SDK Xilinx SDK 2014.4
Compile U-Boot, Compile Linux Kernel以降

コンパイル環境については,Xilinx SDKを使用せず,PetaLinuxツールを使用しました. 参考にした上記記事との違いは,この点くらいです.

OS Ubuntu 14.04 LTS 32bit
PetaLinuxツール Zynq、MicroBlaze用 PetaLinux 2014.4
PetaLinuxツールのインストール

PetaLinuxツールをインストールしました.XilinxのWebサイトからFirefoxでダウンロードし,Installation Guideを参考にして,下記のようにコマンドを実行しました.

1
2
3
4
5
6
7
~$ mv ./ダウンロード/petalinux-v2014.4-final-installer.run .
~$ chmod +x petalinux-v2014.4-final-installer.run
~$ sudo ./petalinux-v2014.4-final-installer.run /opt 2>&1 | tee petalinux-v2014.4-final-installer.run.log
~$ cd /opt/petalinux-v2014.4-final/
petalinux-v2014.4-final$ source settings.sh 2>&1 | tee ~/settings.sh.log
petalinux-v2014.4-final$ echo $PETALINUX
/opt/petalinux-v2014.4-final

私の環境では,初回インストール時に下記メッセージが表示されてエラー終了しました.

1
2
3
4
5
6
7
~$ sudo ./petalinux-v2014.4-final-installer.run /opt 2>&1 | tee petalinux-v2014.4-final-installer.run.log
# 出力メッセージ一部省略
ERROR: You are missing the following system tools required by PetaLinux:
 
- gawk
Please check PetaLinux installation guide - required tools and libraries pacakge section for detailed information
# 出力メッセージ一部省略

下記コマンドでgawkをインストールすることで解決しました.

1
sudo apt-get install gawk

インストール中,下記のような警告が表示されました. どうやら,MicroBlazeシステムにLinuxシステムのイメージをダウンロードするために必要のようです. 今回は関係ないと判断し,無視しました.

1
WARNING: No tftp server found - please refer to "PetaLinux SDK Installation     Guide" for its impact and solution
作業ログ
1. Hardware Customization

上記の参考記事を読みながら進めました. 特に躓くことはなかったと思います. プロジェクトを開きなおすと「system_LEDs_4Bits_1.upgrade_log」が見つからないとのCritical Warningが出るので,プロジェクトから該当ファイルを削除しておきました.


Hardware Customization
2. Compile U-Boot

ここでも,特に躓くことはなかったと思います. Ubuntu上でのコマンド実行ログです.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
~$ cd /opt/petalinux-v2014.4-final/
petalinux-v2014.4-final$ source settings.sh
# 出力メッセージ省略
petalinux-v2014.4-final$ echo $PETALINUX
# 出力メッセージ省略
petalinux-v2014.4-final$ cd ~
~$ mkdir zybo_bsd_linux
~$ cd zybo_bsd_linux/
zybo_bsd_linux$ git clone -b master-next https://github.com/DigilentInc/u-boot-Digilent-Dev.git
# 出力メッセージ省略
zybo_bsd_linux$ cd u-boot-Digilent-Dev/
# 出力メッセージ省略
u-boot-Digilent-Dev$ make CROSS_COMPILE=arm-xilinx-linux-gnueabi- zynq_zybo_config
# 出力メッセージ省略
u-boot-Digilent-Dev$ make CROSS_COMPILE=arm-xilinx-linux-gnueabi-
# 出力メッセージ省略
3. Generate BOOT.BIN

参考記事と重複しますが,注意点だけ書きます.

  • workspaceのビルドが進まない
  • FSBLプロジェクトを作成後,自動的にビルドが開始されますが,進捗率が79%のまま動かなくなってしまいました. ビルドを中断させてFSBLプロジェクトを削除し,Xilinx SDKを再起動して再試行すると上手くいきました.
  • system.bitではなく,system_wrapper.bit
  • Hands-on Tutorialの3.2.10ではsystem.bitになっていますが,system_wrapper.bitでした.
4. Compile Linux Kernel

Ubuntu上でのコマンド実行ログです.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
~$ cd /opt/petalinux-v2014.4-final/
petalinux-v2014.4-final$ source settings.sh
# 出力メッセージ省略
petalinux-v2014.4-final$ echo $PETALINUX
# 出力メッセージ省略
petalinux-v2014.4-final$ cd ~
~$ cd zybo_bsd_linux/
zybo_bsd_linux$ sudo apt-get install u-boot-tools
# 出力メッセージ省略
zybo_bsd_linux$ git clone -b master-next https://github.com/DigilentInc/Linux-Digilent-Dev.git
# 出力メッセージ省略
zybo_bsd_linux$ cd Linux-Digilent-Dev/
Linux-Digilent-Dev$ make ARCH=arm CROSS_COMPILE=arm-xilinx-linux-gnueabi- xilinx_zynq_defconfig
Linux-Digilent-Dev$ make ARCH=arm CROSS_COMPILE=arm-xilinx-linux-gnueabi-
Linux-Digilent-Dev$ make ARCH=arm CROSS_COMPILE=arm-xilinx-linux-gnueabi- UIMAGE_LOADADDR=0x8000 uImage
5. Test Kernel Image with Pre-built File System

参考記事にしたがい,5.2.1のzynq-zybo.dtsの編集は実行しませんでした. また,ramdisk8M.image.gzはZedBoardのデザインから流用しました.

[追記 2015/01/25] ramdisk8M.image.gzは,下記リンクからwget (ダウンロード)してきた方が良さそうです. 下記で述べているような,Linux起動時の警告が出なくなります. 「yuki-sato.com - 7. Zynq RAMディスク」が参考になりました. ありがとうございます.

1
2
3
4
5
6
7
~$ cd zybo_bsd_linux/
zybo_bsd_linux$ wget http://www.digilentinc.com/Data/Products/ZEDBOARD/ZedBoard_OOB_Design.zip
zybo_bsd_linux$ unzip ZedBoard_OOB_Design.zip
zybo_bsd_linux$ cp ./ZedBoard_OOB_Design/sd_image/ramdisk8M.image.gz .
zybo_bsd_linux$ ./u-boot-Digilent-Dev/tools/mkimage -A arm -T ramdisk -c gzip -d ./ramdisk8M.image.gz uramdisk.image.gz
zybo_bsd_linux$ cd Linux-Digilent-Dev
Linux-Digilent-Dev$ ./scripts/dtc/dtc -I dts -O dtb -o ../devicetree.dtb ./arch/arm/boot/dts/zynq-zybo.dts

Linuxが起動しました!下記はTera Term上のログです. 228行目付近で警告が出ています.ramdisk8M.image.gzをZedBoardのデザインから流用したことが原因でしょう. この問題については,次回記事「ZYBOのFile System (ramdisk)を修正してみました」で解決しました.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
0
Device: zynq_sdhci
Manufacturer ID: 74
OEM: 4a45
Name: USD
Tran Speed: 50000000
Rd Block Len: 512
SD version 3.0
High Capacity: Yes
Capacity: 7.5 GiB
Bus Width: 4-bit
reading uEnv.txt
** Unable to read file uEnv.txt **
Copying Linux from SD to RAM...
reading uImage
3819360 bytes read in 334 ms (10.9 MiB/s)
reading devicetree.dtb
7442 bytes read in 16 ms (454.1 KiB/s)
reading uramdisk.image.gz
3694172 bytes read in 325 ms (10.8 MiB/s)
## Booting kernel from Legacy Image at 03000000 ...
   Image Name:   Linux-3.14.0-xilinx-13567-g906a2
   Image Type:   ARM Linux Kernel Image (uncompressed)
   Data Size:    3819296 Bytes = 3.6 MiB
   Load Address: 00008000
   Entry Point:  00008000
   Verifying Checksum ... OK
## Loading init Ramdisk from Legacy Image at 02000000 ...
   Image Name:
   Image Type:   ARM Linux RAMDisk Image (gzip compressed)
   Data Size:    3694108 Bytes = 3.5 MiB
   Load Address: 00000000
   Entry Point:  00000000
   Verifying Checksum ... OK
## Flattened Device Tree blob at 02a00000
   Booting using the fdt blob at 0x2a00000
   Loading Kernel Image ... OK
   Loading Ramdisk to 1f7a9000, end 1fb2ee1c ... OK
   Loading Device Tree to 1f7a4000, end 1f7a8d11 ... OK
 
Starting kernel ...
 
Uncompressing Linux... done, booting the kernel.
[    0.000000] Booting Linux on physical CPU 0x0
[    0.000000] Linux version 3.14.0-xilinx-13567-g906a2c9 (省略) (gcc version 4.8.3 20140320 (prerelease) (Sourcery CodeBench Lite 2014.05-23) ) #1 SMP PREEMPT Thu Jan 22 20:59:00 JST 2015
[    0.000000] CPU: ARMv7 Processor [413fc090] revision 0 (ARMv7), cr=18c5387d
[    0.000000] CPU: PIPT / VIPT nonaliasing data cache, VIPT aliasing instruction cache
[    0.000000] Machine model: Xilinx Zynq
[    0.000000] bootconsole [earlycon0] enabled
[    0.000000] cma: CMA: reserved 128 MiB at 17400000
[    0.000000] Memory policy: Data cache writealloc
[    0.000000] PERCPU: Embedded 8 pages/cpu @dfb9e000 s10752 r8192 d13824 u32768
[    0.000000] Built 1 zonelists in Zone order, mobility grouping on.  Total pages: 130048
[    0.000000] Kernel command line: console=ttyPS0,115200 root=/dev/ram rw earlyprintk
[    0.000000] PID hash table entries: 2048 (order: 1, 8192 bytes)
[    0.000000] Dentry cache hash table entries: 65536 (order: 6, 262144 bytes)
[    0.000000] Inode-cache hash table entries: 32768 (order: 5, 131072 bytes)
[    0.000000] Memory: 371800K/524288K available (5133K kernel code, 319K rwdata, 1888K rodata, 206K init, 5339K bss, 152488K reserved, 0K highmem)
[    0.000000] Virtual kernel memory layout:
[    0.000000]     vector  : 0xffff0000 - 0xffff1000   (   4 kB)
[    0.000000]     fixmap  : 0xfff00000 - 0xfffe0000   ( 896 kB)
[    0.000000]     vmalloc : 0xe0800000 - 0xff000000   ( 488 MB)
[    0.000000]     lowmem  : 0xc0000000 - 0xe0000000   ( 512 MB)
[    0.000000]     pkmap   : 0xbfe00000 - 0xc0000000   (   2 MB)
[    0.000000]     modules : 0xbf000000 - 0xbfe00000   (  14 MB)
[    0.000000]       .text : 0xc0008000 - 0xc06e3a0c   (7023 kB)
[    0.000000]       .init : 0xc06e4000 - 0xc0717a00   ( 207 kB)
[    0.000000]       .data : 0xc0718000 - 0xc0767d40   ( 320 kB)
[    0.000000]        .bss : 0xc0767d4c - 0xc0c9eb88   (5340 kB)
[    0.000000] Preemptible hierarchical RCU implementation.
[    0.000000]  RCU lockdep checking is enabled.
[    0.000000]  Dump stacks of tasks blocking RCU-preempt GP.
[    0.000000]  RCU restricting CPUs from NR_CPUS=4 to nr_cpu_ids=2.
[    0.000000] RCU: Adjusting geometry for rcu_fanout_leaf=16, nr_cpu_ids=2
[    0.000000] NR_IRQS:16 nr_irqs:16 16
[    0.000000] ps7-slcr mapped to e0802000
[    0.000000] zynq_clock_init: clkc starts at e0802100
[    0.000000] Zynq clock init
[    0.000016] sched_clock: 64 bits at 325MHz, resolution 3ns, wraps every 3383112499200ns
[    0.008513] ps7-ttc #0 at e0804000, irq=43
[    0.013573] Console: colour dummy device 80x30
[    0.017911] Lock dependency validator: Copyright (c) 2006 Red Hat, Inc., Ingo Molnar
[    0.025991] ... MAX_LOCKDEP_SUBCLASSES:  8
[    0.030015] ... MAX_LOCK_DEPTH:          48
[    0.034187] ... MAX_LOCKDEP_KEYS:        8191
[    0.038604] ... CLASSHASH_SIZE:          4096
[    0.042959] ... MAX_LOCKDEP_ENTRIES:     16384
[    0.047431] ... MAX_LOCKDEP_CHAINS:      32768
[    0.051932] ... CHAINHASH_SIZE:          16384
[    0.056376]  memory used by lock dependency info: 3695 kB
[    0.061821]  per task-struct memory footprint: 1152 bytes
[    0.067269] Calibrating delay loop... 1292.69 BogoMIPS (lpj=6463488)
[    0.110964] pid_max: default: 32768 minimum: 301
[    0.116269] Mount-cache hash table entries: 1024 (order: 0, 4096 bytes)
[    0.122807] Mountpoint-cache hash table entries: 1024 (order: 0, 4096 bytes)
[    0.137470] CPU: Testing write buffer coherency: ok
[    0.143774] CPU0: thread -1, cpu 0, socket 0, mpidr 80000000
[    0.149417] Setting up static identity map for 0x4deb20 - 0x4deb78
[    0.155792] L310 cache controller enabled
[    0.159748] l2x0: 8 ways, CACHE_ID 0x410000c8, AUX_CTRL 0x72760000, Cache size: 512 kB
[    0.240379] CPU1: Booted secondary processor
[    0.328292] CPU1: thread -1, cpu 1, socket 0, mpidr 80000001
[    0.329296] Brought up 2 CPUs
[    0.342159] SMP: Total of 2 processors activated.
[    0.346860] CPU: All CPU(s) started in SVC mode.
[    0.354961] devtmpfs: initialized
[    0.365682] VFP support v0.3: implementor 41 architecture 3 part 30 variant 9 rev 4
[    0.380023] regulator-dummy: no parameters
[    0.393184] NET: Registered protocol family 16
[    0.401929] DMA: preallocated 256 KiB pool for atomic coherent allocations
[    0.415568] cpuidle: using governor ladder
[    0.419550] cpuidle: using governor menu
[    0.446536] syscon f8000000.ps7-slcr: regmap [mem 0xf8000000-0xf8000fff] registered
[    0.459089] hw-breakpoint: found 5 (+1 reserved) breakpoint and 1 watchpoint registers.
[    0.467267] hw-breakpoint: maximum watchpoint size is 4 bytes.
[    0.473438] zynq-ocm f800c000.ps7-ocmc: ZYNQ OCM pool: 256 KiB @ 0xe0880000
[    0.544952] bio: create slab <bio-0> at 0
[    0.554037] vgaarb: loaded
[    0.558501] SCSI subsystem initialized
[    0.564648] usbcore: registered new interface driver usbfs
[    0.570615] usbcore: registered new interface driver hub
[    0.576354] usbcore: registered new device driver usb
[    0.582915] media: Linux media interface: v0.10
[    0.587742] Linux video capture interface: v2.00
[    0.593338] pps_core: LinuxPPS API ver. 1 registered
[    0.598177] pps_core: Software ver. 5.3.6 - Copyright 2005-2007 Rodolfo Giometti <giometti@linux.it>
[    0.607731] PTP clock support registered
[    0.612599] EDAC MC: Ver: 3.0.0
[    0.618915] Advanced Linux Sound Architecture Driver Initialized.
[    0.635057] DMA-API: preallocated 4096 debug entries
[    0.639893] DMA-API: debugging enabled by kernel config
[    0.645836] Switched to clocksource arm_global_timer
[    0.707882] NET: Registered protocol family 2
[    0.714807] TCP established hash table entries: 4096 (order: 2, 16384 bytes)
[    0.722911] TCP bind hash table entries: 4096 (order: 5, 147456 bytes)
[    0.731113] TCP: Hash tables configured (established 4096 bind 4096)
[    0.737614] TCP: reno registered
[    0.740747] UDP hash table entries: 256 (order: 2, 20480 bytes)
[    0.746997] UDP-Lite hash table entries: 256 (order: 2, 20480 bytes)
[    0.754516] NET: Registered protocol family 1
[    0.760483] RPC: Registered named UNIX socket transport module.
[    0.766333] RPC: Registered udp transport module.
[    0.770994] RPC: Registered tcp transport module.
[    0.775723] RPC: Registered tcp NFSv4.1 backchannel transport module.
[    0.783239] Trying to unpack rootfs image as initramfs...
[    0.790123] rootfs image is not initramfs (no cpio magic); looks like an initrd
[    0.821510] Freeing initrd memory: 3604K (df7a9000 - dfb2e000)
[    0.827672] hw perfevents: enabled with ARMv7 Cortex-A9 PMU driver, 7 counters available
[    0.841602] futex hash table entries: 512 (order: 3, 32768 bytes)
[    0.855309] jffs2: version 2.2. (NAND) (SUMMARY)  c 2001-2006 Red Hat, Inc.
[    0.862864] msgmni has been set to 989
[    0.868170] io scheduler noop registered
[    0.871976] io scheduler deadline registered
[    0.876515] io scheduler cfq registered (default)
[    0.900709] dma-pl330 f8003000.ps7-dma: Loaded driver for PL330 DMAC-2364208
[    0.907677] dma-pl330 f8003000.ps7-dma:      DBUFF-128x8bytes Num_Chans-8 Num_Peri-4 Num_Events-16
[    0.919825] e0001000.serial: ttyPS0 at MMIO 0xe0001000 (irq = 82, base_baud = 3125000) is a xuartps
[    0.929303] console [ttyPS0] enabled
[    0.929303] console [ttyPS0] enabled
[    0.936409] bootconsole [earlycon0] disabled
[    0.936409] bootconsole [earlycon0] disabled
[    0.947544] xdevcfg f8007000.ps7-dev-cfg: ioremap 0xf8007000 to e0866000
[    0.957372] [drm] Initialized drm 1.1.0 20060810
[    0.995475] brd: module loaded
[    1.017895] loop: module loaded
[    1.033602] m25p80 spi0.0: found s25fl128s1, expected n25q128
[    1.040189] m25p80 spi0.0: s25fl128s1 (16384 Kbytes)
[    1.045214] 4 ofpart partitions found on MTD device spi0.0
[    1.050922] Creating 4 MTD partitions on "spi0.0":
[    1.055660] 0x000000000000-0x000000400000 : "qspi-fsbl-uboot"
[    1.069039] 0x000000400000-0x000000900000 : "qspi-linux"
[    1.078943] 0x000000900000-0x000000920000 : "qspi-device-tree"
[    1.089592] 0x000000920000-0x000001000000 : "qspi-user"
[    1.108949] e1000e: Intel(R) PRO/1000 Network Driver - 2.3.2-k
[    1.114704] e1000e: Copyright(c) 1999 - 2013 Intel Corporation.
[    1.126884] libphy: XEMACPS mii bus: probed
[    1.133208] xemacps e000b000.ps7-ethernet: pdev->id -1, baseaddr 0xe000b000, irq 54
[    1.143729] ehci_hcd: USB 2.0 'Enhanced' Host Controller (EHCI) Driver
[    1.150943] ehci-pci: EHCI PCI platform driver
[    1.156081] ULPI transceiver vendor/product ID 0x0424/0x0007
[    1.161664] Found SMSC USB3320 ULPI transceiver.
[    1.166381] ULPI integrity check: passed.
[    1.171211] zynq-ehci zynq-ehci.0: Xilinx Zynq USB EHCI Host Controller
[    1.178687] zynq-ehci zynq-ehci.0: new USB bus registered, assigned bus number 1
[    1.215958] zynq-ehci zynq-ehci.0: irq 53, io mem 0x00000000
[    1.235908] zynq-ehci zynq-ehci.0: USB 2.0 started, EHCI 1.00
[    1.248654] hub 1-0:1.0: USB hub found
[    1.252653] hub 1-0:1.0: 1 port detected
[    1.260691] usbcore: registered new interface driver usb-storage
[    1.269555] mousedev: PS/2 mouse device common for all mice
[    1.277214] i2c /dev entries driver
[    1.289700] zynq-edac f8006000.ps7-ddrc: ecc not enabled
[    1.295928] cpufreq_cpu0: failed to get cpu0 regulator: -19
[    1.304355] Xilinx Zynq CpuIdle Driver started
[    1.310701] sdhci: Secure Digital Host Controller Interface driver
[    1.317065] sdhci: Copyright(c) Pierre Ossman
[    1.321340] sdhci-pltfm: SDHCI platform and OF driver helper
[    1.328580] mmc0: no vqmmc regulator found
[    1.332608] mmc0: no vmmc regulator found
[    1.375889] mmc0: SDHCI controller on e0100000.ps7-sdio [e0100000.ps7-sdio] using ADMA
[    1.388343] usbcore: registered new interface driver usbhid
[    1.395941] usbhid: USB HID core driver
[    1.408774] TCP: cubic registered
[    1.412021] NET: Registered protocol family 17
[    1.417018] Registering SWP/SWPB emulation handler
[    1.424329] regulator-dummy: disabling
[    1.428776] drivers/rtc/hctosys.c: unable to open rtc device (rtc0)
[    1.438583] mmc0: new high speed SDHC card at address b368
[    1.446898] mmcblk0: mmc0:b368 USD   7.45 GiB
[    1.456894]  mmcblk0: p1
[    1.462271] ALSA device list:
[    1.465168]   No soundcards found.
[    1.470654] RAMDISK: gzip image found at block 0
[    1.884229] EXT2-fs (ram0): warning: mounting unchecked fs, running e2fsck is recommended
[    1.892697] VFS: Mounted root (ext2 filesystem) on device 1:0.
[    1.899470] devtmpfs: mounted
[    1.902748] Freeing unused kernel memory: 204K (c06e4000 - c0717000)
Starting rcS...
++ Mounting filesystem
++ Setting up mdev
++ Configure static IP 192.168.1.10
++ Starting telnet daemon
++ Starting http daemon
++ Starting ftp daemon
++ Starting dropbear (ssh) daemon
[    2.676499] random: dropbear urandom read with 7 bits of entropy available
++ Starting OLED Display
insmod: can't read '/lib/modules/3.14.0-xilinx-13567-g906a2c9/pmodoled-gpio.ko': No such file or directory
++ Exporting LEDs & SWs
rcS Complete
zynq> ls
bin         lib         lost+found  proc        sys         var
dev         licenses    mnt         root        tmp
etc         linuxrc     opt         sbin        usr
zynq>
6. Modify Device Tree and Compose Kernel Driver

Ubuntu上でのコマンド実行ログです.

1
2
3
4
5
6
7
8
9
10
zybo_bsd_linux$ mkdir drivers
zybo_bsd_linux$ cd drivers/
drivers$ vi Makefile
# Hands-on Tutorialにしたがい,編集
drivers$ wget http://nerdengineer.com/jp/resources/Blog_2014-08-19/myled.c
drivers$ make ARCH=arm CROSS_COMPILE=arm-xilinx-linux-gnueabi-
drivers$ cp ../Linux-Digilent-Dev/arch/arm/boot/dts/zynq-zybo.dts .
drivers$ vi zynq-zybo.dts
# Hands-on Tutorialにしたがい,編集
drivers$ ../Linux-Digilent-Dev/scripts/dtc/dtc -I dts -O dtb -o devicetree.dtb zynq-zybo.dts
7. User Application

Ubuntu上でのコマンド実行ログです.

1
2
3
4
5
6
zybo_bsd_linux$ mkdir user_app
zybo_bsd_linux$ cd user_app/
user_app$ wget http://nerdengineer.com/jp/resources/Blog_2014-08-19/led_blink.c
user_app$ vi Makefile
# Hands-on Tutorialにしたがい,編集
user_app$ make
2015/01/14

ZYBO Base System Design (Vivado 2014.4) - 3

はじめに

本投稿は,ZYBO Base System Design (Vivado 2014.4) - 2の続きです. ソフトウェアのビルドまで完了していますので,引き続きXilinx SDK 2014.4を使用してソフトウェアを実行します.

作業備忘録
  1. FPGAにBitstreamをダウンロードする
  2. 「Xilinx Tools」 - 「Program FPGA」をクリックし,「Program FPGA」ウィンドウを開きます. 「Program」をクリックすると,FPGAにBitstreamがダウンロードされます. ダウンロードが完了すると,ZYBO上のDONE LED (緑色)が点灯します.

    Program FPGA
  3. UART,HDMIの接続を行う
  4. Tera Termを起動し,シリアルポートに接続しておきます. また,HDMIケーブルを使用して,液晶ディスプレイと接続しておきます. VGA接続でも良いと思いますが,私はまだ試していません.
  5. ソフトウェアを実行する
  6. 「Project Explorer」上で「base_demo」を右クリックし,「Run As...」 - 「Launch on Hardware (GDB)」を選択します. 「Xilinx C/C++ Application」ウィンドウが開きますので,Debug用またはRelease用の「base_demo.elf」を選択して,「OK」をクリックします. この操作により,ソフトウェアの実行が開始されます.

    Run Configurations
  7. base_demo
  8. 実行時の写真とスクリーンキャプチャです. Tera Term上から,音声出力と映像出力を操作できるものでした.

    メインメニュー

    実行開始直後の出力映像(HDMI)

    HDMIメニュー
microSDHCから起動するためには…
「C:\work\zybo_base_system\SDK\README.txt」を参照してください. これまでの作業がベースになっているため,特に迷うことはありませんでした.
2015/01/12

Ubuntu上にnxtOSEKの開発環境を構築する

はじめに

Lego Mindstorms NXTの開発環境(ARM用クロスコンパイル環境とnxtOSEK)をUbuntu上に構築しましたので,コマンドの実行履歴を参考に,作業手順をメモしておきます. 今回は下記のWebページを参考に開発環境を構築しました. なお,公式Webページの「nxtOSEK Installation in Linux (Ubuntu 11.10/10.04/9.10/8.10)」は,タイトルの通りUbuntu 11.10以前を例に記述されており,内容が少々古いようです.

私も初心者ですので,内容に誤りが含まれている場合があります. また,本記事投稿現在,サンプルプログラムのmakeが通ることは確認していますが,実機での動作確認ができていません…. つきましては,何かお気づきの際は,コメントなどでご指摘いただければ幸いです.

開発環境

仮想マシンにインストールした,Ubuntu 14.04 LTS 32bit上に構築しました.

OS Ubuntu 14.04 LTS 32bit

今回の開発環境は,下記バージョンを使用して構築しました.

GNU Binutils 2.20.1
GCC 4.4.7
Newlib 1.18.0
nxtOSEK 2.18
作業備忘録
  1. 既存環境を最新状態に更新する
  2. 下記コマンドを実行しました.

    1
    2
    ~$ sudo apt-get update
    ~$ sudo apt-get upgrade
  3. ディレクトリを作成する
  4. ホームディレクトリに,ディレクトリ「ETRobo」を作成しました.

    1
    ~$ mkdir ETRobo
  5. インストールスクリプトを取得する
  6. gmsanchez/nxtOSEK · GitHub」で公開されている,nxtOSEK 2.18 + Ubuntu 14.04 LTS向けのインストールスクリプトを使用することにしました. 下記コマンドを実行し,gitでインストールスクリプトのリポジトリを取得しました. gitをインストールしていない場合は,先にapt-getでインストールを完了してください.

    1
    2
    ~$ cd ~/ETRobo/
    ETRobo$ git clone https://github.com/gmsanchez/nxtOSEK.git
  7. 必要なライブラリをインストールする
  8. 必要なライブラリをインストールしました. 「tk-dev」および「ncurses-dev」は不要かもしれません.

    1
    2
    3
    4
    ETRobo$ sudo apt-get install tk-dev ncurses-dev
    ETRobo$ sudo apt-get install build-essential texinfo libgmp-dev libmpfr-dev libppl-dev libcloog-ppl-dev
    ETRobo$ sudo apt-get install jlha-utils
    ETRobo$ sudo apt-get install wine
  9. GNU ARMのビルドとインストールを実行する
  10. インストールスクリプトを使用して,GNU ARMのビルドとインストールを実行しました. 「Build complete!」と表示されたら,成功です. この処理は,私の環境では1時間弱かかりました.

    1
    2
    ETRobo$ cd ~/ETRobo/nxtOSEK/
    nxtOSEK$ sh ./build_arm_toolchain.sh 2>&1 | tee ./build_arm_toolchain.sh.log
  11. gccの状態を確認する
  12. 下記コマンドを実行し,ビルドとインストールを終えたgccの状態を確認しました.

    1
    2
    3
    4
    5
    6
    7
    nxtOSEK$ ./gnuarm/bin/arm-elf-gcc -print-multi-lib
    .;
    thumb;@mthumb
    fpu;@mhard-float
    interwork;@mthumb-interwork
    fpu/interwork;@mhard-float@mthumb-interwork
    thumb/interwork;@mthumb@mthumb-interwork
  13. nxtOSEKのセットアップを行う
  14. 下記コマンドを実行し,必要なファイルのダウンロードと,ファイルの追加処理を実行しました.

    1
    2
    3
    4
    5
    6
    nxtOSEK$ wget http://sourceforge.net/projects/lejos-osek/files/nxtOSEK/nxtOSEK_v218.zip
    nxtOSEK$ wget http://www.toppers.jp/download.cgi/osek_os-1.1.lzh
    nxtOSEK$ unzip nxtOSEK_v218.zip
    nxtOSEK$ lha -e osek_os-1.1.lzh
    nxtOSEK$ mv toppers_osek/sg/sg.exe ./nxtOSEK/toppers_osek/sg
    nxtOSEK$ rm -rf toppers_osek

    続いて,同じディレクトリでファイルの上書き処理を実行しました.

    1
    2
    3
    nxtOSEK$ cp ecrobot.mak ./nxtOSEK/ecrobot/
    nxtOSEK$ cp ecrobot++.mak ./nxtOSEK/ecrobot/
    nxtOSEK$ cp tool_gcc.mak ./nxtOSEK/ecrobot/

    テキストエディタで「tool_gcc.mak」を開きます.

    1
    2
    nxtOSEK$ cd ~/ETRobo/nxtOSEK/nxtOSEK/ecrobot/
    ecrobot$ vi tool_gcc.mak

    「tool_gcc.mak」の9行目を,下記のように変更します. これで開発環境の構築は完了です.

    7
    8
    9
    10
    11
    # specify GNU-ARM root directory
    ifndef GNUARM_ROOT
    GNUARM_ROOT = ~/ETRobo/nxtOSEK/gnuarm
    #/cygdrive/C/cygwin/GNUARM
    endif
  15. インストール状態を確認する
  16. 下記コマンドを実行し,インストール状態を確認しました.

    1
    2
    3
    ecrobot$ cd ~/ETRobo/nxtOSEK/nxtOSEK/samples_c/helloworld/
    helloworld$ export LC_ALL=C
    helloworld$ make all

    正常終了の場合は,「helloworld_OSEK.rxe」が生成されます.

    1
    2
    3
    Generating binary image file: helloworld_OSEK_rom.bin
    Generating binary image file: helloworld_OSEK_ram.bin
    Generating binary image file: helloworld_OSEK.rxe

    下記のエラーメッセージでmakeが中断した場合は,「export LC_ALL=C」を実行し忘れていないか確認してください. この環境変数の変更処理は,日本語環境特有のようです.

    1
    2
    3
    4
    Compiling kernel_cfg.c to kernel_cfg.o
    arm-elf-gcc: kernel_cfg.c: そのようなファイルやディレクトリはありません
    arm-elf-gcc: no input files
    make: *** [build/./kernel_cfg.o] エラー 1

以上,参考になれば幸いです.

2015/01/07

OpenCV 2.4.10をUbuntu 14.04 32bitにインストール

OpenCV 2.4.10を仮想マシン上のUbuntu 14.04 LTS 32bitにインストールしました. OpenCVをLinux環境にインストールしたのは初めてで,ちゃんとインストールできるまでにかなり時間がかかってしまいました…. 作業手順をメモしておきます. 掲載内容に間違いがありましたら,コメントにてご指摘いただければ幸いです.

インストール前の準備
  1. 既存環境を最新状態に更新する
  2. 下記コマンドを実行しました.

    1
    2
    ~$ sudo apt-get update
    ~$ sudo apt-get upgrade
  3. OpenCVのソースファイルをダウンロードする
  4. ホームディレクトリに「OpenCV」ディレクトリを作成し,OpenCVのソースをダウンロードしました. ダウンロードした圧縮ファイルは,展開しておきました.

    1
    2
    3
    4
    ~$ mkdir OpenCV
    ~$ cd OpenCV/
    OpenCV$ wget http://sourceforge.net/projects/opencvlibrary/files/opencv-unix/2.4.10/opencv-2.4.10.zip
    OpenCV$ unzip opencv-2.4.10.zip
  5. ソースにパッチを適用する(32bit環境のみ)
  6. Ubuntu 14.04 LTS 32bitではmakeがエラー終了してしまいました. 対処方法は,core: fix x86 PIC code compilationで紹介されています. 「opencv-2.4.10_system.cpp.patch」というファイル名で,下記コードをホームディレクトリに保存してください.

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    *** ./OpenCV/opencv-2.4.10/modules/core/src/system.cpp  2014-10-01 16:33:36.000000000 +0900
    --- ./system.cpp    2014-12-08 08:25:38.178802775 +0900
    ***************
    *** 273,280 ****
               "movl $7,%%eax\n\t"
               "movl $0,%%ecx\n\t"
               "cpuid\n\t"
               "popl %%ebx\n\t"
    !          : "=a"(cpuid_data[0]), "=b"(cpuid_data[1]), "=c"(cpuid_data[2]), "=d"(cpuid_data[3])
               :
               : "cc"
              );
    --- 273,281 ----
               "movl $7,%%eax\n\t"
               "movl $0,%%ecx\n\t"
               "cpuid\n\t"
    +          "movl %%ebx,%1\n\t"
               "popl %%ebx\n\t"
    !          : "=a"(cpuid_data[0]), "=r"(cpuid_data[1]), "=c"(cpuid_data[2]), "=d"(cpuid_data[3])
               :
               : "cc"
              );

    ホームディレクトリに戻り,パッチを適用してください.

    1
    2
    OpenCV$ cd ~
    ~$ patch -p0 < opencv-2.4.10_system.cpp.patch
インストール
シェルスクリプトの準備

作業自動化のため,下記のWebサイトを参考に,シェルスクリプトを作成しました. 下記コードを,「opencv-2.4.10.sh」というファイル名で,ホームディレクトリに保存してください.

[変更 2015/03/18] cmakeコマンドのオプション記述を変更しました.改行位置を変更したのみで,シェルスクリプトの動作に影響はありません.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
#!/bin/sh
 
echo "Installing Dependenices"
sudo apt-get update
# Build Tools
sudo apt-get -y install build-essential checkinstall cmake pkg-config yasm
# GUI
sudo apt-get -y install libqt4-dev libgtk2.0-dev
# Media & Video
sudo apt-get -y install libjpeg-dev libpng-dev libtiff5-dev libjasper-dev
sudo apt-get -y install libavcodec-dev libavformat-dev libswscale-dev libgstreamer0.10-dev libgstreamer-plugins-base0.10-dev libv4l-dev libxine-dev
sudo apt-get -y install libfaac-dev libmp3lame-dev libopencore-amrnb-dev libopencore-amrwb-dev libtheora-dev libvorbis-dev libxvidcore-dev
sudo apt-get -y install x264 v4l-utils
# Parallelism and linear algebra libraries
sudo apt-get -y install libtbb-dev libeigen3-dev
# Python
sudo apt-get -y install python-dev python-numpy
 
echo "Installing OpenCV 2.4.10"
cd ~/OpenCV/opencv-2.4.10
mkdir release
cd release
cmake \
    -DCMAKE_BUILD_TYPE=RELEASE \
    -DCMAKE_INSTALL_PREFIX=/usr/local \
    -DBUILD_EXAMPLES=ON \
    -DINSTALL_C_EXAMPLES=ON \
    -DINSTALL_PYTHON_EXAMPLES=ON \
    -DWITH_1394=OFF \
    -DWITH_OPENGL=ON \
    -DWITH_QT=ON \
    -DWITH_TBB=ON \
    -DWITH_V4L=ON \
    -DWITH_XINE=ON \
    ..
make
sudo make install
sudo sh -c 'echo "/usr/local/lib" > /etc/ld.so.conf.d/opencv.conf'
sudo ldconfig
echo "OpenCV 2.4.10 ready to be used"
シェルスクリプトの実行

シェルスクリプトを実行しました. 実行中,パスワードの入力を求められる場合があります. 私の環境では,実行完了まで1時間弱かかりました.

1
2
~$ chmod +x opencv-2.4.10.sh
~$ ./opencv-2.4.10.sh 2>&1 | tee ./opencv-2.4.10_install.log
(参考)cmakeの実行結果

私の環境でのcmakeの実行結果は下記のとおりです. ホームディレクトリに作成されるログファイル「opencv-2.4.10_install.log」で確認できます.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
-- General configuration for OpenCV 2.4.10 =====================================
--   Version control:               unknown
--
--   Platform:
--     Host:                        Linux 3.13.0-24-generic i686
--     CMake:                       2.8.12.2
--     CMake generator:             Unix Makefiles
--     CMake build tool:            /usr/bin/make
--     Configuration:               RELEASE
--
--   C/C++:
--     Built as dynamic libs?:      YES
--     C++ Compiler:                /usr/bin/c++  (ver 4.8.2)
--     C++ flags (Release):         -fsigned-char -W -Wall -Werror=return-type -Werror=address -Werror=sequence-point -Wformat -Werror=format-security -Wmissing-declarations -Wundef -Winit-self -Wpointer-arith -Wshadow -Wsign-promo -Wno-narrowing -Wno-delete-non-virtual-dtor -fdiagnostics-show-option -pthread -march=i686 -fomit-frame-pointer -msse -msse2 -msse3 -mfpmath=sse -ffunction-sections -O2 -DNDEBUG  -DNDEBUG
--     C++ flags (Debug):           -fsigned-char -W -Wall -Werror=return-type -Werror=address -Werror=sequence-point -Wformat -Werror=format-security -Wmissing-declarations -Wundef -Winit-self -Wpointer-arith -Wshadow -Wsign-promo -Wno-narrowing -Wno-delete-non-virtual-dtor -fdiagnostics-show-option -pthread -march=i686 -fomit-frame-pointer -msse -msse2 -msse3 -mfpmath=sse -ffunction-sections -g  -O0 -DDEBUG -D_DEBUG
--     C Compiler:                  /usr/bin/cc
--     C flags (Release):           -fsigned-char -W -Wall -Werror=return-type -Werror=address -Werror=sequence-point -Wformat -Werror=format-security -Wmissing-declarations -Wmissing-prototypes -Wstrict-prototypes -Wundef -Winit-self -Wpointer-arith -Wshadow -Wno-narrowing -fdiagnostics-show-option -pthread -march=i686 -fomit-frame-pointer -msse -msse2 -msse3 -mfpmath=sse -ffunction-sections -O2 -DNDEBUG  -DNDEBUG
--     C flags (Debug):             -fsigned-char -W -Wall -Werror=return-type -Werror=address -Werror=sequence-point -Wformat -Werror=format-security -Wmissing-declarations -Wmissing-prototypes -Wstrict-prototypes -Wundef -Winit-self -Wpointer-arith -Wshadow -Wno-narrowing -fdiagnostics-show-option -pthread -march=i686 -fomit-frame-pointer -msse -msse2 -msse3 -mfpmath=sse -ffunction-sections -g  -O0 -DDEBUG -D_DEBUG
--     Linker flags (Release):     
--     Linker flags (Debug):       
--     Precompiled headers:         YES
--
--   OpenCV modules:
--     To be built:                 core flann imgproc highgui features2d calib3d ml video legacy objdetect photo gpu ocl nonfree contrib python stitching superres ts videostab
--     Disabled:                    world
--     Disabled by dependency:      -
--     Unavailable:                 androidcamera dynamicuda java viz
--
--   GUI:
--     QT 4.x:                      YES (ver 4.8.6 EDITION = OpenSource)
--     QT OpenGL support:           YES (/usr/lib/i386-linux-gnu/libQtOpenGL.so)
--     OpenGL support:              YES (/usr/lib/i386-linux-gnu/libGLU.so /usr/lib/i386-linux-gnu/libGL.so /usr/lib/i386-linux-gnu/libSM.so /usr/lib/i386-linux-gnu/libICE.so /usr/lib/i386-linux-gnu/libX11.so /usr/lib/i386-linux-gnu/libXext.so)
--     VTK support:                 NO
--
--   Media I/O:
--     ZLib:                        /usr/lib/i386-linux-gnu/libz.so (ver 1.2.8)
--     JPEG:                        /usr/lib/i386-linux-gnu/libjpeg.so (ver )
--     PNG:                         /usr/lib/i386-linux-gnu/libpng.so (ver 1.2.50)
--     TIFF:                        /usr/lib/i386-linux-gnu/libtiff.so (ver 42 - 4.0.3)
--     JPEG 2000:                   /usr/lib/i386-linux-gnu/libjasper.so (ver 1.900.1)
--     OpenEXR:                     build (ver 1.7.1)
--
--   Video I/O:
--     DC1394 1.x:                  NO
--     DC1394 2.x:                  NO
--     FFMPEG:                      YES
--       codec:                     YES (ver 54.35.0)
--       format:                    YES (ver 54.20.4)
--       util:                      YES (ver 52.3.0)
--       swscale:                   YES (ver 2.1.1)
--       gentoo-style:              YES
--     GStreamer:                  
--       base:                      YES (ver 0.10.36)
--       video:                     YES (ver 0.10.36)
--       app:                       YES (ver 0.10.36)
--       riff:                      YES (ver 0.10.36)
--       pbutils:                   YES (ver 0.10.36)
--     OpenNI:                      NO
--     OpenNI PrimeSensor Modules:  NO
--     PvAPI:                       NO
--     GigEVisionSDK:               NO
--     UniCap:                      NO
--     UniCap ucil:                 NO
--     V4L/V4L2:                    Using libv4l1 (ver 1.0.1) / libv4l2 (ver 1.0.1)
--     XIMEA:                       NO
--     Xine:                        YES (ver 1.1.21)
--
--   Other third-party libraries:
--     Use IPP:                     NO
--     Use Eigen:                   YES (ver 3.2.0)
--     Use TBB:                     YES (ver 4.2 interface 7000)
--     Use OpenMP:                  NO
--     Use GCD                      NO
--     Use Concurrency              NO
--     Use C=:                      NO
--     Use Cuda:                    NO
--     Use OpenCL:                  YES
--
--   OpenCL:
--     Version:                     dynamic
--     Include path:                /home/省略/OpenCV/opencv-2.4.10/3rdparty/include/opencl/1.2
--     Use AMD FFT:                 NO
--     Use AMD BLAS:                NO
--
--   Python:
--     Interpreter:                 /usr/bin/python2 (ver 2.7.6)
--     Libraries:                   /usr/lib/i386-linux-gnu/libpython2.7.so (ver 2.7.6)
--     numpy:                       /usr/lib/python2.7/dist-packages/numpy/core/include (ver 1.8.2)
--     packages path:               lib/python2.7/dist-packages
--
--   Java:
--     ant:                         NO
--     JNI:                         NO
--     Java tests:                  NO
--
--   Documentation:
--     Build Documentation:         NO
--     Sphinx:                      NO
--     PdfLaTeX compiler:           NO
--
--   Tests and samples:
--     Tests:                       YES
--     Performance tests:           YES
--     C/C++ Examples:              YES
--
--   Install path:                  /usr/local
--
--   cvconfig.h is in:              /home/省略/OpenCV/opencv-2.4.10/release
-- -----------------------------------------------------------------
動作確認

Webカメラの映像を表示するプログラムをコンパイルし,実行してみました. 私の環境では,14~16行目のようにフレームサイズとフレームレートを設定しなかった場合,端末に「select timeout」と表示されてWebカメラの映像を表示できませんでした. Webカメラは720p,30fpsにも対応している,Logicool HD Webcam C270です. 仮想マシン上で実行していることなど,環境依存の問題なのではないかと考えていますが,表示できなかった理由はわかっていません….

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
#include <iostream>
#include <opencv2/opencv.hpp>
 
using namespace std;
using namespace cv;
 
int key = -1;
 
int main(int argc, char *argv[])
{
    VideoCapture cap(0);
    Mat frame;
     
    cap.set(CV_CAP_PROP_FRAME_WIDTH, 320);
    cap.set(CV_CAP_PROP_FRAME_HEIGHT, 240);
    cap.set(CV_CAP_PROP_FPS, 5);
     
    if(!cap.isOpened()){
        cout << "webcam is not detected" << endl;
         
        return 1;
    }
    cout << "webcam is detected" << endl;
     
    while(key != 'q'){
        namedWindow("webcam", 1);
        cap >> frame;
        imshow("webcam", frame);
        key = waitKey(30);
    }
     
    return 0;
}

上記コードを「webcam.cpp」というファイル名で保存し,コンパイルと実行を行いました.

1
2
work$ g++ -o webcam webcam.cpp `pkg-config --cflags opencv` `pkg-config --libs opencv`
work$ ./webcam

実行例です.ウィンドウがMac OS X風ですが,Ubuntuです.


webcamの実行結果

以上,参考になれば幸いです.

製品紹介
LOGICOOL ウェブカム HD画質 120万画素 C270
ロジクール (2010-08-20)
売り上げランキング: 736