2010年1月20日水曜日

Debug in Qemu

Now it is time to try the debug in qemu.

1. Start the qemu use the switch "-s"
$ qemu-system-arm -s -kernel uImage --nographic -serial stdio -M mini2440

2. Run the gdb with the uboot, and then connect to the port 1234
$ arm-none-linux-gnueabi-gdb ~/mini2440/bootldr/mini2440/u-boot
(gdb) target remote localhost:1234

all right, you can debug the uboot now ^_^

Reference url:
http://www.h7.dion.ne.jp/~qemu-win/qemu-doc-ja.html#SEC29
http://www.technochakra.com/gdb-debugging-in-assembly/
http://wiki.linuxmce.com/index.php/Mini2440

2010年1月16日土曜日

Qemuでmini2440の試験環境構築

一、nfsとtftpの機能を使いたいので、先日作成したバッチファイルを使ってネット環境を設定
$ sudo bridge.sh eth0
$ ifconfig
br0 Link encap:Ethernet HWaddr 00:0a:e4:25:4e:5c
inet addr:192.168.2.1 Bcast:192.168.2.255 Mask:255.255.255.0
inet6 addr: fe80::20a:e4ff:fe25:4e5c/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:13185 errors:0 dropped:0 overruns:0 frame:0
TX packets:14223 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:541714 (541.7 KB) TX bytes:8957464 (8.9 MB)

eth0 Link encap:Ethernet HWaddr 00:0a:e4:25:4e:5c
UP BROADCAST MULTICAST MTU:1500 Metric:1
RX packets:0 errors:0 dropped:0 overruns:0 frame:0
TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:0 (0.0 B) TX bytes:0 (0.0 B)


二、バッチファイルによってQemuを起動する
$ sudo qemu-boot.sh nfs uImage 192.168.2.1 /home/arm/mini2440/rootfs mini2440
U-Boot 1.3.2-mini2440 (Oct 6 2009 - 12:51:09)

I2C: ready
DRAM: 64 MB
Flash: 2 MB
NAND: Bad block table not found for chip 0
Bad block table not found for chip 0
64 MiB
*** Warning - bad CRC or NAND, using default environment

USB: S3C2410 USB Deviced
In: serial
Out: serial
Err: serial
MAC: 08:08:11:18:12:27
Hit any key to stop autoboot: 0
MINI2440 #


三、u-bootでipaddrとserveripを設定
MINI2440 # setenv ipaddr 192.168.2.2
MINI2440 # setenv serverip 192.168.2.1


四、kernelをtftpで30008000にダウンロード
MINI2440 # tftpboot 30008000 uImage
dm9000 i/o: 0x20000300, id: 0x90000a46
DM9000: running in 16 bit mode
MAC: 08:08:11:18:12:27
TFTP from server 192.168.2.1; our IP address is 192.168.2.2
Filename 'uImage'.
Load address: 0x30008000
Loading: #################################################################
#################################################################
#################################################################
#################################################################
#################################################################
#################################################################
###########
done
Bytes transferred = 2051788 (1f4ecc hex)

MINI2440 # md 30008000
30008000: 56190527 243ee462 e986514b 8c4e1f00 '..Vb.>$KQ....N.
30008010: 00800030 00800030 e7051465 00020205 0...0...e.......

五、
nfsでrootfsをマウントするように、起動パラメータを設定
MINI2440 # setenv bootargs console=ttySAC0,115200 noinitrd init=/sbin/init mini2440=1tb ip=192.168.2.2 root=/dev/nfs rw nfsroot=192.168.2.1:/home/arm/mini2440/rootfs

六、kernelを起動
bootm 30008000


参考URL:
http://wiki.linuxmce.org/index.php/Mini2440





2010年1月15日金曜日

Qemu.mini2440

Got sources by git, use the commands as follow:

$ git clone git://repo.or.cz/qemu/mini2440.git
$ cd mini2440
$ ./configure --target-list=arm-softmmu --disable-kvm
$ make
$ sudo make install

put your u-boot.bin into "./mini2440/", and then

