| 帮同学宣传一下http://shop57644665.taobao.com/ |
scatter-loading机制允许我们通过scatter file将image中的各个区域指定到特定的地址上。其实对于一个特定的系统,这个也是必须的,因为每个系统的片选地址是不一样的。
以下这个简单的例子中,flash的开始地址是0×0000,其长度为0×8000,用于存放code和各种Read-Olny数据。RAM的起始地址是0×10000,其可用大小为0×6000,用于存放Read-Write数据。
Load和Run时的情况如下
我们也可以通过类似bootarm.obj (C$$code,+First)的格式,来手动指定特定c文件中特定部分(使用预处理指令命名,例子中为C$$code)出现在该段的最前面(+First)或最后面(+Last)。
当然scatter file支持更加复杂的应用,比如多个load rom,内存共用,代码在ram中执行等等…
使用scatter file会对应生成一些与之相对应的符号(symbols)。这些符号是可以在我们的代码中进行引用的。生成的符号及其意义如下:
Load$$region_name$$Base Load address of the region.
Image$$region_name$$Base Execution address of the region.
Image$$region_name$$Length Execution region length in bytes (multiple of 4).
Image$$region_name$$Limit Address of the byte beyond the end of the execution region.
Image$$region_name$$ZI$$Base Execution address of the ZI output section in this region.
Image$$region_name$$ZI$$Length Length of the ZI output section in bytes (multiple of 4).
Image$$region_name$$ZI$$Limit Address of the byte beyond the end of the ZI output section in the execution region.
在我们的代码中使用如下例子。
IMPORT ||Image$$region_name$$ZI$$Limit||
__user_initial_stackheap
LDR r0, =||Image$$region_name$$ZI$$Limit||
MOV pc, lr


















