HOST:WinXP
VM:6.5
VMOS:Ubuntu 8.04.1TLS
安装VMwareTools后,可以通过共享拷贝文件
拷贝linux-2.6.25.tar.bz2到$HOME
$tar xvf linux-2.6.25.tar.bz2
$cd linux-2.6.25
拷贝2.6.25-at91.patch.gz到$HOME/linux-2.6.25
打补丁:AT91SAM9261EK for linux2.6.25
$zcat 2.6.25-at91.patch.gz | patch -p1
修改Makefile:
ARCH ?=arm
CROSS_COMPILE ?=/usr/local/arm/3.4.1/bin/arm-linux-
清空以前的编译痕迹:
$make distclean
$cp arch/arm/configs/at91sam9261ek_defconfig ./.config
拷贝mkimage、tools文件到$HOME/linux-2.6.25(注:mkimage与tools都可以从原有的ebd9261的linux源码包中取得),修改这两个文件的属性为可执行:
$chmod 777 ./mkimage
$chmod 777 ./tools
刚开始make menuconfig时出错,提示要安装ncurses,安装下列包即可:
$sudo apt-get install libncurses5-dev
以下是成功编译的总结:
$make menuconfig
修改内核配置如下:
去除[Kernel Features]->EABI选项。arm-linux-3.4.1交叉编译工具不支持EABI
修改[Boot Option]中的配置:
旧的:mem=64M console=ttyS0,115200 initrd=0x21100000, 3145728 root=/dev/ram0 rw
新的:mem=64M console=ttyS0,115200 initrd=0x21100000,17000000 root=/dev/ram0 rw
修改所能支持的RAMDISK大小:
[Devices driver]->[Block devices]->Default RAM disk size,修改该值为40960
$./mkimage 注:使用mkimage可以生成uImage映像用于Uboot
将uImage与原EBD9261的ramdisk.gz下载到目标板:
U-Boot> setenv ipaddr 172.16.10.211
U-Boot> setenv serverip 172.16.10.212
U-Boot> saveenv
上述三个步骤在第一次使用时设置下即可,不需每次都设置
U-Boot> tftp 20400000 uImage
U-Boot> tftp 21100000 ramdisk.gz
U-Boot> bootm 0x20400000
Linux系统可跑起来。但显示、声音等驱动都不正常。
以下是失败的过程:
$make menuconfig
去除[Kernel Features]->EABI选项
注:由于我用的是arm-linux-3.4.1交叉编译工具,该工具不支持EABI,因此在配置Kernel时要去除[Kernel Features]中的EABI选项。
$./mkimage最后生成Kernel:uImage9261
将新生成的Kernel映像uImage9261及原板自带的ramdisk.gz下载到目标板EBD9261:
U-Boot> setenv ipaddr 172.16.10.211
U-Boot> setenv serverip 172.16.10.212
U-Boot> saveenv
上述三个步骤在第一次使用时设置下即可,不需每次都设置
U-Boot> tftp 20400000 uImage
U-Boot> tftp 21100000 ramdisk.gz
U-Boot> bootm 0x20400000
这边必须用uImage,不能用zImage、bzImage等格式Kernel镜像
uImage是使用mkImage工具生成的
启动过程如下(2.6.25启动信息1.txt):
## Booting image at 20400000 ...
Image Name: linux-2.6
Image Type: ARM Linux Kernel Image (gzip compressed)
Data Size: 1506280 Bytes = 1.4 MB
Load Address: 20008000
Entry Point: 20008000
Verifying Checksum ... OK
Uncompressing Kernel Image ... OK
Starting kernel ...
Linux version 2.6.25 (cmy@cmy-ubuntu) (gcc version 3.4.1) #1 Tue Dec 16 21:19:49
CST 2008
CPU: ARM926EJ-S [41069265] revision 5 (ARMv5TEJ), cr=00053177
Machine: Atmel AT91SAM9261-EK
Ignoring unrecognised tag 0x54410008
Memory policy: ECC disabled, Data cache writeback
Clocks: CPU 198 MHz, master 99 MHz, main 18.432 MHz
CPU0: D VIVT write-back cache
CPU0: I cache: 16384 bytes, associativity 4, 32 byte lines, 128 sets
CPU0: D cache: 16384 bytes, associativity 4, 32 byte lines, 128 sets
Built 1 zonelists in Zone order, mobility grouping on. Total pages: 16256
Kernel command line: mem=64M console=ttyS0,115200 initrd=0x21100000,3145728 root
=/dev/ram0 rw
AT91: 96 gpio irqs in 3 banks
PID hash table entries: 256 (order: 8, 1024 bytes)
Console: colour dummy device 80x30
console [ttyS0] enabled
Dentry cache hash table entries: 8192 (order: 3, 32768 bytes)
Inode-cache hash table entries: 4096 (order: 2, 16384 bytes)
Memory: 64MB = 64MB total
Memory: 58636KB available (2788K code, 236K data, 124K init)
Mount-cache hash table entries: 512
CPU: Testing write buffer coherency: ok
net_namespace: 152 bytes
NET: Registered protocol family 16
AT91: Power Management
AT91: Starting after general reset
SCSI subsystem initialized
usbcore: registered new interface driver usbfs
usbcore: registered new interface driver hub
usbcore: registered new device driver usb
NET: Registered protocol family 2
IP route cache hash table entries: 1024 (order: 0, 4096 bytes)
TCP established hash table entries: 2048 (order: 2, 16384 bytes)
TCP bind hash table entries: 2048 (order: 1, 8192 bytes)
TCP: Hash tables configured (established 2048 bind 2048)
TCP reno registered
checking if image is initramfs...it isn't (no cpio magic); looks like an initrd
Freeing initrd memory: 3072K
NetWinder Floating Point Emulator V0.97 (double precision)
JFFS2 version 2.2. (NAND) (SUMMARY) © 2001-2006 Red Hat, Inc.
io scheduler noop registered
io scheduler anticipatory registered (default)
atmel_lcdfb atmel_lcdfb.0: 160KiB frame buffer at 00300000 (mapped at c4880000)
Console: switching to colour frame buffer device 30x40
atmel_lcdfb atmel_lcdfb.0: fb0: Atmel LCDC at 0x00600000 (mapped at c485c000), i
rq 21
atmel_usart.0: ttyS0 at MMIO 0xfefff200 (irq = 1) is a ATMEL_SERIAL
brd: module loaded
loop: module loaded
ssc ssc.1: Atmel SSC device at 0xc4860000 (irq 15)
dm9000 Ethernet Driver, V1.30
eth0: dm9000 at c485e000,c4866044 IRQ 107 MAC: 22:34:56:78:99:aa (chip)
Driver 'sd' needs updating - please use bus_type methods
NAND device: Manufacturer ID: 0xec, Chip ID: 0x76 (Samsung NAND 64MiB 3,3V 8-bit
)
AT91 NAND: 8-bit, Software ECC
Scanning device for bad blocks
Creating 2 MTD partitions on "at91_nand":
0x00000000-0x00040000 : "Partition 1"
0x00040000-0x04000000 : "Partition 2"
atmel_spi atmel_spi.0: Atmel SPI Controller at 0xfffc8000 (irq 12)
mtd_dataflash spi0.0: AT45DB161x (2112 KBytes)
usbmon: debugfs is not available
at91_ohci at91_ohci: AT91 OHCI
at91_ohci at91_ohci: new USB bus registered, assigned bus number 1
at91_ohci at91_ohci: irq 20, io mem 0x00500000
usb usb1: configuration #1 chosen from 1 choice
hub 1-0:1.0: USB hub found
hub 1-0:1.0: 2 ports detected
Initializing USB Mass Storage driver...
usbcore: registered new interface driver usb-storage
USB Mass Storage support registered.
udc: at91_udc version 3 May 2006
mice: PS/2 mouse device common for all mice
input: gpio-keys as /class/input/input0
ads7846 spi0.2: touchscreen, irq 29
input: ADS784x Touchscreen as /class/input/input1
rtc-at91sam9 at91_rtt.0: rtc core: registered at91_rtt as rtc0
rtc-at91sam9 at91_rtt.0: rtc0: SET TIME!
Registered led device: ds7
Registered led device: ds8
Registered led device: ds1
usbcore: registered new interface driver usbhid
drivers/hid/usbhid/hid-core.c: v2.6:USB HID core driver
Advanced Linux Sound Architecture Driver Version 1.0.16rc2 (Thu Jan 31 16:40:16
2008 UTC).
at73c213 spi0.3: at73c213: supported bitrate is 48500 (64 divider)
ALSA device list:
#0: AT91SAM9261-EK external DAC on irq 15
TCP cubic registered
NET: Registered protocol family 1
NET: Registered protocol family 17
RPC: Registered udp transport module.
RPC: Registered tcp transport module.
rtc-at91sam9 at91_rtt.0: hctosys: unable to read the hardware clock
RAMDISK: Compressed image found at block 0
RAMDISK: incomplete write (-28 != 32768) 8388608
RAMDISK: ran out of compressed data
invalid compressed format (err=1)
EXT2-fs warning: maximal mount count reached, running e2fsck is recommended
VFS: Mounted root (ext2 filesystem).
Freeing init memory: 124K
attempt to access beyond end of device
ram0: rw=0, want=49164, limit=16384
EXT2-fs error (device ram0): ext2_get_inode: unable to read inode block - inode=
6145, block=24581
Warning: unable to open an initial console.
attempt to access beyond end of device
ram0: rw=0, want=49178, limit=16384
EXT2-fs error (device ram0): ext2_get_inode: unable to read inode block - inode=
6205, block=24588
attempt to access beyond end of device
ram0: rw=0, want=65544, limit=16384
EXT2-fs error (device ram0): ext2_get_inode: unable to read inode block - inode=
8193, block=32771
attempt to access beyond end of device
ram0: rw=0, want=16396, limit=16384
EXT2-fs error (device ram0): ext2_get_inode: unable to read inode block - inode=
2049, block=8197
attempt to access beyond end of device
ram0: rw=0, want=16396, limit=16384
EXT2-fs error (device ram0): ext2_get_inode: unable to read inode block - inode=
2049, block=8197
Kernel panic - not syncing: No init found. Try passing init= option to kernel.
从“RAMDISK: incomplete write (-28 != 32768) 8388608”开始就出错了,google了一下,说是分配给RamDisk的空间太小,然后我修改Boot参数为:
mem=64M console=ttyS0,115200 initrd=0x21100000,17000000 root=/dev/ram0 rw
重新编译生成uImage,跟ramdisk.gz一起下载到目标板上,启动信息如下(2.6.25启动信息2.txt):
……
RAMDISK: Compressed image found at block 0
RAMDISK: incomplete write (-28 != 32768) 8388608
EXT2-fs warning: maximal mount count reached, running e2fsck is recommended
……
可以看到有所改善,但系统还是没起来。
会不会是ramdisk.gz的问题,我决定重新做一个:
交叉编译器还是使用arm-linux-3.4.1,先编译busybox工具
拷贝busybox-1.11.1到$HOME后进行编译
$tar xvf busybox-1.11.1.tar.bz2
$cd busybox-1.11.1
修改Makefile文件中的ARCH与CROSS_COMPIL,可参考Kernel编译时的设置
$make
我使用busybox-1.11.1,编译出错:
networking/interface.c:818: error: `ARPHRD_INFINIBAND' undeclared here (not in a function)
networking/interface.c:818: error: initializer element is not constant
networking/interface.c:818: error: (near initialization for `ib_hwtype.type')
networking/interface.c:818: error: `ARPHRD_INFINIBAND' undeclared here (not in a function)
networking/interface.c:818: error: initializer element is not constant
networking/interface.c:818: error: (near initialization for `ib_hwtype.type')
可能busybox版本太新缘故,换了个低版本的(busybox-1.3.2),编译出现错误:
applets/applets.c:22:2: #warning Static linking against glibc produces buggy executables
applets/applets.c:23:2: #warning (glibc does not cope well with ld --gc-sections).
applets/applets.c:24:2: #warning See sources.redhat.com/bugzilla/show_bug.cgi?id=3400
applets/applets.c:25:2: #warning Note that glibc is utterly unsuitable for static linking anyway.
make[1]: *** [applets/applets.o] 错误 1
注释掉如下警告信息:
重新编译,出现如下错误
/home/cmy/busybox-1.3.2/scripts/trylink: 5: function: not found
/home/cmy/busybox-1.3.2/scripts/trylink: 11: Syntax error: "}" unexpected
make: *** [busybox_unstripped] 错误 2
由于ubuntu默认的sh是dash,要将它改成bash:
$sudo rm /bin/sh
$sudo ln –s /bin/bash /bin/sh
再次编译,出错:
In file included from e2fsprogs/ext2fs/ismounted.c:22:
/usr/local/arm/3.4.1/lib/gcc/arm-linux/3.4.1/../../../../arm-linux/sys-include/linux/fd.h:342: error: variable or field `__user' declared void
/usr/local/arm/3.4.1/lib/gcc/arm-linux/3.4.1/../../../../arm-linux/sys-include/linux/fd.h:342: error: parse error before '*' token
/usr/local/arm/3.4.1/lib/gcc/arm-linux/3.4.1/../../../../arm-linux/sys-include/linux/fd.h:360: error: parse error before '}' token
make[1]: *** [e2fsprogs/ext2fs/ismounted.o] 错误 1
make: *** [e2fsprogs/ext2fs] 错误 2
gcc 3.4.1中新增类型 __user ,需要引入编译器定义头文件,在引用#include 的前面加上#include 后,继续编译,出现如下错误:
modutils/lib.a(insmod.o)(.text.insmod_main+0x370): In function `insmod_main':
: undefined reference to `query_module'
modutils/lib.a(insmod.o)(.text.insmod_main+0x3a4): In function `insmod_main':
: undefined reference to `query_module'
modutils/lib.a(insmod.o)(.text.insmod_main+0x44c): In function `insmod_main':
: undefined reference to `query_module'
去除Linux Module Utilities->Support version 2.2.x to 2.4.x Linux kernels选项,继续编译,这次编译成功了,接着要进行安装:
$make install
完成后会在当前目录下生成_install文件夹。
紧接着可以开始制作Ramdisk根文件系统了,主要参考该文章:
http://www.cnitblog.com/zouzheng/articles/14423.html
最后生成根文件系统:ramdisk.gz
将uImage、ramdisk.gz下载到目标板上:
U-Boot> tftp 20400000 uImage
U-Boot> tftp 21100000 ramdisk.gz
U-Boot> bootm 0x20400000
启动信息如下:
## Booting image at 20400000 ...
Image Name: linux-2.6
Image Type: ARM Linux Kernel Image (gzip compressed)
Data Size: 1506275 Bytes = 1.4 MB
Load Address: 20008000
Entry Point: 20008000
Verifying Checksum ... OK
Uncompressing Kernel Image ... OK
Starting kernel ...
Linux version 2.6.25 (cmy@cmy-ubuntu) (gcc version 3.4.1) #3 Tue Dec 16 22:10:45
CST 2008
CPU: ARM926EJ-S [41069265] revision 5 (ARMv5TEJ), cr=00053177
Machine: Atmel AT91SAM9261-EK
Ignoring unrecognised tag 0x54410008
Memory policy: ECC disabled, Data cache writeback
Clocks: CPU 198 MHz, master 99 MHz, main 18.432 MHz
CPU0: D VIVT write-back cache
CPU0: I cache: 16384 bytes, associativity 4, 32 byte lines, 128 sets
CPU0: D cache: 16384 bytes, associativity 4, 32 byte lines, 128 sets
Built 1 zonelists in Zone order, mobility grouping on. Total pages: 16256
Kernel command line: mem=64M console=ttyS0,115200 initrd=0x21100000,17000000 roo
t=/dev/ram0 rw
AT91: 96 gpio irqs in 3 banks
PID hash table entries: 256 (order: 8, 1024 bytes)
Console: colour dummy device 80x30
console [ttyS0] enabled
Dentry cache hash table entries: 8192 (order: 3, 32768 bytes)
Inode-cache hash table entries: 4096 (order: 2, 16384 bytes)
Memory: 64MB = 64MB total
Memory: 45104KB available (2788K code, 236K data, 124K init)
Mount-cache hash table entries: 512
CPU: Testing write buffer coherency: ok
net_namespace: 152 bytes
NET: Registered protocol family 16
AT91: Power Management
AT91: Starting after user reset
SCSI subsystem initialized
usbcore: registered new interface driver usbfs
usbcore: registered new interface driver hub
usbcore: registered new device driver usb
NET: Registered protocol family 2
IP route cache hash table entries: 1024 (order: 0, 4096 bytes)
TCP established hash table entries: 2048 (order: 2, 16384 bytes)
TCP bind hash table entries: 2048 (order: 1, 8192 bytes)
TCP: Hash tables configured (established 2048 bind 2048)
TCP reno registered
checking if image is initramfs...it isn't (no cpio magic); looks like an initrd
Freeing initrd memory: 16601K
NetWinder Floating Point Emulator V0.97 (double precision)
JFFS2 version 2.2. (NAND) (SUMMARY) © 2001-2006 Red Hat, Inc.
io scheduler noop registered
io scheduler anticipatory registered (default)
atmel_lcdfb atmel_lcdfb.0: 160KiB frame buffer at 00300000 (mapped at c4880000)
Console: switching to colour frame buffer device 30x40
atmel_lcdfb atmel_lcdfb.0: fb0: Atmel LCDC at 0x00600000 (mapped at c485c000), i
rq 21
atmel_usart.0: ttyS0 at MMIO 0xfefff200 (irq = 1) is a ATMEL_SERIAL
brd: module loaded
loop: module loaded
ssc ssc.1: Atmel SSC device at 0xc4860000 (irq 15)
dm9000 Ethernet Driver, V1.30
eth0: dm9000 at c485e000,c4866044 IRQ 107 MAC: 22:34:56:78:99:aa (chip)
Driver 'sd' needs updating - please use bus_type methods
NAND device: Manufacturer ID: 0xec, Chip ID: 0x76 (Samsung NAND 64MiB 3,3V 8-bit
)
AT91 NAND: 8-bit, Software ECC
Scanning device for bad blocks
Creating 2 MTD partitions on "at91_nand":
0x00000000-0x00040000 : "Partition 1"
0x00040000-0x04000000 : "Partition 2"
atmel_spi atmel_spi.0: Atmel SPI Controller at 0xfffc8000 (irq 12)
mtd_dataflash spi0.0: AT45DB161x (2112 KBytes)
usbmon: debugfs is not available
at91_ohci at91_ohci: AT91 OHCI
at91_ohci at91_ohci: new USB bus registered, assigned bus number 1
at91_ohci at91_ohci: irq 20, io mem 0x00500000
usb usb1: configuration #1 chosen from 1 choice
hub 1-0:1.0: USB hub found
hub 1-0:1.0: 2 ports detected
Initializing USB Mass Storage driver...
usbcore: registered new interface driver usb-storage
USB Mass Storage support registered.
udc: at91_udc version 3 May 2006
mice: PS/2 mouse device common for all mice
input: gpio-keys as /class/input/input0
ads7846 spi0.2: touchscreen, irq 29
input: ADS784x Touchscreen as /class/input/input1
rtc-at91sam9 at91_rtt.0: rtc core: registered at91_rtt as rtc0
rtc-at91sam9 at91_rtt.0: rtc0: SET TIME!
Registered led device: ds7
Registered led device: ds8
Registered led device: ds1
usbcore: registered new interface driver usbhid
drivers/hid/usbhid/hid-core.c: v2.6:USB HID core driver
Advanced Linux Sound Architecture Driver Version 1.0.16rc2 (Thu Jan 31 16:40:16
2008 UTC).
at73c213 spi0.3: at73c213: supported bitrate is 48500 (64 divider)
ALSA device list:
#0: AT91SAM9261-EK external DAC on irq 15
TCP cubic registered
NET: Registered protocol family 1
NET: Registered protocol family 17
RPC: Registered udp transport module.
RPC: Registered tcp transport module.
rtc-at91sam9 at91_rtt.0: hctosys: unable to read the hardware clock
RAMDISK: Compressed image found at block 0
EXT2-fs warning: mounting unchecked fs, running e2fsck is recommended
VFS: Mounted root (ext2 filesystem).
Freeing init memory: 124K
mount: can't find / in /etc/mtab
dm9000 dm9000.0: WARNING: no IRQ resource flags set.
eth0: link down
mount: mounting /dev/fd0 on / failed
+++++++++++++ Welcom to Lianic Arm Linux ++++++++++++++++++
+ This is a arm linux system which is running on at91rm9200.
+ It contains more than 100 basic Linux commands and tools.
+ All these great features are powered by BusyBox 1.1.1
+ This is a free system tool developed by Edward Lianic.
+ If you have any problem please mailto : [email protected]
+ Enjoy!!!
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Please press Enter to activate this console.
BusyBox v1.3.2 (2008-12-18 12:18:52 CST) Built-in shell (msh)
Enter 'help' for a list of built-in commands.
#
至此,Linux2.6.25在EBD9261板上跑起来了,接着,还有很多事情要做。
发现当ramdisk超过了8MB,目标板启动出错,出错信息是:
RAMDISK: incomplete write (-28 != 32768) 8388608
修改内核配置中的:
Device Drivers->Block Device->RAM disk size 将该值修改为40960。
重新编译得到uImage,将该uImage与原EBD9261的ramdisk下载到目标板上,文件系统加载正常,但驱动显然不对,LCD屏图像显示异常、播放MP3没有声音输出。
下一步的工作就是移驱动了。
To be continue…