Chinaunix首页 | 论坛 | 博客
  • 博客访问: 6558741
  • 博文数量: 1159
  • 博客积分: 12444
  • 博客等级: 上将
  • 技术积分: 12570
  • 用 户 组: 普通用户
  • 注册时间: 2008-03-13 21:34
文章分类

全部博文(1159)

文章存档

2016年(126)

2015年(350)

2014年(56)

2013年(91)

2012年(182)

2011年(193)

2010年(138)

2009年(23)

分类: 嵌入式

2011-06-17 08:19:13

                       嵌入式系统移植基础三

                计算机与信息工程学院   林光辉   计应一班    0906041018

准备工作:在进行嵌入式系统的模拟移植时,首先应该安装skyeye,模拟嵌入式的计算机系统;skyeye的安装  (1)解压源码包:    [root@localhost Desktop]# tar -xjvf skyeye-1.2.6_rc1.tar.bz2 -C ./

(2)  编译skyeye-1.2.6: [root@localhost Desktop]# cd skyeye-1.2.6_rc1

[root@localhost skyeye-1.2.6_rc1]# ./configure                        

[root@localhost skyeye-1.2.6_rc1]# make                               

[root@localhost skyeye-1.2.6_rc1]# make install

(3)修改名称:        [root@localhostskyeye-1.2.6_rc1]#mv/usr/local/bin/skyeye /usr/local/bin/skyeye1.2.6

三部曲的第一步bootloader的移植   所需材料:u-boot-1.1.4.tar.bz2

1.        解压u-boot-1.1.4.tar.bz2

 [root@localhost Desktop]# tar -xjvf u-boot-1.1.4.tar.bz2  -C  ./

[root@localhost Desktop]# cd u-boot-1.1.4

2.编辑u-boot目录中的Makefile文件

[root@localhost u-boot-1.1.4]# gedit Makefile

(1)将

ifeq ($(ARCH),arm)

CROSS_COMPILE = arm-linux-

Endif

改为

ifeq ($(ARCH),arm)

CROSS_COMPILE=/usr/local/arm/2.95.3/bin/arm-linux-

endif

 

(2)在

smdk2410_config        :        unconfig

              @./mkconfig $(@:_config=) arm arm920t smdk2410 NULL s3c24x0

后面添加

ok2410_config        :        unconfig

@./mkconfig $(@:_config=) arm arm920t ok2410 NULL s3c24x0

 

3复制必要的文件,编辑ok2410.h头文件

[root@localhost u-boot-1.1.4]# mkdir board/ok2410

[root@localhost u-boot-1.1.4]# cp board/smdk2410/* board/ok2410/

[root@localhost u-boot-1.1.4]# mv board/ok2410/smdk2410.c board/ok2410/ok2410.c

[root@localhost u-boot-1.1.4]# cp include/configs/smdk2410.h include/configs/ok2410.h

[root@localhost u-boot-1.1.4]# gedit include/configs/ok2410.h

   

#define        CFG_PROMPT                "SMDK2410 # "        /* Monitor Command Prompt        */

改为

#define        CFG_PROMPT                "lgh # "        /* Monitor Command Prompt        */

4.编辑board/ok2410/Makefile文件

[root@localhost u-boot-1.1.4]# gedit board/ok2410/Makefile

    OBJS        := smdk2410.o flash.o   改为  OBJS        := ok2410.o flash.o

5.配置、编译u-boot      [root@localhost u-boot-1.1.4]# make ok2410_config

                             Configuring for ok2410 board...

[root@localhost u-boot-1.1.4]# make

出现如下错误  ……

make -C examples all

make[1]: Entering directory `/root/Desktop/u-boot-1.1.4/examples'

/usr/local/arm/2.95.3/bin/arm-linux-gcc -g  -Os   -fno-strict-aliasing  -fno-common -ffixed-r8 -msoft-float  -D__KERNEL__ -DTEXT_BASE=0x33F80000 -I/root/Desktop/u-boot-1.1.4/include -fno-builtin -ffreestanding -nostdinc -isystem /usr/local/arm/2.95.3/lib/gcc-lib/arm-linux/2.95.3/include -pipe  -DCONFIG_ARM -D__ARM__ -march=armv4 -mabi=apcs-gnu -Wall -Wstrict-prototypes -c -o hello_world.o hello_world.c

cc1: Invalid option `abi=apcs-gnu'

make[1]: *** [hello_world.o] 错误 1

make[1]: Leaving directory `/root/Desktop/u-boot-1.1.4/examples'

make: *** [examples] 错误 2

修改cpu/arm920t/config.mk文件

[root@localhost u-boot-1.1.4]# gedit cpu/arm920t/config.mk

    

PLATFORM_CPPFLAGS +=$(call cc-option,-mapcs-32,-mabi=apcs-gnu)

改成:

PLATFORM_CPPFLAGS +=$(call cc-option,-mapcs-32,$(call cc-option,-mabi=apcs-gnu,))

[root@localhost u-boot-1.1.4]# make

接着出现了如下的错误

......

/usr/local/arm/2.95.3/bin/arm-linux-ar crv libstubs.a  stubs.o

a - stubs.o

make[1]: *** 没有规则可以创建“all”需要的目标“hello_world.srec”。 停止。

make[1]: Leaving directory `/root/Desktop/u-boot-1.1.4/examples'

make: *** [examples] 错误 2

[root@localhost u-boot-1.1.4]# gedit examples/Makefile

将原文件的第58行开始的内容:

SREC        = hello_world.srec

BIN        = hello_world.bin hello_world

改为

SREC        = hello_world.o

BIN        = hello_world.o hello_world

[root@localhost u-boot-1.1.4]# make

  

