Fingerprint: 9013 DAD7 84DD C644 DC1A AB43 D81F 415A 3003 E8D8
2009年6月24日星期三
My PGP Public Key
-----BEGIN PGP PUBLIC KEY BLOCK-----
Version: GnuPG v2.0.10 (GNU/Linux)
mQGiBEpBhvQRBADP95PG0teyveIfFJbxl8DootgI41mOENgJ394wvB77yPLvq/lf
KUN+eq3V5IwkaX+P8u2Hf/1ZQI49Up/fSmchw4ITsgXmLsXyoZcMw373mL9o9BZp
kf8PXXKojMpUINJ976JCdJETYJUfh5EvP2cKLivw5ENdx/cdAzSoExt/LwCgiQiy
xv/jxN1HUtXm/Tjw99ig2iUD/3sXc2/ljUyw9DSwf1KTQR17eiYlLQj1OnnvnKWv
r11bzwZ6xyDNxvRnY4/QovbuBaswcVTV5piEsy0p4boKf6dEnaTF6LOeFV02ZrAu
TB1kFiWBzRnvcqcHY53XzCDo6OCM78ULI8dEt4kCW+mCCfuPqLkEUk3TO4p8U79E
0p7vA/9Kk4qBne1uKbB/GzPnMBtRF7TeDY58mNtpt/UUV40UvevpoyZ/Cn/zcrl/
Hz0sPlUAQzMQ0lnBDEHlso20DmhnbyUofW9RzV2UaF4t5++kurBAoGqxpMrXH4eE
yKm/vCy46o29NQ+n647yQbg8TZQsfO7KqgdUeTrwD9MW+dJxL7QkSGFpeWFuZyBL
YW5nIDxrYW5naGFpeWFuZ0BnbWFpbC5jb20+iGAEExECACAFAkpBhvQCGwMGCwkI
BwMCBBUCCAMEFgIDAQIeAQIXgAAKCRDYH0FaMAPo2LViAJ9Zc9d5fUzvM7ToKFBU
GUzjn/lDiQCbBJl4Z2y6+WkliEsdl5bXzPhJF8i5Ag0ESkGG9BAIAJuPwo8X+bZ9
hY5WkiIfS4BqlN+O1SpEwBoljxikcmo9t2rajiJkkEp+X6mg+cZq3q+bEt7SLGdz
Q7UIQLjcdakUy+NOobd3sodWOM+gwI5bWAP/ZHUu6ETc1EUDV7bsabsl29pwHDvF
jdZrgmg9Bc7Rg03giizvjbFiddLzQfSE23sSbxWo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QmISQQYEQIACQUCSkGG9AIbDAAK
CRDYH0FaMAPo2O/kAJ9DEhg9Kg4eqKDQ9yY0cBhbmM7kagCfSW0Er/De6HfYuMgq
tmrDyF5Frrw=
=lYW3
-----END PGP PUBLIC KEY BLOCK-----
2009年6月22日星期一
How To: Running Fedora-ARM under QEMU
from [http://fedoraproject.org/wiki/Architectures/ARM/HowToQemu]
How To: Running Fedora-ARM under QEMU
Introduction
QEMU is a well-known emulator that supports ARM platforms, and can be used to run the Fedora-ARM distribution. This provides a convenient platform to try out the distribution as well as to development and customization.
The howto describes a process to get the Fedora-ARM distribution running under QEMU. Although we have tested this on Fedora 7 and Fedora 8 with QEMU 0.9.0, most of the process should work on any other Linux system as well. We assumes that you can run commands as root (or using sudo) whenever necessary.
The QEMU system is set up to get its root file system from a local loopback block device or over NFS from the host system (requires networking between the host system and the QEMU guest). The host's networking can then be configured to get its IP address using DHCP.
Install QEMU
If you are running Fedora 7/8, you can just install qemu using yum.
yum install qemu
Setup Networking
You can skip this section if you are going to use a local loopback device for your root file system. However that may prevent you from using yum to install new packages on your Fedora-ARM guest.
Networking is setup between the host system and the QEMU guest to allow the guest to get its IP address using DHCP.
The networking setup uses host TAP devices to connect to QEMU. In recent kernels, this requires CAP_NET_ADMIN capability. The host system needs to have TUN/TAP networking enabled (CONFIG_TUN=m or CONFIG_TUN=y). You can verify this using:
grep CONFIG_TUN= /boot/config-`uname -r`
Also make sure that /dev/net/tun exists. If not, you can make it as follows:
mknod /dev/net/tun c 10 200
Now, we need to set up a network bridge interface. Install some utilities to configure a ethernet bridge:
# yum install bridge-utils
/usr/sbin/brctl addbr br0
/sbin/ifconfig eth0 0.0.0.0 promisc up
/usr/sbin/brctl addif br0 eth0
/sbin/dhclient br0
/sbin/iptables -F FORWARD
Also, create a script qemu-ifup as follows. This will be needed when we boot into QEMU.
#!/bin/sh
/sbin/ifconfig $1 0.0.0.0 promisc up
/usr/sbin/brctl addif br0 $1
Setup Kernel Image
You can either simply use a pre-built kernel image or build your own from source.
Pre-built Kernel Image
You can get one of the following pre-built kernel images for ARM:
1. zImage-versatile-2.6.24-rc7.armv5tel
1. zImage-versatile-2.6.23-rc4
1. zImage-versatile-2.6.22
Build Kernel Image From Source
You will need to have an ARM cross-compiler. If you do not have one, download one from CodeSourcery's web-site, install it and ensure that is it in your path.
export arch=ARM
export CROSS_COMPILE=arm-none-linux-gnueabi-
You can also use the Fedora cross toolchain that we provide.
Download Linux kernel (I have tested it with 2.6.21 and 2.6.22) and build it for ARM Versatile board. But, first you will have to customize the defconfig for it to work correctly.
cp arch/arm/configs/versatile_defconfig .config
make menuconfig
Enable DHCP Support (CONFIG_IP_PNP_DHCP). It is under Networking -> Networking Support -> Networking Options ->
TCP/IP Networking -> IP: Kernel Level autoconfiguration.
Enable Universal Tun/Tap Driver Support (CONFIG_TUN). It is under Device Drivers -> Network Device Support ->
Network Device Support.
Enable ARM EABI Support (CONFIG_AEABI). It is under Kernel Features.
Enable tmpfs support (CONFIG_TMPFS). It is under File Systems -> Pseudo File Systems.
If you will be booting from a file system image (not NFS), then the following steps should also be taken:
Enable PCI support (CONFIG_PCI). It is under Bus Support.
Enable SCSI Device Support. It is under Device Drivers -> SCSI Device Support.
Enable SCSI Disk Support. It is under Device Drivers -> SCSI Device Support.
Enable SYM53C8XX Version 2 SCSI Support. It is under Device Drivers -> SCSI Device Support -> SCSI low-level drivers
Build the kernel.
make
Setup Root File System
Download the root file system tarball . It is approximately 93MB in size.
Root File System On Loopback Device
Create a loopback device -- 4GB is a reasonable size.
dd if=/dev/zero of=rootfs-f8-dev bs=1024k count=4096
Create a file system.
mkfs.ext3 rootfs-f8-dev -L arm
Prepare the root file-system. This assumes that the loopback device is mounted under /mnt/ARM_FS.
mount rootfs-f8-dev /mnt/ARM_FS -o loop
tar -xjf rootfs-f8.tar.bz2 -C /mnt/ARM_FS
mv /mnt/ARM_FS/rootfs-f8/* /mnt/ARM_FS
rm -rf /mnt/ARM_FS/rootfs-f8
umount rootfs-f8-dev
Root File System Over NFS
This assumes that the root file system is in /mnt/ARM_FS. We need to export it through NFS. Add the following in your /etc/exports.
/mnt/ARM_FS/ *(rw,sync,no_root_squash)
Now, restart the NFS service.
/sbin/service nfs restart
Boot into QEMU
Now you are ready to boot into QEMU. Replace <host-ip> with the IP address of the host machine.
qemu-system-arm -M versatilepb -kernel zImage-versatile -append root="/dev/nfs nfsroot=<host-ip>:/mnt/ARM_FS rw ip=dhcp" \
-net nic,vlan=0 -net tap,vlan=0,ifname=tap0,script=./qemu-ifup
2009年5月30日星期六
powerpc 汇编语言注释
.file "sort.s"
.globl array
.section ".data" /*把array变量放到数据段*/
.align 2
.type array, @object
.size array, 24
array:
.long 21
.long 2
.long 3
.long 90
.long 10
.long 11
.section .rodata
.align 3
.LC0:
.string "%d\n"
.section ".text"
.align 2
.globl main
.type main, @function
main:
stwu 1,-32(1)
mflr 0
stw 31,28(1)
stw 0,36(1)
mr 31,1
/* r9 is the address of array*/
lis 9,array@ha /*读array地址的高16位并左移16位*/
la 9,array@l(9) /*读array地址的低16位,并将其与r9 (上条指令的执行结果)相加,得到array的地址,存放到r9中*/
li 0,0
stw 0,0(9)
li 0,1
stw 0,4(9)
li 10,2
stw 10,8(31)
1:
lwz 10,8(31)
addi 0,10,-2 /*将r10减去2,结果放到r0中*/
slwi 0,0,2
add 11,9,0
lwz 4,0(11) /*从内存加载数据到r0*/
addi 0,10,-1
slwi 0,0,2 /*将r0左移两位*/
add 11,9,0
lwz 0,0(11)
add 11,4,0
slwi 0,10,2
add 4,9,0
stw 11,0(4)
addi 0,10,1
stw 0,8(31)
cmpwi 7,0,5
ble 7,1b
li 0,0
stw 0,8(31)
b .L2
.L3:
lwz 0,8(31)
lis 9,array@ha
la 9,array@l(9)
slwi 0,0,2
add 9,0,9
lwz 0,0(9)
lis 9,.LC0@ha
la 3,.LC0@l(9)
mr 4,0
crxor 6,6,6
bl printf
lwz 9,8(31)
addi 0,9,1
stw 0,8(31)
.L2:
lwz 0,8(31)
cmpwi 7,0,5
ble 7,.L3
li 0,0
mr 3,0
lwz 11,0(1)
lwz 0,4(11)
mtlr 0
lwz 31,-4(11)
mr 1,11
blr
.size main,.-main
.ident "GCC: (GNU) 4.1.2 20071124 (Red Hat 4.1.2-42)"
.section .note.GNU-stack,"",@progbits
.globl array
.section ".data" /*把array变量放到数据段*/
.align 2
.type array, @object
.size array, 24
array:
.long 21
.long 2
.long 3
.long 90
.long 10
.long 11
.section .rodata
.align 3
.LC0:
.string "%d\n"
.section ".text"
.align 2
.globl main
.type main, @function
main:
stwu 1,-32(1)
mflr 0
stw 31,28(1)
stw 0,36(1)
mr 31,1
/* r9 is the address of array*/
lis 9,array@ha /*读array地址的高16位并左移16位*/
la 9,array@l(9) /*读array地址的低16位,并将其与r9 (上条指令的执行结果)相加,得到array的地址,存放到r9中*/
li 0,0
stw 0,0(9)
li 0,1
stw 0,4(9)
li 10,2
stw 10,8(31)
1:
lwz 10,8(31)
addi 0,10,-2 /*将r10减去2,结果放到r0中*/
slwi 0,0,2
add 11,9,0
lwz 4,0(11) /*从内存加载数据到r0*/
addi 0,10,-1
slwi 0,0,2 /*将r0左移两位*/
add 11,9,0
lwz 0,0(11)
add 11,4,0
slwi 0,10,2
add 4,9,0
stw 11,0(4)
addi 0,10,1
stw 0,8(31)
cmpwi 7,0,5
ble 7,1b
li 0,0
stw 0,8(31)
b .L2
.L3:
lwz 0,8(31)
lis 9,array@ha
la 9,array@l(9)
slwi 0,0,2
add 9,0,9
lwz 0,0(9)
lis 9,.LC0@ha
la 3,.LC0@l(9)
mr 4,0
crxor 6,6,6
bl printf
lwz 9,8(31)
addi 0,9,1
stw 0,8(31)
.L2:
lwz 0,8(31)
cmpwi 7,0,5
ble 7,.L3
li 0,0
mr 3,0
lwz 11,0(1)
lwz 0,4(11)
mtlr 0
lwz 31,-4(11)
mr 1,11
blr
.size main,.-main
.ident "GCC: (GNU) 4.1.2 20071124 (Red Hat 4.1.2-42)"
.section .note.GNU-stack,"",@progbits
2009年4月28日星期二
使用gdbserver调试arm应用程序
1.下载gdbserver
gdbserver的源代码在gdb的源代码包中
ftp://sourceware.org/pub/gdb/releases/gdb-6.8.tar.bz2
2.准备toolchain
使用codesoucery的toolchain
http://www.codesourcery.com/sgpp/lite/arm/portal/package3696/public/arm-none-linux-gnueabi/arm-2008q3-72-arm-none-linux-gnueabi-i686-pc-linux-gnu.tar.bz2
3.配置gdbserver
在gdb文件下下,能找到gdbserver文件夹
首先声明一个环境变量CC
export CC=YOUR-PATH-OF-GCC/arm-none-linux-gnueabi-gcc
配置
./configure --host=arm-none-linux --target=arm-none-linux
意思是说编译在arm-none-linux上运行的,能执行arm-none-linux目标文件的gdbserver
4.make 编译
就会生成一个gdbserver可执行文件
5.使用gdbserver远程调试应用程序
以串口为例
假设应用程序为hello
在arm板子上的命令行下运行
gdbserver /dev/ttyS0 hello
在开发机上运行
gdb hello
在gdb的提示符下运行
target remote YOUR SERIAL
gdbserver的源代码在gdb的源代码包中
ftp://sourceware.org/pub/gdb/releases/gdb-6.8.tar.bz2
2.准备toolchain
使用codesoucery的toolchain
http://www.codesourcery.com/sgpp/lite/arm/portal/package3696/public/arm-none-linux-gnueabi/arm-2008q3-72-arm-none-linux-gnueabi-i686-pc-linux-gnu.tar.bz2
3.配置gdbserver
在gdb文件下下,能找到gdbserver文件夹
首先声明一个环境变量CC
export CC=YOUR-PATH-OF-GCC/arm-none-linux-gnueabi-gcc
配置
./configure --host=arm-none-linux --target=arm-none-linux
意思是说编译在arm-none-linux上运行的,能执行arm-none-linux目标文件的gdbserver
4.make 编译
就会生成一个gdbserver可执行文件
5.使用gdbserver远程调试应用程序
以串口为例
假设应用程序为hello
在arm板子上的命令行下运行
gdbserver /dev/ttyS0 hello
在开发机上运行
gdb hello
在gdb的提示符下运行
target remote YOUR SERIAL
2009年4月26日星期日
编译busybox1.14.0
1.下载toolchain
http://www.codesourcery.com/sgpp/lite/arm/portal/package3698/public/arm-none-linux-gnueabi/arm-2008q3-72-arm-none-linux-gnueabi.bin
2.在busybox目录下
配置busybox
make menuconfig
配置成静态链接,并指定toolchain路径和前缀
3.make 编译
如果提示dnsd.c lvalue error相关的错误,打下面的补丁给busybox
http://www.busybox.net/downloads/fixes-1.14.0/busybox-1.14.0-unaligned.patch
编译成功后,会生成一个busybox可执行文件
http://www.codesourcery.com/sgpp/lite/arm/portal/package3698/public/arm-none-linux-gnueabi/arm-2008q3-72-arm-none-linux-gnueabi.bin
2.在busybox目录下
配置busybox
make menuconfig
配置成静态链接,并指定toolchain路径和前缀
3.make 编译
如果提示dnsd.c lvalue error相关的错误,打下面的补丁给busybox
http://www.busybox.net/downloads/fixes-1.14.0/busybox-1.14.0-unaligned.patch
编译成功后,会生成一个busybox可执行文件
使用qemu和kgdb调试内核
1.配置内核
CONFIG_KGDB=y
CONFIG_DEBUG_INFO=y
CONFIG_DEBUG_BUGVERBOSE=y
CONFIG_FRAME_POINTER=y
CONFIG_KGDB_SERIAL_CONSOLE=y
2.运行qemu (以versatilepb机器为例)
qemu-system-arm -M versatilepb -kernel arch/arm/boot/zImage -append "kgdboc=ttyAMA0 kgdbwait root=/dev/nfs \
nfsroot=192.168.1.24:/mnt/arm-fs rw ip=dhcp" -net nic,vlan=0 -net tap,vlan=0,script=./qemu-ifup -serial tcp::4444,server
kgdboc选项指定了通过串口用kgdb来调试内核,kgdbwait,等待gdb链接
-serial 选项指定了串口和tcp端口的映射
3.运行gdb
arm-eabi-gdb vmlinux
target remote 主机ip:4444
可以开始调试了。
CONFIG_KGDB=y
CONFIG_DEBUG_INFO=y
CONFIG_DEBUG_BUGVERBOSE=y
CONFIG_FRAME_POINTER=y
CONFIG_KGDB_SERIAL_CONSOLE=y
2.运行qemu (以versatilepb机器为例)
qemu-system-arm -M versatilepb -kernel arch/arm/boot/zImage -append "kgdboc=ttyAMA0 kgdbwait root=/dev/nfs \
nfsroot=192.168.1.24:/mnt/arm-fs rw ip=dhcp" -net nic,vlan=0 -net tap,vlan=0,script=./qemu-ifup -serial tcp::4444,server
kgdboc选项指定了通过串口用kgdb来调试内核,kgdbwait,等待gdb链接
-serial 选项指定了串口和tcp端口的映射
3.运行gdb
arm-eabi-gdb vmlinux
target remote 主机ip:4444
可以开始调试了。
订阅:
博文 (Atom)