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

全部博文(1159)

文章存档

2016年(126)

2015年(350)

2014年(56)

2013年(91)

2012年(182)

2011年(193)

2010年(138)

2009年(23)

分类: 嵌入式

2011-06-17 08:16:22

院系:计算机与信息工程学院         班级: 09计算机应用二班

姓名:赵晓晓(09嵌入式方向)       学号:0906042051

 

嵌入式系统移植三步曲

 

一、Bootloader的移植

二、linux 内核的编译

三、linux根文件系统移植

 

第一步、BootLoader的移植

首先建立交叉编译环境,交叉编译器:arm-linux-gcc2.95.3;接下来要

做的就是根据硬件环境编译原程序.本试验用的是u-boot-1.1.4.tar.bz2,进

BootLoader的移植:

1.      修改Makefile文件内容:

[root@localhost u-boot-1.1.4]# gedit 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

后面添加

xiaoxiao2410_config   :     unconfig

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

 

2.编辑xiaoxiao2410.h头文件

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

3.编辑board/xiaoxiao2410/Makefile文件

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

OBJS   := smdk2410.o flash.o

改为

OBJS   := xiaoxiao2410.o flash.o

4.修改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,))

 

5.修改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

[root@localhost u-boot-1.1.4]# ll u-boot*

-rwxr-xr-x 1 root root 441425 06-08 09:29 u-boot

-rwxr-xr-x 1 root root 115468 06-08 09:29 u-boot.bin

-rw-r--r-- 1 root root  50542 06-08 09:29 u-boot.map

-rwxr-xr-x 1 root root 346474 06-08 09:29 u-boot.srec

 

 6.添加skyeye.conf文件

# skyeye config file for S3C2410X

cpu: arm920t

mach: s3c2410x

# physical memory

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

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

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

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

# all peripherals I/O mapping area

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

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

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

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

#lcd:type=s3c2410x, mod=gtk

dbct:state=on

7执行skyeye1.2.6

In:    serial

Out:   serial

Err:   serial

Hit any key to stop autoboot:  0

XIAOXIAO2410 #

8.开始移植nand

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

9.修改board/xiaoxiao2410/Makefile

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

OBJS       := xiaoxiaook2410.o flash.o

改为

OBJS       := xiaoxiao2410.o flash.o nand_read.o

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

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

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

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

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

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

[root@localhost u-boot-1.1.4]# skyeye1.2.6       //再次执行skyeye1.2.6

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

Finish

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

-rw-rw-rw- 1 root root 69206016 06-08 09:29 nand.dump

[root@localhost u-boot-1.1.4]# skyeye1.2.6       //再次执行skyeye1.2.6

 

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

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

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

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

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

15.修改 common/cmd_nand.c文件

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

16.编译、测试

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

[root@localhost u-boot-1.1.4]# ll u-boot*

-rwxr-xr-x 1 root root 441425 06-08 09:29 u-boot

-rwxr-xr-x 1 root root 115468 06-08 09:29 u-boot.bin

-rw-r--r-- 1 root root  50542 06-08 09:29 u-boot.map

-rwxr-xr-x 1 root root 346474 06-08 09:29 u-boot.srec

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

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

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

In:    serial

Out:   serial

Err:   serial

Hit any key to stop autoboot:  0

TFTP from server 10.0.0.1; our IP address is 10.0.0.110

Filename 'uImage'.

Load address: 0x31000000

Loading: checksum bad

T T T T T T T T

 

第二步:编译内核(进行linux的移植)

首先建立开发环境,inux2.6.14的交叉编译器为gcc-3.4.1,下来要做的就是根据硬件环境编译原程序。本试验用的是linux,将其解压之后修改Makefile文件,然后再对网上进行移植

inux的移植,根据自己的需要配置linux内核,编译内核创建uimag放置在TFTP服务器根目录(tftpboot/),这样在远程下载模式下,可以在TFTP       服务器根目录(tftpboot/)下载文件系统引导系统

 

第三步:根文件系统的移植 busybox,yaffs2根文件系统的建立,在重启服务器之后再启动开发版

 

后总结验中现问题:

一.在Bootloader的移植中出现的问题如下

1. 执行命令mknandflashdump会有提示说mknandflashdump 命令找不到

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

bash: mknandflashdump: command not found

用下面命令就可解决此问题:

[root@localhost u-boot-1.1.4]# gcc -g mknandflashdump.c

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

offset: 0x0 = 0

1  pos: 0x0 = 0

2  pos: 0x0 = 0

finish

2.  移植完成后,执行skyeye1.2.6 ,会出现T(表示try),这时就需要根文件系统的移植

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

In:    serial

Out:   serial

Err:   serial

Hit any key to stop autoboot:  0

TFTP from server 10.0.0.1; our IP address is 10.0.0.110

Filename 'uImage'.

Load address: 0x31000000

Loading: checksum bad

T T T T T T T T

此时是tftp服务器没有搭建,需要对tftp进行搭建,同时对其权限进行修改,

#chmod-R 755 /tftpboot;

3.防火墙问题

此时可执行iptables命令:

[root@localhost Desktop]# iptables -F

 

.在linux的移植中出现的问题如下

1.执行命令make会有提示说make 命令找不到

[root@localhost linux-2.6.14.7]# make

