なんだこれは

はてなダイアリーから移転しました。

せっかくなので qemu で Raspberry PI の仮想環境を整備したい6

qemu/Yosemite 上の仮想環境の Raspberian ですが、しばらく放置していたら Raspberian の 新しいのがでていたので、やりなおすことにした。あと、Clozure CLをインストールした。

sudo port installed | grep qemu

qemu @2.2.0_0+cocoa+ssh+target_arm+target_i386+target_x86_64+usb (active)

です。

qemu が raspberry に対応しているか確認する。

>|sh|
qemu-system-arm -M versatilepb -cpu '?' | grep arm1176
|

arm1176 ありました。

イメージダウンロード

http://www.raspberrypi.org/downloads から Raspbian のイメージをダウンロードし解凍する。今回は、2015-02-16-raspbian-wheezy.img 。
同じディレクトリに http://xecdesign.com/downloads/linux-qemu/kernel-qemu からカーネルイメージをダウンロードする。これは kernel-qemu

設定のために起動する。

bash を起動する。

qemu-system-arm -kernel kernel-qemu -cpu arm1176 -m 256 -M versatilepb -no-reboot -serial stdio -append "root=/dev/sda2 panic=1 rootfstype=ext4 rw init=/bin/bash" -hda 2015-02-16-raspbian-wheezy.img


/etc/ld.so.preload を編集してコメントアウトする。

#/usr/lib/arm-linux-gnueabihf/libcofi_rpi.so

このときに何もかんがえずに vi でやると、前回同様に キーボードが設定できていなくてびびる。 shift+; で コロンが入力できる。これで脱出できるはず。

/etc/udev/rules.d/90-qemu.rules を作成して以下を記入します.

KERNEL=="sda", SYMLINK+="mmcblk0"
KERNEL=="sda?", SYMLINK+="mmcblk0p%n"
KERNEL=="sda2", SYMLINK+="root"

ここもキーボードのレイアウトがアレなので ^ で =が、shift+^ で+ が shift+*で" が入力できたはず。

bash おしまい

exit

raspberian の Linux を起動する。

qemu-system-arm -kernel kernel-qemu -cpu arm1176 -m 256 -M versatilepb -no-reboot -serial stdio -append "root=/dev/sda2 panic=1 rootfstype=ext4 rw" -hda 2015-02-16-raspbian-wheezy.img

iTerm の方からログインして操作できるので、こちらからいろいろすることにする。

Uncompressing Linux... done, booting the kernel.

Raspbian GNU/Linux 7 raspberrypi ttyAMA0

raspberrypi login:

User=pi Password=raspberry でログインする。

Linux raspberrypi 3.10.26+ #2 Fri Jan 17 22:13:59 EST 2014 armv6l

The programs included with the Debian GNU/Linux system are free software;
the exact distribution terms for each program are described in the
individual files in /usr/share/doc/*/copyright.

Debian GNU/Linux comes with ABSOLUTELY NO WARRANTY, to the extent
permitted by applicable law.

NOTICE: the software on this Raspberry Pi has not been fully configured. Please run 'sudo raspi-config'

更新する

sudo apt-get update
sudo apt-get upgrade

Clozure CL をインストールする

ARMで動作する Clozure CL をインストールする。

Clozure CLのインストールに必要な準備
sudo apt-get install build-essential m4 subversion
Clozure CLのダウンロード
mkdir work
cd work
svn co http://svn.clozure.com/publicsvn/openmcl/release/1.10/linuxarm/ccl
Clozure CL の実行
./armcl

残念だがエラーがでた。

./armcl: /lib/arm-linux-gnueabihf/libc.so.6: version `GLIBC_2.15' not found (required by ./armcl)

このようなエラーは公式HPにあるように、この環境でカーネルをビルドしなおす必要がある。
ここで build-essential と m4 が必要になる。

If the lisp kernel binary does not work, you probably need to rebuild it on your local system. An error message that says somthing like "GLIBC_2.15 not found" is an indication that you need to do this. See the section below for instructions.

...(snip)...

Building the lisp kernel

As mentioned above, it is sometimes necessary to compile the lisp kernel binary on your local system.

To do this, from your ccl directory, go to lisp-kernel/linuxx8664 (or whatever the proper directory is for your system; see the table above), and do "make clean && make".

For example, on FreeBSD, you would do:

cd lisp-kernel/freebsdx8664 # or freebsdx8632 for the 32-bit version
make clean && make

Note that you must have m4 installed in order to compile the lisp kernel. On OS X, if you get warnings about not being able to find certain include files, run "xcode-select --install".

http://ccl.clozure.com/install.html
Clozure CL のカーネルのビルド
cd lisp-kernel/linuxarm
make clean
make
cd ../..
Clozure CLの起動
./armcl

Welcome to Clozure Common Lisp Version 1.10-r16196 (LinuxARM32)!

CCL is developed and maintained by Clozure Associates. For more information
about CCL visit http://ccl.clozure.com. To enquire about Clozure's Common Lisp
consulting services e-mail info@clozure.com or visit http://www.clozure.com.

?

とりあえず終了できた。

(quit)