$ qemu-system-arm -kernel uImage --nographic -M mini2440
( Carefully, we didn't specific the path of u-boot.bin, because the path had been fix in sources,

image_size = load_image("mini2440/u-boot.bin", qemu_get_ram_ptr(0x03f80000));
if (image_size <>
image_size = load_image("u-boot.bin", qemu_get_ram_ptr(0x03f80000));
if (image_size > 0) {
if (image_size & (512 -1)) /* round size to a NAND block size */
image_size = (image_size + 512) & ~(512-1);
mini2440_printf("loaded override u-boot (size %x)\n", image_size);
s->cpu->env->regs[15] = S3C_RAM_BASE | 0x03f80000; /* start address, u-boot already relocated */
}
so, you should put the u-boot.bin into mini2440 folder first )

ok, now is u-boot time

S3C: CLK=240 HCLK=240 PCLK=240 UCLK=57
QEMU: ee24c08_init
DM9000: INIT QEMU MAC : 52:54:00:12:34:56
QEMU mini2440_reset: loaded default u-boot from NAND
QEMU mini2440_reset: loaded override u-boot (size 38c00)
QEMU mini2440_reset: loaded uImage (size 1f5000)
S3C: CLK=240 HCLK=240 PCLK=240 UCLK=48
S3C: CLK=304 HCLK=304 PCLK=304 UCLK=48
S3C: CLK=304 HCLK=101 PCLK=50 UCLK=48
S3C: CLK=304 HCLK=76 PCLK=38 UCLK=48
S3C: CLK=304 HCLK=76 PCLK=38 UCLK=48
S3C: CLK=405 HCLK=101 PCLK=50 UCLK=48


U-Boot 1.3.2-mini2440 (Jan 13 2010 - 19:40:10)

I2C: ready
DRAM: 64 MB
Flash: 2 MB
NAND: Bad block table not found for chip 0
Bad block table not found for chip 0
64 MiB
*** Warning - bad CRC or NAND, using default environment

USB: S3C2410 USB Deviced
ERROR: usbd_device_event_irq(), 613: (3401cd88,1) NULL device or device->bus
ERROR: usbd_device_event_irq(), 613: (3401cd88,2) NULL device or device->bus
ERROR: usbd_device_event_irq(), 613: (3401cd88,3) NULL device or device->bus
In: serial
Out: serial
Err: serial
MAC: 08:08:11:18:12:27
Hit any key to stop autoboot: 0
MINI2440 #



2010年1月14日木曜日

Fedoraでmini2440のQemu環境構築

① sudoの時、PATHが変わってしまうので、下記の命令が.bashrcに追加して解決できた。
alias sudo='sudo env PATH=$PATH'

② Qemuを使う前、bridgeの設定がバッチファイルにまとめ
#!/bin/sh
if [ -z "$1" ]; then
echo "Usage: `basename $0` {network interface name}."
exit
fi

# get ipaddress from ifconfig
IPADDR=`/sbin/ifconfig $1 | grep "inet addr" | awk '{ print $2}' | awk 'BEGIN { FS=":" } {print $2}'`
# get netmask from ifconfig
NETMASK=`/sbin/ifconfig $1 | grep "Mask" | awk '{ print $4}' | awk 'BEGIN { FS=":" } {print $2}'`

if [ -z $IPADDR ]; then
echo "Not found the ip address"
exit
elif [ -z $NETMASK ]; then
echo "Not found the netmask"
exit
fi

sudo /sbin/ifconfig br0 down
sudo /usr/sbin/brctl delbr br0
sudo /usr/sbin/brctl addbr br0
sudo /usr/sbin/brctl addif br0 $1
sudo /sbin/ifconfig br0 up
sudo /sbin/ifconfig $1 0.0.0.0 up
sudo /sbin/ifconfig br0 $IPADDR netmask $NETMASK

③起動と終了のスクリプト
[arm@localhost images]$ more ~/tools/qemu-ifup
#! /bin/sh
/sbin/ifconfig $1 0.0.0.0 promisc up
/usr/sbin/brctl addif br0 $1

[arm@localhost images]$ more ~/tools/qemu-ifdown
#! /bin/sh
/usr/sbin/brctl delif br0 $1
/sbin/ifconfig $1 down

④Qemuの命令が長いので、バッチファイルを作ろう
#! /bin/sh
METHOD=$1
SCRIPTPATH="/home/arm/tools"
SCRIPT="$SCRIPTPATH/qemu-ifup"
DOWNSCRIPT="$SCRIPTPATH/qemu-ifdown"
NETFLAG="-net nic,vlan=0 -net tap,vlan=0,ifname=tap0,script=$SCRIPT,downscript=$DOWNSCRIPT "

if [ $METHOD == "file" ]; then

MACHINE=$4
KERNEL=$2
ROOTFS=$3
EXPECTED_ARGS=3

if [ $# -ge $EXPECTED_ARGS ]; then

if ! [ -f "$KERNEL" ];then
echo "not found kernel file"
exit
elif ! [ -f "$ROOTFS" ];then
echo "not found rootfs file"
exit
elif [ -z "$MACHINE" ];then
MACHINE=versatileab

fi

qemu-system-arm -M $MACHINE -kernel $KERNEL -append root=/dev/sda1 $ROOTFS $NETFLAG
exit
fi

elif [ $METHOD == "nfs" ]; then

MACHINE=$5
NFSPATH=$4
KERNEL=$2
HOSTIP=$3
EXPECTED_ARGS=4

if ! [ -f "$KERNEL" ];then
echo "not found kernel file"
exit
elif [ -z "$MACHINE" ];then
MACHINE=versatileab
fi

qemu-system-arm -M $MACHINE -kernel $KERNEL -append root="/dev/nfs nfsroot=$HOSTIP:$NFSPATH rw ip=dhcp" $NETFLAG
exit
fi

echo "Usage: `basename $0` (file/nfs) Kernel (Rootfs/(Hostip Nfspath) [Machine]"