LoginSignup
6
6

More than 5 years have passed since last update.

ARM V8をシミュレータで試食(Linuxを動かしてみる)

Last updated at Posted at 2014-06-06

前回( http://qiita.com/chromabox/items/1923d92e035cd27e8bb7 )の続きです。

Hello Worldを動かしただけではおもしろく無いのでLinuxを動かしてみます。

すでにLinaroがポーティングをしているので割と楽に動かせます。
ほんといい時代になったもんです。

シミュレータ入れて無い人はとりあえず前回の記事を見て入れましょう。

イメージの入手

とりあえずイメージが無かったら話になりません。
イメージはここからダウンロードしてきます。

ファイルが色々ありますがとりあえず動かすのであれば以下だけでOKです。

  • img-foundation.axf
  • vexpress64-openembedded_minimal-armv8-gcc-4.8_20140417-630.img.gz

ダウンロードしたら、vexpress64-openembedded_ほげほげimg.gzは展開してあげてください。

$ gunzip vexpress64-openembedded_minimal-armv8-gcc-4.8_20140417-630.img.gz

起動方法

イメージを落としたらあとはコマンドを叩いて動かすだけですが、環境変数を設定するスクリプトを作っておくと便利です。
注意すべき点としてはライブラリのパスも指定しないと動かないところですね。

v8foundation.sh
#!/bin/bash
export PATH=[hogehoge]Foundation_v8pkg/models/Linux64_GCC-4.1:$PATH
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:[hogehoge]Foundation_v8pkg/models/Linux64_GCC-4.1
echo "set arm foundation v8"

[hogehoge]の部分は適時環境に合わせて変更してください。
スクリプトを作ったら以下のようにして環境変数を設定します。
$ . ./v8foundation.sh

次のコマンドで実際にシミュレータ上でlinuxを起動させます。

cmd

$ Foundation_v8 --image img-foundation.axf --block-device vexpress64-openembedded_minimal-armv8-gcc-4.8_20140417-630.img --network nat --cores=4 --no-secure-memory

うまくいったらXtermが新しく起動して、それがシミュレータ上で動くコンソール(UART)の代わりになります。

xtermが嫌な場合は起動中に
$ telnet 127.0.0.1 5000
とやると、xtermが消えて今のコンソールがUARTになります。

NATモードを指定していますが、ネットワークがつながらないみたいなのでその辺はまた確認したいと思います。→できました。

起動ログは長いので最後に示しています…

NATを使いたい

実は起動方法を変えると利用できました。

以下のファイルが追加で必要になりますので、ここ( http://releases.linaro.org/14.04/openembedded/aarch64/ )よりダウンロードします。
* Image (カーネルイメージそのもの)
* fvp-foundation-gicv2-psci.dtb (デバイス定義ツリー)
* fvp_bl1.bin (ファームウェアその1)
* fvp_fip.bin (ファームウェアその2)

そして、事前にfvp-foundation-gicv2-psci.dtbの名前をfdt.dtbに変更しておきます。
で、次のコマンドでシミュレータを実行するとOKです。

cmd

$ Foundation_v8 --cores=4 --no-secure-memory --gicv3 --data=fvp_bl1.bin@0x0 --data=fvp_fip.bin@0x8000000 --block-device vexpress64-openembedded_minimal-armv8-gcc-4.8_20140417-630.img --network nat

ブートローダ(UEFI)で止まる場合は、Imageファイルとfdt.dtbファイルがコマンド実行したディレクトリと同じ場所に無い事が考えられるので確認を。。

どうやら前のコマンド(img-foundation.axf)は、以前のシミュレータのバージョンでも動くようにファームが古かったのでNATが使えなかったみたいです。
で、次のようにPINGが通ればOKです。

cmd

$ ping 127.20.51.1
PING 127.20.51.1 (127.20.51.1) 56(84) bytes of data.
64 bytes from 127.20.51.1: icmp_req=1 ttl=64 time=0.030 ms
64 bytes from 127.20.51.1: icmp_req=2 ttl=64 time=0.024 ms
64 bytes from 127.20.51.1: icmp_req=3 ttl=64 time=0.019 ms

ファイルシステムの中身を変えたい

ネットワークが動いてない状態では、外からファイルシステムの中身を変えるのはとにかく面倒くさいので、マウントのやり方を書きます。

ただ、Linaroイメージツールで作成した.imgはパーティションも含んでいるため、単純にはマウントできません。

まず、fdiskコマンドでファイルイメージの状態を調べます。
(イメージファイルは長ったらしいのでdiskimg.imgに名前変えました…)

cmd

$ fdisk -u -l diskimg.img 

ディスク diskimg.img: 3221 MB, 3221225472 バイト
ヘッド 255, セクタ 63, シリンダ 391, 合計 6291456 セクタ
Units = セクタ数 of 1 * 512 = 512 バイト
セクタサイズ (論理 / 物理): 512 バイト / 512 バイト
I/O サイズ (最小 / 推奨): 512 バイト / 512 バイト
ディスク識別子: 0x00000000

デバイス ブート      始点        終点     ブロック   Id  システム
diskimg.img1   *          63      139262       69600    e  W95 FAT16 (LBA)
diskimg.img2          139264     6291455     3076096   83  Linux

Linuxパーティションの開始位置が139264と分かったので、このオフセットを直接指定してやってマウントをします。

$ sudo mount -o loop,offset=$[139264*512] diskimg.img tmpmount

(参考:https://wiki.linaro.org/Resources/HowTo/Qemu-beagleboard)

起動ログ

こんな感じになります。
CPUは4個動いてます。

log
root@genericarmv8:~# dmesg
[    0.000000] Linux version 3.14.0-1-linaro-vexpress64 (buildslave@Ubuntu-1204-precise-64-minimal) (gcc version 4.8.3 20140303 (prerelease) (crosstool-NG linaro-1.13.1-4.8-2014.03 - Linaro GCC 2014.03) ) #1ubuntu1~ci+140417081059 SMP Thu Apr 17 10:11:42 CEST 2014
[    0.000000] Kernel was built at commit id ''
[    0.000000] CPU: AArch64 Processor [410fd000] revision 0
[    0.000000] bootconsole [earlycon0] enabled
[    0.000000] On node 0 totalpages: 1048576
[    0.000000]   DMA zone: 7168 pages used for memmap
[    0.000000]   DMA zone: 0 pages reserved
[    0.000000]   DMA zone: 524288 pages, LIFO batch:31
[    0.000000]   Normal zone: 7168 pages used for memmap
[    0.000000]   Normal zone: 524288 pages, LIFO batch:31
[    0.000000] PERCPU: Embedded 12 pages/cpu @ffffffc87ffa2000 s17600 r8192 d23360 u49152
[    0.000000] pcpu-alloc: s17600 r8192 d23360 u49152 alloc=12*4096
[    0.000000] pcpu-alloc: [0] 0 [0] 1 [0] 2 [0] 3 
[    0.000000] Built 1 zonelists in Zone order, mobility grouping on.  Total pages: 1034240
[    0.000000] Kernel command line: console=ttyAMA0 earlyprintk=pl011,0x1c090000 consolelog=9 rw root=/dev/vda2
[    0.000000] PID hash table entries: 4096 (order: 3, 32768 bytes)
[    0.000000] Dentry cache hash table entries: 524288 (order: 10, 4194304 bytes)
[    0.000000] Inode-cache hash table entries: 262144 (order: 9, 2097152 bytes)
[    0.000000] Memory: 4120572K/4194304K available (6121K kernel code, 485K rwdata, 2228K rodata, 293K init, 597K bss, 73732K reserved)
[    0.000000] Virtual kernel memory layout:
[    0.000000]     vmalloc : 0xffffff8000000000 - 0xffffffbbffff0000   (245759 MB)
[    0.000000]     vmemmap : 0xffffffbc01c00000 - 0xffffffbc1f800000   (   476 MB)
[    0.000000]     modules : 0xffffffbffc000000 - 0xffffffc000000000   (    64 MB)
[    0.000000]     memory  : 0xffffffc000000000 - 0xffffffc880000000   ( 34816 MB)
[    0.000000]       .init : 0xffffffc0008a9000 - 0xffffffc0008f24c0   (   294 kB)
[    0.000000]       .text : 0xffffffc000080000 - 0xffffffc0008a84f4   (  8354 kB)
[    0.000000]       .data : 0xffffffc0008f3000 - 0xffffffc00096c7c8   (   486 kB)
[    0.000000] Hierarchical RCU implementation.
[    0.000000]  RCU restricting CPUs from NR_CPUS=8 to nr_cpu_ids=4.
[    0.000000] RCU: Adjusting geometry for rcu_fanout_leaf=16, nr_cpu_ids=4
[    0.000000] NR_IRQS:64 nr_irqs:64 0
[    0.000000] Architected cp15 timer(s) running at 100.00MHz (phys).
[    0.000025] sched_clock: 56 bits at 100MHz, resolution 10ns, wraps every 2748779069440ns
[    0.001510] Console: colour dummy device 80x25
[    0.001619] Calibrating delay loop (skipped), value calculated using timer frequency.. 200.00 BogoMIPS (lpj=1000000)
[    0.001691] pid_max: default: 32768 minimum: 301
[    0.002209] Security Framework initialized
[    0.002282] AppArmor: AppArmor initialized
[    0.002481] Mount-cache hash table entries: 8192 (order: 4, 65536 bytes)
[    0.002550] Mountpoint-cache hash table entries: 8192 (order: 4, 65536 bytes)
[    0.008928] hw perfevents: enabled with arm/armv8-pmuv3 PMU driver, 9 counters available
[    0.013218] CPU1: Booted secondary processor
[    0.014853] CPU2: Booted secondary processor
[    0.016485] CPU3: Booted secondary processor
[    0.017051] Brought up 4 CPUs
[    0.017172] SMP: Total of 4 processors activated.
[    0.020055] devtmpfs: initialized
[    0.032663] xor: measuring software checksum speed
[    0.130081]    8regs     :   168.000 MB/sec
[    0.230246]    8regs_prefetch:   148.000 MB/sec
[    0.330414]    32regs    :   172.400 MB/sec
[    0.430605]    32regs_prefetch:   148.000 MB/sec
[    0.430655] xor: using function: 32regs (172.400 MB/sec)
[    0.432572] regulator-dummy: no parameters
[    0.434104] NET: Registered protocol family 16
[    0.437178] cpuidle: using governor ladder
[    0.437220] cpuidle: using governor menu
[    0.449627] vdso: 2 pages (1 code, 1 data) at base ffffffc0008f9000
[    0.449719] hw-breakpoint: found 16 breakpoint and 16 watchpoint registers.
[    0.449811] Serial: AMBA PL011 UART driver
[    0.450081] 1c090000.uart: ttyAMA0 at MMIO 0x1c090000 (irq = 37, base_baud = 0) is a PL011 rev2
[    0.450147] console [ttyAMA0] enabled
[    0.450202] bootconsole [earlycon0] disabled
[    0.451257] 1c0a0000.uart: ttyAMA1 at MMIO 0x1c0a0000 (irq = 38, base_baud = 0) is a PL011 rev2
[    0.452262] 1c0b0000.uart: ttyAMA2 at MMIO 0x1c0b0000 (irq = 39, base_baud = 0) is a PL011 rev2
[    0.453256] 1c0c0000.uart: ttyAMA3 at MMIO 0x1c0c0000 (irq = 40, base_baud = 0) is a PL011 rev2
[    0.457306] software IO TLB [mem 0xffc00000-0x100000000] (4MB) mapped at [ffffffc07fc00000-ffffffc07fffffff]
[    0.518660] bio: create slab <bio-0> at 0
[    0.681502] raid6: int64x1     55 MB/s
[    0.852203] raid6: int64x2     65 MB/s
[    1.021822] raid6: int64x4     71 MB/s
[    1.193113] raid6: int64x8     58 MB/s
[    1.362840] raid6: neonx1     125 MB/s
[    1.532895] raid6: neonx2     151 MB/s
[    1.703231] raid6: neonx4     168 MB/s
[    1.873633] raid6: neonx8     153 MB/s
[    1.873678] raid6: using algorithm neonx4 (168 MB/s)
[    1.873723] raid6: using intx1 recovery algorithm
[    1.876733] SCSI subsystem initialized
[    1.878837] usbcore: registered new interface driver usbfs
[    1.879315] usbcore: registered new interface driver hub
[    1.879791] usbcore: registered new device driver usb
[    1.885471] NetLabel: Initializing
[    1.885512] NetLabel:  domain hash size = 128
[    1.885554] NetLabel:  protocols = UNLABELED CIPSOv4
[    1.885794] NetLabel:  unlabeled traffic allowed by default
[    1.886483] Switched to clocksource arch_sys_counter
[    1.957437] AppArmor: AppArmor Filesystem Enabled
[    1.998022] NET: Registered protocol family 2
[    2.000164] TCP established hash table entries: 32768 (order: 6, 262144 bytes)
[    2.003918] TCP bind hash table entries: 32768 (order: 7, 524288 bytes)
[    2.008579] TCP: Hash tables configured (established 32768 bind 32768)
[    2.008729] TCP: reno registered
[    2.008793] UDP hash table entries: 2048 (order: 4, 65536 bytes)
[    2.009601] UDP-Lite hash table entries: 2048 (order: 4, 65536 bytes)
[    2.011231] NET: Registered protocol family 1
[    2.012036] RPC: Registered named UNIX socket transport module.
[    2.012084] RPC: Registered udp transport module.
[    2.012129] RPC: Registered tcp transport module.
[    2.012176] RPC: Registered tcp NFSv4.1 backchannel transport module.
[    2.013765] kvm [1]: Using HYP init bounce page @ff81b000
[    2.014192] kvm [1]: interrupt-controller@2c004000 IRQ25
[    2.014564] kvm [1]: timer IRQ27
[    2.014625] kvm [1]: Hyp mode initialized successfully
[    2.019562] futex hash table entries: 1024 (order: 4, 65536 bytes)
[    2.019823] audit: initializing netlink subsys (disabled)
[    2.019912] audit: type=2000 audit(2.010:1): initialized
[    2.022668] HugeTLB registered 2 MB page size, pre-allocated 0 pages
[    2.025372] VFS: Disk quotas dquot_6.5.2
[    2.026000] Dquot-cache hash table entries: 512 (order 0, 4096 bytes)
[    2.029882] NFS: Registering the id_resolver key type
[    2.030163] Key type id_resolver registered
[    2.030208] Key type id_legacy registered
[    2.030322] jffs2: version 2.2. (NAND) (SUMMARY)  © 2001-2006 Red Hat, Inc.
[    2.031770] 9p: Installing v9fs 9p2000 file system support
[    2.031952] msgmni has been set to 8047
[    2.034431] Block layer SCSI generic (bsg) driver version 0.4 loaded (major 253)
[    2.034486] io scheduler noop registered
[    2.034532] io scheduler deadline registered
[    2.034670] io scheduler cfq registered (default)
[    2.294894] Serial: 8250/16550 driver, 4 ports, IRQ sharing disabled
[    2.335835] brd: module loaded
[    2.354624] loop: module loaded
[    2.355745] blk-mq: CPU -> queue map
[    2.355788]   CPU 0 -> Queue 0
[    2.355830]   CPU 1 -> Queue 0
[    2.355872]   CPU 2 -> Queue 0
[    2.355914]   CPU 3 -> Queue 0
[    2.357722]  vda: vda1 vda2
[    2.364497] mtdoops: mtd device (mtddev=name/number) must be supplied
[    2.364621] tun: Universal TUN/TAP device driver, 1.6
[    2.364668] tun: (C) 1999-2004 Max Krasnyansky <maxk@qualcomm.com>
[    2.365881] smc91x 1a000000.ethernet (unregistered net_device): smc91x: IOADDR ffffff8000080000 doesn't match configuration (300).
[    2.365946] smc91x.c: v1.1, sep 22 2004 by Nicolas Pitre <nico@fluxnic.net>
[    2.377378] smc91x 1a000000.ethernet eth0: SMC91C11xFD (rev 1) at ffffff8000080000 IRQ 47
[    2.377429] 
[    2.377492] smc91x 1a000000.ethernet eth0: Ethernet addr: 00:02:f7:ef:04:69
[    2.378246] ehci_hcd: USB 2.0 'Enhanced' Host Controller (EHCI) Driver
[    2.378298] ehci-h20ahb: H20AHB-EHCI Host Controller driver
[    2.378730] ohci_hcd: USB 1.1 'Open' Host Controller (OHCI) Driver
[    2.379215] usbcore: registered new interface driver usb-storage
[    2.380677] mousedev: PS/2 mouse device common for all mice
[    2.383667] device-mapper: ioctl: 4.27.0-ioctl (2013-10-30) initialised: dm-devel@redhat.com
[    2.385506] usbcore: registered new interface driver usbhid
[    2.385549] usbhid: USB HID core driver
[    2.386385] TCP: cubic registered
[    2.386423] Initializing XFRM netlink socket
[    2.386835] NET: Registered protocol family 10
[    2.390706] sit: IPv6 over IPv4 tunneling driver
[    2.393705] NET: Registered protocol family 17
[    2.393815] NET: Registered protocol family 15
[    2.394151] 9pnet: Installing 9P2000 support
[    2.394602] Key type dns_resolver registered
[    2.398740] bio: create slab <bio-1> at 1
[    2.400072] Btrfs loaded
[    2.400284] AppArmor: AppArmor sha1 policy hashing enabled
[    2.400762] regulator-dummy: disabling
[    2.401023] /home/buildslave/workspace/package-and-publish-linux-linaro/kernel_build/test_build/linux/drivers/rtc/hctosys.c: unable to open rtc device (rtc0)
[    2.403196] EXT3-fs (vda2): error: couldn't mount because of unsupported optional features (240)
[    2.404080] EXT2-fs (vda2): error: couldn't mount because of unsupported optional features (240)
[    2.410825] EXT4-fs (vda2): mounted filesystem with ordered data mode. Opts: (null)
[    2.410909] VFS: Mounted root (ext4 filesystem) on device 254:2.
[    2.411255] devtmpfs: mounted
[    2.411588] Freeing unused kernel memory: 292K (ffffffc0008a9000 - ffffffc0008f2000)
[    3.166032] udevd[1015]: starting version 182
[    3.397104] EXT4-fs (vda2): re-mounted. Opts: data=ordered
[    3.559965] random: dd urandom read with 9 bits of entropy available
[    4.747980] smc91x 1a000000.ethernet eth0: link up, 10Mbps, half-duplex, lpa 0x0000

root@genericarmv8:~# cat /proc/cpuinfo    
Processor   : AArch64 Processor rev 0 (aarch64)
processor   : 0
processor   : 1
processor   : 2
processor   : 3
Features    : fp asimd evtstrm 
CPU implementer : 0x41
CPU architecture: AArch64
CPU variant : 0x0
CPU part    : 0xd00
CPU revision    : 0

Hardware    : Foundation-v8A

root@genericarmv8:~# cat /proc/version 
Linux version 3.14.0-1-linaro-vexpress64 (buildslave@Ubuntu-1204-precise-64-minimal) (gcc version 4.8.3 20140303 (prerelease) (crosstool-NG linaro-1.13.1-4.8-2014.03 - Linaro GCC 2014.03) ) #1ubuntu1~ci+140417081059 SMP Thu Apr 17 10:11:42 CEST 2014

root@genericarmv8:~# 

6
6
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
6
6