Chinaunix首页 | 论坛 | 博客
  • 博客访问: 299421
  • 博文数量: 103
  • 博客积分: 2345
  • 博客等级: 大尉
  • 技术积分: 902
  • 用 户 组: 普通用户
  • 注册时间: 2009-09-01 09:10
文章分类

全部博文(103)

文章存档

2022年(1)

2018年(3)

2017年(2)

2016年(3)

2015年(8)

2014年(8)

2013年(2)

2012年(9)

2011年(29)

2010年(20)

2009年(18)

我的朋友

分类:

2010-06-10 11:16:27

1,下载源码和补丁
#
AT91Bootstrap1.14.zip 
arm-2008q1-126-arm-none-linux-gnueabi-i686-pc-linux-gnu.tar.bz2
u-boot-1.3.4-exp.3.diff 
u-boot-1.3.4.tar.bz
22.6.24.at91.2-exp.patch.gz 
2.6.24-at91.patch.gz 
linux-2.6.24  linux-2.6.24.tar.bz2
2,建立工作目录文件夹,解压源码和打入相应的补丁:
3,开始编译源码:
3.1:编译一级启动代码:
# unzip AT91Bootstrap1.14.zip
# ls
AT91Bootstrap1.14.zip  Bootstrap-v1.14
# cd Bootstrap-v1.14/board/at91sam9260ek/nandflash/
# ls
at91sam9260ek.h  debug.o  main.o                       nandflash_at91sam9260ek.elf  pmc.o     udiv.o
at91sam9260ek.o  div0.o   Makefile                     nandflash_at91sam9260ek.map  sdramc.o  _udivsi3.o
crt0_gnu.o       gpio.o   nandflash_at91sam9260ek.bin  nandflash.o                  string.o  _umodsi3.o
# make clean
rm -f *.o *.bin *.elf *.map
# ls
at91sam9260ek.h  Makefile
因为9260编译后必须使这个烧入文件小于4K,所以要针对Makefile做修改:
# vim Makefile
修改下面这个地方:
OBJDUMP=$(CROSS_COMPILE)objdump
CCFLAGS=-g -mcpu=arm9 -O1 -Wall -D$(TARGET) -I$(INCL)
ASFLAGS=-g -mcpu=arm9 -c -O1 -Wall -D$(TARGET) -I$(INCL) -DTOP_OF_MEM=$(TOP_OF_MEMORY)
# cd include/
# ls
AT91CAP9_inc.h     AT91SAM9263_inc.h  AT91SAM9XE128_inc.h  debug.h  nandflash.h  part.h   sdramc.h
AT91SAM9260_inc.h  AT91SAM9G45_inc.h  dataflash.h          gpio.h   nand_ids.h   pmc.h
AT91SAM9261_inc.h  AT91SAM9RL_inc.h   ddramc.h             main.h   norflash.h   sddrc.h
修改这个文件:
# vim nand_ids.h
#ifndef _NAND_IDS_H
#define _NAND_IDS_H
#include "../include/nandflash.h"
/* Supported NandFlash devices */
static struct SNandInitInfo NandFlash_InitInfo[] = {
 {0xecda, 0x800, 0x20000, 0x800, 0x40, 0x0, "K9F2G08U0M\0"},
 //{0xecaa, 0x800, 0x20000, 0x800, 0x40, 0x0, "K9F2G08R0A\0"},
 //{0x2cca, 0x800, 0x20000, 0x800, 0x40, 0x1, "MT29F2G16AAB\0"}, 
 //{0x2cda, 0x800, 0x20000, 0x800, 0x40, 0x0, "MT29F2G08AAC\0"},
 //{0x20aa, 0x800, 0x20000, 0x800, 0x40, 0x0, "STMNAND02GR3B\0"}, 
 //{0x2caa, 0x800, 0x20000, 0x800, 0x40, 0x0, "MT29F2G08ABD\0"},
 {0,}
};
#endif
屏蔽掉你不用的nandflash,这样就可以使编译最后的大小小于4K!
# make
# ls -l
total 140
-rwxrwxrwx 1 root   root     5118 2008-12-04 19:18 at91sam9260ek.h
-rw-r--r-- 1 root   root     5652 2010-05-18 21:26 at91sam9260ek.o
-rw-r--r-- 1 root   root     2604 2010-05-18 21:26 crt0_gnu.o
-rw-r--r-- 1 root   root      992 2010-05-18 21:26 debug.o
-rw-r--r-- 1 root   root     2068 2010-05-18 21:26 div0.o
-rw-r--r-- 1 root   root     8336 2010-05-18 21:26 gpio.o
-rw-r--r-- 1 root   root     2472 2010-05-18 21:26 main.o
-rwxr--r-- 1 nobody nogroup  3219 2010-05-18 21:22 Makefile
-rwxr-xr-x 1 root   root     3972 2010-05-18 21:26 nandflash_at91sam9260ek.bin
-rwxr-xr-x 1 root   root    27381 2010-05-18 21:26 nandflash_at91sam9260ek.elf
-rw-r--r-- 1 root   root    18270 2010-05-18 21:26 nandflash_at91sam9260ek.map
-rw-r--r-- 1 root   root     9924 2010-05-18 21:26 nandflash.o
-rw-r--r-- 1 root   root     4092 2010-05-18 21:26 pmc.o
-rw-r--r-- 1 root   root     3864 2010-05-18 21:26 sdramc.o
-rw-r--r-- 1 root   root     3448 2010-05-18 21:26 string.o
-rw-r--r-- 1 root   root     4920 2010-05-18 21:26 udiv.o
-rw-r--r-- 1 root   root     1752 2010-05-18 21:26 _udivsi3.o
-rw-r--r-- 1 root   root     1828 2010-05-18 21:26 _umodsi3.o
可以看到nandflash_at91sam9260ek.bin小于4K!
将编译出来的文件写入nandflash的0x00000000里面去:
3.2:编译u-boot:
# ls -l
total 7668
-rw-rw-rw-  1 root root  111418 2009-10-23 10:08 u-boot-1.3.4-exp.3.diff
-rw-rw-rw-  1 root root 7714456 2009-05-11 09:51 u-boot-1.3.4.tar.bz2
# tar -xjvf u-boot-1.3.4.tar.bz2
# ls
u-boot-1.3.4  u-boot-1.3.4-exp.3.diff  u-boot-1.3.4.tar.bz2
进入u-boot目录:
# cd u-boot-1.3.4
将补丁复制到u-boot目录里:
# cp ../u-boot-1.3.4-exp.3.diff .
打入atmel的补丁:
# cat u-boot-1.3.4-exp.3.diff | patch -p1
# make distclean
# make at91sam9260ek_nandflash_config
... with environment variable in NAND FLASH
Configuring for at91sam9260ek board...
# make
这样就可以编译出u-boot.bin
可以去这个文件来看u-boot烧写进nandflash的地址
# vim at91sam9260ek.h
/* ******************************************************************* */
/* BootStrap Settings                                                  */
/*                                                                     */
/* ******************************************************************* */
#define IMG_ADDRESS   0x20000  /* Image Address in NandFlash */
#define IMG_SIZE  0x40000  /* Image Size in NandFlash    */
看到烧到nandflash的地址是:0x20000
然后打开串口,写入进nandflash串口信息如下:
RomBOOT
>
U-Boot 1.3.4 (May 18 2010 - 21:40:34)
DRAM:  64 MB
NAND:  256 MiB
*** Warning - bad CRC or NAND, using default environment
In:    serial
Out:   serial
Err:   serial
Net:   macb0
macb0: Starting autonegotiation...
macb0: Autonegotiation complete
macb0: link up, 100Mbps full-duplex (lpa: 0x41e1)
Hit any key to stop autoboot:  0
NAND read: device 0 offset 0xa0000, size 0x200000
 2097152 bytes read: OK
