About the startup section, interrupt return section, and MISC section in sep4020 arm sample code

Source: Internet
Author: User

It took some time to sort out the code of the bottom layer of the sep4020 sample code and paste your notes for future reference:

 

I. Problems found:

1. The SP of USR is the same as the SP of SYS, so no two SP needs to be defined. The SP is still based on 8 m of SDRAM, but now it is 32 m;
2. In MSR cpsr_cf and R4, only cpsr_c is required;
3. There is a problem with the annotation of pmu_pcsr;
4. Why didn't I return to the user mode after the configuration is complete ??
5. The Code returned for the interruption is messy and has been modified again.
6. heap. S is it too casual to directly define a memory space to get the address. The experience is heap. the heap space obtained by S is 30008000 2xxx, but the general load address of our program is, which means that if malloc has a large space, it will directly overwrite the program. You need to re-manage the stack.
7. stack. S is not required, because the upper limit of the stack has been assigned a value when the system is powered on. C will also find that the stack is not used. s.

 

Ii. About _ user_intial_stackheap () in retarget. c ()

If you are using scatter loading, however, you must retarget
_ User_intial_stackheap () to initialize the stack and heap. An example of how to do
This is in retarget. C.
Printf () is implemented by customizing sendchar () in retarget. C. Therefore, this file is the underlying driver for implementing the printf () function.

_ User_initial_stackheap () must be reimplemented if you are using
Scatter loading. Ensure that you have reimplemented the Function
Correctly and that the new module is linked with your code. Use
Reimplementation provided in the examples directory as a starting point
For your reimplementation.

 

_ User_initial_stackheap () is implemented in _ main, which implements heap and stack for applications. Therefore, our startup code can be divided into two parts:
First, system initialization, including the establishment of the interrupt vector table, clock, storage system initialization, key I/O port initialization, and stack pointer initialization in each processor mode. For example, our common boot_gfd

The second is application initialization (or C library function initialization), including the moving of RW segments and clearing of Zi segments, and the establishment of C Application Stack (_ user_initial_stackheap () function initialization Stack pointer. _ Main function, including our heap. S, stack. S, retarget. c

This point is well described in section 3.5 of the Development Guide.

 

The document says that with the scatf file, we need to use _ user_initial_stackheap for reload. We used this, but only initialized the heap without initializing the stack, the heap address is only obtained by obtaining the address. The stack address is also the address in ESRAM when the system is reset. The heap increases upwards and the stack increases downward, stack should be larger than heap address ??
------ This problem is caused by the problem of the basic file of the previous version, and the basic file after unification does not have this problem.

 

Iii. startup Methods

 

Simple mode:
In fact, the address is the ESRAM address. Simple can be used to merge the boot_gfd and int_gfd files into one. In fact, the system can start from int_gfd. In this case, you need to map ESRAM to the 0 address so that the interrupt can jump there. You can also implement simple in scattered mode as follows:
ESRAM 0x04000000
{
ESRAM 0x04000000
{
Int_gfd.o (INT, + first)
* (+ RO, + RW, + zi)
}

}
If you want to actually burn the content on the board, you need to use bootloader to transfer the content in norflash to ESRAM.

Scattered mode:
Our code is to place the program entry in ESRAM, so we need to locate boot_gfd in ESRAM. Here we do not map ESRAM remap to 0, but map the SDRAM to 0, therefore, the int_gfd is located in 30000000 of SDRAM and the ro rw Zi segment is also mapped here.
Bootloader should also be used if it is installed on the board.

 

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.