Chinaunix首页 | 论坛 | 博客
  • 博客访问: 837001
  • 博文数量: 489
  • 博客积分: 475
  • 博客等级: 下士
  • 技术积分: 3087
  • 用 户 组: 普通用户
  • 注册时间: 2011-03-08 16:28
文章分类

全部博文(489)

文章存档

2013年(7)

2012年(301)

2011年(181)

分类:

2012-04-23 22:18:48

本文经过我参照网上好心人的做法整理而成,如有侵犯您的权益,请留言,我改正。
首先,确定u-boot中的MACH_TYPE。在u-boot的include/asm-arm/mach-types.h文件中针对不同的CPU定义了非常多的MACH_TYPE,可以找到下面这个定义:

#define MACH_TYPE_SMDK2440 1008  //针对2440的MACH_TYPE码的值定义为1008

 
那么我们就修改u-boot的MACH_TYPE代码引用部分,确定u-boot的MACH_TYPE。如下:

#gedit board/samsung/my2440/my2440.c   //修改board_init函数

/* arch number of SMDK2410-Board */
//gd->bd->bi_arch_number = MACH_TYPE_SMDK2410;
改为:
gd->bd->bi_arch_number = MACH_TYPE_SMDK2440;

 
其次,确定kernel中的MACH_TYPE。在kernel的arch/arm/tools/mach-types文件中也针对不同的CPU定义了非常多的MACH_TYPE,也可以找到下面这个定义:

smdk2440  MACH_SMDK2440   SMDK2440   1008

 
那么我们就修改kernel的MACH_TYPE代码引用部分,确定kernel的MACH_TYPE。如下:

#gedit arch/arm/mach-s3c2440/mach-smdk2440.c   //修改文件最后面

//MACHINE_START(S3C2440, "SMDK2440")
改为:
MACHINE_START(SMDK2440, "SMDK2440")

 

#gedit arch/arm/kernel/head.S  //在ENTRY(stext)下添加如下代码(红色部分)

ENTRY(stext)

    mov    r0, #0
    mov    r1, #0x3f0   //上面的MACH_TYPE值1008换成十六进制就是0x3f0
    ldr    r2, =0x30000100
 
   
msr cpsr_c, #PSR_F_BIT | PSR_I_BIT | SVC_MODE

    .......

 
分别重新编译u-boot和kernel。u-boot下载后,记得要saveenv;kernel用tftp下载到内存后使用go命令来测试引导内核,结果可以引导了,如下:

## Starting application at 0x30008000 ... Uncompressing Linux............................................................. Linux version 2.6.25.8 (root@localhost.localdomain) (gcc version 4.3.3 (Sourcer0 CPU: ARM920T [41129200] revision 0 (ARMv4T), cr=00007177 Machine: SMDK2440 Warning: bad configuration page, trying to continue Memory policy: ECC disabled, Data cache writeback CPU S3C2440A (id 0x32440001) S3C244X: core 405.000 MHz, memory 101.250 MHz, peripheral 50.625 MHz S3C24XX Clocks, (c) 2004 Simtec Electronics CLOCK: Slow mode (1.500 MHz), fast, MPLL on, UPLL on

在这次u-boot移植的过程中,我明白了zImage并不能直接由u-boot从nand中引导,而uImage是可以由u-boot直接引导的,下面说明引导过程,首先进入内核目录,保证编译通过,最好是以前用别人的u-boot能启动的内核,然后执行

[root@localhost linux-2.6.25.8]# make uImage

即可在内核的boot目录下生成uImage,拷贝到tftpboot目录待下载。

查看内核在arch/arm/plat-s3c24xx/common-smdk.c中的分区情况如下

[0] = {
                .name = "EmbedSky_Board_uboot_T",
                .size = 0x00000000,
                .offset = 0x00040000,
        },
        [1] = {
                .name = "EmbedSky_Board_kernel",
                .offset = 0x00200000,
                .size = 0x00200000,
        },
        [2] = {
                .name = "EmbedSky_Board_yaffs2",
                .offset = 0x00400000,
                .size = 0x0FB80000,
        }

设置修改u-boot的启动参数,在u-boot命令行下输入:

//设置启动参数,意思是将nand中0x50000-0x00200000(和kernel分区一致)的内容读到内存0x31000000中,然后用bootm命令来执行
set bootcmd 'nand read 0x31000000 0x200000 0x00200000;bootm 0x31000000'
saveenv

把uImage.img用tftp下载到内存中,然后再固化到Nand Flash中,操作和执行图如下:

tftp 0x30000000 uImage.img //将uImage.img下载到内存0x30000000处
nand erase 0x200000 0x200000 //擦除nand的0x50000-0x200000的内容
nand write 0x30000000 0x200000 0x200000 //将内存0x30000000处的内容写入到nand的0x50000处

TFTP from server 192.168.0.102; our IP address is 192.168.0.101
Filename 'uImage'.
Load address: 0x30000000
Loading: *
ARP Retry count exceeded; starting again
dm9000 i/o: 0x20000300, id: 0x90000a46
DM9000: running in 16 bit mode
MAC: 08:00:3e:26:0a:5b
operating at unknown: 0 mode
Using dm9000 device
TFTP from server 192.168.0.102; our IP address is 192.168.0.101
Filename 'zImage'.
Load address: 0x30000000
Loading: *
ARP Retry count exceeded; starting again
dm9000 i/o: 0x20000300, id: 0x90000a46
DM9000: running in 16 bit mode
MAC: 08:00:3e:26:0a:5b
operating at unknown: 0 mode
Using dm9000 device
TFTP from server 192.168.0.102; our IP address is 192.168.0.101
Filename 'zImage'.
Load address: 0x30000000
Loading: #################################################################
         #################################################################
         ##########
done
Bytes transferred = 2052152 (1f5038 hex)
YY2440 # nanad erase 0x200000 0x200000
Unknown command 'nanad' - try 'help'
YY2440 # nand erase 0x200000 0x200000
                                                                                
NAND erase: device 0 offset 0x200000, size 0x200000
Erasing at 0x2 -- 4063232% complete.
OK
YY2440 # nand write 0x30000000 0x200000 0x200000                      
NAND write: device 0 offset 0x200000, size 0x200000
 2097152 bytes written: OK

然后boot即可成功引导内核,重新上电也可以……

YY2440 # boot                                                                 
NAND read: device 0 offset 0x200000, size 0x200000
 2097152 bytes read: OK
## Booting kernel from Legacy Image at 31000000 ...
   Image Name: Linux-2.6.25.8
   Created: 2010-01-20 16:12:01 UTC
   Image Type: ARM Linux Kernel Image (uncompressed)
   Data Size: 2052152 Bytes = 2 MB
   Load Address: 30008000
   Entry Point: 30008000
   Verifying Checksum ... OK
   Loading Kernel Image ... OK
OK
                                                                                
Starting kernel ...
                                                                                
Uncompressing Linux.............................................................
Linux version 2.6.25.8 (root@localhost.localdomain) (gcc version 4.3.3 (Sourcer0
CPU: ARM920T [41129200] revision 0 (ARMv4T), cr=00007177
Machine: SMDK2440
Warning: bad configuration page, trying to continue
Memory policy: ECC disabled, Data cache writeback
CPU S3C2440A (id 0x32440001)

参考文献http://blog.chinaunix.net/u3/101649/showart_2126764.html

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