2009年6月29日星期一

编译arm平台的ethtool

1.下载ethtool源代码
git clone git://git.kernel.org/pub/scm/network/ethtool/ethtool.git
2.准备交叉编译工具
可以从codesoucery下载
3.编译
假设目标机器的规格如下:
ABI: EABI version 4
little endian
armv5te

按如下顺序运行:
./autogen.sh
./configure CC=CROSS-COMPILER PATH CFLAGS=-march=armv5te --host=arm-xx-linux
如果需要静态编译则
打开vim Makefile 在CC= CROSS-COMPILER后面加上--static
保存
make

就在当前文件夹内生成一个可执行文件ethtool
确认编译后的文件
readelf -h ethtool
确认以下信息(具体内容要看自己的配置了)
OS/ABI UNIX - System V
Machine :ARM
Flags Version4 EABI

2009年6月27日星期六

编译2.6.31内核和busybox1.14.2

源代码下载就不说了。
目标板versatile。
CPU核: ARM926T,arm9tdmi
ARM指令集:armv5te

交叉编译工具:
http://www.codesourcery.com/sgpp/lite/arm/portal/package4571/public/arm-none-linux-gnueabi/arm-2009q1-203-arm-none-linux-gnueabi-i686-pc-linux-gnu.tar.bz2
内核配置:
先使用源码自带的
make versatile_defconfig
另外将CONFIG_AEABI选项也选择了。
配置好后,make 编译就行了。

busybox的配置。
配置时候,添加如下的附加编译器条件:
-mlittle-endian -marm -fno-omit-frame-pointer -mapcs -mno-sched-prolog
-mabi=aapcs-linux -mno-thumb-interwork -march=armv5te -mtune=arm9tdmi
-msoft-float -fno-stack-protector -fno-optimize-sibling-calls -fwrapv

编译

最后,确认下编译好的内核和busybox
查看ELF Header内核和busybox要保持一致
readelf -h vmlinux
readelf -h busybox

Version: 1 (current)
OS/ABI: UNIX -System V
ABI Version: 0
Machine: ARM
Version: 0x1
Flags: 0x5000002, has entry point, Version5 EABI

2009年6月24日星期三

My PGP Public Key ID and Fingerprint

KeyID:3003E8D8
Fingerprint: 9013 DAD7 84DD C644 DC1A  AB43 D81F 415A 3003 E8D8

My PGP Public Key

-----BEGIN PGP PUBLIC KEY BLOCK-----
Version: GnuPG v2.0.10 (GNU/Linux)

mQGiBEpBhvQRBADP95PG0teyveIfF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Ie2D8AYW0LcAAwcH+wdNqisKEmcAdlJ7N5BxqhjP0CXRymtPogYUbtBurSwat49q
SqDESqW8A65vo2DIDvdDz6YUaaji1EXNqNzHBSgyy4u5ekhSXe+Hhx+URw4oEDHs
0sIQpsKYuwYTFMNZHjgflsGFfYB2SDUNMgw9u+1B8k9dn8dP3jKDtgNctjJOG4ip
dR2vqVvE2bJumh94pf+1XyqQs2FfbmYB7DbURBnt0dGEGZOxPM3FRhHG1QSQHaB+
HfWhiz6Kd/mqaeOOAW3u30Wu/ZPiESgVTxGGJ8d3+VMSdWfPzAp2FmqBoRbcBueL
ljqzY08i8C2nLSodrwmpyVJWV9+f3LcXK+q+gQmISQQYEQIACQUCSkGG9AIbDAAK
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