Wrong Image Format for bootm command
ERROR: can't get kernel image!
U-Boot>
可以看到u-boot启动起来了:
然后插上网线,看下网络能通吗?
U-Boot> ping 192.168.1.1
macb0: link up, 100Mbps full-duplex (lpa: 0x41e1)
*** ERROR: `ipaddr' not set
ping failed; host 192.168.1.1 is not alive
看到提示没有设置ipaddr:
U-Boot> setenv ipaddr 192.168.1.250
U-Boot> printenv
bootargs=console=ttyS0,115200 root=/dev/mtdblock5 mtdparts=at91_nand:128k(bootstrap)ro,256k(uboot)ro,128k(env1)ro,128k(env2)ro,2M(linux),-(root) rw rootfstype=jffs2
bootcmd=nand read 0x22000000 0xA0000 0x200000; bootm
bootdelay=3
baudrate=115200
stdin=serial
stdout=serial
stderr=serial
ethact=macb0
ipaddr=192.168.1.250
Environment size: 321/131067 bytes
U-Boot> saveenv
Saving Environment to NAND...
Erasing redundant Nand...
Erasing at 0x80000 -- 100% complete.
Writing to redundant Nand... done
U-Boot> setenv ethaddr 3e:36:65:ba:6f:be
U-Boot> setenv netmask 255.255.255.0
U-Boot> setenv gatewayip 192.168.1.1
U-Boot> savenv
Unknown command 'savenv' - try 'help'
U-Boot> saveenv
Saving Environment to NAND...
Erasing Nand...
Erasing at 0x60000 -- 100% complete.
Writing to Nand... done
U-Boot> ping 192.168.1.1
macb0: link up, 100Mbps full-duplex (lpa: 0x41e1)
Using macb0 device
host 192.168.1.1 is alive
现在可以ping通网络了:
我们现在ping下google:
U-Boot> ping 66.249.89.104
macb0: link up, 100Mbps full-duplex (lpa: 0x41e1)
Using macb0 device
host 66.249.89.104 is alive
可以看到也能ping到外网!
3.3移植linux内核:
# tar -xjvf linux-2.6.24.tar.bz2
# ls
2.6.24.at91.2-exp.patch.gz  2.6.24-at91.patch.gz linux-2.6.24.tar.bz2
# zcat 2.6.24.at91.2-exp.patch.gz | patch -p1
# zcat
2.6.24-at91.patch.gz | patch -p1
# cd linux-2.6.24
# ls
arch     CREDITS        drivers  init    kernel       Makefile        net             samples   sound       vmlinux
block    crypto         fs       ipc     lib          mm              README          scripts   System.map  vmlinux.o
COPYING  Documentation  include  Kbuild  MAINTAINERS  Module.symvers  REPORTING-BUGS  security  usr
# vim Makefile
linux-2.6.24 主目录下有个Makefile 文件,打开,找到185 行左右,修改
ARCH ?= arm
CROSS_COMPILE ?= arm-none-linux-gnueabi-
保存退出。
# make distclean
# make at91sam9261ek_defconfig
# make menuconfig
然后配置:
kernel Features -->选中:
[*]Use the ARM EABI to compile the kernel
[*]Allow old ABI ............
然后编译:
# make uImage
# pwd
/workdir/atmel/at91sam9260/kernel/linux-2.6.24/arch/arm/mach-at91
# vim board-sam9260ek.c
修改这里可以修改为自己想要的:
116行开始:
/*
 * NAND flash
 */
static struct mtd_partition __initdata ek_nand_partition[] = {
        {
                .name   = "Bootstrap",
                .offset = 0,
                .size   = 4 * 1024 * 1024,
 },
 {
  .name = "u-boot",
  .offset = 4 * 1024 * 1024,
  .size = 4 * 1024 * 1024,
 },
 {
  .name = "kernel",
  .offset = 8 * 1024 * 1024,
  .size = 22 * 1024 * 1024,
 },
 {
  .name = "fs",
  .offset = 30 * 1024 * 1024,
  .size = 40 * 1024 * 1024,
 },
 {
  .name = "user space0",
  .offset = 70 * 1024 * 1024,
  .size = 60 * 1024 * 1024,
 },
 {
  .name = "user space2",
  .offset = 130 * 1024 * 1024,
  .size = MTDPART_SIZ_FULL,
 },
};
我的是256M的nandflash!
然后编译写入板子:
串口信息如下:
RomBOOT
>
U-Boot 1.3.4 (May 18 2010 - 21:40:34)
DRAM:  64 MB
NAND:  256 MiB
*** Warning - bad CRC or NAND, using default environment
In:    serial
Out:   serial
Err:   serial
Net:   macb0
macb0: Starting autonegotiation...
macb0: Autonegotiation complete
macb0: link up, 100Mbps full-duplex (lpa: 0x41e1)
Hit any key to stop autoboot:  0
NAND read: device 0 offset 0xa0000, size 0x200000
 2097152 bytes read: OK
Wrong Image Format for bootm command
ERROR: can't get kernel image!
U-Boot> printenv          
bootargs=console=ttyS0,115200 root=/dev/mtdblock5 mtdparts=at91_nand:128k(bootstrap)ro,256k(uboot)ro,128k(env1)ro,128k(env2)ro,2M(linux),-(root) rw rootfstype=jffs2
bootcmd=nand read 0x22000000 0xA0000 0x200000; bootm
bootdelay=3
baudrate=115200
stdin=serial
stdout=serial
stderr=serial
ethact=macb0
Environment size: 300/131067 bytes
U-Boot> nand read 0x22000000 0x800000 0x200000
NAND read: device 0 offset 0x800000, size 0x200000
 2097152 bytes read: OK
U-Boot> bootm 0x22000000
## Booting kernel from Legacy Image at 22000000 ...
   Image Name:   Linux-2.6.24
   Image Type:   ARM Linux Kernel Image (uncompressed)
   Data Size:    1070252 Bytes =  1 MB
   Load Address: 20008000
   Entry Point:  20008000
   Verifying Checksum ... OK
   Loading Kernel Image ... OK
OK
Starting kernel ...
Uncompressing Linux....................................................................... done, booting the kernel.
Linux version 2.6.24 () (gcc version 4.2.3 (Sourcery G++ Lite 2008q1-126)) #1 Tue May 18 22:50:41 HKT 2010
CPU: ARM926EJ-S [41069265] revision 5 (ARMv5TEJ), cr=00053177
Machine: Atmel AT91SAM9260-EK
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: 8192 bytes, associativity 4, 32 byte lines, 64 sets
CPU0: D cache: 8192 bytes, associativity 4, 32 byte lines, 64 sets
Built 1 zonelists in Zone order, mobility grouping on.  Total pages: 16256
Kernel command line: console=ttyS0,115200 root=/dev/mtdblock5 mtdparts=at91_nand:128k(bootstrap)ro,256k(uboot)ro,128k(env1)ro,128k(env2)ro,2M(linux),-(root) rw rootfstype=jffs2
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: 62616KB available (1944K code, 194K data, 100K init)
Mount-cache hash table entries: 512
CPU: Testing write buffer coherency: ok
net_namespace: 64 bytes
NET: Registered protocol family 16
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
Time: pit clocksource has been installed.
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
NetWinder Floating Point Emulator V0.97 (double precision)
io scheduler noop registered
io scheduler anticipatory registered (default)
Internal error: Oops - undefined instruction: 0 [#1]
Modules linked in:
CPU: 0    Not tainted  (2.6.24 #1)
PC is at device_create+0x20/0xb8
LR is at tty_register_device+0xb4/0xd0
pc : []    lr : []    psr: a0000013
sp : c3c19ea8  ip : c3c19ed8  fp : c3c19ed0
r10: 00000000  r9 : 00000000  r8 : c3c18000
r7 : c00e8c17  r6 : 00000004  r5 : c3c36bc0  r4 : 00000002
r3 : c3c19ee0  r2 : 00400003  r1 : 00000000  r0 : c3c36bc0
Flags: NzCv  IRQs on  FIQs on  Mode SVC_32  ISA ARM  Segment kernel
Control: 0005317f  Table: 20004000  DAC: 00000017
Process swapper (pid: 1, stack limit = 0xc3c18268)
Stack: (0xc3c19ea8 to 0xc3c1a000)
9ea0:                   00000000 c3c19ea8 c00e8c18 00000002 00000001 00000004
9ec0: 00000000 c3c19f3c c3c19ed8 c00e8c18 c010127c c3c19ee0 0000001c 00000004
9ee0: 33797474 c3c19e00 c010530c c019cf94 00000000 c3c52804 c3c52800 c3cab800
9f00: 00000000 c3c18000 00000000 00000000 c3c19f3c c3c19f20 c007d518 c0105210
9f20: 00000003 c3c52800 c3cab800 00000000 c3c19f64 c3c19f40 c00e9744 c00e8b74
9f40: c3c19f64 00400001 c0234404 c0233ae0 00000000 c001d60c c3c19f7c c3c19f68
9f60: c0017a2c c00e95b0 00000000 c0233ae0 c3c19f94 c3c19f80 c00172c4 c0017988
9f80: c001e000 00000000 c3c19ff4 c3c19f98 c0008934 c0017160 c0035918 c00354d4
9fa0: 00000000 c3c19fb0 c0021e64 c0035910 00000000 00000000 c0008870 c003bbc0
9fc0: 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
9fe0: 00000000 00000000 00000000 c3c19ff8 c003bbc0 c0008880 ffffff7f feffefff
Backtrace:
[] (device_create+0x4/0xb8) from [] (tty_register_device+0xb4/0xd0)
 r7:00000000 r6:00000004 r5:00000001 r4:00000002
[] (tty_register_device+0x0/0xd0) from [] (tty_register_driver+0x1a4/0x1e4)
 r7:00000000 r6:c3cab800 r5:c3c52800 r4:00000003
[] (tty_register_driver+0x0/0x1e4) from [] (vty_init+0xb4/0xec)
 r7:c001d60c r6:00000000 r5:c0233ae0 r4:c0234404
[] (vty_init+0x0/0xec) from [] (tty_init+0x174/0x1cc)
 r5:c0233ae0 r4:00000000
[] (tty_init+0x0/0x1cc) from [] (kernel_init+0xc4/0x284)
 r5:00000000 r4:c001e000
[] (kernel_init+0x0/0x284) from [] (do_exit+0x0/0x710)
Code: e24dd00c e2505000 e1a07001 e1a06002 (0a000019)
---[ end trace 119d4c116316149b ]---
Kernel panic - not syncing: Attempted to kill init!
可以看到内核是启动起来了!但是还文件系统等还没完全启动,所以还需要进行修改!
4:添加内核对yaffs2的支持
上面可以看到,没有对yaffs2文件系统的支持,现在就添加yaffs2的支持
4.1解压yaffs2文件包
# tar -xzvf yaffs2.tar.gz
# ls
2.6.24.at91.2-exp.patch.gz  2.6.24-at91.patch.gz  linux-2.6.24  linux-2.6.24.tar.bz2  yaffs2  yaffs2.tar.gz
# cd linux-2.6.24/fs
# mkdir yaffs
# pwd
/workdir/atmel/at91sam9260/kernel/linux-2.6.24/fs/yaffs
# cp ../../../yaffs/*.h .
# cp ../../../yaffs/*.c .
# ls
devextras.h        yaffs_fs.c            yaffs_mtdif1.h  yaffs_nandemul2k.h   yaffs_qsort.c         yportenv.h
moduleconfig.h     yaffs_getblockinfo.h  yaffs_mtdif2.c  yaffs_nand.h         yaffs_qsort.h
yaffs_checkptrw.c  yaffs_guts.c          yaffs_mtdif2.h  yaffs_packedtags1.c  yaffs_tagscompat.c
yaffs_checkptrw.h  yaffs_guts.h          yaffs_mtdif.c   yaffs_packedtags1.h  yaffs_tagscompat.h
yaffs_ecc.c        yaffsinterface.h      yaffs_mtdif.h   yaffs_packedtags2.c  yaffs_tagsvalidity.c
yaffs_ecc.h        yaffs_mtdif1.c        yaffs_nand.c    yaffs_packedtags2.h  yaffs_tagsvalidity.h
# cp ../../../yaffs2/Makefile.kernel .
# ls
devextras.h        yaffs_ecc.h           yaffs_mtdif1.c  yaffs_nand.c         yaffs_packedtags2.h   yaffs_tagsvalidity.h
Makefile.kernel    yaffs_fs.c            yaffs_mtdif1.h  yaffs_nandemul2k.h   yaffs_qsort.c         yportenv.h
moduleconfig.h     yaffs_getblockinfo.h  yaffs_mtdif2.c  yaffs_nand.h         yaffs_qsort.h
yaffs_checkptrw.c  yaffs_guts.c          yaffs_mtdif2.h  yaffs_packedtags1.c  yaffs_tagscompat.c
yaffs_checkptrw.h  yaffs_guts.h          yaffs_mtdif.c   yaffs_packedtags1.h  yaffs_tagscompat.h
yaffs_ecc.c        yaffsinterface.h      yaffs_mtdif.h   yaffs_packedtags2.c  yaffs_tagsvalidity.c
# mv Makefile.kernel Makefile
# ls
devextras.h        yaffs_ecc.h           yaffs_mtdif1.c  yaffs_nand.c         yaffs_packedtags2.h   yaffs_tagsvalidity.h
Makefile           yaffs_fs.c            yaffs_mtdif1.h  yaffs_nandemul2k.h   yaffs_qsort.c         yportenv.h
moduleconfig.h     yaffs_getblockinfo.h  yaffs_mtdif2.c  yaffs_nand.h         yaffs_qsort.h
yaffs_checkptrw.c  yaffs_guts.c          yaffs_mtdif2.h  yaffs_packedtags1.c  yaffs_tagscompat.c
yaffs_checkptrw.h  yaffs_guts.h          yaffs_mtdif.c   yaffs_packedtags1.h  yaffs_tagscompat.h
yaffs_ecc.c        yaffsinterface.h      yaffs_mtdif.h   yaffs_packedtags2.c  yaffs_tagsvalidity.c
# pwd
/workdir/atmel/at91sam9260/kernel/linux-2.6.24/fs/yaffs2
# cp ../../../yaffs2/Kconfig .
# cd ..
# pwd
/workdir/atmel/at91sam9260/kernel/linux-2.6.24/fs
119行开始:
obj-$(CONFIG_OCFS2_FS)  += ocfs2/
obj-$(CONFIG_GFS2_FS)           += gfs2/
obj-$(CONFIG_YAFFS_FS)           += yaffs/
# vim Kconfig
修改2119行:
endif # NETWORK_FILESYSTEMS
source "fs/yaffs2/Kconfig"
if BLOCK
menu "Partition Types"
# make distclean
# make at91sam9260ek_defconfig
# make menuconfig
修改配置,去选择支持yaffs!
Device Drivers --> Memory Technology Device(MTD) support
File Systems --> YAFFS2 file system support
                 Autoselect yaffs2 format
                 Disable lazy loading
                 Turn off wide tnodes
Kernel Features --> Use the ARM EABI to compile the kernel
                    Allow ole ABI binaries to run with this kernel
# make uImage
# pwd
/workdir/atmel/at91sam9260/kernel/yaffs2/utils
# ls
Makefile  mkyaffs2image.c  mkyaffsimage.c
# make
# ls
Makefile       mkyaffs2image.c  mkyaffsimage    mkyaffsimage.o  yaffs_ecc.o          yaffs_packedtags2.o   yaffs_tagsvalidity.o
mkyaffs2image  mkyaffs2image.o  mkyaffsimage.c  yaffs_ecc.c     yaffs_packedtags2.c  yaffs_tagsvalidity.c
然后将这个"mkyaffs2image"目录添加到环境变量里面去!
# cd ../../../../
# ls
AT91Bootstrap  crosstool  filesyetem  kernel  setenv-9260  Source Insight Workdir  u-boot
然后就得到支持yaffs2的内核了!
 
==================================================================================
 

1,ubuntu建立tftp服务器:

1.1:首先设置虚拟机能上网步骤如下:

1.1.1配置ip,配置 /etc/network/interfaces 文件

1.1.2.然后是DNS,配置 /etc/resolv.conf

例如:配置静态IP地址

vim /etc/network/interfaces

内容如下:

auto lo

iface lo inet loopback

iface eth0 inet static

address 192.168.1.5

netmask 255.255.255.0

gateway 192.168.1.1

auto eth0

配置DNS

vim /etc/resolv.conf

增加以下内容:

nameserver 202.96.134.133

1.1.3.增加默认网关

route add default gw 192.168.1.1

1.1.4.重新启动网络配置

/etc/init.d/networking restart

1.2:建立tftp服务器:

网上摘抄方法:

1. sudo apt-get install tftp-hpa tftpd-hpa
2. cd /
sudo mkdir /tftpboot
sudo chmod 777 /tftpboot
3. sudo in.tftpd -l /tftpboot
这样tftp服务器就启动了,下面可以做一个测试

4. cd /tftpboot
touch test
建立一个文件
5. cd /home/usrname
登录另一个目录
6. tftp 192.168.0.60
换成自己的ip
> get /tftpboot/test
如果能够得到文件,那么就成功了。

PS
:不要忘了 sudo apt-get install xinetd
sudo apt-get install netkit-inetd
关于不能上传(put)的解决

打开目录 /etc/xinetd.d/
新建文件
tftp
tftp
内容:

service tftp
{
disable = no
socket_type = dgram
protocol = udp
wait = yes
user = root
server = /usr/sbin/in.tftpd
server_args = -s /tftpboot -c
per_source = 11
cps = 100 2
}
重新启动服务:
sudo /etc/init.d/xinetd restart
sudo in.tftpd -l /tftpboot
安装过程中出现的问题及原因
现象一:
tftp> get test.log
Transfer timed out.
原因:
tftpd
服务没有启动
现象二:
tftp> get test.log
Error code 2: Only absolute filenames allowed
原因:
/etc/xinetd.d/tftpd中设置的server_args/etc/default/tftpd-hpa
cat /etc/default/tftpd-hpa
#Defaults for tftpd-hpa
RUN_DAEMON="no"
OPTIONS="-s /home/tftpd -c -p -U 077 -u tftpd"
设置的时候只要将server_args=改为你自己设定的服务器文件夹就行了

现象三:
tftp> put ex070416.log
Error code 1: File not found
原因:
指定的文件不存在;或tftpd启动参数中没有指定-c选项,允许上传文件。

3.板子通过tftp下载虚拟机的文件:

U-Boot> setenv ethaddr 3e:36:65:ba:6f:be
U-Boot> setenv ipaddr 192.168.1.254    
U-Boot> setenv getwayip 192.168.1.1
U-Boot> setenv netmask 255.255.255.0

U-Boot> setenv serverip 192.168.1.5

U-Boot> setenv bootfile uImage
U-Boot> saveenv
Saving Environment to NAND...
Erasing Nand...
Erasing at 0x60000 -- 100% complete.
Writing to Nand... done

U-Boot> tftp uImage
macb0: link up, 100Mbps full-duplex (lpa: 0x41e1)
Using macb0 device
TFTP from server 192.168.1.5; our IP address is 192.168.1.254
Filename 'uImage'.
Load address: 0x0
Loading: #################################################################
         ###########
done
Bytes transferred = 1113208 (10fc78 hex)

这样u-boot就可以直接下载文件到板子上了!

当然你也可以下载其它的文件:
U-Boot> tftp test 

2.下载内核:

U-Boot> tftp 0x22000000 uImage
macb0: link up, 100Mbps full-duplex (lpa: 0x41e1)
Using macb0 device
TFTP from server 192.168.1.5; our IP address is 192.168.1.254
Filename 'uImage'.
Load address: 0x22000000
Loading: #################################################################
         #########
done
Bytes transferred = 1075144 (1067c8 hex)
U-Boot> bootm 0x22000000

U-Boot> bootm 0x22000000     
## Booting kernel from Legacy Image at 22000000 ...
   Image Name:   Linux-2.6.24
   Image Type:   ARM Linux Kernel Image (uncompressed)
   Data Size:    1075080 Bytes =  1 MB
   Load Address: 20008000
   Entry Point:  20008000
   Verifying Checksum ... OK
   Loading Kernel Image ... OK
OK

Starting kernel ...

Uncompressing Linux....................................................................... done, booting the kernel.
Linux version 2.6.24 () (gcc version 4.2.3 (Sourcery G++ Lite 2008q1-126)) #1 Thu May 20 21:16:55 HKT 2010
CPU: ARM926EJ-S [41069265] revision 5 (ARMv5TEJ), cr=00053177
Machine: Atmel AT91SAM9260-EK
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: 8192 bytes, associativity 4, 32 byte lines, 64 sets
CPU0: D cache: 8192 bytes, associativity 4, 32 byte lines, 64 sets
Built 1 zonelists in Zone order, mobility grouping on.  Total pages: 16256
Kernel command line: console=ttyS0,115200
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: 62616KB available (1944K code, 194K data, 100K init)
Mount-cache hash table entries: 512
CPU: Testing write buffer coherency: ok
net_namespace: 64 bytes
NET: Registered protocol family 16
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
Time: pit clocksource has been installed.
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
NetWinder Floating Point Emulator V0.97 (double precision)
io scheduler noop registered
io scheduler anticipatory registered (default)
atmel_usart.0: ttyS0 at MMIO 0xfefff200 (irq = 1) is a ATMEL_SERIAL
atmel_usart.1: ttyS1 at MMIO 0xfffb0000 (irq = 6) is a ATMEL_SERIAL
atmel_usart.2: ttyS2 at MMIO 0xfffb4000 (irq = 7) is a ATMEL_SERIAL
RAMDISK driver initialized: 16 RAM disks of 8192K size 1024 blocksize
ssc ssc.0: Atmel SSC device at 0xc4820000 (irq 14)
MACB_mii_bus: probed
eth0: Atmel MACB at 0xfffc4000 irq 21 (3e:36:65:ba:6f:be)
eth0: attached PHY driver [Generic PHY] (mii_bus:phy_addr=ffffffff:00, irq=-1)
Driver 'sd' needs updating - please use bus_type methods
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
rtc-at91sam9 at91_rtt.0: rtc core: registered at91_rtt as rtc0
rtc-at91sam9 at91_rtt.0: rtc0: SET TIME!
i2c /dev entries driver
i2c-gpio i2c-gpio: using pins 55 (SDA) and 56 (SCL)
at91sam9_wdt: invalid timeout (must be between 1 and 16)
TCP cubic registered
NET: Registered protocol family 1
NET: Registered protocol family 17
rtc-at91sam9 at91_rtt.0: hctosys: unable to read the hardware clock
VFS: Cannot open root device "" or unknown-block(0,0)
Please append a correct "root=" boot option; here are the available partitions:
Kernel panic - not syncing: VFS: Unable to mount root fs on unknown-block(0,0)

停在这里就运行不下去了!

google下,知道是内核恐慌.原因是内核的

Linux内核命令行有6个环境变量。如果即将达到或者已经超过了的话 root= 参数会没有传进去启动时会引发panics错误。

所以去看uboot的参数传递,没有!

现在去看下u-boot

配置内核 :

RomBOOT
>

U-Boot 1.3.4 (May 18 2010 - 21:40:34)

DRAM:  64 MB
NAND:  256 MiB
In:    serial
Out:   serial
Err:   serial
Net:   macb0
macb0: Starting autonegotiation...
macb0: Autonegotiation complete
macb0: link up, 100Mbps full-duplex (lpa: 0x41e1)
Hit any key to stop autoboot:  0
U-Boot>
U-Boot>
U-Boot>
U-Boot>
U-Boot>
U-Boot>
U-Boot>
U-Boot>
U-Boot>
U-Boot>
U-Boot>
U-Boot>
U-Boot> printenv
bootdelay=3
baudrate=115200
ethact=macb0
ethaddr=3e:36:65:ba:6f:be
ipaddr=192.168.1.254
getwayip=192.168.1.1
netmask=255.255.255.0
serverip=192.168.1.5
bootfile=uImage
bootcmd=nand read 0x22000000 0x00800000 0x20000000; bootm 0x22000000
bootargs=noinitrd console=ttyS0,115200 init=/linuxrc root=/dev/mtdblock2 rootfs=cramfs men=64M
stdin=serial
stdout=serial
stderr=serial

Environment size: 373/131067 bytes
U-Boot> tftp 0x22000000 uImage
macb0: link up, 100Mbps full-duplex (lpa: 0x41e1)
Using macb0 device
TFTP from server 192.168.1.5; our IP address is 192.168.1.254
Filename 'uImage'.
Load address: 0x22000000
Loading: #################################################################
         ############
done
Bytes transferred = 1119716 (1115e4 hex)
U-Boot> bootm 0x22000000
## Booting kernel from Legacy Image at 22000000 ...
   Image Name:   Linux-2.6.24
   Image Type:   ARM Linux Kernel Image (uncompressed)
   Data Size:    1119652 Bytes =  1.1 MB
   Load Address: 20008000
   Entry Point:  20008000
   Verifying Checksum ... OK
   Loading Kernel Image ... OK
OK

Starting kernel ...

Uncompressing Linux.......................................................................... done, booting the kernel.
Linux version 2.6.24 () (gcc version 4.2.3 (Sourcery G++ Lite 2008q1-126)) #1 Thu May 20 22:01:58 HKT 2010
CPU: ARM926EJ-S [41069265] revision 5 (ARMv5TEJ), cr=00053177
Machine: Atmel AT91SAM9260-EK
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: 8192 bytes, associativity 4, 32 byte lines, 64 sets
CPU0: D cache: 8192 bytes, associativity 4, 32 byte lines, 64 sets
Built 1 zonelists in Zone order, mobility grouping on.  Total pages: 16256
Kernel command line: noinitrd console=ttyS0,115200 init=/linuxrc root=/dev/mtdblock2 rootfs=cramfs men=64M
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: 62592KB available (2036K code, 195K data, 100K init)
Mount-cache hash table entries: 512
CPU: Testing write buffer coherency: ok
net_namespace: 64 bytes
NET: Registered protocol family 16
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
Time: pit clocksource has been installed.
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
NetWinder Floating Point Emulator V0.97 (double precision)
yaffs May 20 2010 21:59:45 Installing.
io scheduler noop registered
io scheduler anticipatory registered (default)
Unable to handle kernel NULL pointer dereference at virtual address 00000c20
pgd = c0004000
[00000c20] *pgd=00000000
Internal error: Oops: 0 [#1]
Modules linked in:
CPU: 0    Not tainted  (2.6.24 #1)
PC is at 0xc20
LR is at link_path_walk+0x8c/0x168
pc : [<00000c20>]    lr : []    psr: 60000013
sp : c3c79d98  ip : c022d511  fp : c3c79de4
r10: c022d516  r9 : 00000000  r8 : c022d510
r7 : 00000000  r6 : c3800d08  r5 : c3c79ee0  r4 : 00000107
r3 : 00000000  r2 : c3c79db0  r1 : c3c79da4  r0 : c3c79ee0
Flags: nZCv  IRQs on  FIQs on  Mode SVC_32  ISA ARM  Segment kernel
Control: 0005317f  Table: 20004000  DAC: 00000017
Process khelper (pid: 616, stack limit = 0xc3c78268)
Stack: (0xc3c79d98 to 0xc3c7a000)
9d80:                                                       00000101 c3c78000
9da0: 00000107 01c000e1 00000004 c022d511 c3c0d7a0 c3801a18 c3c78000 c3c263c0
9dc0: c3c79ee0 c3c0d7a0 c3801798 c022d510 00000000 00000000 c3c79e5c c3c79de8
9de0: c008479c c00838a8 c3801798 c3c0d7a0 c3c79f64 c3801698 c3c1ab20 00000101
9e00: 00000001 00000000 c3c79f34 c3c79f10 00000001 c0238e10 c0239590 c0238e10
9e20: 3f2e5100 00000000 c3c79f54 00000011 00000000 c3c27b20 c3c79ecc c3c263c0
9e40: 00000001 c3c79ee0 00000001 c022d510 c3c79e6c c3c79e60 c00848a0 c0084720
9e60: c3c79e9c c3c79e70 c0084d04 c0084888 c022d510 00000001 c3c79e9c c3c79ee0
9e80: ffffff9c c022d510 00000001 c3c79f70 c3c79ebc c3c79ea0 c00857ec c0084ad0
9ea0: c3c79ee0 c022d510 c3cfe000 c3c19dfc c3c79ed4 c3c79ec0 c00858c0 c00857a8
9ec0: 00000011 00000000 c3c79f44 c3c79ed8 c007eef8 c00858ac 00000011 00000000
9ee0: c3801798 c3c0d7a0 c3c79f64 c3801698 c3c1ab20 00000105 00000001 00000000
9f00: c3c79f34 c3c79f10 00000001 c0238e10 c0239590 c0238e10 3f2e5100 00000000
9f20: c3c79f54 00000011 00000000 c3c27b20 c3c64380 c022d510 c3c79f6c c3c79f48
9f40: c008042c c007eed8 c022d510 c3c19dfc c3cfe000 c3c79f70 00000000 00000000
9f60: c3c79fd4 c3c79f70 c00254f4 c00803fc 00000000 00000000 00000000 00000000
9f80: 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
9fa0: 00000000 00000000 00000000 00000000 00000000 00000000 00000000 c3c78000
9fc0: 00000000 c3c741e0 c3c79ff4 c3c79fd8 c0048700 c00254c4 00000000 00000000
9fe0: 00000000 00000000 00000000 c3c79ff8 c003bbc0 c0048630 ffffffff ffffffff
Backtrace:
[] (__link_path_walk+0x0/0xe78) from [] (link_path_walk+0x8c/0x168)
[] (link_path_walk+0x0/0x168) from [] (path_walk+0x28/0x2c)
 r8:c022d510 r7:00000001 r6:c3c79ee0 r5:00000001 r4:c3c263c0
[] (path_walk+0x0/0x2c) from [] (do_path_lookup+0x244/0x274)
[] (do_path_lookup+0x0/0x274) from [] (__path_lookup_intent_open+0x54/0x94)
 r8:c3c79f70 r7:00000001 r6:c022d510 r5:ffffff9c r4:c3c79ee0
[] (__path_lookup_intent_open+0x0/0x94) from [] (path_lookup_open+0x24/0x2c)
 r7:c3c19dfc r6:c3cfe000 r5:c022d510 r4:c3c79ee0
[] (path_lookup_open+0x0/0x2c) from [] (open_exec+0x30/0xc0)
[] (open_exec+0x0/0xc0) from [] (do_execve+0x40/0x184)
 r5:c022d510 r4:c3c64380
[] (do_execve+0x0/0x184) from [] (kernel_execve+0x40/0x8c)
 r9:00000000 r8:00000000 r7:c3c79f70 r6:c3cfe000 r5:c3c19dfc
r4:c022d510
[] (kernel_execve+0x0/0x8c) from [] (____call_usermodehelper+0xe0/0xec)
 r7:c3c741e0 r6:00000000 r5:c3c78000 r4:00000000
[] (____call_usermodehelper+0x0/0xec) from [] (do_exit+0x0/0x710)
 r7:00000000 r6:00000000 r5:00000000 r4:00000000
Code: bad PC value.
---[ end trace e314335e86712eef ]---
atmel_usart.0: ttyS0 at MMIO 0xfefff200 (irq = 1) is a ATMEL_SERIAL
atmel_usart.1: ttyS1 at MMIO 0xfffb0000 (irq = 6) is a ATMEL_SERIAL
atmel_usart.2: ttyS2 at MMIO 0xfffb4000 (irq = 7) is a ATMEL_SERIAL
RAMDISK driver initialized: 16 RAM disks of 8192K size 1024 blocksize
ssc ssc.0: Atmel SSC device at 0xc4820000 (irq 14)
MACB_mii_bus: probed
eth0: Atmel MACB at 0xfffc4000 irq 21 (3e:36:65:ba:6f:be)
eth0: attached PHY driver [Generic PHY] (mii_bus:phy_addr=ffffffff:00, irq=-1)
Driver 'sd' needs updating - please use bus_type methods
usbmon: debugfs is not available
ohci_hcd: 2006 August 04 USB 1.1 'Open' Host Controller (OHCI) Driver
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
rtc-at91sam9 at91_rtt.0: rtc core: registered at91_rtt as rtc0
rtc-at91sam9 at91_rtt.0: rtc0: SET TIME!
i2c /dev entries driver
i2c-gpio i2c-gpio: using pins 55 (SDA) and 56 (SCL)
at91sam9_wdt: invalid timeout (must be between 1 and 16)
TCP cubic registered
NET: Registered protocol family 1
NET: Registered protocol family 17
rtc-at91sam9 at91_rtt.0: hctosys: unable to read the hardware clock
VFS: Cannot open root device "mtdblock2" or unknown-block(0,0)
Please append a correct "root=" boot option; here are the available partitions:
Kernel panic - not syncing: VFS: Unable to mount root fs on unknown-block(0,0)

现在内核已经起来了,现在就是要做文件系统了!

对内核进行重新配置
# make menuconfig

修改后重新启动板子可以看到mtd分区:

RomBOOT
>

U-Boot 1.3.4 (May 18 2010 - 21:40:34)

DRAM:  64 MB
NAND:  RomBOOT
>

U-Boot 1.3.4 (May 18 2010 - 21:40:34)

DRAM:  64 MB
NAND:  256 MiB
In:    serial
Out:   serial
Err:   serial
Net:   macb0
macb0: Starting autonegotiation...
macb0: Autonegotiation complete
macb0: link up, 100Mbps full-duplex (lpa: 0x41e1)
Hit any key to stop autoboot:  0
macb0: link up, 100Mbps full-duplex (lpa: 0x41e1)
Using macb0 device
TFTP from server 192.168.1.5; our IP address is 192.168.1.254
Filename 'uImage'.
Load address: 0x22000000
Loading: #################################################################
         #############################
done
Bytes transferred = 1377500 (1504dc hex)
## Booting kernel from Legacy Image at 22000000 ...
   Image Name:   Linux-2.6.24
   Image Type:   ARM Linux Kernel Image (uncompressed)
   Data Size:    1377436 Bytes =  1.3 MB
   Load Address: 20008000
   Entry Point:  20008000
   Verifying Checksum ... OK
   Loading Kernel Image ... OK
OK

Starting kernel ...

Uncompressing Linux.......................................................................................... done, booting the kernel.
Linux version 2.6.24 () (gcc version 4.2.3 (Sourcery G++ Lite 2008q1-126)) #2 Thu May 20 23:52:25 HKT 2010
CPU: ARM926EJ-S [41069265] revision 5 (ARMv5TEJ), cr=00053177
Machine: Atmel AT91SAM9260-EK
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: 8192 bytes, associativity 4, 32 byte lines, 64 sets
CPU0: D cache: 8192 bytes, associativity 4, 32 byte lines, 64 sets
Built 1 zonelists in Zone order, mobility grouping on.  Total pages: 16256
Kernel command line: menm=64M noinitrd console=ttyS0,115200 init=linuxrc root=/dev/mtdblock2 rootfstype=cramfs
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: 61964KB available (2544K code, 245K data, 112K init)
Mount-cache hash table entries: 512
CPU: Testing write buffer coherency: ok
net_namespace: 64 bytes
NET: Registered protocol family 16
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
Time: pit clocksource has been installed.
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
NetWinder Floating Point Emulator V0.97 (double precision)
Installing knfsd (copyright (C) 1996 ).
yaffs May 20 2010 23:08:52 Installing.
io scheduler noop registered
io scheduler anticipatory registered (default)
atmel_usart.0: ttyS0 at MMIO 0xfefff200 (irq = 1) is a ATMEL_SERIAL
atmel_usart.1: ttyS1 at MMIO 0xfffb0000 (irq = 6) is a ATMEL_SERIAL
atmel_usart.2: ttyS2 at MMIO 0xfffb4000 (irq = 7) is a ATMEL_SERIAL
RAMDISK driver initialized: 16 RAM disks of 8192K size 1024 blocksize
nbd: registered device at major 43
ssc ssc.0: Atmel SSC device at 0xc4820000 (irq 14)
MACB_mii_bus: probed
eth0: Atmel MACB at 0xfffc4000 irq 21 (3e:36:65:ba:6f:be)
eth0: attached PHY driver [Generic PHY] (mii_bus:phy_addr=ffffffff:00, irq=-1)
Driver 'sd' needs updating - please use bus_type methods
NAND device: Manufacturer ID: 0xec, Chip ID: 0xda (Samsung NAND 256MiB 3,3V 8-bit)
AT91 NAND: 8-bit, Software ECC
Scanning device for bad blocks
Creating 6 MTD partitions on "at91_nand":
0x00000000-0x00400000 : "Bootstrap"
0x00400000-0x00800000 : "u-boot"
0x00800000-0x01e00000 : "kernel"
0x01e00000-0x04600000 : "fs"
0x04600000-0x08200000 : "user space0"
0x08200000-0x10000000 : "user space2"
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
rtc-at91sam9 at91_rtt.0: rtc core: registered at91_rtt as rtc0
rtc-at91sam9 at91_rtt.0: rtc0: SET TIME!
i2c /dev entries driver
i2c-gpio i2c-gpio: using pins 55 (SDA) and 56 (SCL)
at91sam9_wdt: invalid timeout (must be between 1 and 16)
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
Root-NFS: No NFS server available, giving up.
VFS: Unable to mount root fs via NFS, trying floppy.
VFS: Cannot open root device "mtdblock2" or unknown-block(2,0)
Please append a correct "root=" boot option; here are the available partitions:
Kernel panic - not syncing: VFS: Unable to mount root fs on unknown-block(2,0)

3.板子通过nfs挂载主机的文件:

# apt-get install nfs-kernel-serve

# vim /etc/exports

# /etc/exports: the access control list for filesystems which may be exported
#               to NFS clients.  See exports(5).
#
# Example for NFSv2 and NFSv3:
# /srv/homes       hostname1(rw,sync) hostname2(ro,sync)
#
# Example for NFSv4:
# /srv/nfs4        gss/krb5i(rw,sync,fsid=0,crossmnt)
# /srv/nfs4/homes  gss/krb5i(rw,sync)
#

/workdir/atmel/at91sam9260/filesyetem/rootfs *(rw,sync,no_root_squash)
# exportfs -r

# /etc/init.d/nfs-kernel-server restart
 * Stopping NFS kernel daemon
   ...done.
 * Unexporting directories for NFS kernel daemon...
   ...done.
 * Exporting directories for NFS kernel daemon...
exportfs: /etc/exports [2]: Neither 'subtree_check' or 'no_subtree_check' specified for export "*:/workdir/atmel/at91sam9260/filesyetem/rootfs".
  Assuming default behaviour ('no_subtree_check').
  NOTE: this default has changed since nfs-utils version 1.0.x

   ...done.
 * Starting NFS kernel daemon
   ...done.

@emboard:/workdir/atmel/at91sam9260# mount -t nfs 192.168.1.5:/workdir/atmel/at91sam9260/filesyetem/rootfs /mnt
# ls /mnt/
app  bin  boot  dev  driver  etc  home  lib  linuxrc  mnt  proc  root  sbin  sys  tmp  usr  var

这样可以看到成功挂载,nfs服务器配置成功
# umount 192.168.1.5:/workdir/atmel/at91sam9260/filesyetem/rootfs
# ls /mnt/
hgfs
成功卸载了.

 

================================================

 
1,问题1
为什么我选择下面的这个内核配置会出现这个结果呢?
选种的话,会自己自动创建MTD分
NAND device: Manufacturer ID: 0xec, Chip ID: 0xda (Samsung NAND 256MiB 3,3V 8-bit)
AT91 NAND: 8-bit, Software ECC
Scanning device for bad blocks
6 cmdlinepart partitions found on MTD device at91_nand
Creating 6 MTD partitions on "at91_nand":
0x00000000-0x00020000 : "bootstrap"
0x00020000-0x00060000 : "uboot"
0x00060000-0x00080000 : "env1"
0x00080000-0x000a0000 : "env2"
0x000a0000-0x002a0000 : "linux"
0x002a0000-0x10000000 : "root"
不选中的话:
NAND device: Manufacturer ID: 0xec, Chip ID: 0xda (Samsung NAND 256MiB 3,3V 8-bit)
AT91 NAND: 8-bit, Software ECC
Scanning device for bad blocks
Creating 6 MTD partitions on "NAND 256MiB 3,3V 8-bit":
0x00000000-0x00400000 : "Bootstrap"
0x00400000-0x00800000 : "u-boot"
0x00800000-0x01e00000 : "kernel"
0x01e00000-0x04600000 : "fs"
0x04600000-0x08200000 : "user space0"
0x08200000-0x10000000 : "user space2"
2,NFS文件系统搭建:
主机:

安装nfs服务器端和客户端
root@emboard:/workdir/atmel/at91sam9260# apt-get install portmap nfs-kernel-server
root@emboard:/workdir/atmel/at91sam9260# apt-get install portmap nfs-common
2.
配置共享文件
编辑/etc/exports,在其中增加要共享的目录
/nfs *(rw,sync,no_subtree_check)
root@emboard:/workdir/atmel/at91sam9260#  exportfs -ra
3.
重启服务

root@emboard:/workdir/atmel/at91sam9260#  /etc/init.d/portmap restart
root@emboard:/workdir/atmel/at91sam9260#  /etc/init.d/nfs-kernel-server restart
4.
客户就可以加载了

root@emboard:/workdir/atmel/at91sam9260# mount 192.168.1.5:/nfs /workdir/ -o nolock

5,设置开发板的启动参数

U-Boot>setenv bootargs mem=64M console=ttyS0 115200 root=/dev/nfs

nfsroot=192.168.1.5:/nfs/rootfs

ip=192.168.1.254:192.168.1.5:192.168.1.1:255.255.255.0::eth0:off

这样就可以看到系统通过nfs文件系统启动了.

当然要把内核关于nfs的选项选中

当开发板的系统跑起来后,可以执行这个命令来验证:

[root@microcreat /]$mount -o nolock -t nfs 192.168.1.5:/nfs/rootfs /mnt/

要加上-o nolock

内核里面关于nfs文件系统的选项选上

 

 

 

阅读(2134) | 评论(1) | 转发(0) |
给主人留下些什么吧!~~

chinaunix网友2011-04-27 08:59:15

哥,内核都Oooops!几次了,还是看看怎么回事啊!