嵌入式系统移植三部曲 李炎朔
来源:互联网 发布:通达oa办公软件 编辑:程序博客网 时间:2024/06/03 22:56
嵌入式系统移植三部曲
李炎朔 09机应一班 学号0906041053
三部曲《bootloader的移植》《linux的移植》《根文件系统的移植》
一 bootloader的移植
(1)安装skyeye-1.2.6_rc1
[root@localhost Desktop]# tar -xjvf skyeye-1.2.6_rc1.tar.bz2 -C ./
[root@localhost Desktop]# cd skyeye-1.2.6_rc1
[root@localhost skyeye-1.2.6_rc1]# ls
/*
aclocal.m4 ChangeLog configure depcomp LICENSE misc REPORTING-BUGS
arch config.guess configure.in device MAINTAINERS missing TODO
AUTHORS config.h.in COPYING INSTALL Makefile.am NEWS utils
autom4te.cache config.sub dbct install-sh Makefile.in README
*/
[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 //将skyeye安装到/usr/local/bin/
[root@localhost skyeye-1.2.6_rc1]# ll /usr/local/bin/skyeye
// -rwxr-xr-x 1 root root 2544308 05-17 17:59 /usr/local/bin/skyeye
[root@localhost skyeye-1.2.6_rc1]# mv /usr/local/bin/skyeye /usr/local/bin/skyeye1.2.6 //改名
(2)创建交叉编译环境
[root@localhost Desktop]# tar -xjvf arm-linux-gcc2.95.3.tar.bz2 -C ./ //交叉编译器:arm-linux-gcc2.95.3
(3)bootloader移植
[root@localhost Desktop]# tar -xjvf u-boot-1.1.4.tar.bz2 -C ./ //Bootloader:u-boot-1.1.4
[root@localhost Desktop]# cd u-boot-1.1.4
[root@localhost u-boot-1.1.4]# gedit Makefile //编辑u-boot根目录中的Makefile文件
/*
将
ifeq ($(ARCH),arm)
CROSS_COMPILE = arm-linux-
endif
改为
ifeq ($(ARCH),arm)
CROSS_COMPILE=/usr/local/arm/2.95.3/bin/arm-linux-
endif
在
smdk2410_config : unconfig
@./mkconfig $(@:_config=) arm arm920t smdk2410 NULL s3c24x0
后面添加
ok2410_config : unconfig
@./mkconfig $(@:_config=) arm arm920t ok2410 NULL s3c24x0
*/
[root@localhost u-boot-1.1.4]# mkdir board/ok2410 //创建ok2410移植目录
[root@localhost u-boot-1.1.4]# cp board/smdk2410/* board/ok2410/ //复制必要的文件 */
[root@localhost u-boot-1.1.4]# dir board/ok2410/
// config.mk flash.c lowlevel_init.S Makefile smdk2410.c u-boot.lds
[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 //编辑ok2410.h头文件
/*
将
#define CFG_PROMPT "SMDK2410 # " /* Monitor Command Prompt */
改为
#define CFG_PROMPT "OK2410 # " /* Monitor Command Prompt */
*/
[root@localhost u-boot-1.1.4]# gedit board/ok2410/Makefile
/*
将
OBJS := smdk2410.o flash.o
改为
OBJS := ok2410.o flash.o
*/
[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
*/
//又出现错误了 不怕 修改examples目录下的Makefile文件就解决啦
[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
*/ //第一小步成功了...
[root@localhost u-boot-1.1.4]# ll u-boot*
/*
-rwxr-xr-x 1 root root 396429 05-03 18:32 u-boot
-rwxr-xr-x 1 root root 100156 05-03 18:32 u-boot.bin
-rw-r--r-- 1 root root 48690 05-03 18:32 u-boot.map
-rwxr-xr-x 1 root root 300538 05-03 18:32 u-boot.srec
*/
[root@localhost u-boot-1.1.4]# gedit skyeye.conf //编辑skyeye的配置文件 里面空白 添加如下内容(注释里面的)
/*
# 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
*/
[root@localhost u-boot-1.1.4]# skyeye1.2.6 //执行skyeye
/*
**************************** 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 #
*/ //出现提示符OK2410 # 执行成功 可以输入"?"查看帮助
//开始移植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 */
替换成:
//#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
//以上将从NOR Flash启动改成从NAND Flash启动
[root@localhost u-boot-1.1.4]# gedit board/ok2410/Makefile //修改board/ok2410/Makefile
/*
将
OBJS := ok2410.o flash.o
改为
OBJS := ok2410.o flash.o nand_read.o
*/
[root@localhost u-boot-1.1.4]# gedit board/ok2410/nand_read.c //创建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;
}
[root@localhost u-boot-1.1.4]# gedit include/configs/ok2410.h //编辑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 *******************/
[root@localhost u-boot-1.1.4]# make
[root@localhost u-boot-1.1.4]# skyeye1.2.6 //再次执行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 //这个命令需要从网上下载 复制到/bin/下即可
// finish
[root@localhost u-boot-1.1.4]# ll nand.dump
// -rw-r--r-- 1 root root 118272 05-10 22:29 nand.dump
[root@localhost u-boot-1.1.4]# skyeye1.2.6 //再次执行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添加nand指令的支持
[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 *************************************/
为了能使U-BOOT正确引导Linux内核,必须传递合适的参数给内核。引导内核时可以将bootargs传递给内核。bootargs是指ok2410.h文件中的CONFIG_BOOTARGS宏
将
/*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"
[root@localhost u-boot-1.1.4]# gedit include/configs/ok2410.h
将原来的me add begin与me add end之间的内容替换成以下内容
/****************** 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下载linux-2.6.14.7.tar.bz2 /* 板子上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 *******************/
[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 *******************/
[root@localhost u-boot-1.1.4]# gedit common/cmd_nand.c
将NanD_ReadBuf函数中的
NanD_Command (nand, NAND_CMD_READ0);
改为
//NanD_Command (nand, NAND_CMD_READ0);
[root@localhost u-boot-1.1.4]# make
[root@localhost u-boot-1.1.4]# ./mknandflashdump u-boot.bin nand.dump 0 //也需将此命令复制到u-boot下
[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 //注意这行 出现了对nand的支持
*** 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 #
到此对bootloader的移植已经完毕
二 Linux的移植
//下载linux-2.6.14.7.tar.bz2 交叉编译环境arm-linux-gcc-3.4.1和cs8900网卡到桌面
[root@localhost Desktop]# tar -xjvf arm-linux-gcc-3.4.1.tar.bz2 -C ./
[root@localhost Desktop]# tar -xjvf linux-2.6.14.7.tar.bz2 -C ./
[root@localhost Desktop]# tar -xjvf cs8900.tar.gz -C ./
[root@localhost Desktop]# cd linux-2.6.14.7
[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- // linux2.6.14的交叉编译器为gcc-3.4.1
//将321-329行改为如下 否则将出现找不到编译器的错误
AS = /usr/local/arm/3.4.1/bin/arm-linux-as
LD = /usr/local/arm/3.4.1/bin/arm-linux-ld
CC = /usr/local/arm/3.4.1/bin/arm-linux-gcc
CPP = $(CC) -E
AR = /usr/local/arm/3.4.1/bin/arm-linux-ar
NM = /usr/local/arm/3.4.1/bin/arm-linux-nm
STRIP = /usr/local/arm/3.4.1/bin/arm-linux-strip
OBJCOPY = /usr/local/arm/3.4.1/bin/arm-linux-objcopy
OBJDUMP = /usr/local/arm/3.4.1/bin/arm-linux-objdump
*/
[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/ //移植网卡
[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.
[root@localhost linux-2.6.14.7]# gedit drivers/net/arm/Makefile
在文件最后添加如下内容:
o bj-$(CONFIG_ARM_CS8900) += cs8900.o
[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 }
};
[root@localhost linux-2.6.14.7]# gedit include/asm-arm/arch-s3c2410/smdk2410.h //创建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_
[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,
};
另外,还要修改该文件中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
}
};
[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,
};
[root@localhost linux-2.6.14.7]# gedit drivers/mtd/nand/s3c2410.c
在s3c2410_nand_init_chip()函数中。
将
chip->eccmode = NAND_ECC_SOFT;
改为
chip->eccmode = NAND_ECC_NONE;
[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
[root@localhost linux-2.6.14.7]# cp arch/arm/configs/smdk2410_defconfig .config
[root@localhost linux-2.6.14.7]# make smdk2410_defconfig
[root@localhost linux-2.6.14.7]# make menuconfig //开始配置内核
//在弹出的TUI界面中,进行如下的配置(在smdk2410_defconfig的基础上)。
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)
//保存退出,产生.config文件
[root@localhost linux-2.6.14.7]# make
[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 ..
[root@localhost u-boot-1.1.4]# skyeye1.2.6
//出现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.
//出现如上错误 修改内核的arch/arm/kernel/head.S 即可解决
[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
[root@localhost linux-2.6.14.7]# make
[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
[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 ..
[root@localhost u-boot-1.1.4]# skyeye1.2.6
//将NAND Flash(/dev/mtdblock2)作为根文件系统
**************************** 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 # 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
Kernel panic - not syncing: VFS: Unable to mount root fs on unknown-block(31,2)
//错误,因为mtdblock2中还没有文件系统,该问题将在第三部曲中解决
//通过NFS访问文件系统
**************************** 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文件系统没有准备好,或者是防火墙,该问题将在第三部曲中解决
三 根文件系统的移植
//首先建立YAFFS2根文件
//由于linux-2.6.14.7内核中没有yaffs2的相关代码,因此,要向内核添加支持yaffs2文件系统的源代码
//下载yaffs2文件系统源代码—yaffs2.tar.gz
[root@localhost Desktop]# tar -xzvf yaffs2.tar.gz -C ./
[root@localhost Desktop]# cp -av yaffs2 linux-2.6.14.7/fs/
[root@localhost linux-2.6.14.7]# cp fs/yaffs2/Makefile.kernel fs/yaffs2/Makefile
root@localhost linux-2.6.14.7]# gedit fs/Kconfig
在最后一行(endmenu)的前面添加如下一行。
source "fs/yaffs2/Kconfig"
[root@localhost linux-2.6.14.7]# gedit fs/Makefile
在文件的最后添加如下一行。
obj-$(CONFIG_YAFFS_FS) +=yaffs2/
[root@localhost linux-2.6.14.7]# make menuconfig
File systems --->
<*> YAFFS2 file system support
--- 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)
[root@localhost linux-2.6.14.7]# make //至此,支持yaffs2文件系统的Linux内核映像(vmlinux)已经生成
[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 24 12:10:15 2009
Image Type: ARM Linux Kernel Image (uncompressed)
Data Size: 1126256 Bytes = 1099.86 kB = 1.07 MB
Load Address: 0x30008000
Entry Point: 0x30008000
[root@localhost tools]# cp uImage /tftpboot/ //将制作好的Linux内核映像(uImage)复制到tftp服务器根目录(/tftpboot)中。这样,可以通过tftp协议将其下载的目标板中
[root@localhost tools]#cd /root/Desktop/yaffs2/utils
[root@localhost utils]# ll
-rw-r--r-- 1 root root 1739 2007-03-07 Makefile
-rw-r--r-- 1 root root 13689 2007-02-14 mkyaffs2image.c
-rw-r--r-- 1 root root 14968 2007-02-14 mkyaffsimage.c
[root@localhost utils]# make //编译
[root@localhost utils]# ll mkyaffs* //列出生成的工具
-rwxr-xr-x 1 root root 14270 05-24 12:15 mkyaffs2image
-rwxr-xr-x 1 root root 13480 05-24 12:15 mkyaffsimage
[root@localhost utils]# cp mkyaffs2image /bin/ //复制到命令搜索路径中
[root@localhost utils]# cp mkyaffsimage /bin/
[root@localhost utils]#cd /tmp/[root@localhost tmp]# mkyaffsimage nfs rootfs.yaffs
[root@localhost tmp]# mkyaffs2image nfs rootfs.yaffs2
[root@localhost tmp]# ll rootfs.yaffs*
-rw-rw-rw- 1 root root 4532880 05-24 18:35 rootfs.yaffs
-rw-rw-rw- 1 root root 5121600 05-24 18:34 rootfs.yaffs2
[root@localhost tmp]# cp rootfs.yaffs* /tftpboot/
[root@localhost tmp]# chmod 666 /tftpboot/rootfs.yaffs* //将yaffs文件系统映像复制到/tftpboot目录
//下载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
[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
*/
[root@localhost busybox-1.13.4]# make defconfig //恢复默认配置
[root@localhost busybox-1.13.4]# make menuconfig
在弹出的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
//设置完毕后,保存、退出。
[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
//编译出错,此时需要编辑networking/interface.c文件
[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 //修改busybox属性
[root@localhost busybox-1.13.4]# cd /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
//注意:其中bin、dev、etc、lib、proc、sbin、sys、usr是必备的8个目录
[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
[root@localhost dev]# cd /root/Desktop/busybox-1.13.4/_install
[root@localhost _install]# cp -a bin /tmp/nfs/
[root@localhost _install]# cp -a sbin /tmp/nfs/
[root@localhost _install]# ll linuxrc
lrwxrwxrwx 1 root root 11 05-11 17:41 linuxrc -> bin/busybox
[root@localhost _install]# cp -a linuxrc /tmp/nfs/
[root@localhost _install]# ll /tmp/nfs/linuxrc
lrwxrwxrwx 1 root root 11 05-11 17:43 /tmp/nfs/linuxrc -> bin/busybox
[root@localhost _install]# cd /root/Desktop/busybox-1.13.4
[root@localhost busybox-1.13.4]# cp -a examples/bootfloppy/etc/* /tmp/nfs/etc/ */
[root@localhost busybox-1.13.4]# ls /tmp/nfs/etc/
fstab init.d inittab profile
[root@localhost busybox-1.13.4]# cd /tmp/nfs
[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]# ll etc/inittab
-rw-r--r-- 1 root root 309 05-11 18:28 etc/inittab
[root@localhost nfs]# chmod 755 etc/inittab
[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 liyanshuo, 2009.05"
echo "******************************************************************"
[root@localhost nfs]# ll etc/init.d/rcS
-rw-r--r-- 1 root root 92 05-11 18:27 etc/init.d/rcS
[root@localhost nfs]# chmod 755 etc/init.d/rcS
[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]# ll etc/fstab
-rw-r--r-- 1 root root 59 05-11 18:30 etc/fstab
[root@localhost nfs]# chmod 755 etc/fstab
[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
[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 //将此句中的x删除即可删除引导密码
[root@localhost nfs]# gedit etc/shadow
内容是:root:$1$zs2zr2N4$15U99ll5tUm3DwOvKnCVV1:14335:0:99999:7:::
[root@localhost nfs]# gedit etc/group
内容是:root:x:0:root
[root@localhost nfs]# gedit etc/mdev.conf //为mdev创建配置文件
内容是:空
[root@localhost nfs]# ll etc/
总计 60
-rwxr-xr-x 1 root root 117 05-11 19:28 fstab
-rw-r--r-- 1 root root 14 05-11 20:09 group
drwxr-xr-x 2 root root 4096 05-11 20:04 init.d
-rwxr-xr-x 1 root root 184 05-11 19:33 inittab
-rw-r--r-- 1 root root 0 05-11 20:09 mdev.conf
-rw-r--r-- 1 root root 30 05-11 20:07 passwd
-rwxr-xr-x 1 root root 801 05-11 19:42 proflie
-rw-r--r-- 1 root root 59 05-11 20:08 shadow
[root@localhost nfs]# rm etc/*~ etc/init.d/*~ //删除备份文件 */
[root@localhost nfs]# gedit copy_lib.sh //编写脚本文件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]# ll copy_lib.sh
-rw-r--r-- 1 root root 303 05-11 20:18 copy_lib.sh
[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 -
/tmp/nfs
[root@localhost nfs]# ll lib
总计 2516
-rwxr-xr-x 1 root root 131480 05-11 20:19 ld-2.3.2.so
lrwxrwxrwx 1 root root 11 05-11 20:19 ld-linux.so.2 -> ld-2.3.2.so
-rwxr-xr-x 1 root root 1560352 05-11 20:19 libc-2.3.2.so
-rwxr-xr-x 1 root root 30155 05-11 20:19 libcrypt-2.3.2.so
lrwxrwxrwx 1 root root 17 05-11 20:19 libcrypt.so.1 -> libcrypt-2.3.2.so
lrwxrwxrwx 1 root root 13 05-11 20:19 libc.so.6 -> libc-2.3.2.so
-rwxr-xr-x 1 root root 15736 05-11 20:19 libdl-2.3.2.so
lrwxrwxrwx 1 root root 14 05-11 20:19 libdl.so.2 -> libdl-2.3.2.so
-rwxr-xr-x 1 root root 546854 05-11 20:19 libm-2.3.2.so
lrwxrwxrwx 1 root root 13 05-11 20:19 libm.so.6 -> libm-2.3.2.so
-rwxr-xr-x 1 root root 97975 05-11 20:19 libpthread-0.10.so
lrwxrwxrwx 1 root root 18 05-11 20:19 libpthread.so.0 -> libpthread-0.10.so
-rwxr-xr-x 1 root root 81495 05-11 20:19 libresolv-2.3.2.so
lrwxrwxrwx 1 root root 18 05-11 20:19 libresolv.so.2 -> libresolv-2.3.2.so
-rwxr-xr-x 1 root root 13689 05-11 20:19 libutil-2.3.2.so
lrwxrwxrwx 1 root root 16 05-11 20:19 libutil.so.1 -> libutil-2.3.2.so
drwxr-xr-x 2 root root 4096 05-11 11:23 modules
[root@localhost nfs]# //一个基本的根文件系统(通过NFS挂载)构建完成
[root@localhost nfs]#cd
[root@localhost ~]# cd Desktop/
[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 }
[root@localhost Desktop]# service xinetd restart //重启tftp服务器
[root@localhost Desktop]# gedit /etc/exports
//exports文件内容如下:
/tmp/nfs *(rw,sync,no_root_squash)
[root@localhost u-boot-1.1.4]# service nfs restart //重启NFS服务器
[root@localhost Desktop]# cd u-boot-1.1.4
[root@localhost u-boot-1.1.4]# exportfs
/tmp/nfs
[root@localhost u-boot-1.1.4]# exportfs -ra //重新扫描配置文件
[root@localhost u-boot-1.1.4]# skyeye1.2.6 //使用NFS文件系统
**************************** 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
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
Freeing init memory: 92K
#mount all.......
******************************************************************
OK 2410 Rootfs made by liyanshuo, 2009.05
******************************************************************
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
~ # printenv
USER=root
LD_LIBRARY_PATH=/lib:/usr/lib
HOME=/root
PS1=[\u@\h \W]\$
LOGNAME=root
TERM=vt102
PATH=/bin:/sbin:/usr/bin:/usr/sbin
HISTSIZE=100
SHELL=/bin/sh
PWD=/root
~ # ifconfig
eth0 Link encap:Ethernet HWaddr 08:00:3E:26:0A:5B
inet addr:10.0.0.110 Bcast:10.0.0.255 Mask:255.255.255.0
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:1826 errors:0 dropped:0 overruns:0 frame:0
TX packets:730 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:2386884 (2.2 MiB) TX bytes:116644 (113.9 KiB)
Interrupt:53 Base address:0x300
lo Link encap:Local Loopback
inet addr:127.0.0.1 Mask:255.0.0.0
UP LOOPBACK RUNNING MTU:16436 Metric:1
RX packets:0 errors:0 dropped:0 overruns:0 frame:0
TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:0 (0.0 B) TX bytes:0 (0.0 B)
~ # ping -c 2 10.0.0.1
PING 10.0.0.1 (10.0.0.1): 56 data bytes
64 bytes from 10.0.0.1: seq=0 ttl=64 time=0.034 ms
64 bytes from 10.0.0.1: seq=1 ttl=64 time=0.021 ms
--- 10.0.0.1 ping statistics ---
2 packets transmitted, 2 packets received, 0% packet loss
round-trip min/avg/max = 0.021/0.027/0.034 ms
~ #
//成功移植
//以下使用/dev/mtdblock2中的文件系统
[root@localhost tmp]# pwd
/tmp
[root@localhost tmp]# mkfs.cramfs nfs ok2410.cramfs
[root@localhost tmp]# ll ok2410.cramfs
-rw-r--r-- 1 root root 2199552 05-13 08:18 ok2410.cramfs
[root@localhost tmp]# cp ok2410.cramfs /tftpboot/ //复制ok2410.cramfs到tftp服务器根目录
[root@localhost u-boot-1.1.4]# pwd
/root/Desktop/u-boot-1.1.4
[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
…… //启动信息省略
//到此 嵌入式系统移植三部曲移植成功
http://blog.chinaunix.net/space.php?uid=14735472&do=blog&id=110947
李炎朔 09机应一班 学号0906041053
三部曲《bootloader的移植》《linux的移植》《根文件系统的移植》
一 bootloader的移植
(1)安装skyeye-1.2.6_rc1
[root@localhost Desktop]# tar -xjvf skyeye-1.2.6_rc1.tar.bz2 -C ./
[root@localhost Desktop]# cd skyeye-1.2.6_rc1
[root@localhost skyeye-1.2.6_rc1]# ls
/*
aclocal.m4 ChangeLog configure depcomp LICENSE misc REPORTING-BUGS
arch config.guess configure.in device MAINTAINERS missing TODO
AUTHORS config.h.in COPYING INSTALL Makefile.am NEWS utils
autom4te.cache config.sub dbct install-sh Makefile.in README
*/
[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 //将skyeye安装到/usr/local/bin/
[root@localhost skyeye-1.2.6_rc1]# ll /usr/local/bin/skyeye
// -rwxr-xr-x 1 root root 2544308 05-17 17:59 /usr/local/bin/skyeye
[root@localhost skyeye-1.2.6_rc1]# mv /usr/local/bin/skyeye /usr/local/bin/skyeye1.2.6 //改名
(2)创建交叉编译环境
[root@localhost Desktop]# tar -xjvf arm-linux-gcc2.95.3.tar.bz2 -C ./ //交叉编译器:arm-linux-gcc2.95.3
(3)bootloader移植
[root@localhost Desktop]# tar -xjvf u-boot-1.1.4.tar.bz2 -C ./ //Bootloader:u-boot-1.1.4
[root@localhost Desktop]# cd u-boot-1.1.4
[root@localhost u-boot-1.1.4]# gedit Makefile //编辑u-boot根目录中的Makefile文件
/*
将
ifeq ($(ARCH),arm)
CROSS_COMPILE = arm-linux-
endif
改为
ifeq ($(ARCH),arm)
CROSS_COMPILE=/usr/local/arm/2.95.3/bin/arm-linux-
endif
在
smdk2410_config : unconfig
@./mkconfig $(@:_config=) arm arm920t smdk2410 NULL s3c24x0
后面添加
ok2410_config : unconfig
@./mkconfig $(@:_config=) arm arm920t ok2410 NULL s3c24x0
*/
[root@localhost u-boot-1.1.4]# mkdir board/ok2410 //创建ok2410移植目录
[root@localhost u-boot-1.1.4]# cp board/smdk2410/* board/ok2410/ //复制必要的文件 */
[root@localhost u-boot-1.1.4]# dir board/ok2410/
// config.mk flash.c lowlevel_init.S Makefile smdk2410.c u-boot.lds
[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 //编辑ok2410.h头文件
/*
将
#define CFG_PROMPT "SMDK2410 # " /* Monitor Command Prompt */
改为
#define CFG_PROMPT "OK2410 # " /* Monitor Command Prompt */
*/
[root@localhost u-boot-1.1.4]# gedit board/ok2410/Makefile
/*
将
OBJS := smdk2410.o flash.o
改为
OBJS := ok2410.o flash.o
*/
[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
*/
//又出现错误了 不怕 修改examples目录下的Makefile文件就解决啦
[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
*/ //第一小步成功了...
[root@localhost u-boot-1.1.4]# ll u-boot*
/*
-rwxr-xr-x 1 root root 396429 05-03 18:32 u-boot
-rwxr-xr-x 1 root root 100156 05-03 18:32 u-boot.bin
-rw-r--r-- 1 root root 48690 05-03 18:32 u-boot.map
-rwxr-xr-x 1 root root 300538 05-03 18:32 u-boot.srec
*/
[root@localhost u-boot-1.1.4]# gedit skyeye.conf //编辑skyeye的配置文件 里面空白 添加如下内容(注释里面的)
/*
# 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
*/
[root@localhost u-boot-1.1.4]# skyeye1.2.6 //执行skyeye
/*
**************************** 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 #
*/ //出现提示符OK2410 # 执行成功 可以输入"?"查看帮助
//开始移植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 */
替换成:
//#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
//以上将从NOR Flash启动改成从NAND Flash启动
[root@localhost u-boot-1.1.4]# gedit board/ok2410/Makefile //修改board/ok2410/Makefile
/*
将
OBJS := ok2410.o flash.o
改为
OBJS := ok2410.o flash.o nand_read.o
*/
[root@localhost u-boot-1.1.4]# gedit board/ok2410/nand_read.c //创建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;
}
[root@localhost u-boot-1.1.4]# gedit include/configs/ok2410.h //编辑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 *******************/
[root@localhost u-boot-1.1.4]# make
[root@localhost u-boot-1.1.4]# skyeye1.2.6 //再次执行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 //这个命令需要从网上下载 复制到/bin/下即可
// finish
[root@localhost u-boot-1.1.4]# ll nand.dump
// -rw-r--r-- 1 root root 118272 05-10 22:29 nand.dump
[root@localhost u-boot-1.1.4]# skyeye1.2.6 //再次执行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添加nand指令的支持
[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 *************************************/
为了能使U-BOOT正确引导Linux内核,必须传递合适的参数给内核。引导内核时可以将bootargs传递给内核。bootargs是指ok2410.h文件中的CONFIG_BOOTARGS宏
将
/*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"
[root@localhost u-boot-1.1.4]# gedit include/configs/ok2410.h
将原来的me add begin与me add end之间的内容替换成以下内容
/****************** 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下载linux-2.6.14.7.tar.bz2 /* 板子上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 *******************/
[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 *******************/
[root@localhost u-boot-1.1.4]# gedit common/cmd_nand.c
将NanD_ReadBuf函数中的
NanD_Command (nand, NAND_CMD_READ0);
改为
//NanD_Command (nand, NAND_CMD_READ0);
[root@localhost u-boot-1.1.4]# make
[root@localhost u-boot-1.1.4]# ./mknandflashdump u-boot.bin nand.dump 0 //也需将此命令复制到u-boot下
[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 //注意这行 出现了对nand的支持
*** 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 #
到此对bootloader的移植已经完毕
二 Linux的移植
//下载linux-2.6.14.7.tar.bz2 交叉编译环境arm-linux-gcc-3.4.1和cs8900网卡到桌面
[root@localhost Desktop]# tar -xjvf arm-linux-gcc-3.4.1.tar.bz2 -C ./
[root@localhost Desktop]# tar -xjvf linux-2.6.14.7.tar.bz2 -C ./
[root@localhost Desktop]# tar -xjvf cs8900.tar.gz -C ./
[root@localhost Desktop]# cd linux-2.6.14.7
[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- // linux2.6.14的交叉编译器为gcc-3.4.1
//将321-329行改为如下 否则将出现找不到编译器的错误
AS = /usr/local/arm/3.4.1/bin/arm-linux-as
LD = /usr/local/arm/3.4.1/bin/arm-linux-ld
CC = /usr/local/arm/3.4.1/bin/arm-linux-gcc
CPP = $(CC) -E
AR = /usr/local/arm/3.4.1/bin/arm-linux-ar
NM = /usr/local/arm/3.4.1/bin/arm-linux-nm
STRIP = /usr/local/arm/3.4.1/bin/arm-linux-strip
OBJCOPY = /usr/local/arm/3.4.1/bin/arm-linux-objcopy
OBJDUMP = /usr/local/arm/3.4.1/bin/arm-linux-objdump
*/
[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/ //移植网卡
[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.
[root@localhost linux-2.6.14.7]# gedit drivers/net/arm/Makefile
在文件最后添加如下内容:
o bj-$(CONFIG_ARM_CS8900) += cs8900.o
[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 }
};
[root@localhost linux-2.6.14.7]# gedit include/asm-arm/arch-s3c2410/smdk2410.h //创建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_
[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,
};
另外,还要修改该文件中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
}
};
[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,
};
[root@localhost linux-2.6.14.7]# gedit drivers/mtd/nand/s3c2410.c
在s3c2410_nand_init_chip()函数中。
将
chip->eccmode = NAND_ECC_SOFT;
改为
chip->eccmode = NAND_ECC_NONE;
[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
[root@localhost linux-2.6.14.7]# cp arch/arm/configs/smdk2410_defconfig .config
[root@localhost linux-2.6.14.7]# make smdk2410_defconfig
[root@localhost linux-2.6.14.7]# make menuconfig //开始配置内核
//在弹出的TUI界面中,进行如下的配置(在smdk2410_defconfig的基础上)。
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)
//保存退出,产生.config文件
[root@localhost linux-2.6.14.7]# make
[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 ..
[root@localhost u-boot-1.1.4]# skyeye1.2.6
//出现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.
//出现如上错误 修改内核的arch/arm/kernel/head.S 即可解决
[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
[root@localhost linux-2.6.14.7]# make
[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
[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 ..
[root@localhost u-boot-1.1.4]# skyeye1.2.6
//将NAND Flash(/dev/mtdblock2)作为根文件系统
**************************** 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 # 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
Kernel panic - not syncing: VFS: Unable to mount root fs on unknown-block(31,2)
//错误,因为mtdblock2中还没有文件系统,该问题将在第三部曲中解决
//通过NFS访问文件系统
**************************** 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文件系统没有准备好,或者是防火墙,该问题将在第三部曲中解决
三 根文件系统的移植
//首先建立YAFFS2根文件
//由于linux-2.6.14.7内核中没有yaffs2的相关代码,因此,要向内核添加支持yaffs2文件系统的源代码
//下载yaffs2文件系统源代码—yaffs2.tar.gz
[root@localhost Desktop]# tar -xzvf yaffs2.tar.gz -C ./
[root@localhost Desktop]# cp -av yaffs2 linux-2.6.14.7/fs/
[root@localhost linux-2.6.14.7]# cp fs/yaffs2/Makefile.kernel fs/yaffs2/Makefile
root@localhost linux-2.6.14.7]# gedit fs/Kconfig
在最后一行(endmenu)的前面添加如下一行。
source "fs/yaffs2/Kconfig"
[root@localhost linux-2.6.14.7]# gedit fs/Makefile
在文件的最后添加如下一行。
obj-$(CONFIG_YAFFS_FS) +=yaffs2/
[root@localhost linux-2.6.14.7]# make menuconfig
File systems --->
<*> YAFFS2 file system support
--- 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)
[root@localhost linux-2.6.14.7]# make //至此,支持yaffs2文件系统的Linux内核映像(vmlinux)已经生成
[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 24 12:10:15 2009
Image Type: ARM Linux Kernel Image (uncompressed)
Data Size: 1126256 Bytes = 1099.86 kB = 1.07 MB
Load Address: 0x30008000
Entry Point: 0x30008000
[root@localhost tools]# cp uImage /tftpboot/ //将制作好的Linux内核映像(uImage)复制到tftp服务器根目录(/tftpboot)中。这样,可以通过tftp协议将其下载的目标板中
[root@localhost tools]#cd /root/Desktop/yaffs2/utils
[root@localhost utils]# ll
-rw-r--r-- 1 root root 1739 2007-03-07 Makefile
-rw-r--r-- 1 root root 13689 2007-02-14 mkyaffs2image.c
-rw-r--r-- 1 root root 14968 2007-02-14 mkyaffsimage.c
[root@localhost utils]# make //编译
[root@localhost utils]# ll mkyaffs* //列出生成的工具
-rwxr-xr-x 1 root root 14270 05-24 12:15 mkyaffs2image
-rwxr-xr-x 1 root root 13480 05-24 12:15 mkyaffsimage
[root@localhost utils]# cp mkyaffs2image /bin/ //复制到命令搜索路径中
[root@localhost utils]# cp mkyaffsimage /bin/
[root@localhost utils]#cd /tmp/[root@localhost tmp]# mkyaffsimage nfs rootfs.yaffs
[root@localhost tmp]# mkyaffs2image nfs rootfs.yaffs2
[root@localhost tmp]# ll rootfs.yaffs*
-rw-rw-rw- 1 root root 4532880 05-24 18:35 rootfs.yaffs
-rw-rw-rw- 1 root root 5121600 05-24 18:34 rootfs.yaffs2
[root@localhost tmp]# cp rootfs.yaffs* /tftpboot/
[root@localhost tmp]# chmod 666 /tftpboot/rootfs.yaffs* //将yaffs文件系统映像复制到/tftpboot目录
//下载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
[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
*/
[root@localhost busybox-1.13.4]# make defconfig //恢复默认配置
[root@localhost busybox-1.13.4]# make menuconfig
在弹出的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
//设置完毕后,保存、退出。
[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
//编译出错,此时需要编辑networking/interface.c文件
[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 //修改busybox属性
[root@localhost busybox-1.13.4]# cd /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
//注意:其中bin、dev、etc、lib、proc、sbin、sys、usr是必备的8个目录
[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
[root@localhost dev]# cd /root/Desktop/busybox-1.13.4/_install
[root@localhost _install]# cp -a bin /tmp/nfs/
[root@localhost _install]# cp -a sbin /tmp/nfs/
[root@localhost _install]# ll linuxrc
lrwxrwxrwx 1 root root 11 05-11 17:41 linuxrc -> bin/busybox
[root@localhost _install]# cp -a linuxrc /tmp/nfs/
[root@localhost _install]# ll /tmp/nfs/linuxrc
lrwxrwxrwx 1 root root 11 05-11 17:43 /tmp/nfs/linuxrc -> bin/busybox
[root@localhost _install]# cd /root/Desktop/busybox-1.13.4
[root@localhost busybox-1.13.4]# cp -a examples/bootfloppy/etc/* /tmp/nfs/etc/ */
[root@localhost busybox-1.13.4]# ls /tmp/nfs/etc/
fstab init.d inittab profile
[root@localhost busybox-1.13.4]# cd /tmp/nfs
[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]# ll etc/inittab
-rw-r--r-- 1 root root 309 05-11 18:28 etc/inittab
[root@localhost nfs]# chmod 755 etc/inittab
[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 liyanshuo, 2009.05"
echo "******************************************************************"
[root@localhost nfs]# ll etc/init.d/rcS
-rw-r--r-- 1 root root 92 05-11 18:27 etc/init.d/rcS
[root@localhost nfs]# chmod 755 etc/init.d/rcS
[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]# ll etc/fstab
-rw-r--r-- 1 root root 59 05-11 18:30 etc/fstab
[root@localhost nfs]# chmod 755 etc/fstab
[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
[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 //将此句中的x删除即可删除引导密码
[root@localhost nfs]# gedit etc/shadow
内容是:root:$1$zs2zr2N4$15U99ll5tUm3DwOvKnCVV1:14335:0:99999:7:::
[root@localhost nfs]# gedit etc/group
内容是:root:x:0:root
[root@localhost nfs]# gedit etc/mdev.conf //为mdev创建配置文件
内容是:空
[root@localhost nfs]# ll etc/
总计 60
-rwxr-xr-x 1 root root 117 05-11 19:28 fstab
-rw-r--r-- 1 root root 14 05-11 20:09 group
drwxr-xr-x 2 root root 4096 05-11 20:04 init.d
-rwxr-xr-x 1 root root 184 05-11 19:33 inittab
-rw-r--r-- 1 root root 0 05-11 20:09 mdev.conf
-rw-r--r-- 1 root root 30 05-11 20:07 passwd
-rwxr-xr-x 1 root root 801 05-11 19:42 proflie
-rw-r--r-- 1 root root 59 05-11 20:08 shadow
[root@localhost nfs]# rm etc/*~ etc/init.d/*~ //删除备份文件 */
[root@localhost nfs]# gedit copy_lib.sh //编写脚本文件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]# ll copy_lib.sh
-rw-r--r-- 1 root root 303 05-11 20:18 copy_lib.sh
[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 -
/tmp/nfs
[root@localhost nfs]# ll lib
总计 2516
-rwxr-xr-x 1 root root 131480 05-11 20:19 ld-2.3.2.so
lrwxrwxrwx 1 root root 11 05-11 20:19 ld-linux.so.2 -> ld-2.3.2.so
-rwxr-xr-x 1 root root 1560352 05-11 20:19 libc-2.3.2.so
-rwxr-xr-x 1 root root 30155 05-11 20:19 libcrypt-2.3.2.so
lrwxrwxrwx 1 root root 17 05-11 20:19 libcrypt.so.1 -> libcrypt-2.3.2.so
lrwxrwxrwx 1 root root 13 05-11 20:19 libc.so.6 -> libc-2.3.2.so
-rwxr-xr-x 1 root root 15736 05-11 20:19 libdl-2.3.2.so
lrwxrwxrwx 1 root root 14 05-11 20:19 libdl.so.2 -> libdl-2.3.2.so
-rwxr-xr-x 1 root root 546854 05-11 20:19 libm-2.3.2.so
lrwxrwxrwx 1 root root 13 05-11 20:19 libm.so.6 -> libm-2.3.2.so
-rwxr-xr-x 1 root root 97975 05-11 20:19 libpthread-0.10.so
lrwxrwxrwx 1 root root 18 05-11 20:19 libpthread.so.0 -> libpthread-0.10.so
-rwxr-xr-x 1 root root 81495 05-11 20:19 libresolv-2.3.2.so
lrwxrwxrwx 1 root root 18 05-11 20:19 libresolv.so.2 -> libresolv-2.3.2.so
-rwxr-xr-x 1 root root 13689 05-11 20:19 libutil-2.3.2.so
lrwxrwxrwx 1 root root 16 05-11 20:19 libutil.so.1 -> libutil-2.3.2.so
drwxr-xr-x 2 root root 4096 05-11 11:23 modules
[root@localhost nfs]# //一个基本的根文件系统(通过NFS挂载)构建完成
[root@localhost nfs]#cd
[root@localhost ~]# cd Desktop/
[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 }
[root@localhost Desktop]# service xinetd restart //重启tftp服务器
[root@localhost Desktop]# gedit /etc/exports
//exports文件内容如下:
/tmp/nfs *(rw,sync,no_root_squash)
[root@localhost u-boot-1.1.4]# service nfs restart //重启NFS服务器
[root@localhost Desktop]# cd u-boot-1.1.4
[root@localhost u-boot-1.1.4]# exportfs
/tmp/nfs
[root@localhost u-boot-1.1.4]# exportfs -ra //重新扫描配置文件
[root@localhost u-boot-1.1.4]# skyeye1.2.6 //使用NFS文件系统
**************************** 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
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
Freeing init memory: 92K
#mount all.......
******************************************************************
OK 2410 Rootfs made by liyanshuo, 2009.05
******************************************************************
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
~ # printenv
USER=root
LD_LIBRARY_PATH=/lib:/usr/lib
HOME=/root
PS1=[\u@\h \W]\$
LOGNAME=root
TERM=vt102
PATH=/bin:/sbin:/usr/bin:/usr/sbin
HISTSIZE=100
SHELL=/bin/sh
PWD=/root
~ # ifconfig
eth0 Link encap:Ethernet HWaddr 08:00:3E:26:0A:5B
inet addr:10.0.0.110 Bcast:10.0.0.255 Mask:255.255.255.0
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:1826 errors:0 dropped:0 overruns:0 frame:0
TX packets:730 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:2386884 (2.2 MiB) TX bytes:116644 (113.9 KiB)
Interrupt:53 Base address:0x300
lo Link encap:Local Loopback
inet addr:127.0.0.1 Mask:255.0.0.0
UP LOOPBACK RUNNING MTU:16436 Metric:1
RX packets:0 errors:0 dropped:0 overruns:0 frame:0
TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:0 (0.0 B) TX bytes:0 (0.0 B)
~ # ping -c 2 10.0.0.1
PING 10.0.0.1 (10.0.0.1): 56 data bytes
64 bytes from 10.0.0.1: seq=0 ttl=64 time=0.034 ms
64 bytes from 10.0.0.1: seq=1 ttl=64 time=0.021 ms
--- 10.0.0.1 ping statistics ---
2 packets transmitted, 2 packets received, 0% packet loss
round-trip min/avg/max = 0.021/0.027/0.034 ms
~ #
//成功移植
//以下使用/dev/mtdblock2中的文件系统
[root@localhost tmp]# pwd
/tmp
[root@localhost tmp]# mkfs.cramfs nfs ok2410.cramfs
[root@localhost tmp]# ll ok2410.cramfs
-rw-r--r-- 1 root root 2199552 05-13 08:18 ok2410.cramfs
[root@localhost tmp]# cp ok2410.cramfs /tftpboot/ //复制ok2410.cramfs到tftp服务器根目录
[root@localhost u-boot-1.1.4]# pwd
/root/Desktop/u-boot-1.1.4
[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
…… //启动信息省略
//到此 嵌入式系统移植三部曲移植成功
0
上一篇:嵌入式系统移植三部曲 王晓峰
下一篇:ser and client.c 王晓峰
相关热门文章
- SHTML是什么_SSI有什么用...
- shell中字符串操作
- 卡尔曼滤波的原理说明...
- 关于java中的“错误:找不到或...
- shell中的特殊字符
- linux dhcp peizhi roc
- 关于Unix文件的软链接
- 求教这个命令什么意思,我是新...
- sed -e "/grep/d" 是什么意思...
- 谁能够帮我解决LINUX 2.6 10...
给主人留下些什么吧!~~
评论热议
0 0
- 嵌入式系统移植三部曲 李炎朔
- 嵌入式系统移植三部曲
- 嵌入式系统移植三部曲 王晓峰
- 嵌入式系统移植三部曲 吴素芬
- 嵌入式系统移植三部曲 刘峰
- 嵌入式系统移植三部曲 李敏敏
- 嵌入式系统移植三部曲 刘莹
- 嵌入式系统移植三部曲 赵超越
- 嵌入式系统移植三部曲 于青林
- 嵌入式系统移植基础三部曲 段彦青
- 嵌入式移植三部曲 付伟贺
- 嵌入式WEB服务器移植三部曲之BOA的移植
- 嵌入式WEB服务器移植三部曲之PHP的移植
- 嵌入式WEB服务器移植三部曲之SQLite的移植
- 嵌入式系统移植
- 移植resiprocate到嵌入式系统
- 嵌入式系统上移植iperf
- 嵌入式系统平台移植步骤
- Android.mk
- 嵌入式系统移植三步曲 孟明明
- H5+MUI+Node.js+Socket.io群组即时聊天+发送图片+图片压缩
- 嵌入式系统移植三步曲 王延龙
- 嵌入式系统移植三部曲 王晓峰
- 嵌入式系统移植三部曲 李炎朔
- Java CopyOnWriteArray
- 解析 this.initialize.apply(this, arguments)
- Android 为应用程序创建桌面快捷方式
- ser and client.c 王晓峰
- 深入理解JVM(一)-Java运行时数据区域
- EXCEL中如何保持图片大小不随单元格变化而变化
- 李炎朔 编程分析
- 嵌入式系统移植三步曲 赵晓晓
原创粉丝点击
热门IT博客
热门问题
老师的惩罚
人脸识别
我在镇武司摸鱼那些年
重生之率土为王
我在大康的咸鱼生活
盘龙之生命进化
天生仙种
凡人之先天五行
春回大明朝
姑娘不必设防,我是瞎子
大益集团
大益行情网
大益普洱茶怎么样
大益茶价格
大益普洱茶价格
大益茶
东和茶叶大益每日价格表
大益普洱茶价格表
大理石一平米多少钱
干挂大理石多少钱一平米
大理石多少钱一平方米
大理石线条多少钱一米
厨房大理石多少钱一米
人造大理石多少钱一米
人造大理石多少钱一平米
大理石漆多少钱一平方
大理石的价钱
仿大理石漆多少钱一平方
米白色大理石图片
大盘
大盘鸡做法
大盘鸡
大盘走势
股票大盘
新疆大盘鸡
正宗大盘鸡
川味大盘鸡
家常大盘鸡
沪指大盘
大盘鸡图片
沙湾大盘鸡
大盘行情
大盘分析
大盘走势图
大盘图片
沪市大盘
广发大盘
大盘预测
什么是大盘
跑赢大盘
大盘点数