make: /usr/local/arm/3.4.1/bin/arm-linux-:命令未找到

  CHK     include/linux/version.h

  UPD     include/linux/version.h

  SPLIT   include/linux/autoconf.h -> include/config/*

  SYMLINK include/asm-arm/arch -> include/asm-arm/arch-s3c2410

  Generating include/asm-arm/mach-types.h

  SYMLINK include/asm -> include/asm-arm

  CC      arch/arm/kernel/asm-offsets.s

/bin/sh: /usr/local/arm/3.4.1/bin/arm-linux-: 没有那个文件或目录

make[1]: *** [arch/arm/kernel/asm-offsets.s] 错误 1

make: *** [prepare0] 错误 2

出现错误。

将Makefile文件中的$(CROSS_COMPILE)改成绝对路径 /usr/local/arm/3.4.1/bin/arm-linux-     

把解压后的文件夹/usr/local/arm/usr/local/arm/3.4.1/中的3.4.1文件夹移到/usr/local/arm/下

再次执行make命令

2.执行命令cp ../cs8900/cs8900.c 会有提示说cp ../cs8900/cs8900.c 没有那个文件或目录

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

cp: 无法 stat “../cs8900/cs8900.c”: 没有那个文件或目录

在/opt/下建立一个文件夹,把cs8900.c和cs8900.h移到cs8900文件夹下即可

3. 执行命令cp initrd.img会有提示说cp initrd.img命令找不到

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

cp: 无法 stat “initrd.img”: 没有那个文件或目录

出现错误将initrd.img移到/opt/u-boot-1.1.4/tools/文件夹下即可

4. 执行命令cp initrd.img /tmp/nfs/会有提示说cp initrd.img /tmp/nfs/命令找不到

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

cp: 无法创建一般文件“/tmp/nfs/”: 是一个目录

出现错误/tmp/下建立一个文件夹,名字为nfs

5.有时在启动的时候会出现如下情况:

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

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

Console: colour dummy device 80x30

[root@localhost u-boot-1.1.4]#

重启计算机后会出现错误,执行如下命令即可:

[root@localhost opt]# service xinetd restart

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

启动 NFS 服务:                                            [确定]

关掉 NFS 配额:                                            [确定]

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

启动 NFS mountd                                          [确定]

[root@localhost opt]# iptables -F

 

.在根文件系统的移植中出现的问题如下:

1.出现的错误:

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

            OK 2410 Rootfs made by xiaoxiao , 2009.05

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

10.0.0.110 login: root

Password:

login[25]: root login on 'console'

login: cannot run /bin/bash: Exec format error

解决办法如下:

[root@localhost nfs]gedit etc/passwd

将:root:x:0:0:root:/root:/bin/bash

改为:root:x:0:0:root:/root:/bin/sh

 

2.出现的错误:

0.110:10.0.0.1:10.0.0.1:255.255.255.0 init=linuxrc console=ttySAC0,115200  mem=64M

irq: clearing pending status 00004000

irq: clearing pending status 00008000

irq: clearing pending status 00004000

irq: clearing pending status 00800000

irq: clearing subpending status 00000092

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

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

Console: colour dummy device 80x30

[root@localhost /]# service nfs restart

关闭 NFS mountd:                                          [确定]

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

关闭 NFS quotas:                                          [确定]

关闭 NFS 服务:                                            [确定]

启动 NFS 服务:                                            [确定]

关掉 NFS 配额:                                            [确定]

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

启动 NFS mountd:                                          [确定]

[root@localhost /]# iptables -F

[root@localhost /]# service xinetd restart

停止 xinetd:                                              [确定]

启动 xinetd:                                              [确定]

或者是当启动到

In:    serial

Out:   serial

Err:   serial

、最后正确的执行结果如下

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

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

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

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

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

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

Your elf file is little endian.

arch: arm

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

mach info: name s3c2410x, mach_init addr 0x806bae0

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

nandflash: dump ./nand.dump

file size:69206016

dbct info: turn on dbct!

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

SKYEYE: use arm920t mmu ops

Loaded RAM   ./u-boot.bin

ERROR: s3c2410x_io_write_word(0x4c000000) = 0x00ffffff

ERROR: s3c2410x_io_write_word(0x4c000008) = 0x00048032

U-Boot 1.1.4 (Jun  8 2011 - 09:28:44)

U-Boot code: 33F80000 -> 33F9C30C  BSS: -> 33FA03E8

RAM Configuration:

Bank #0: 30000000 64 MB

Flash: 512 kB

NAND:  64 MB

warning when RE  falling,do nothing

 warning when RE  falling,do nothing

 warning when RE  falling,do nothing

 warning when RE  falling,do nothing

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

In:    serial

Out:   serial

Err:   serial

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

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

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

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

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

done

Bytes transferred = 1138580 (115f94 hex)

## Booting image at 31000000 ...

   Image Name:   linux-2.6.14.7

   Created:      2011-06-11   9:19:42 UTC

   Image Type:   ARM Linux Kernel Image (uncompressed)

   Data Size:    1138516 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) #2 Sat Jun 11 15:52:11 CST 2011

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

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: 62464KB available (1843K code, 397K data, 96K 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: devfs_debug: 0x0

devfs: boot_options: 0x1

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

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

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

loop: loaded (max 8 devices)

nbd: registered device at major 43

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

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: 96K

#mount all.......

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

            OK 2410 Rootfs made by xiaoxiao , 2009.05

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

10.0.0.110 login: root

login[25]: root login on 'console'

xaoxiao 2009.05

Processing /etc/profile... Done

 

~ # ls

~ # cd /

/ # ls

bin          dev          initrd.img   mnt          sbin       tmp 

boot         etc          lib          proc         sys          usr

copy_lib.sh  home         linuxrc      root         temp      var  

/ #

 

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


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