uARM をもごもごしてみるなど
以下なエントリを発見。
これはこれは、ということで早速リポジトリを clone してます。で、とりあえず gtags -v して emacs 起動。Makefile を眺めてみるに
CC_FLAGS = -O2 -mmcu=atmega1284p -I/usr/lib/avr/include -DEMBEDDED -D_SIM -ffunction-sections
/usr/lib/avr は無いな。apt-cache search avr してみるに
- avr-libc
あたりなのかどうなのか。apt-get install してみるに以下が導入、らしい。
入れてみます。
すると確かに /usr/lib/avr/include はできておりますね。試しに make してみます。て、一瞬でコンパイルが終わりよった。を、uARM な実行ファイルもできている模様。
ちょっと README 見ながら動かしてみよ。
$ bzcat jaunty.rel.v2.bz2 > jaunty.rel.v2 $ ./uARM jaunty.rel.v2 (中略 Running: mount /dev/pvd1 /mnt ext4 rw [ 1.946083] EXT4-fs (pvd1): warning: checktime reached, running e2fsck is recommended [ 1.948735] EXT4-fs (pvd1): mounted filesystem with ordered data mode Running: umount /proc Running: cd /mnt Running: chroot . /bin/bash **ARG** 0:/bin/bash* **ENV** 0:SHELL=/bin/sh* 1:TTY=/dev/console* 2:HOME=/* 3:TERM=linux* 4:PATH=/sbin:/bin* bash: groups: command not found root@(none):/# uname -a Linux (none) 2.6.34.1-dgv #52 Sun Apr 1 00:36:21 PDT 2012 armv5tel GNU/Linux
これはすばら。あとイメージも確認してみたのですが、以下とのこと (改行付けてます)。
$ file jaunty.rel.v2 jaunty.rel.v2: x86 boot sector; partition 1: ID=0x83, starthead 1, startsector 32, 786432 sectors; partition 2: ID=0xdf, active, starthead 1, startsector 786464, 4096 sectors; partition 3: ID=0x82, starthead 1, startsector 790560, 262112 sectors, code offset 0x20
元エントリによれば AVR で動作する ARM エミュレータなんだけど PC でも動く、とありますね。main 関数のキモっぽい部分によれば以下。
root = fopen64(argv[1], "r+b"); if(!root){ fprintf(stderr,"Failed to open root device\n"); exit(-1); } if(argc >= 3) gdbPort = atoi(argv[2]); socInit(&soc, socRamModeAlloc, NULL, readchar, writechar, rootOps, root); signal(SIGINT, &ctl_cHandler); socRun(&soc, gdbPort);
イメージを open して、argv[2] は gdb なポートを指定する模様。gdb も使えるのか。そしてその下あたりがエントリポイントなのかどうか。
あ、今見てるのは main_pc.c です。QEMU は巨大なので、こちら足がかり、というのが正しいのかどうなのか。