1. Xldr.bib
先贴出xldr.bib文件的
MEMORY
; Name Start Size Type
; ------- -------- -------- ----
$(TARGETNAME) 1FFEA000 00003000 RAMIMAGE ; 12K (4K for extraromimage page + 8K actual XLDR code. Comments below)
RAM 1FFED000 00040000 RAM ; romimage wants a RAMsection even though we will not use it
; just specify 256K
CONFIG
AUTOSIZE=OFF
COMPRESSION=OFF
PROFILE=OFF
KERNELFIXUPS=ON
;ROM* creates xldr.nb0 file
;Notes:
; 1) romimage always adds a 4K page to thebeginning of file. To get rid of this 4K page
; we'll specify additional 4K space for RAMIMAGE (above) and then cut itoff from
; xldr.nb0 by specifying romstart at an offset of 4k.
; 2) since RAMIMAGE compiles with range0x0->0x01c00 and we chop off first 4K,
; and flash the remaining 4K at 0x00 on flash; it means we can't have
; absolute addressing in XLDR code. Only relative addresses should beused.
; 2) if xldr.nb1 is generated you cansafely ignore it if it contains only
; pTOC and other debugging data since we don't need them. Look at thegenerated
; file xldr.map to make sure that your code does not overflow beyond 2kboundary.
;
ROMSTART=1FFEB000 ; chop off first 4K specified inRAMIMAGE above.
ROMWIDTH=32
ROMSIZE=00002000 ; XLDR is 8KB.
; ROMOFFSET adjusts the .bin file recordheaders to that they lie in flash
; (this tells the bootloader already on thedevice to store the image in flash).
;
; 0x9FA00400 = (0x1FFEA000 + ROMOFFSET)& 0xFFFFFFFF ==> ROMOFFSET = 0x7FA16400
; (0x9FA00400 is the CA ofIMAGE_BOOT_XLDRIMAGE_SD_PA_START defined in image_cfg.h)
;
ROMOFFSET=7FA16400
这里的TARGETNAME其实就是xldr,为什么xldr的开始地址从1FFEA000开始呢?先来看
图1
IMX515内部的ROM/RAM内存映射图如下:
图2
我们再来看数据手册Memory Map这章给出的图:
图3
由上图可知CPU内部的RAM起始地址为0x1FFE0000,有这这些信息,我们来看xldr.bib的内容:
⑴xldr.bib第一部分
MEMORY
; Name Start Size Type
; ------- -------- -------- ----
$(TARGETNAME) 1FFEA000 00003000 RAMIMAGE ;
RAM 1FFED000 00040000 RAM ;
RAMIMAGE定义的0x1FFEA000到0x1FFECFFFF这12KB的用于ROM boot code把xldr的镜像文件拷贝到这块内存区域中。我们虽然知道CPU内部的开始地址是0x1FFE0000,但为什么这里RAMIMAGE的起始地址是0x1FFEA000,这和ROM boot code有关,需要有这部分代码深入学习才能搞清楚。
RAM定义了从0x1FFED000都0x2002CFFF这256KB的RAM给romimage,但实际上我们并不需要使用。
⑵xldr.bib第二部分
ROMSTART=1FFEB000 ; chop off first 4K specified inRAMIMAGE above.
ROMWIDTH=32
ROMSIZE=00002000 ; XLDR is 8KB.
根据文章最前面xldr.bib文件的注释部分可知,romimage.exe在生产xldr.nb0文件的时候总会增加页大小为4K的内容,所以为了去掉这4K,ROMSTART(指xldr在内存存放的起始地址)需要在0x1FFEA000的基础上向后偏移4K,也就是0x1FFEB000。
ROMWIDTH表示数据总线的宽度,因为ROMSTART这里的地址在SCC RAM中,而CPU内核是通过AHB来访问SCC控制器的,且IMX515中的AHB是32位的,所以之类的ROMWIDTH就是32,可见数据手册的相关描述:
图4
ROMSIZE指xldr.nb0的大小,这指定了了romimage.exe生成xldr.nb0的大小。
⑶xldr.bib第三部分
ROMOFFSET=7FA16400,指定一个偏移量来修改.bin文件中的每一个记录的地址。一般用于ROM中的.bin文件加载到RAM来运行的情况,主要是表示存储.bin的位置和运行.bin的位置不一样。
这里通过ROMOFFSET,再加上1FFEA000就可以知道xldr.bin文件存放在外部RAM中的位置,也就是0x7FA16400+0x1FFEA000 = 0x9FA00400,这就是Image_cfg.h中指定的xldr在外部RAM中存放的起始地址。