现在的位置: 首页 > 综合 > 正文

s3c2440学习系列3

2017年12月21日 ⁄ 综合 ⁄ 共 1398字 ⁄ 字号 评论关闭

在执行kernel的时候,mkimage已经指定了-e 30008000,这个地址是TEXTBASE的物理地址,

TEXTBASE就是如上描述的连接地址和运行时域。-a 30008000,

在上面我们可能回忽略一个问题,就是什么时候将kernel读到dram中,这个是在uboot中,通过nand命令来执行的。首先,我们应该知道nand的分区,这样我们知道kernelflash上的位置

例如:

我对nand flash的空间划分如下。其中0x40000~0x50000的空间没有使用。作为保留空间。

uboot           
:       0x00000000     
0x00030000      0

param          
:       0x00030000     
0x000040000      0

kernel         
:       0x00050000     
0x00200000      0

root           
:       0x00250000     
0x03dac000      0

命令:set bootcmd 'nand read 0x31000000 0x50000 0x00200000;bootm 0x31000000',因为这里的0x31000000-a 30008000不相等,那么u-boot 把指针定位到0x40之后的位置, 这里才是真正的kernelzImage zImage 搬运(copy)到 
ih_load
,也就是30008000这个地址上去。关于根文件系统,我们可以set bootargs 'noinitrd
root=/dev/mtdblock2 init=/linuxrc console=ttySAC0'
,或者在kernelcmdline设置。当然如果你在ram中,通过把rootfs地址指定到bootm中也可以:

例如:bootargs=root=/dev/ram0
rw console=ttySAC0,115200 mem=64M ramdisk=32768 initrd=0x30800000,20M
init=/linuxrc

bootcmd=tftpboot
0x33000000 uImage-tt; tftpboot 0x30800000 initrd_fs.img; bootm33000000

 

这里我们知道了kernel是如何搬运的,那么这里还有一个问题,为什么是从30008000开始,而不是从0x30000000开始呢?

 If the zImage is stored in flash, and
is linked correctly to be run from flash, then it is legal for the boot loader
to call the zImage in flash directly.The zImage may also be placed in system
RAM (at any location) and called there. Note that the kernel uses 16K of RAM
below the image to store page tables. The recommended placement is 32KiB into
RAM.
看来在image下面用了32K(0x8000)的空间存放内核页表,0x30008000就是2410的内核在RAM中的启动地址,这个地址就是这么来的

抱歉!评论已关闭.