Chinaunix首页 | 论坛 | 博客
  • 博客访问: 81676
  • 博文数量: 28
  • 博客积分: 65
  • 博客等级: 民兵
  • 技术积分: 115
  • 用 户 组: 普通用户
  • 注册时间: 2012-08-04 11:06
文章分类

全部博文(28)

文章存档

2014年(22)

2013年(5)

2012年(1)

我的朋友

分类: LINUX

2013-06-09 00:34:14

编译完内核之后,会产生zImage,而把它直接导入0x30008000,会出现 Bad Magic Number.

    查明是需要将内核加一个0x40大小的头,mkimage工具来添加.mkimage在编译u-boot时在u-boot-1.1.6/tools下生成,可以为编译的内核添加头信息的.bootm命令中会解析这个头,获得参数.zImage在编译内核时,在arch/arm/boot目录下生成。我们需要把zImagemkimage工具处理一下。

mkimage 参数的意义如下:

        -A == set architecture to 'arch'

        -O == set operating system to 'os'

        -T == set image type to 'type'

        -C == set compression type 'comp'

        -a == set load address to 'addr' (hex)

        -e == set entry point to 'ep' (hex)

        -n == set image name to 'name'

        -d == use image data from 'datafile'

        -x == set XIP (execute in place)

    首先可以把zImage 拷贝到 u-boot-1.1.6/tools目录下,在此目录下,执行如下命令:

./mkimage -n 'linux-2.6.26' -A arm -O linux -T kernel -C none -a 0x30007fc0 -e 0x30008000 -d zImage uImage

输出信息如下:

Image Name:   linux-2.6.26

Created:      Tue Jul 28 18:50:26 2009

Image Type:   ARM Linux Kernel Image (uncompressed)

Data Size:    1655648 Bytes = 1616.84 kB = 1.58 MB

Load Address: 0x30007FC0

Entry Point:  0x30008000

可以看出加载地址是 0x30007fc0,而入口地址是 0x30008000.

GEC2410 # tftp 30008000 uImage

TFTP from server 192.168.0.50; our IP address is 192.168.0.100

Filename 'uImage'.

Load address: 0x30008000

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

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

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

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

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

done

Bytes transferred = 1655712 (1943a0 hex)

GEC2410 # bootm 30008000

## Booting image at 30008000 ...

   Image Name:   linux-2.6.26

   Created:      2009-07-28  10:50:26 UTC

   Image Type:   ARM Linux Kernel Image (uncompressed)

   Data Size:    1655648 Bytes =  1.6 MB

   Load Address: 30007fc0

   Entry Point:  30008000

   Verifying Checksum ... OK

OK

 

Starting kernel ...(卡死在这儿了)

 

GEC2410 # tftp 30008000 uImage

TFTP from server 192.168.0.50; our IP address is 192.168.0.100

Filename 'uImage'.

Load address: 0x30008000

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

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

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

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

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

done

Bytes transferred = 1655712 (1943a0 hex)

GEC2410 # bootm 30007fc0

## Booting image at 30007fc0 ...

Bad Magic Number

 

GEC2410 # tftp 30007fc0 uImage

TFTP from server 192.168.0.50; our IP address is 192.168.0.100

Filename 'uImage'.

Load address: 0x30007fc0

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

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

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

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

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

done

Bytes transferred = 1655712 (1943a0 hex)

GEC2410 # bootm 30008000

## Booting image at 30008000 ...

Bad Magic Number

GEC2410 #

 

GEC2410 # tftp 0x30007fc0 uImage

TFTP from server 192.168.0.50; our IP address is 192.168.0.100

Filename 'uImage'.

Load address: 0x30007fc0

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

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

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

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

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

done

Bytes transferred = 1655712 (1943a0 hex)

GEC2410 # bootm 30007fc0

## Booting image at 30007fc0 ...

   Image Name:   linux-2.6.26

   Created:      2009-07-28  10:50:26 UTC

   Image Type:   ARM Linux Kernel Image (uncompressed)

   Data Size:    1655648 Bytes =  1.6 MB

   Load Address: 30007fc0

   Entry Point:  30008000

   Verifying Checksum ... OK

   XIP Kernel Image ... OK

 

Starting kernel ...

 

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

………………….

(一大堆信息)

从上面可以看出,tftp下载的地址和bootm引导的地址是同一个地址,且是mkimage的参数 -a 的地址,即加载地址,而不是入口地址。

 

./mkimage -n 'linux-2.6.26' -A arm -O linux -T kernel -C none -a 0x30008000 -e 0x30008000 -d zImage uImage

Created:      Tue Jul 28 19:21:15 2009

Image Type:   ARM Linux Kernel Image (uncompressed)

Data Size:    1655648 Bytes = 1616.84 kB = 1.58 MB

Load Address: 0x30008000

Entry Point:  0x30008000

入口地址和加载地址一样的时候,

我在做这个尝试的时候,导致开发板重启……

 

现在能正确引导内核啦,但是GEC2410的网卡芯片是CS8900A的芯片,要能正确的启动Linux系统,还必须添加CS8900A的驱动……

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