make[1]: Leaving directory `/root/Desktop/u-boot-1.1.4/common'

UNDEF_SYM=`/usr/local/arm/2.95.3/bin/arm-linux-objdump -x lib_generic/libgeneric.a board/ok2410/libok2410.a cpu/arm920t/libarm920t.a cpu/arm920t/s3c24x0/libs3c24x0.a lib_arm/libarm.a fs/cramfs/libcramfs.a fs/fat/libfat.a fs/fdos/libfdos.a fs/jffs2/libjffs2.a fs/reiserfs/libreiserfs.a fs/ext2/libext2fs.a net/libnet.a disk/libdisk.a rtc/librtc.a dtt/libdtt.a drivers/libdrivers.a drivers/sk98lin/libsk98lin.a post/libpost.a post/cpu/libcpu.a common/libcommon.a |sed  -n -e 's/.*\(__u_boot_cmd_.*\)/-u\1/p'|sort|uniq`;\

                /usr/local/arm/2.95.3/bin/arm-linux-ld -Bstatic -T /root/Desktop/u-boot-1.1.4/board/ok2410/u-boot.lds -Ttext 0x33F80000  $UNDEF_SYM cpu/arm920t/start.o \

 

                        --start-group lib_generic/libgeneric.a board/ok2410/libok2410.a cpu/arm920t/libarm920t.a cpu/arm920t/s3c24x0/libs3c24x0.a lib_arm/libarm.a fs/cramfs/libcramfs.a fs/fat/libfat.a fs/fdos/libfdos.a fs/jffs2/libjffs2.a fs/reiserfs/libreiserfs.a fs/ext2/libext2fs.a net/libnet.a disk/libdisk.a rtc/librtc.a dtt/libdtt.a drivers/libdrivers.a drivers/sk98lin/libsk98lin.a post/libpost.a post/cpu/libcpu.a common/libcommon.a --end-group -L /usr/local/arm/2.95.3/lib/gcc-lib/arm-linux/2.95.3 -lgcc \

                        -Map u-boot.map -o u-boot

/usr/local/arm/2.95.3/bin/arm-linux-objcopy --gap-fill=0xff -O srec u-boot u-boot.srec

/usr/local/arm/2.95.3/bin/arm-linux-objcopy —gap-fill=0xff -O binary u-boot u-boot.bin

6.编辑skyeye.conf文件

[root@localhost u-boot-1.1.4]# gedit skyeye.conf

  # skyeye config file for S3C2410X

cpu: arm920t

mach: s3c2410x

# physical memory

mem_bank: map=M, type=RW, addr=0x00000000, size=0x00800000, file=./u-boot.bin ,boot=yes

mem_bank: map=M, type=RW, addr=0x30000000, size=0x00800000

mem_bank: map=M, type=RW, addr=0x30800000, size=0x00800000

mem_bank: map=M, type=RW, addr=0x31000000, size=0x03000000

# all peripherals I/O mapping area

mem_bank: map=I, type=RW, addr=0x48000000, size=0x20000000

mem_bank: map=I, type=RW, addr=0x19000300, size=0x00000020

 

net: type=cs8900a, base=0x19000300, size=0x20,int=9, mac=08:00:3E:26:0A:5B, ethmod=tuntap, hostip=10.0.0.1

nandflash: type=s3c2410x,name=K9F1208U0B,dump=./nand.dump

#lcd:type=s3c2410x, mod=gtk

dbct:state=on

7.执行skyeye1.2.6

[root@localhost u-boot-1.1.4]# skyeye1.2.6

**************************** WARNING **********************************

If you want to run ELF image, you should use -e option to indicate

your elf-format image filename. Or you only want to run binary image,

you need to set the filename of the image and its entry in skyeye.conf.

***********************************************************************

Your elf file is little endian.

arch: arm

cpu info: armv4, arm920t, 41009200, ff00fff0, 2

mach info: name s3c2410x, mach_init addr 0x806bae0

ethmod num=1, mac addr=8:0:3e:26:a:5b, hostip=10.0.0.1

nandflash: dump ./nand.dump

file size:69206016

dbct info: turn on dbct!

uart_mod:0, desc_in:, desc_out:, converter:

SKYEYE: use arm920t mmu ops

Loaded RAM   ./u-boot.bin

ERROR: s3c2410x_io_write_word(0x4c000000) = 0x00ffffff

ERROR: s3c2410x_io_write_word(0x4c000008) = 0x00048032

 

U-Boot 1.1.4 (May  3 2009 - 18:31:55)

 

U-Boot code: 33F80000 -> 33F9873C  BSS: -> 33F9C814

RAM Configuration:

Bank #0: 30000000 64 MB

Flash: 512 kB

*** Warning - bad CRC, using default environment

 

In:    serial

Out:   serial

Err:   serial

OK2410 #

8开始移植nand

[root@localhost u-boot-1.1.4]# gedit cpu/arm920t/start.S

将以下U-Boot的重定向语句段:

#ifndef CONFIG_SKIP_RELOCATE_UBOOT

relocate:                                /* relocate U-Boot to RAM            */

        adr        r0, _start                /* r0 <- current position of code   */

        ldr        r1, _TEXT_BASE                /* test if we run from flash or RAM */

        cmp     r0, r1                  /* don't reloc during debug         */

        beq     stack_setup

 

        ldr        r2, _armboot_start

        ldr        r3, _bss_start

        sub        r2, r3, r2                /* r2 <- size of armboot            */

        add        r2, r0, r2                /* r2 <- source end address         */

 

copy_loop:

        ldmia        r0!, {r3-r10}                /* copy from source address [r0]    */

        stmia        r1!, {r3-r10}                /* copy to   target address [r1]    */

        cmp        r0, r2                        /* until source end addreee [r2]    */

        ble        copy_loop

#endif        /* CONFIG_SKIP_RELOCATE_UBOOT */

#ifdef CONFIG_S3C2410_NAND_BOOT

@ reset NAND

        mov r1, #NAND_CTL_BASE

        ldr   r2, =0xf830           @ initial value

        str   r2, [r1, #oNFCONF]

        ldr   r2, [r1, #oNFCONF]

        bic  r2, r2, #0x800              @ enable chip

        str   r2, [r1, #oNFCONF]

        mov r2, #0xff         @ RESET command

        strb r2, [r1, #oNFCMD]

 

 

        mov r3, #0                   @ wait

nand1:

        add  r3, r3, #0x1

        cmp r3, #0xa

        blt   nand1

 

nand2:

        ldr   r2, [r1, #oNFSTAT]      @ wait ready

        tst    r2, #0x1

        beq  nand2

 

        ldr   r2, [r1, #oNFCONF]

        orr  r2, r2, #0x800              @ disable chip

        str   r2, [r1, #oNFCONF]

 

@ get read to call C functions (for nand_read())

        ldr   sp, DW_STACK_START       @ setup stack pointer

        mov fp, #0                    @ no previous frame, so fp=0

 

@ copy U-Boot to RAM

        ldr   r0, =TEXT_BASE

        mov     r1, #0x0

        mov r2, #0x20000

        bl    nand_read_ll

        tst    r0, #0x0

        beq  ok_nand_read

 

bad_nand_read:

loop2:    b     loop2          @ infinite loop

 

ok_nand_read:

@ verify

        mov r0, #0

        ldr   r1, =TEXT_BASE

        mov r2, #0x400     @ 4 bytes * 1024 = 4K-bytes

go_next:

        ldr   r3, [r0], #4

        ldr   r4, [r1], #4

        teq   r3, r4

        bne  notmatch

        subs r2, r2, #4

        beq  stack_setup

        bne  go_next

 

notmatch:

loop3:     b     loop3         @ infinite loop

 

#endif /* CONFIG_S3C2410_NAND_BOOT */

_start_armboot:        .word start_armboot

后面加入

        .align        2

DW_STACK_START:  .word  STACK_BASE+STACK_SIZE-4

9修改board/ok2410/Makefile

[root@localhost u-boot-1.1.4]# gedit board/ok2410/Makefile

   

OBJS        := ok2410.o flash.o

改为

OBJS        := ok2410.o flash.o nand_read.o

10创建board/ok2410/nand_read.c文件

[root@localhost u-boot-1.1.4]# gedit board/ok2410/nand_read.c

 

#include

#define __REGb(x) (*(volatile unsigned char *)(x))

#define __REGi(x) (*(volatile unsigned int *)(x))

#define NF_BASE  0x4e000000

#define NFCONF  __REGi(NF_BASE + 0x0)

#define NFCMD  __REGb(NF_BASE + 0x4)

#define NFADDR  __REGb(NF_BASE + 0x8)

#define NFDATA  __REGb(NF_BASE + 0xc)

#define NFSTAT  __REGb(NF_BASE + 0x10)

#define BUSY 1

#ifndef NAND_SECTOR_SIZE

#define NAND_SECTOR_SIZE 512

#endif

#ifndef NAND_BLOCK_MASK

#define NAND_BLOCK_MASK 511

#endif

 

inline void wait_idle(void) {

        int i;

        while(!(NFSTAT & BUSY))

        for(i=0; i<10; i++);

}

 

/* low level nand read function */

int nand_read_ll(unsigned char *buf, unsigned long start_addr, int size)

{

        int i, j;

        if ((start_addr & NAND_BLOCK_MASK) || (size & NAND_BLOCK_MASK)) {

                return -1; /* invalid alignment */

        }

        /* chip Enable */

        NFCONF &= ~0x800;

        for(i=0; i<10; i++);

        for(i=start_addr; i < (start_addr + size);) {

                /* READ0 */

                NFCMD = 0;

                /* Write Address */

                NFADDR = i & 0xff;

                NFADDR = (i >> 9) & 0xff;

                NFADDR = (i >> 17) & 0xff;

                NFADDR = (i >> 25) & 0xff;

                wait_idle();

                for(j=0; j < NAND_SECTOR_SIZE; j++, i++) {

                        *buf = (NFDATA & 0xff);

                        buf++;

                }

        }

        /* chip Disable */

        NFCONF |= 0x800; /* chip disable */

        return 0;

}

11.编辑include/configs/ok2410.h文件

[root@localhost u-boot-1.1.4]# gedit include/configs/ok2410.h

 在文件的后部添加

/****************** me add begin *******************/

/*

* Nandflash Boot

*/

#define CONFIG_S3C2410_NAND_BOOT 1

#define STACK_BASE    0x33f00000

#define STACK_SIZE    0x8000

//#define UBOOT_RAM_BASE    0x33f80000

/* NAND Flash Controller */

#define NAND_CTL_BASE            0x4E000000

#define bINT_CTL(Nb)        __REG(INT_CTL_BASE + (Nb))

/* Offset */

#define oNFCONF               0x00

#define oNFCMD                0x04

#define oNFADDR               0x08

#define oNFDATA               0x0c

#define oNFSTAT               0x10

#define oNFECC                0x14

/****************** me add end *******************/

12.编译u-boot,然后测试u-boot是否可以从nand启动

[root@localhost u-boot-1.1.4]# make

[root@localhost u-boot-1.1.4]# skyeye1.2.6

 

**************************** WARNING **********************************

If you want to run ELF image, you should use -e option to indicate

your elf-format image filename. Or you only want to run binary image,

you need to set the filename of the image and its entry in skyeye.conf.

***********************************************************************

Your elf file is little endian.

arch: arm

cpu info: armv4, arm920t, 41009200, ff00fff0, 2

mach info: name s3c2410x, mach_init addr 0x806bae0

ethmod num=1, mac addr=8:0:3e:26:a:5b, hostip=10.0.0.1

nandflash: dump ./nand.dump

 

Init nandflash dump file.

file size:69206016

finish init nandflash dump

dbct info: turn on dbct!

uart_mod:0, desc_in:, desc_out:, converter:

SKYEYE: use arm920t mmu ops

Loaded RAM   ./u-boot.bin    到此停止不动 执行如下命令:

[root@localhost u-boot-1.1.4]# mknandflashdump u-boot.bin nand.dump 0

 若出现如下情况  命令没找到:

bash: mknandflashdump: command not found

解决方法:将mknandflashdump的二进制文件移到/bin/的目录下 重新执行:

 结果如下:    offset: 0x0 = 0

1  pos: 0x0 = 0

2  pos: 0x0 = 0

finish

[root@localhost u-boot-1.1.4]# chmod 666 nand.dump

[root@localhost u-boot-1.1.4]# skyeye1.2.6

**************************** WARNING **********************************

If you want to run ELF image, you should use -e option to indicate

your elf-format image filename. Or you only want to run binary image,

you need to set the filename of the image and its entry in skyeye.conf.

***********************************************************************

Your elf file is little endian.

arch: arm

cpu info: armv4, arm920t, 41009200, ff00fff0, 2

mach info: name s3c2410x, mach_init addr 0x806bae0

ethmod num=1, mac addr=8:0:3e:26:a:5b, hostip=10.0.0.1

nandflash: dump ./nand.dump

file size:69206016

dbct info: turn on dbct!

uart_mod:0, desc_in:, desc_out:, converter:

SKYEYE: use arm920t mmu ops

Loaded RAM   ./u-boot.bin

ERROR: s3c2410x_io_write_word(0x4c000000) = 0x00ffffff

ERROR: s3c2410x_io_write_word(0x4c000008) = 0x00048032

 

 

U-Boot 1.1.4 (May  3 2009 - 18:57:18)

 

U-Boot code: 33F80000 -> 33F988D4  BSS: -> 33F9C9AC

RAM Configuration:

Bank #0: 30000000 64 MB

Flash: 512 kB

*** Warning - bad CRC, using default environment

 

In:    serial

Out:   serial

Err:   serial

OK2410 # ?                         //显示可以使用的u-boot命令

……                                //可以使用的u-boot命令省略

OK2410 #

注:13~15步对u-boot添加nand指令的支持:

13.编辑include/configs/ok2410.h文件

[root@localhost u-boot-1.1.4]# gedit include/configs/ok2410.h

 

#define CONFIG_BAUDRATE                115200

后面添加

/*********************** me add begin *************************************/

/* enable passing of ATAGs   */

#define CONFIG_CMDLINE_TAG      1

#define CONFIG_SETUP_MEMORY_TAGS 1

#define CONFIG_INITRD_TAG   1

/*********************** me add end *************************************/

 

                        /*CFG_CMD_NAND        |*/ \

改为

                        CFG_CMD_NAND        | \

/*#define CONFIG_BOOTARGS            "root=ramfs devfs=mount console=ttySA0,9600" */

改为

#define CONFIG_BOOTARGS        "noinitrd root=/dev/nfs rw nfsroot=10.0.0.1:/tmp/nfs ip=10.0.0.110:10.0.0.1:10.0.0.1:255.255.255.0 init=linuxrc console=ttySAC0,115200  mem=64M"

/*#define CONFIG_BOOTCOMMAND        "tftp; bootm" */

改为

#define CONFIG_BOOTCOMMAND        "tftp 0x31000000 uImage;bootm 0x31000000"

再次编辑include/configs/ok2410.h文件:在最后修改11步添加的内容为:

 

/****************** me add begin *******************/

//  #define        CFG_ENV_IS_IN_FLASH        1        /*将该行注释,添加下面一行*/

#define CFG_ENV_IS_IN_NAND  1                /*该行很重要,没有该行,saveenv命令将失效*/

#define CFG_ENV_SIZE        0x10000                /* Total Size of Environment Sector */

#define CFG_NAND_LEGACY 1

#define CFG_ENV_OFFSET  0X20000                /*环境变量在Nand Flash的0x20000处*/

#if (CONFIG_COMMANDS & CFG_CMD_NAND)

#define CFG_NAND_BASE 0x4E000000        /* physical address to access nand at CS0*/

                                                        /* Nand Flash控制器在SFR区起始寄存器地址 */

#define CFG_MAX_NAND_DEVICE 1                /*支持Nand Flash设备的最大个数*/

#define SECTORSIZE 512

#define NAND_SECTOR_SIZE SECTORSIZE

#define NAND_BLOCK_MASK 511

#define ADDR_COLUMN 1

#define ADDR_PAGE 3

#define ADDR_COLUMN_PAGE 4

#define NAND_ChipID_UNKNOWN 0x00        /* 未知芯片的ID号 */

#define NAND_MAX_FLOORS 1

#define NAND_MAX_CHIPS 1                        /* 板子NAND Flash芯片的最大个数 */

/*下面7行是Nand Flash命令层底层接口函数 */

#define WRITE_NAND_COMMAND(d, adr) {rNFCMD = d;}

#define WRITE_NAND_ADDRESS(d, adr) {rNFADDR = d;}

#define WRITE_NAND(d, adr) {rNFDATA = d;}

#define READ_NAND(adr) (rNFDATA)

#define NAND_WAIT_READY(nand) {while(!(rNFSTAT&(1<<0)));}

#define NAND_DISABLE_CE(nand) {rNFCONF |= (1<<11);}

#define NAND_ENABLE_CE(nand) {rNFCONF &= ~(1<<11);}

/* the following functions are NOP's because S3C24X0 handles this in hardware */

#define NAND_CTL_CLRALE(nandptr)

#define NAND_CTL_SETALE(nandptr)

#define NAND_CTL_CLRCLE(nandptr)

#define NAND_CTL_SETCLE(nandptr)

#define CONFIG_MTD_NAND_VERIFY_WRITE 1        /* 允许Nand Flash写校验 */

/*

* Nandflash Boot

*/

#define CONFIG_S3C2410_NAND_BOOT 1

#define STACK_BASE    0x33f00000

#define STACK_SIZE    0x8000

//#define UBOOT_RAM_BASE    0x33f80000

/* NAND Flash Controller */

#define NAND_CTL_BASE            0x4E000000

#define bINT_CTL(Nb)        __REG(INT_CTL_BASE + (Nb))

/* Offset */

#define oNFCONF               0x00

#define oNFCMD                0x04

#define oNFADDR               0x08

#define oNFDATA               0x0c

#define oNFSTAT               0x10

#define oNFECC                0x14

#define rNFCONF (*(volatile unsigned int *)0x4e000000)

#define rNFCMD (*(volatile unsigned char *)0x4e000004)

#define rNFADDR (*(volatile unsigned char *)0x4e000008)

#define rNFDATA (*(volatile unsigned char *)0x4e00000c)

#define rNFSTAT (*(volatile unsigned int *)0x4e000010)

#define rNFECC (*(volatile unsigned int *)0x4e000014)

#define rNFECC0 (*(volatile unsigned char *)0x4e000014)

#define rNFECC1 (*(volatile unsigned char *)0x4e000015)

#define rNFECC2 (*(volatile unsigned char *)0x4e000016)

#endif /* CONFIG_COMMANDS & CFG_CMD_NAND*/

/****************** me add end *******************/

14.编辑board/ok2410/ok2410.c文件

[root@localhost u-boot-1.1.4]# gedit board/ok2410/ok2410.c

在文件尾部添加如下内容:

/****************** me add begin *******************/

#if (CONFIG_COMMANDS & CFG_CMD_NAND)

typedef enum {

         NFCE_LOW,

         NFCE_HIGH

} NFCE_STATE;

 

static inline void NF_Conf(u16 conf)

{

         S3C2410_NAND * const nand = S3C2410_GetBase_NAND();

         nand->NFCONF = conf;

}

 

static inline void NF_Cmd(u8 cmd)

{

         S3C2410_NAND * const nand = S3C2410_GetBase_NAND();

         nand->NFCMD = cmd;

}

 

static inline void NF_CmdW(u8 cmd)

{

         NF_Cmd(cmd);

         udelay(1);

}

 

static inline void NF_Addr(u8 addr)

{

         S3C2410_NAND * const nand = S3C2410_GetBase_NAND();

         nand->NFADDR = addr;

}

 

static inline void NF_SetCE(NFCE_STATE s)

{

         S3C2410_NAND * const nand = S3C2410_GetBase_NAND();

         switch (s) {

                  case NFCE_LOW:

                           nand->NFCONF &= ~(1<<11);

                           break;

                  case NFCE_HIGH:

                           nand->NFCONF |= (1<<11);

                           break;

         }

}

 

static inline void NF_WaitRB(void)

{

         S3C2410_NAND * const nand = S3C2410_GetBase_NAND();

         while (!(nand->NFSTAT & (1<<0)));

}

 

static inline void NF_Write(u8 data)

{

         S3C2410_NAND * const nand = S3C2410_GetBase_NAND();

         nand->NFDATA = data;

}

 

static inline u8 NF_Read(void)

{

         S3C2410_NAND * const nand = S3C2410_GetBase_NAND();

         return(nand->NFDATA);

}

 

static inline void NF_Init_ECC(void)

{

         S3C2410_NAND * const nand = S3C2410_GetBase_NAND();

         nand->NFCONF |= (1<<12);

}

 

static inline u32 NF_Read_ECC(void)

{

         S3C2410_NAND * const nand = S3C2410_GetBase_NAND();

         return(nand->NFECC);

}

 

#endif

/*

* NAND flash initialization.

*/

#if (CONFIG_COMMANDS & CFG_CMD_NAND)

extern ulong nand_probe(ulong physadr);

 

static inline void NF_Reset(void)

{

         int i;

         NF_SetCE(NFCE_LOW);

         NF_Cmd(0xFF); /* reset command */

         for(i = 0; i < 10; i++); /* tWB = 100ns. */

         NF_WaitRB(); /* wait 200~500us; */

         NF_SetCE(NFCE_HIGH);

}

 

static inline void NF_Init(void)

{

#if 0 /* a little bit too optimistic */

#define TACLS 0

#define TWRPH0 3

#define TWRPH1 0

#else

#define TACLS 0

#define TWRPH0 4

#define TWRPH1 2

#endif

 

         NF_Conf((1<<15)|(0<<14)|(0<<13)|(1<<12)|(1<<11)|(TACLS<<8)|(TWRPH0<<4)|(TWRPH1<<0));

/*nand->NFCONF = (1<<15)|(1<<14)|(1<<13)|(1<<12)|(1<<11)|(TACLS<<8)|(TWRPH0<<4)|(TWRPH1<<0); */

/* 1 1 1 1, 1 xxx, r xxx, r xxx */

/* En 512B 4step ECCR nFCE=H tACLS tWRPH0 tWRPH1 */

         NF_Reset();

}

 

void nand_init(void)

{

         S3C2410_NAND * const nand = S3C2410_GetBase_NAND();

         NF_Init();

#ifdef DEBUG

         printf("NAND flash probing at 0x%.8lX\n", (ulong)nand);

#endif

         printf ("%4lu MB\n", nand_probe((ulong)nand) >> 20);

}

#endif

/****************** me add end *******************/

15修改 common/cmd_nand.c文件

[root@localhost u-boot-1.1.4]# gedit common/cmd_nand.c

NanD_ReadBuf函数中的

NanD_Command (nand, NAND_CMD_READ0);行注释掉

16编译、测试

[root@localhost u-boot-1.1.4]# make

[root@localhost u-boot-1.1.4]# ./mknandflashdump u-boot.bin nand.dump 0

[root@localhost u-boot-1.1.4]# skyeye1.2.6

**************************** WARNING **********************************

If you want to run ELF image, you should use -e option to indicate

your elf-format image filename. Or you only want to run binary image,

you need to set the filename of the image and its entry in skyeye.conf.

***********************************************************************

Your elf file is little endian.

arch: arm

cpu info: armv4, arm920t, 41009200, ff00fff0, 2

mach info: name s3c2410x, mach_init addr 0x806bae0

ethmod num=1, mac addr=8:0:3e:26:a:5b, hostip=10.0.0.1

nandflash: dump ./nand.dump

 

Init nandflash dump file.

file size:69206016

finish init nandflash dump

dbct info: turn on dbct!

uart_mod:0, desc_in:, desc_out:, converter:

SKYEYE: use arm920t mmu ops

Loaded RAM   ./u-boot.bin

ERROR: s3c2410x_io_write_word(0x4c000000) = 0x00ffffff

ERROR: s3c2410x_io_write_word(0x4c000008) = 0x00048032

 

U-Boot 1.1.4 (May 03 2009 - 19:19:50)

 

U-Boot code: 33F80000 -> 33F9BFC8  BSS: -> 33FA00A0

RAM Configuration:

Bank #0: 30000000 64 MB

Flash: 512 kB

NAND:  64 MB

*** Warning - bad CRC, using default environment

 

In:    serial

Out:   serial

Err:   serial

Hit any key to stop autoboot:  0

OK2410 #

OK2410 # ?

?       - alias for 'help'

……

mw      - memory write (fill)

nand    - NAND sub-system        //新添加的nand命令,关于该命令的使用,将在后面几小节中介绍

nboot   - boot from NAND device

nfs     - boot image via network using NFS protocol

……

OK2410 #

三部曲的第二步:linux内核的移植

注意:在进行linux内核的移植之前应该现在宿主机上搭建tftp服务器:

1.tftp的配置文件

[root@localhost Desktop]# gedit /etc/xinetd.d/tftp

1        # default: off

 2        # description: The tftp server serves files using t he trivial file transfer \

 3        #        protocol.  The tftp protocol is often used to boot diskless \

 4        #        workstations, download configuration files to network-aware printers, \

 5        #        and to start the installation process for some operating systems.

 6        service tftp

 7        {

 8                socket_type                = dgram

 9                protocol                = udp

10                wait                        = yes

11                user                        = root

12                server                        = /usr/sbin/in.tftpd

13                server_args                = -s /tftpboot

14                disable                = no

15                per_source                = 11

16                cps                        = 100 2

17                flags                        = IPv4

18        }

[root@localhost Desktop]# chmod -R 777 /tftpboot

2.tftp服务器

[root@localhost Desktop]# service xinetd restart

停止 xinetd:                                              [确定]

启动 xinetd:                                              [确定]

 

 

linux内核的移植

1.所需材料:linux-2.6.14.7.tar.bz2

2.解压linux-2.6.14.7.tar.bz2

[root@localhost Desktop]# tar -xjvf linux-2.6.14.7.tar.bz2 -C ./

[root@localhost Desktop]# cd linux-2.6.14.7

 

3.编辑Makefile文件

[root@localhost linux-2.6.14.7]# gedit Makefile

ARCH                ?= $(SUBARCH)

CROSS_COMPILE        ?=

改为

ARCH                ?= arm

CROSS_COMPILE        ?= /usr/local/arm/3.4.1/bin/arm-linux-  //注意:这里的复制必须删除到arm-linux-,不需留空个格,否则会出错:

第4、5、6步是对cs8900网卡的移植

4复制cs8900

[root@localhost linux-2.6.14.7]# cp ../cs8900/cs8900.c drivers/net/arm/

[root@localhost linux-2.6.14.7]# cp ../cs8900/cs8900.h drivers/net/arm/

5修改drivers/net/arm/目录下的Kconfig文件

[root@localhost linux-2.6.14.7]# gedit drivers/net/arm/Kconfig

在最后添加如下内容:

config ARM_CS8900

        tristate "CS8900 support"

        depends on NET_ETHERNET && ARM && ARCH_SMDK2410

        help

          Support for CS8900A chipset based Ethernet cards. If you have a network

          (Ethernet) card of this type, say Y and read the Ethernet-HOWTO, available

          from as well as .To compile this driver as a module, choose M here and read.

          The module will be called cs8900.o.

6.修改drivers/net/arm/目录下的Makefile文件,

[root@localhost linux-2.6.14.7]# gedit drivers/net/arm/Makefile

文件最后添加如下内容:obj-$(CONFIG_ARM_CS8900)        += cs8900.o

7.编辑arch/arm/mach-s3c2410/mach-smdk2410.c文件

[root@localhost linux-2.6.14.7]# gedit arch/arm/mach-s3c2410/mach-smdk2410.c

添加一个头文件

#include

 

static struct map_desc smdk2410_iodesc[] __initdata = {

  /* nothing here yet */

};

改为

static struct map_desc smdk2410_iodesc[] __initdata = {

        /* nothing here yet */

        /* Map the ethernet controller CS8900A */

        { vSMDK2410_ETH_IO, pSMDK2410_ETH_IO, SZ_1M, MT_DEVICE }

};

8.在include/asm-arm/arch-s3c2410/目录下创建smdk2410.h文件

[root@localhost linux-2.6.14.7]# gedit include/asm-arm/arch-s3c2410/smdk2410.h

 内容如下:

#ifndef _INCLUDE_SMDK2410_H_

#define _INCLUDE_SMDK2410_H_

#include

#define pSMDK2410_ETH_IO 0x19000000

#define vSMDK2410_ETH_IO 0xE0000000

#define SMDK2410_ETH_IRQ IRQ_EINT9

#endif // _INCLUDE_SMDK2410_H_

9.设置Flash分区

在此编辑3个文件devs.cmach-smdk2410.cs3c2410.c:

(1)编辑devs.c文件指明分区信息

[root@localhost linux-2.6.14.7]# gedit arch/arm/mach-s3c2410/devs.c

添加如下内容/*nand */

#include

#include

#include

/* NAND Controller */

/************************ 建立Nand Flash分区表 ************************/

/* 一个Nand Flash总共64MB, 按如下大小进行分区 */

/*

name代表分区名字

size代表Flash分区大小单位:字节

offset代表Flash分区的起始地址相对于0x0的偏移

*/

static struct mtd_partition partition_info[] =

{

    { /* 1MB */

        name: "bootloader",

        size: 0x00100000,

        offset: 0x0,

    },

    { /* 3MB */

        name: "kernel",

        size: 0x00300000,

        offset: 0x00100000,

    },

    { /* 40MB */

        name: "root",

        size: 0x02800000,

        offset: 0x00400000,

    },

    { /* 20MB */

        name: "user",

        size: 0x00f00000,

        offset: 0x02d00000,

    }

};

/************************ 加入Nand Flash分区 ************************/

/*

nr_partitions指明partition_info中定义的分区数目

partitions分区信息表

*/

struct s3c2410_nand_set nandset =

{

    nr_partitions: 4,            /* the number of partitions */

    partitions: partition_info,     /* partition table */

};

/************************ 建立Nand Flash芯片支持 ************************/

/*

tacls, twrph0, twrph1的意思见S3C2410手册的63,

这3个值最后会被设置到NFCONF中,见S3C2410手册66.

sets支持的分区集

nr_set分区集的个数

*/

struct s3c2410_platform_nand superlpplatform=

{

    tacls:0,

    twrph0:30,

    twrph1:0,

    sets: &nandset,

    nr_sets: 1,

}; 

// 注意:要将以上的内容添加到arch/arm/mach-s3c2410/devs.c文件的宏定义之后,不可以直接添加到文件的最后否则后面的执行会出现错误  切记切记.....

修改文件中s3c_device_nand结构体变量添加对dev成员的赋值:

struct platform_device s3c_device_nand = {

        .name                  = "s3c2410-nand",                   /* device name */

        .id                  = -1,                                        /* device id */

        .num_resources          = ARRAY_SIZE(s3c_nand_resource),

        .resource          = s3c_nand_resource,                   /* Nand Flash Controller Registers */

        .dev =                                               /* Add the Nand Flash device */

        {

                .platform_data = &superlpplatform

        }

};

(2)编辑mach-smdk2410.c文件指定启动时初始化

[root@localhost linux-2.6.14.7]# gedit arch/arm/mach-s3c2410/mach-smdk2410.c

  修改smdk2410_devices[]指明初始化时包括前面设置的Flash分区信息:

static struct platform_device *smdk2410_devices[] __initdata = {

        &s3c_device_usb,

        &s3c_device_lcd,

        &s3c_device_wdt,

        &s3c_device_i2c,

        &s3c_device_iis,

        /* 添加如下语句 */

        &s3c_device_nand,

}

(3)编辑s3c2410.c文件禁止Flash ECC校验

[root@localhost linux-2.6.14.7]# gedit drivers/mtd/nand/s3c2410.c

      chip->eccmode            = NAND_ECC_SOFT;

改为   chip->eccmode            = NAND_ECC_NONE;

10.配置内核

(1)支持启动时挂载devfs

[root@localhost linux-2.6.14.7]# gedit fs/Kconfig

在语句menu "Pseudo filesystems"后面添加如下语句:

config DEVFS_FS

        bool "/dev file system support (OBSOLETE)"

        default y

config DEVFS_MOUNT

        bool "Automatically mount at boot"

        default y

        depends on DEVFS_FS

2配置内核产生.config文件

[root@localhost linux-2.6.14.7]# make smdk2410_defconfig

[root@localhost linux-2.6.14.7]# make menuconfig

 

 Loadable module support  --->

     [*] Enable loadable module support

 

# 设置内核启动参数

Boot options >

     (root=1f04 mem=32M) Default kernel command string

改为

     noinitrd mem=64M root=/dev/mtdblock2 init=/linuxrc console=ttySAC0,115200

#说明:

# mtdblock2代表第3个Flash分区,是rootfs

# console=ttySAC0,115200使kernel启动期间的信息全部输出到串口0上

# 2.6内核对于串口的命名改为ttySAC0,但这不影响用户空间的串口编程用户空间的串口编程针对的仍是/dev/ttyS0等

 

Floating point emulation  --->

     [*] NWFPE math emulation

     //This is necessary to run most binaries!!!

 

#接下来要做的是对内核MTD子系统的设置

Device Drivers  --->

    Memory Technology Devices (MTD)  --->

         <*> Memory Technology Device (MTD) support

         [*]   MTD partitioning support

         #支持MTD分区,这样我们在前面设置的分区才有意义

         [*]     Command line partition table parsing

         #支持从命令行设置flash分区信息,灵活

         RAM/ROM/Flash chip drivers  --->

            <*> Detect flash chips by Common Flash Interface (CFI) probe

            <*> Detect non-CFI AMD/JEDEC-compatible flash chips

            [ ] Flash chip driver advanced configuration options

            <*> Support for Intel/Sharp flash chips

            <*> Support for AMD/Fujitsu flash chips

            (0)   Retry failed commands (erase/program) (NEW)

            < > Support for ST (Advanced Architecture) flash chips      

            < > Support for RAM chips in bus mapping

            <*> Support for ROM chips in bus mapping

            < > Support for absent chips in bus mapping

            < > XIP aware MTD support

 

         NAND Flash Device Drivers  --->

            <*> NAND Device Support

            <*> NAND Flash support for S3C2410/S3C2440 SoC

 

# 内核支持从Ramdisk启动

Device Drivers  --->

         Block devices  --->

            <*> Loopback device support

            <*> Network block device support

            <*> RAM disk support

            (16)  Default number of RAM disks

            (4096) Default RAM disk size (kbytes)

            [*]   Initial RAM disk (initrd) support

 

# 设置CS8900的支持, 将前面添加的网卡驱动程序,以静态的方式添加到内核中

Device Drivers  --->

         Network device support  --->

            Ethernet (10 or 100Mbit)  --->

                [*] Ethernet (10 or 100Mbit)

                <*>  CS8900 support

 

#接下来要做的是对串口的设置

Device Drivers  --->

      Character devices  --->

         [*] Non-standard serial port support

         [*] S3C2410 RTC Driver

 

#接下来要做的是针对文件系统的设置

File systems  --->

    <*> Second extended fs support

    <*> ROM file system support                                        #支持romfs

    Pseudo filesystems  --->

            [*] /dev file system support (OBSOLETE)

            [*]   Automatically mount at boot (NEW)

            [*] /proc file system support

            [*] Virtual memory file system support (former shm fs)

    Miscellaneous filesystems  --->

        <*> Journalling Flash File System (JFFS) support                #支持JFFS

        (0)   JFFS debugging verbosity (0 = quiet, 3 = noisy) (NEW)

        [*]   JFFS stats available in /proc filesystem

        <*> Journalling Flash File System v2 (JFFS2) support        #支持JFFS2

        (0)   JFFS2 debugging verbosity (0 = quiet, 2 = noisy) (NEW)

        [*]   JFFS2 write-buffering support (NEW)

        [ ]   Advanced compression options for JFFS2 (NEW) 

        <*> Compressed ROM file system support (cramfs)         #支持cramfs

     Network File Systems  --->

        <*> NFS file system support

        [*]   Provide NFSv3 client support

        [*] Root file system on NFS

    <*> YAFFS2 file system support                                        #支持YAFFS2

    ---   512 byte / page devices

    [ ]     Use older-style on-NAND data format with pageStatus byte (NEW)

    [*]       Lets Yaffs do its own ECC (NEW)

    [*]         Use the same ecc byte order as Steven Hill's nand_ecc.c

    ---   2048 byte (or larger) / page devices

    [*]     Autoselect yaffs2 format (NEW)

    [*]     Disable lazy loading (NEW)

    [*]   Turn off wide tnodes (NEW)

      [*]   Force chunk erase check (NEW)

    [*]   Cache short names in RAM (NEW)

注意:<*> YAFFS2 file system support可能不存在原因是:不支持YAFFS2文件系统 ,必须打补丁才能支持. 11.编译内核创建uImageuImage复制到tftp服务器的根目录(/tftpboot/

[root@localhost linux-2.6.14.7]# make

 ……

  LD      vmlinux

  SYSMAP  System.map

  SYSMAP  .tmp_System.map

  OBJCOPY arch/arm/boot/Image

  Kernel: arch/arm/boot/Image is ready

  AS      arch/arm/boot/compressed/head.o

  GZIP    arch/arm/boot/compressed/piggy.gz

  AS      arch/arm/boot/compressed/piggy.o

  CC      arch/arm/boot/compressed/misc.o

  LD      arch/arm/boot/compressed/vmlinux

  OBJCOPY arch/arm/boot/zImage

  Kernel: arch/arm/boot/zImage is ready

[root@localhost linux-2.6.14.7]# cp arch/arm/boot/compressed/vmlinux ../u-boot-1.1.4/tools/

[root@localhost linux-2.6.14.7]# cd ../u-boot-1.1.4/tools/

[root@localhost tools]# ./mkimage -A arm -O linux -T kernel -C none -a 30008000 -e 30008000 -n linux-2.6.14.7 -d vmlinux uImage

Image Name:   linux-2.6.14.7

Created:      Sun May 10 15:16:17 2009

Image Type:   ARM Linux Kernel Image (uncompressed)

Data Size:    1009504 Bytes = 985.84 kB = 0.96 MB

Load Address: 0x30008000

Entry Point:  0x30008000

[root@localhost tools]# cp uImage  ../

[root@localhost tools]# cp initrd.img  ../

[root@localhost tools]# cp uImage /tftpboot/

[root@localhost tools]# cp initrd.img /tftpboot/

[root@localhost tools]# cp ../u-boot.bin /tftpboot/

[root@localhost tools]# cp initrd.img /tmp/nfs/

[root@localhost tools]# iptables -F

[root@localhost tools]# cd ..

12.执行skyeye1.2.6,通过u-boot-1.1.4引导linux-2.6.14.7

[root@localhost u-boot-1.1.4]# skyeye1.2.6

**************************** WARNING **********************************

If you want to run ELF image, you should use -e option to indicate

your elf-format image filename. Or you only want to run binary image,

you need to set the filename of the image and its entry in skyeye.conf.

***********************************************************************

 

Your elf file is little endian.

arch: arm

cpu info: armv4, arm920t, 41009200, ff00fff0, 2

mach info: name s3c2410x, mach_init addr 0x806bae0

ethmod num=1, mac addr=8:0:3e:26:a:5b, hostip=10.0.0.1

nandflash: dump ./nand.dump

file size:69206016

dbct info: turn on dbct!

uart_mod:0, desc_in:, desc_out:, converter:

SKYEYE: use arm920t mmu ops

Loaded RAM   ./u-boot.bin

ERROR: s3c2410x_io_write_word(0x4c000000) = 0x00ffffff

ERROR: s3c2410x_io_write_word(0x4c000008) = 0x00048032

 

U-Boot 1.1.4 (May 11 2009 - 11:46:42)

 

U-Boot code: 33F80000 -> 33F9C20C  BSS: -> 33FA02E8

RAM Configuration:

Bank #0: 30000000 64 MB

Flash: 512 kB

NAND:  64 MB

*** Warning - bad CRC, using default environment

 

In:    serial

Out:   serial

Err:   serial

Hit any key to stop autoboot:  0

OK2410 # printenv

bootargs=noinitrd root=/dev/nfs rw nfsroot=10.0.0.1:/tmp/nfs ip=10.0.0.110:10.0.0.1:10.0.0.1:255.255.255.0 init=linuxrc console=ttySAC0,115200  mem=64M

bootcmd=tftp 0x31000000 uImage;bootm 0x31000000        //要记住该环境变量,后面的实例中会用到

bootdelay=3

baudrate=115200

ipaddr=10.0.0.110

serverip=10.0.0.1

netmask=255.255.255.0

stdin=serial

stdout=serial

stderr=serial

ethaddr=08:00:3E:26:0A:5B

 

Environment size: 341/65532 bytes

OK2410 #

OK2410 # setenv bootargs noinitrd mem=64M root=/dev/mtdblock2 init=/linuxrc console=ttySAC0,115200

OK2410 # tftp 0x31000000 uImage

OK2410 # bootm 31000000

## Booting image at 31000000 ...

   Image Name:   linux-2.6.14.7

   Created:      2009-05-10  14:48:03 UTC

   Image Type:   ARM Linux Kernel Image (uncompressed)

   Data Size:    1009504 Bytes = 985.8 kB

   Load Address: 30008000

   Entry Point:  30008000

   Verifying Checksum ... OK

OK

Starting kernel ...

Uncompressing Linux.................................................................... done, booting the kernel.

 

Error: unrecognized/unsupported machine ID (r1 = 0x00000000).                          //出现错误

Available machine support:

ID (hex)        NAME

000000c1        SMDK2410

Please check your kernel config and/or bootloader.

解决方法:[root@localhost linux-2.6.14.7]# gedit arch/arm/kernel/head.S

 

ENTRY(stext)

        /************ me add begin ************/

        mov r0, #0

        mov r1, #0xc1

        ldr r2, =0x30000100

        /************ me add end ************/

        msr        cpsr_c, #PSR_F_BIT | PSR_I_BIT | MODE_SVC @ ensure svc mode

                                                @ and irqs disabled

        bl        __lookup_processor_type                @ r5=procinfo r9=cpuid

        movs        r10, r5                                @ invalid processor (r5=0)?

        beq        __error_p                                @ yes, error 'p'

        bl        __lookup_machine_type                @ r5=machinfo

        movs        r8, r5                                @ invalid machine (r5=0)?

        beq        __error_a                        @ yes, error 'a'

        bl        __create_page_tables

 

重新进行第11、12步的操作

1)将NAND Flash/dev/mtdblock2)作为根文件系统

[root@localhost u-boot-1.1.4]# skyeye1.2.6

**************************** WARNING **********************************

If you want to run ELF image, you should use -e option to indicate

your elf-format image filename. Or you only want to run binary image,

you need to set the filename of the image and its entry in skyeye.conf.

***********************************************************************

 

Your elf file is little endian.

arch: arm

cpu info: armv4, arm920t, 41009200, ff00fff0, 2

mach info: name s3c2410x, mach_init addr 0x806bae0

ethmod num=1, mac addr=8:0:3e:26:a:5b, hostip=10.0.0.1

nandflash: dump ./nand.dump

file size:69206016

dbct info: turn on dbct!

uart_mod:0, desc_in:, desc_out:, converter:

SKYEYE: use arm920t mmu ops

Loaded RAM   ./u-boot.bin

ERROR: s3c2410x_io_write_word(0x4c000000) = 0x00ffffff

ERROR: s3c2410x_io_write_word(0x4c000008) = 0x00048032

 

U-Boot 1.1.4 (May 11 2009 - 11:46:42)

 

U-Boot code: 33F80000 -> 33F9C20C  BSS: -> 33FA02E8

RAM Configuration:

Bank #0: 30000000 64 MB

Flash: 512 kB

NAND:  64 MB

*** Warning - bad CRC, using default environment

 

In:    serial

Out:   serial

Err:   serial

Hit any key to stop autoboot:  0

OK2410 # printenv

bootargs=noinitrd root=/dev/nfs rw nfsroot=10.0.0.1:/tmp/nfs ip=10.0.0.110:10.0.0.1:10.0.0.1:255.255.255.0 init=linuxrc console=ttySAC0,115200  mem=64M

bootcmd=tftp 0x31000000 uImage;bootm 0x31000000        //要记住该环境变量,后面的实例中会用到

bootdelay=3

baudrate=115200

ipaddr=10.0.0.110

serverip=10.0.0.1

netmask=255.255.255.0

stdin=serial

stdout=serial

stderr=serial

ethaddr=08:00:3E:26:0A:5B

 

Environment size: 341/65532 bytes

OK2410 #

OK2410 # setenv bootargs noinitrd mem=64M root=/dev/mtdblock2 init=/linuxrc console=ttySAC0,115200

OK2410 # tftp 0x31000000 uImage

OK2410 # bootm 31000000

## Booting image at 31000000 ...

   Image Name:   linux-2.6.14.7

   Created:      2009-05-10  14:48:03 UTC

   Image Type:   ARM Linux Kernel Image (uncompressed)

   Data Size:    1009504 Bytes = 985.8 kB

   Load Address: 30008000

   Entry Point:  30008000

   Verifying Checksum ... OK

OK

 

Starting kernel ...

Uncompressing Linux................................................................ done, booting the kernel.

Linux version 2.6.14.7 (root@localhost.localdomain) (gcc version 3.4.1) #1 Sun May 10 15:13:57 CST 2009

CPU: ARM920Tid(wb) [41009200] revision 0 (ARMvundefined/unknown)

Machine: SMDK2410

Warning: bad configuration page, trying to continue

Memory policy: ECC disabled, Data cache writeback

CPU S3C2410 (id 0x32410000)

S3C2410: core 202.800 MHz, memory 101.400 MHz, peripheral 50.700 MHz

S3C2410 Clocks, (c) 2004 Simtec Electronics

CLOCK: Slow mode (1.500 MHz), fast, MPLL on, UPLL on

CPU0: D VIVT write-back cache

CPU0: I cache: 16384 bytes, associativity 64, 32 byte lines, 8 sets

CPU0: D cache: 16384 bytes, associativity 64, 32 byte lines, 8 sets

Built 1 zonelists

Kernel command line: noinitrd mem=64M root=/dev/mtdblock2 init=/linuxrc console=ttySAC0,115200

irq: clearing pending status 00004000

irq: clearing pending status 00008000

irq: clearing pending status 00800000

irq: clearing pending status 10000000

irq: clearing subpending status 00000093

PID hash table entries: 512 (order: 9, 8192 bytes)

timer tcon=00500000, tcnt a509, tcfg 00000200,00000000, usec 00001e4c

Console: colour dummy device 80x30

Dentry cache hash table entries: 16384 (order: 4, 65536 bytes)

Inode-cache hash table entries: 8192 (order: 3, 32768 bytes)

Memory: 64MB = 64MB total

Memory: 62720KB available (1635K code, 321K data, 92K init)

Mount-cache hash table entries: 512

CPU: Testing write buffer coherency: ok

softlockup thread 0 started up.

NET: Registered protocol family 16

S3C2410: Initialising architecture

NetWinder Floating Point Emulator V0.97 (double precision)

devfs: 2004-01-31 Richard Gooch (rgooch@atnf.csiro.au)

devfs: boot_options: 0x1

Console: switching to colour frame buffer device 80x25

fb0: Virtual frame buffer device, using 1024K of video memory

S3C2410 RTC, (c) 2004 Simtec Electronics

s3c2410_serial0 at MMIO 0x50000000 (irq = 70) is a S3C2410

s3c2410_serial1 at MMIO 0x50004000 (irq = 73) is a S3C2410

s3c2410_serial2 at MMIO 0x50008000 (irq = 76) is a S3C2410

io scheduler noop registered

io scheduler anticipatory registered

io scheduler deadline registered

io scheduler cfq registered

RAMDISK driver initialized: 16 RAM disks of 4096K size 1024 blocksize

Cirrus Logic CS8900A driver for Linux (Modified for SMDK2410)

eth0: CS8900A rev D at 0xe0000300 irq=53, no eeprom , addr: 08: 0:3E:26:0A:5B

S3C24XX NAND Driver, (c) 2004 Simtec Electronics

s3c2410-nand: mapped registers at c4980000

s3c2410-nand: timing: Tacls 10ns, Twrph0 30ns, Twrph1 10ns

NAND device: Manufacturer ID: 0xec, Chip ID: 0x76 (Samsung NAND 64MiB 3,3V 8-bit)

NAND_ECC_NONE selected by board driver. This is not recommended !!

Scanning device for bad blocks

Creating 4 MTD partitions on "NAND 64MiB 3,3V 8-bit":

0x00000000-0x00100000 : "bootloader"

0x00100000-0x00400000 : "kernel"

0x00400000-0x02c00000 : "root"

0x02d00000-0x03c00000 : "user"

mice: PS/2 mouse device common for all mice

NET: Registered protocol family 2

IP route cache hash table entries: 1024 (order: 0, 4096 bytes)

TCP established hash table entries: 4096 (order: 2, 16384 bytes)

TCP bind hash table entries: 4096 (order: 2, 16384 bytes)

TCP: Hash tables configured (established 4096 bind 4096)

TCP reno registered

TCP bic registered

NET: Registered protocol family 1

Reading data from NAND FLASH without ECC is not recommended

Reading data from NAND FLASH without ECC is not recommended

Reading data from NAND FLASH without ECC is not recommended

Reading data from NAND FLASH without ECC is not recommended

....................//错误,因为mtdblock2中还没有文件系统

2)通过NFS访问文件系统

[root@localhost u-boot-1.1.4]# skyeye1.2.6

**************************** WARNING **********************************

If you want to run ELF image, you should use -e option to indicate

your elf-format image filename. Or you only want to run binary image,

you need to set the filename of the image and its entry in skyeye.conf.

***********************************************************************

……                     //部分启动信息省略

Hit any key to stop autoboot:  0

OK2410 # tftp 0x31000000 uImage

TFTP from server 10.0.0.1; our IP address is 10.0.0.110

Filename 'uImage'.

Load address: 0x31000000

Loading:

……                     //部分信息省略

done

Bytes transferred = 1009568 (f67a0 hex)

OK2410 # bootm 31000000

……                     //部分信息省略

OK

Starting kernel ...

Uncompressing Linux................................................................ done, booting the kernel.

Linux version 2.6.14.7 (root@localhost.localdomain) (gcc version 3.4.1) #1 Sun May 10 15:13:57 CST 2009

CPU: ARM920Tid(wb) [41009200] revision 0 (ARMvundefined/unknown)

Machine: SMDK2410

……                     //部分信息省略

Kernel command line: noinitrd root=/dev/nfs rw nfsroot=10.0.0.1:/tmp/nfs ip=10.0.0.110:10.0.0.1:10.0.0.1:255.255.255.0 init=linuxrc console=ttySAC0,115200  mem=64M

……                     //部分信息省略

Creating 4 MTD partitions on "NAND 64MiB 3,3V 8-bit":

0x00000000-0x00100000 : "bootloader"

0x00100000-0x00400000 : "kernel"

0x00400000-0x02c00000 : "root"

0x02d00000-0x03c00000 : "user"

……                     //部分信息省略

NET: Registered protocol family 1

IP-Config: Complete:

      device=eth0, addr=10.0.0.110, mask=255.255.255.0, gw=10.0.0.1,

     host=10.0.0.110, domain=, nis-domain=(none),

     bootserver=10.0.0.1, rootserver=10.0.0.1, rootpath=

Looking up port of RPC 100003/2 on 10.0.0.1

Looking up port of RPC 100005/1 on 10.0.0.1

VFS: Mounted root (nfs filesystem).

Mounted devfs on /dev

Freeing init memory: 92K

Failed to execute linuxrc.  Attempting defaults...

Kernel panic - not syncing: No init found.  Try passing init= option to kernel.

//错误,原因可能是NFS文件系统没有准备好,或者是防火墙,

三部曲的第三步: 根文件系统的移植

注意:目标板的跟文件系统是通过nfs远程加载的,因此在根文件系统移植前必须要先搭建nfs服务器:

NFS服务器的搭建

1.查看NFS服务器是否启动

[root@localhost Desktop]# service nfs status   如果是关闭的那麽

2.启动NFS服务器

[root@localhost Desktop]# service nfs start

启动 NFS 服务:                                            [确定]

关掉 NFS 配额:                                            [确定]

启动 NFS 守护进程:                                        [确定]

启动 NFS mountd:                                          [确定]

3.NFS服务器配置文件/etc/exports

[root@localhost Desktop]# gedit /etc/exports

文件内容如下:/tmp/nfs *(rw,sync)

4.创建共享目录

[root@localhost Desktop]# mkdir -p /tmp/nfs/temp

5.使前面设置生效

[root@localhost Desktop]# exportfs -rv

[root@localhost Desktop]# showmount -e                //显示NFS服务器的输出目录列表

[root@localhost Desktop]# showmount -d                //显示NFS服务器中被挂载的共享目录

6.客户端挂载NFS共享目录NFS的IP地址是10.0.0.11

[root@localhost ~]# mount -t nfs 10.0.0.11:/tmp/nfs/ /mnt/tmp/

//注意:在挂载共享目录之前,应该先在u-boot下运行skyeye,并且要注意主机的ip地址;

[root@localhost ~]# touch /mnt/tmp/exam.txt

touch: 无法触碰 “/mnt/tmp/exam.txt”: 权限不够

解决方法:[root@localhost Desktop]# chmod a+w /tmp/nfs/temp

 

 

根文件系统的移植

1.所需材料:busybox-1.13.4.tar.bz2

2.解压busybox-1.13.4.tar.bz2

[root@localhost Desktop]# tar -xjvf busybox-1.13.4.tar.bz2 -C ./

[root@localhost Desktop]# cd busybox-1.13.4

3.编辑Makefile文件

[root@localhost busybox-1.13.4]# gedit Makefile

CROSS_COMPILE ?=

改为

CROSS_COMPILE ?=/usr/local/arm/3.4.1/bin/arm-linux-

 

ARCH ?= $(SUBARCH)

改为

ARCH ?= arm

4.进行默认配置

[root@localhost busybox-1.13.4]# make defconfig       

5.对配置信息进行修改

[root@localhost busybox-1.13.4]# make menuconfig

HOSTLD  scripts/kconfig/mconf

  HOSTCC  scripts/kconfig/lxdialog/checklist.o

  HOSTCC  scripts/kconfig/lxdialog/inputbox.o

  HOSTCC  scripts/kconfig/lxdialog/lxdialog.o

  HOSTCC  scripts/kconfig/lxdialog/menubox.o

  HOSTCC  scripts/kconfig/lxdialog/msgbox.o

  HOSTCC  scripts/kconfig/lxdialog/textbox.o

  HOSTCC  scripts/kconfig/lxdialog/util.o

  HOSTCC  scripts/kconfig/lxdialog/yesno.o

  HOSTLD  scripts/kconfig/lxdialog/lxdialog

scripts/kconfig/mconf Config.in

在TUI界面中进行如下配置

检查Miscellaneous Utilities--->

    taskset 是否去除

同时设置如下:

Busybox Settings --->

        Build Options --->

            [*]Build BusyBox as a static binry (no shared libs)                //选用静态连接

            [*]Build with Large File Support (for accessing files > 2 GB)

            (/usr/local/arm/3.4.1/bin/arm-linux-) Cross Compiler prefix

        Installation Options --->

            [*] Don't use /usr

            (./_install) BusyBox installation prefix                              //安装路径

        Busybox Library Tuning  --->

            (6) Minimum password length

            (2) MD5: Trade Bytes for Speed

            [*] Faster /proc scanning code (+100 bytes)

            [ ] Support for /etc/networks

            [*] Command line editing

            (1024) Maximum length of input

            [*]   vi-style line editing commands

            (15)  History size

            [*]   History saving

            [*]   Tab completion

            [*]     Username completion

            [*]   Fancy shell prompts                //Setting this option allows for prompts to use things like \w and

                                                        //  \$ and escape codes.

            [ ] Give more precise messages when copy fails (cp, mv etc)

            (4) Copy buffer size, in kilobytes

            [ ] Use clock_gettime(CLOCK_MONOTONIC) syscall

            [*] Use ioctl names rather than hex values in error messages

            [*] Support infiniband HW

6.编译

[root@localhost busybox-1.13.4]# make

......

  CC      networking/inetd.o

  CC      networking/interface.o

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')

make[1]: *** [networking/interface.o] 错误 1

make: *** [networking] 错误 2

解决方法:[root@localhost busybox-1.13.4]# gedit networking/interface.c

networking/interface.c文件的818行修改.type = -1

再次编译:[root@localhost busybox-1.13.4]# make

......

  CC      util-linux/volume_id/volume_id.o

  CC      util-linux/volume_id/xfs.o

  AR      util-linux/volume_id/lib.a

  LINK    busybox_unstripped

Trying libraries: crypt m

 Library crypt is not needed, excluding it

 Library m is needed, can't exclude it (yet)

Final link with: m

  DOC     busybox.pod

  DOC     BusyBox.txt

  DOC     BusyBox.1

  DOC     BusyBox.html

[root@localhost busybox-1.13.4]# make install

如果成功,会出现如下信息:

--------------------------------------------------

You will probably need to make your busybox binary

setuid root to ensure all configured applets will

work properly.

--------------------------------------------------

解决办法修改_install/bin/busybox文件的属性

[root@localhost busybox-1.13.4]# chmod 4755 ./_install/bin/busybox

7.对配置信息进行修改

(1)在/tmp/nfs中创建所需的目录

[root@localhost nfs]# mkdir -p bin sbin lib/modules etc/init.d dev usr/bin usr/sbin usr/lib proc sys  home root boot mnt/etc mnt/jffs2 mnt/yaffs mnt/data mnt/temp var/lib var/lock var/log var/run var/tmp tmp

[root@localhost nfs]# chmod 1777 tmp

[root@localhost nfs]# chmod 1777 var/tmp

[root@localhost nfs]# cd dev/

[root@localhost dev]# mknod -m 600 console c 5 1

[root@localhost dev]# mknod -m 666 null c 1 3

2)复制文件到/tmp/nfs中

[root@localhost _install]# cp -a bin /tmp/nfs/

[root@localhost _install]# cp -a sbin /tmp/nfs/

[root@localhost _install]# cp -a linuxrc /tmp/nfs/

[root@localhost _install]# cd ..

[root@localhost busybox-1.13.4]# cp -a examples/bootfloppy/etc/* /tmp/nfs/etc/

8.创建配置文件

1)编写etc/inittab文件、修改其权限

[root@localhost nfs]# gedit etc/inittab

文件内容如下

::sysinit:/etc/init.d/rcS           #指定系统初始化脚本文件

::respawn:-/bin/login            #加上-语句会在登陆终端之后调用/etc/目录下的profile文件

::restart:/sbin/init                        #指定系统重启时执行的初始化程序

 

tty0::respawn:-/bin/login

 

::shutdown:/bin/umount -a -r        #指定关机时执行的操

::shutdown:/sbin/swapoff -a

[root@localhost nfs]# chmod 755 etc/inittab

2)编写etc/init.d/rcS文件、修改其权限

[root@localhost nfs]# gedit etc/init.d/rcS

文件内容如下:#!/bin/sh

# mount all filesystem defined in "fstab"

echo "#mount all......."

/bin/mount -a

/bin/mknod -m 600 /dev/console c 5 1

/bin/mknod -m 666 /dev/null c 1 3

/bin/mknod -m 666 /dev/tty0 c 4 0

/bin/mknod -m 666 /dev/mtdblock0 b 31 0

/bin/mknod -m 666 /dev/mtdblock1 b 31 1

/bin/mknod -m 666 /dev/mtdblock2 b 31 2

/bin/mknod -m 666 /dev/mtdblock3 b 31 3

#/bin/mount -t ext2 /dev/mtdblock3 /mnt/temp/

echo "******************************************************************"

echo "                   OK 2410 Rootfs made by ztg, 2009.05"

echo "******************************************************************"

[root@localhost nfs]# chmod 755 etc/init.d/rcS

3)编写etc/fstab文件、修改其权限

[root@localhost nfs]# gedit etc/fstab

文件内容如下

proc        /proc        proc        defaults        0        0

sysfs        /sys        sysfs        defaults        0        0

none        /tmp        ramfs        defaults        0        0

mdev        /dev        ramfs        defaults        0        0

[root@localhost nfs]# chmod 755 etc/fstab

4)编写etc/proflie文件、修改其权限

[root@localhost nfs]# gedit etc/proflie

文件内容如下

# /etc/profile: system-wide .profile file for the Bourne shells

echo

echo -n "Processing /etc/profile... "

# no-op

# Set search library path

echo "Set search library path in /etc/profile"

export LD_LIBRARY_PATH=/lib:/usr/lib

# Set user path

echo "Set user path in /etc/profile"

export PATH=/bin:/sbin:/usr/bin:/usr/sbin        #设置命令搜索路径

export HISTSIZE=100

export PS1='[\u@\h \W]\$ '

alias ll='ls -l'

#/sbin/ifconfig eth0 192.168.1.22 netmask 255.255.255.0

/sbin/ifconfig lo 127.0.0.1

echo "Configure net done"

echo "All Done"

Echo

5)创建密码文件、修改其权限

[root@localhost nfs]# cp /etc/passwd etc/ ;cp /etc/shadow etc/ ;cp /etc/group etc/

[root@localhost nfs]# chmod 600 etc/shadow

[root@localhost nfs]# gedit etc/passwd

内容是:root:x:0:0:root:/root:/bin/sh

[root@localhost nfs]# gedit etc/shadow

内容是:root:$1$zs2zr2N4$15U99ll5tUm3DwOvKnCVV1:14335:0:99999:7:::

[root@localhost nfs]# gedit etc/group

内容是:root:x:0:root

6)为mdev创建配置文件

[root@localhost nfs]# gedit etc/mdev.conf

内容是:空

7)删除备份文件

[root@localhost nfs]# rm etc/*~ etc/init.d/*

9.复制常用的文件

编写脚本文件copy_lib.sh

[root@localhost nfs]# gedit copy_lib.sh

文件内容如下

#!/bin/bash

#You should put this file cp.sh in /usr/local/arm/3.4.1/arm-linux/lib/

ROOTFS_LIB=/tmp/nfs/lib/

for file in libc libcrypt libdl libm libpthread libresolv libutil

do

cp $file-*.so ${ROOTFS_LIB}

cp -d $file.so.[*0-9] ${ROOTFS_LIB}

done

cp -d ld*.so* ${ROOTFS_LIB}

[root@localhost nfs]# chmod a+x copy_lib.sh

[root@localhost nfs]# cp copy_lib.sh /usr/local/arm/3.4.1/arm-linux/lib/

[root@localhost nfs]# cd /usr/local/arm/3.4.1/arm-linux/lib/

[root@localhost lib]# ./copy_lib.sh

[root@localhost lib]# cd -

 

10.完整的启动过程(u-boot、内核、文件系统)

1)编辑/etc/xinetd.d/tftp文件

[root@localhost Desktop]# gedit /etc/xinetd.d/tftp

tftp文件内容如下

1        # default: off

 2        # description: The tftp server serves files using the trivial file transfer \

 3        #        protocol.  The tftp protocol is often used to boot diskless \

 4        #        workstations, download configuration files to network-aware printers, \

 5        #        and to start the installation process for some operating systems.

 6        service tftp

 7        {

 8                socket_type                = dgram

 9                protocol                = udp

10                wait                        = yes

11                user                        = root

12                server                        = /usr/sbin/in.tftpd

13                server_args                = -s /tftpboot

14                disable                = no

15                per_source                = 11

16                cps                        = 100 2

17                flags                        = IPv4

18        }

2)重启tftp服务器

[root@localhost Desktop]# service xinetd restart

3)编辑/etc/exports文件

[root@localhost Desktop]# gedit /etc/exports

exports文件内容如下:

/tmp/nfs *(rw,sync,no_root_squash)

(4)重启NFS服务器

[root@localhost u-boot-1.1.4]# service nfs restart

关闭 NFS mountd:                                          [确定]

关闭 NFS 守护进程:                                        [确定]

关闭 NFS quotas:                                         [确定]

关闭 NFS 服务:                                            [确定]

启动 NFS 服务:                                            [确定]

关掉 NFS 配额:                                            [确定]

启动 NFS 守护进程:                                        [确定]

启动 NFS mountd:                                          [确定]

[root@localhost u-boot-1.1.4]# exportfs   

/tmp/nfs       

[root@localhost u-boot-1.1.4]# exportfs -ra                //重新扫描配置文件

5)完整的启动过程(u-boot、内核、文件系统、用户程序),使用NFS文件系统

[root@localhost u-boot-1.1.4]# skyeye1.2.6

**************************** WARNING **********************************

If you want to run ELF image, you should use -e option to indicate

your elf-format image filename. Or you only want to run binary image,

you need to set the filename of the image and its entry in skyeye.conf.

***********************************************************************

……                     //部分启动信息省略

Hit any key to stop autoboot:  0

OK2410 # run bootcmd

TFTP from server 10.0.0.1; our IP address is 10.0.0.110

Filename 'uImage'.

Load address: 0x31000000

Loading: checksum bad  

//注意:如果到这里老是出现大写的T T T T T T 表明tftp没有搭建好,此时可以重新搭建一下tftp服务器,如果还出现错误,这时候可能是防火墙的原因,可以执行 iptables -F 关闭防火墙。

checksum bad

#################################################################

         #################################################################

         #################################################################

         ################################

done

Bytes transferred = 1161416 (11b8c8 hex)

## Booting image at 31000000 ...

   Image Name:   linux-2.6.14.7

   Created:      2009-05-24  11:22:39 UTC

   Image Type:   ARM Linux Kernel Image (uncompressed)

   Data Size:    1161352 Bytes =  1.1 MB

   Load Address: 30008000

   Entry Point:  30008000

   Verifying Checksum ... OK

OK

 

Starting kernel ...

 

Uncompressing Linux.......................................................................... done, booting the kernel.

Linux version 2.6.14.7 (root@localhost.localdomain) (gcc version 3.4.1) #6 Sun May 24 19:22:08 CST 2009

CPU: ARM920Tid(wb) [41009200] revision 0 (ARMvundefined/unknown)

Machine: SMDK2410

Memory policy: ECC disabled, Data cache writeback

CPU S3C2410 (id 0x32410000)

S3C2410: core 202.800 MHz, memory 101.400 MHz, peripheral 50.700 MHz

S3C2410 Clocks, (c) 2004 Simtec Electronics

CLOCK: Slow mode (1.500 MHz), fast, MPLL on, UPLL on

CPU0: D VIVT write-back cache

CPU0: I cache: 16384 bytes, associativity 64, 32 byte lines, 8 sets

CPU0: D cache: 16384 bytes, associativity 64, 32 byte lines, 8 sets

Built 1 zonelists

Kernel command line: noinitrd root=/dev/nfs rw nfsroot=10.0.0.1:/tmp/nfs ip=10.0.0.110:10.0.0.1:10.0.0.1:255.255.255.0 init=linuxrc console=ttySAC0,115200  mem=64M

……                     //部分启动信息省略

Memory: 64MB = 64MB total

Memory: 62464KB available (1888K code, 393K data, 92K init)

……                     //部分启动信息省略

JFFS version 1.0, (C) 1999, 2000  Axis Communications AB

JFFS2 version 2.2. (NAND) (C) 2001-2003 Red Hat, Inc.

yaffs May 24 2009 19:21:42 Installing.

Console: switching to colour frame buffer device 80x25

fb0: Virtual frame buffer device, using 1024K of video memory

……                     //部分启动信息省略

RAMDISK driver initialized: 16 RAM disks of 4096K size 1024 blocksize

Cirrus Logic CS8900A driver for Linux (Modified for SMDK2410)

eth0: CS8900A rev D at 0xe0000300 irq=53, no eeprom , addr: 08: 0:3E:26:0A:5B

S3C24XX NAND Driver, (c) 2004 Simtec Electronics

s3c2410-nand: mapped registers at c4980000

s3c2410-nand: timing: Tacls 10ns, Twrph0 30ns, Twrph1 10ns

NAND device: Manufacturer ID: 0xec, Chip ID: 0x76 (Samsung NAND 64MiB 3,3V 8-bit)

NAND_ECC_NONE selected by board driver. This is not recommended !!

Scanning device for bad blocks

Bad eraseblock 7 at 0x0001c000

Creating 4 MTD partitions on "NAND 64MiB 3,3V 8-bit":

0x00000000-0x00100000 : "bootloader"

0x00100000-0x00400000 : "kernel"

0x00400000-0x02c00000 : "root"

0x02d00000-0x03c00000 : "user"

mice: PS/2 mouse device common for all mice

NET: Registered protocol family 2

……                     //部分启动信息省略

IP-Config: Complete:

      device=eth0, addr=10.0.0.110, mask=255.255.255.0, gw=10.0.0.1,

     host=10.0.0.110, domain=, nis-domain=(none),

     bootserver=10.0.0.1, rootserver=10.0.0.1, rootpath=

Looking up port of RPC 100003/2 on 10.0.0.1

Looking up port of RPC 100005/1 on 10.0.0.1

VFS: Mounted root (nfs filesystem).

Mounted devfs on /dev

//注意:如果到这里出现mount_devfs_fs(): unable to mount devfs, err: -2错误信息,表示不支持nfs文件系统,此时应该搭建nfs服务器解决。

 

Freeing init memory: 92K

#mount all.......

******************************************************************

                   OK 2410 Rootfs made by ztg, 2009.05

******************************************************************

ztg login: root

如果此时示输入密码,那麽可以执行:[root@localhost nfs]# gedit etc/passwd

内容是:root:x:0:0:root:/root:/bin/sh   把x删除掉即可

ztg login: root

login[25]: root login on 'console'

 

Processing /etc/profile... Set search library path in /etc/profile

Set user path in /etc/profile

Configure net done

All Done

[root@10 root]#

 

6)完整的启动过程(u-boot、内核、文件系统),使用/dev/mtdblock2中的文件系统

创建cramfs文件系统

[root@localhost tmp]# mkfs.cramfs nfs ok2410.cramfs

② 复制ok2410.cramfs到tftp服务器根目录

[root@localhost tmp]# cp ok2410.cramfs /tftpboot/

③ 执行skyeye1.2.6,启动系统

[root@localhost u-boot-1.1.4]# skyeye1.2.6

 

**************************** WARNING **********************************

If you want to run ELF image, you should use -e option to indicate

your elf-format image filename. Or you only want to run binary image,

you need to set the filename of the image and its entry in skyeye.conf.

***********************************************************************

……                     //部分启动信息省略

Hit any key to stop autoboot:  0

OK2410 # tftp 0x31000000 ok2410.cramfs

TFTP from server 10.0.0.1; our IP address is 10.0.0.110

Filename 'ok2410.cramfs'.

Load address: 0x31000000

Loading: checksum bad

############checksum bad

#####################################################

         #################################################################

         #################################################################

         #################################################################

         #################################################################

         #################################################################

         #######################################

done

Bytes transferred = 2195456 (218000 hex)

OK2410 # nand erase 400000 300000

 

NAND erase: device 0 offset 4194304, size 3145728 ... OK

OK2410 # nand write 31000000 400000 0x218000

 

NAND write: device 0 offset 4194304, size 2195456 ...  2195456 bytes written: OK

OK2410 # setenv bootargs noinitrd mem=64M root=/dev/mtdblock2 init=/linuxrc console=ttySAC0,115200

OK2410 # run bootcmd

……               //启动信息省略

 

尾声序:nfs是Ram上的文件系统,必须通过借用tftp和nfs服务器进行远程挂载,属于内核文件系统,他的使用分为服务器端和客户端:服务器端提供要共享的文件,客户端通过挂载来实现对共享文件的访问;

jffs/jffs2是开源的日志文件系统,最适合在Flash芯片上使用,因此他们存在于nand flash,相当于硬盘文件系统,可以自行加载到内核,无须借助载体;

建立jffs2文件系统:

1.所需要的资料:mtd-snapshot-20050519.tar.bz2

2.解压、编译、安装MTD工具包

[root@localhost Desktop]# tar -xjvf mtd-snapshot-20050519.tar.bz2 -C ./

[root@localhost Desktop]# cd mtd/util

[root@localhost util]# make

[root@localhost util]# cp mkfs.jffs /bin/                       

[root@localhost util]# cp mkfs.jffs2 /bin/       

3.制作jffs2文件系统

[root@localhost tftpboot]# mkfs.jffs2 -r /tmp/nfs -o rootfs.jffs2 -e 0x4000 --pad=0x800000 -n

4.下载、烧写、挂载jffs2根文件系统

[root@localhost u-boot-1.1.4]# iptables -F

[root@localhost u-boot-1.1.4]# skyeye1.2.6

 

**************************** WARNING **********************************

If you want to run ELF image, you should use -e option to indicate

your elf-format image filename. Or you only want to run binary image,

you need to set the filename of the image and its entry in skyeye.conf.

***********************************************************************

 

Your elf file is little endian.

arch: arm

cpu info: armv4, arm920t, 41009200, ff00fff0, 2

mach info: name s3c2410x, mach_init addr 0x806bae0

ethmod num=1, mac addr=8:0:3e:26:a:5b, hostip=10.0.0.1

nandflash: dump ./nand.dump

file size:69206016

dbct info: turn on dbct!

uart_mod:0, desc_in:, desc_out:, converter:

SKYEYE: use arm920t mmu ops

Loaded RAM   ./u-boot.bin

 

U-Boot 1.1.4 (May 24 2009 - 11:07:49)

 

U-Boot code: 33F80000 -> 33F9C304  BSS: -> 33FA03E0

RAM Configuration:

Bank #0: 30000000 64 MB

Flash: 512 kB

NAND:  64 MB

*** Warning - bad CRC or NAND, using default environment

 

In:    serial

Out:   serial

Err:   serial

Hit any key to stop autoboot:  0

OK2410 # tftp 0x31000000 rootfs.jffs2    //将根文件系统映像文件下载到开发板中内存的0x31000000地址处

TFTP from server 10.0.0.1; our IP address is 10.0.0.110

Filename 'rootfs.jffs2'.

Load address: 0x31000000

Loading: checksum bad

checksum bad

#################################################################

         #################################################################

         ##############

done

Bytes transferred = 8388608 (800000 hex)

OK2410 # nand erase 2d00000 800000   //擦写,2d000000是MTD第4个分区的起始地址,80000000(8MB)表示大小

 

NAND erase: device 0 offset 47185920, size 8388608 ... OK

OK2410 # nand write 31000000 2d00000 0x800000; setenv bootargs noinitrd mem=64M root=/dev/mtdblock3 rootfstype=jffs2 rw init=/linuxrc console=ttySAC0,115200; run bootcmd

//上面两行共3条命令,由分号隔开。nand write命令将rootfs.jffs2烧写到NAND Flash的第4个分区;setenv命令设置内核启动参数,注意root=/dev/mtdblock3,表示Linux内核将挂载NAND Flash的第4个分区中的文件系统;第3条命令中的bootcmd=tftp 0x31000000 uImage;bootm 0x31000000表示先执行tftp 0x31000000 uImage命令,将内核映像下载到开发板中内存的0x31000000地址处,然后执行bootm 0x31000000命令启动内核。

 

//注意:对NAND Flash烧写(nand write)之前,一定要先擦写(nand erase

 

NAND write: device 0 offset 47185920, size 8388608 ...  8388608 bytes written: OK

TFTP from server 10.0.0.1; our IP address is 10.0.0.110

Filename 'uImage'.

Load address: 0x31000000

Loading: #################################################################

         ################################

done

Bytes transferred = 1161416 (11b8c8 hex)

## Booting image at 31000000 ...

   Image Name:   linux-2.6.14.7

   Created:      2009-05-24  11:22:39 UTC

   Image Type:   ARM Linux Kernel Image (uncompressed)

   Data Size:    1161352 Bytes =  1.1 MB

   Load Address: 30008000

   Entry Point:  30008000

   Verifying Checksum ... OK

OK

 

Starting kernel ...

 

Uncompressing Linux.......................................................................... done, booting the kernel.

Linux version 2.6.14.7 (root@localhost.localdomain) (gcc version 3.4.1) #6 Sun May 24 19:22:08 CST 2009

CPU: ARM920Tid(wb) [41009200] revision 0 (ARMvundefined/unknown)

Machine: SMDK2410

Memory policy: ECC disabled, Data cache writeback

CPU S3C2410 (id 0x32410000)

S3C2410: core 202.800 MHz, memory 101.400 MHz, peripheral 50.700 MHz

S3C2410 Clocks, (c) 2004 Simtec Electronics

CLOCK: Slow mode (1.500 MHz), fast, MPLL on, UPLL on

CPU0: D VIVT write-back cache

CPU0: I cache: 16384 bytes, associativity 64, 32 byte lines, 8 sets

CPU0: D cache: 16384 bytes, associativity 64, 32 byte lines, 8 sets

Built 1 zonelists

Kernel command line: noinitrd mem=64M root=/dev/mtdblock3 rootfstype=jffs2 rw init=/linuxrc console=ttySAC0,115200

……                     //部分启动信息省略

Memory: 64MB = 64MB total

Memory: 62464KB available (1888K code, 393K data, 92K init)

Mount-cache hash table entries: 512

CPU: Testing write buffer coherency: ok

softlockup thread 0 started up.

NET: Registered protocol family 16

S3C2410: Initialising architecture

NetWinder Floating Point Emulator V0.97 (double precision)

devfs: 2004-01-31 Richard Gooch (rgooch@atnf.csiro.au)

devfs: boot_options: 0x1

JFFS version 1.0, (C) 1999, 2000  Axis Communications AB

JFFS2 version 2.2. (NAND) (C) 2001-2003 Red Hat, Inc.

yaffs May 24 2009 19:21:42 Installing.

Console: switching to colour frame buffer device 80x25

……                     //部分启动信息省略

RAMDISK driver initialized: 16 RAM disks of 4096K size 1024 blocksize

Cirrus Logic CS8900A driver for Linux (Modified for SMDK2410)

eth0: CS8900A rev D at 0xe0000300 irq=53, no eeprom , addr: 08: 0:3E:26:0A:5B

S3C24XX NAND Driver, (c) 2004 Simtec Electronics

s3c2410-nand: mapped registers at c4980000

s3c2410-nand: timing: Tacls 10ns, Twrph0 30ns, Twrph1 10ns

NAND device: Manufacturer ID: 0xec, Chip ID: 0x76 (Samsung NAND 64MiB 3,3V 8-bit)

NAND_ECC_NONE selected by board driver. This is not recommended !!

Scanning device for bad blocks

Bad eraseblock 7 at 0x0001c000

Creating 4 MTD partitions on "NAND 64MiB 3,3V 8-bit":

0x00000000-0x00100000 : "bootloader"

0x00100000-0x00400000 : "kernel"

0x00400000-0x02c00000 : "root"

0x02d00000-0x03c00000 : "user"

……                     //部分启动信息省略

VFS: Mounted root (jffs2 filesystem).                   //挂载根文件系统

Mounted devfs on /dev

Freeing init memory: 92K

#mount all.......

******************************************************************

                   OK 2410 Rootfs made by ztg, 2009.05

******************************************************************

(none) login: root

Processing /etc/profile... Set search library path in /etc/profile

Set user path in /etc/profile

Configure net done

All Done

[root@(none) /root]#

 

 

 

 

 http://blog.chinaunix.net/space.php?uid=14735472&do=blog&id=110947

 

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