全部博文(1159)
分类: 嵌入式
2011-06-17 15:21:46
嵌入式移植三部曲
姓名:付伟贺 班级:09应用2班 学号:0906042035
一.Bootloader的移植
二.linux的移植
三.根文件系统的移植
一.Bootloader的移植
交叉编译器:arm-linux-gcc2.95.3
1.编辑u-boot根目录中的Makefile文件
[root@localhost u-boot-1.1.4]# gedit Makefile
2.复制必要的文件,编辑ok2410.h头文件
3.编辑board/ok2410/Makefile文件
[root@localhost u-boot-1.1.4]# gedit board/ok2410/Makefile
4.配置、编译u-boot
[root@localhost u-boot-1.1.4]# make ok2410_configConfiguring for ok2410 board...
[root@localhost u-boot-1.1.4]# make
5.编辑skyeye.conf文件[root@localhost u-boot-1.1.4]# gedit skyeye.conf
6.执行skyeye1.2.67.[root@localhost u-boot-1.1.4]# skyeye1.2.6
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
fwh2410 #
8.开始移植nand
[root@localhost u-boot-1.1.4]# gedit cpu/arm920t/start.S
将从NOR Flash启动改成从NAND Flash启动。
9.修改board/ok2410/Makefile
[root@localhost u-boot-1.1.4]# gedit board/ok2410/Makefile
10.创建board/ok2410/nand_read.c文件[root@localhost u-boot-1.1.4]# gedit board/ok2410/nand_read.c
11.编辑include/configs/ok2410.h文件[root@localhost u-boot-1.1.4]# gedit include/configs/ok2410.h
12.编译u-boot,然后测试u-boot是否可以从nand启动
[root@localhost u-boot-1.1.4]# make
[root@localhost u-boot-1.1.4]# ll u-boot*
[root@localhost u-boot-1.1.4]# skyeye1.2.6
[root@localhost u-boot-1.1.4]# mknandflashdump u-boot.bin nand.dump 0
[root@localhost u-boot-1.1.4]# skyeye1.2.6 //再次执行skyeye1.2.6
13.编辑include/configs/ok2410.h文件
[root@localhost u-boot-1.1.4]# gedit include/configs/ok2410.h
14.编辑board/ok2410/ok2410.c文件[root@localhost u-boot-1.1.4]# gedit common/cmd_nand.c
15.修改 common/cmd_nand.c文件[root@localhost u-boot-1.1.4]# gedit board/ok2410/ok2410.c
16.编译、测试[root@localhost u-boot-1.1.4]# make
[root@localhost u-boot-1.1.4]# ll u-boot*
二.linux的移植:
1.[root@localhost 嵌入式实验]# tar -xjvf linux-2.6.14.7.tar.bz2 -C ./
2.[root@localhost 嵌入式实验]#cd linux-2.6.14.7
3.[root@localhost linux-2.6.14.7]# gedit Makefile
4.将
ARCH ?= $(SUBARCH)
CROSS_COMPILE ?=
改为
ARCH ?= arm
CROSS_COMPILE ?= /usr/local/arm/3.4.1/bin/arm-linux- // linux2.6.14的交叉编译器为gcc-3.4.1
5.[root@localhost linux-2.6.14.7]#cp ../cs8900/cs8900.c drivers/net/arm/
6.[root@localhost linux-2.6.14.7]#cp ../cs8900/cs8900.h drivers/net/arm/
7.[root@localhost linux-2.6.14.7]#gedit drivers/net/arm/Kconfig 进行相应的修改
8.[root@localhost linux-2.6.14.7]#gedit drivers/net/arm/Makefile
9.[root@localhost linux-2.6.14.7]# gedit arch/arm/mach-s3c2410/mach-smdk2410.c 进行相应的修改
10.[root@localhost linux-2.6.14.7]# gedit include/asm-arm/arch-s3c2410/smdk2410.h
11.[root@localhost linux-2.6.14.7]# gedit arch/arm/mach-s3c2410/devs.c
12.[root@localhost linux-2.6.14.7]# gedit arch/arm/mach-s3c2410/mach-smdk2410.c
13.[root@localhost linux-2.6.14.7]# gedit drivers/mtd/nand/s3c2410.c
14.[root@localhost linux-2.6.14.7]# gedit fs/Kconfig
15.[root@localhost linux-2.6.14.7]# cp arch/arm/configs/smdk2410_defconfig .config
16.[root@localhost linux-2.6.14.7]# make smdk2410_defconfig
17.[root@localhost linux-2.6.14.7]# make menuconfig 进行配置内核
18.[root@localhost linux-2.6.14.7]# make
出现了以下错误:
[root@localhost linux-2.6.14.7]# make
make: /usr/local/arm/3.4.1/bin/arm-linux-:命令未找到
CHK include/linux/version.h
make[1]: “include/asm-arm/mach-types.h”是最新的。
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
[root@localhost linux-2.6.14.7]# gedit Makefile 把文件中的CROSS_COMPILE 修改成绝对路径/usr/local/arm/3.4.1/bin/arm-linux-
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
19.18.[root@localhost linux-2.6.14.7]# make
又出现了错误:
[root@localhost linux-2.6.14.7]# make
................
arch/arm/mach-s3c2410/devs.c:139: error: `superlpplatform' undeclared here (not in a function)
arch/arm/mach-s3c2410/devs.c:139: error: initializer element is not constant
arch/arm/mach-s3c2410/devs.c:139: error: (near initialization for `s3c_device_nand.dev.platform_data')
arch/arm/mach-s3c2410/devs.c:139: error: initializer element is not constant
arch/arm/mach-s3c2410/devs.c:139: error: (near initialization for `s3c_device_nand.dev')
make[1]: *** [arch/arm/mach-s3c2410/devs.o] 错误 1
make: *** [arch/arm/mach-s3c2410] 错误 2
解决方法:
[root@localhost linux-2.6.14.7]# gedit arch/arm/mach-s3c2410/devs.c
把第11步的添加的文件添加到 该文件前面
[root@localhost linux-2.6.14.7]# gedit arch/arm/mach-s3c2410/devs.c
................
#include
#include
#include
#include "devs.h"
/*nand */ /*添加到前面了*/
#include
#include
#include
/* NAND Controller */
/************************ 建立Nand Flash分区表 ************************/
/* 一个Nand Flash总共64MB, 按如下大小进行分区 */
/*
name:代表分区名字
size:代表Flash分区大小(单位:字节)
offset:代表Flash分区的起始地址(相对于0x0的偏移)
*/
static struct mtd_partition partition_info[] =
{
20.[root@localhost linux-2.6.14.7]# cp arch/arm/boot/compressed/vmlinux ../u-boot-1.1.4/tools/
21.[root@localhost linux-2.6.14.7]# cd ../u-boot-1.1.4/tools/
22.[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
23.[root@localhost tools]# cp uImage ../
24.[root@localhost tools]# cp uImage /tftpboot/
25.[root@localhost tools]# cp initrd.img /tftpboot/
26.[root@localhost tools]# cp ../u-boot.bin /tftpboot/
27.[root@localhost tools]# cp initrd.img /tmp/nfs/
28.[root@localhost tools]# cd ..
29.[root@localhost u-boot-1.1.4]# skyeye1.2.6
出现问题
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
此时应该关闭防火墙[root@localhost tools]# iptables -F
三.根文件系统的移植:
出现的错误:
1.在编译的时候[root@localhost busybox-1.13.4]# make
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文件。
将第818行的.type = ARPHRD_INFINIBAND,改为 .type = -1,再次执行make命令
[root@localhost busybox-1.13.4]# make
成功出现:
You will probably need to make your busybox binary
setuid root to ensure all configured applets will
work properly.
2.执行[root@localhost u-boot-1.1.4]# skyeye1.2.6出现错误
Password: root
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
3.如果出现错误如下:
...
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
清除防火墙规则:[root@localhost /]# iptables -F
重启tftp服务:[root@localhost /]# service xinetd restart
******************************************************************
OK 2410 Rootfs made by fwh2011.6
******************************************************************
10.0.0.110 login: root
Password:
login[27]: root login on 'console'
Processing /etc/profile... Set search library path in /etc/profile
Set user path in /etc/profile
Configure net done
All Done
[root@fwh /root]#
http://blog.chinaunix.net/space.php?uid=14735472&do=blog&id=110947