Introduction to ARM's distributed load file (scatter)

Source: Internet
Author: User

The program compiled in Keil has passed, but there are some errors when debugging:

Error 65:access violation at 0x4c000018:no ' write ' permission

Error 65:access violation at 0x00000000:no ' execute/read ' permission (RAM.SCT)

I found that the above error occurred when I chose RUNINRAM.SCT and Runinflash.sct or an automatically generated SCT file in linker in my project settings. Should be the address of the problem. But how to fix this error is not clear. To figure out the hair again.

Here is an article to find a worthy reference:

Original address:

Http://hi.baidu.com/pengjj0807/blog/item/ef73e287a212453cc65cc3be.html

Use of distributed loading files under Keil

*************************************************************
; Scatter-loading Description File generated by uvision * * *
; *************************************************************

Lr_irom1 0x08000000 0x00004000; Load region size_region First load domain, start address 0x08000000,{size 0x00004000

Er_irom1 0x08000000 0x00004000; Load address = Execution Address First run-time domain,

{Start 0x08000000, size 0x00004000

*.O (RESET, +first) IAP first stage or run in Flash
* (inroot$ $Sections)
startup_stm32f10x_md.o
}
Er_irom2 0x20008000 0x00004000; Load address = Execution Address second run-time domain,

{Start 0x20008000, size 0x00004000

. Any (+ro) IAP second stage loaded into SDRAM run
}
Rw_iram1 0x20000000 0x00008000; RW data puts both read-write and data initialized to 0 at the beginning of the memory SDRAM

{

. Any (+RW +zi)
}
}

Let MDK himself assign--Choose Linker-usexxx


The concept of decentralized loading is clearly described in the 11th chapter of the ARM architecture and programming book.

The scatter-loaded file (that is, the scatter file suffix. scf) is a text file that specifies the file by writing a scatter-loading
How the ARM connector allocates the storage address for data such as Ro,rw,zi when generating an image file. If you do not specify the scatter file, then
The ARM connector will generate the image file by default, and in general we do not need to use distributed loading files.

But on some occasions, we want to put some data at the designated address, then the scatter file plays a very important role.
and scatter files are very easy to use.

For example: like LPC2378 chip with a plurality of discontinuous SRAM, the general Ram is 32KB, but 32KB is not enough, I want to
A. The RW data in C is placed in the USB SRAM, then this function can be done through the scatter file.
Here is a description of this example:


This is a standard commonly used distributed loading file, now annotated in the later, easy to review:
;******************************************************************************
;
; Scatter LOADING DEION
; Arm
; KEIL ' s UVision3
; (RealView microprocessor Developer Kit)
;
; Filename:LPC2378_Flash.scat
;******************************************************************************

Lr_irom1 0x00000000 0x00080000; First load domain, name lr_irom1, start
{                  ;; The address is 0x0 and the size is 0x80000
Er_irom1 0x00000000 0x00080000; Load the run-time domain in the domain with the name er_irom1
{;; Start address is 0x0, size is 0x80000
VECTORS.O (VECT, +first); Code in file VECTORS.O generated after compiling VECTORS.C
INIT.O (INIT);; And the code in INIT.O.
* (+ro); And all the code that compiles the generated RO property is stored in the
} ;; Run-time domain er_irom1 specified address range, storage method: Sequential storage

Rw_iram1 0x40000000 0x0000e800; This is the second run-time domain, which functions as above
{ ;; where * is the entire data representing the property specified in the ()
* (+rw,+zi); Similar to * features. Any, explained later
} ;; The following declarations select the "Region model";

;; A default __user_initial_stackheap () would be used;
Arm_lib_heap 0x40007000 EMPTY 0x00000100 {};; Specify the stack address
Arm_lib_stack 0x40008000 empty-0x00000e00 {}
}


The following is a configuration for data Ram usage for LPC2378 USB SRAM:

;******************************************************************************
;
; Scatter LOADING DEION
; Arm
; KEIL ' s UVision3
; (RealView microprocessor Developer Kit)
;
; Filename:LPC2378_Flash.scat
;******************************************************************************

Lr_irom1 0x00000000 0x00080000; First load domain, name lr_irom1, start
{                  ;; The address is 0x0 and the size is 0x80000
Er_irom1 0x00000000 0x00080000; Load the run-time domain in the domain with the name er_irom1
{;; Start address is 0x0, size is 0x80000
VECTORS.O (VECT, +first)
INIT.O (INIT)
* (+ro)
}

RW_IRAM1 0x40000000 0x0000e800
{
. Any (+rw,+zi);; Here. Any replaces the original * because one of the following execution domains specifies the storage address for the Rw,zi data in the specified module
;; Use. Any to exclude data that has been specified with the Rw,zi attribute
} ;; The following declarations select the "Region model";

3 distributed load files were found to analyze:

1, 7x256 FLASH.SCT distributed loading file:

Load_region 0x100000 0x40000 {//ro start address is 0x100000, size is 0x40000

Fixed_region 0x100000 0x40000 {
* (Cstartup +first)
. Any (+ro)
}

Relocate_region 0x200000 {//rw and Zi segment addresses are 0x200000

*.O (VECTOR, +first)
. Any (+RW +zi)
}

Arm_lib_heap 0x20e000 EMPTY 0x1000 {
}

Arm_lib_stack 0x210000 empty-0x1000 {
}
}

2. sram.sct file

Load_region 0x200000 0x10000 {

Fixed_region 0x200000 {
*.O (VECTOR, +first)
. Any (+ro)
}

Relocate_region +0 {
* (Cstartup +first)
. Any (+RW +zi)
}

Scatterassert ((Imagelength (fixed_region) + imagelength (relocate_region)) < 0xe000)

Arm_lib_heap 0x20e000 EMPTY 0x1000 {
}

Arm_lib_stack 0x210000 empty-0x1000 {
}
}

3. Custom SRAM.SCT

Lr_irom1 0x00200000 0x00008000 {; load region size_region
Er_irom1 0x00200000 0x00008000 {; Load address = execution address//load domain equals run domain
*.O (RESET, +first)
* (inroot$ $Sections)
. Any (+ro)
}
Rw_iram1 0x00208000 uninit 0x00008000 {; RW data//rw and Zi segments
. Any (+RW +zi)
}
}

What is distributed loading file here is not to repeat.

The first two scattered loading files are copied from other places, used in their own programs may be problematic, because if you do not modify it, it fixed the load address and run the address, if the program is simple and relatively small words may not be a problem, but if the program code is relatively large, Exceeding the definition size of the two loaded files can be problematic, and the workaround is simple, modify the. sct file directly until it is appropriate for your code.

A better way is to define a distributed load file yourself, tick the use Memory Layout from Target Dialog in Keil, then the load file is from the address you define Irom and Iram, If unchecked, it is loaded by your own specified load file.

If the distributed loading file is not correct, the problem is that it is clearly in the SRAM debugging program, but can magically download through Flash downloader to flash, just start is puzzled, and later found to be scattered loading files have errors, I used a specified FLASH.SCT distributed load file, so that I set the Irom and Iram are not valid, the compiler directly according to my assigned FLASH.SCT to distribute code and load code, and then see the FLASH.SCT file is loaded into the flash address space, which is why the J Link-sram project can also be burned by flash downloader tools to write code to flash in the reason

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.