Uboot Explanation and Practice-----------(I.)

Source: Internet
Author: User

Boot Loader arm uboot Transplant Phase a theoretical chapter

1.boot Loader tasks to complete:

1. Entry address of the design program

2. Creating an exception interrupt processing vector

3 "Initialize CPU stacks and registers for various modes

4. Various on-chip devices to be used in the initialization system

5 "Initializing the target board

6 "Booting the operating system

implementation flow of 2.boot loader

In Stage1, boot loader mainly completes 5 aspects of work, in turn

1 "Basic hardware initialization

Block all interrupts, set the CPU speed and clock frequency, initialize the memory controller, initialize the serial port, close the CPU internal instruction/data cache

2 "Preparing memory space for loading stage2

For faster run times, stage2 is typically loaded into RAM space, so it is necessary to prepare a range of available RAM space for the stage2 that loads boot loader. Since Stage2 is typically a C-language code execution, you should consider the size of the stack in addition to the size of the stage2 image when considering the size of the space.

3 "Copy stage2 into memory space

When copying, pay attention to two points:

the stage2 executable image holds the start and end addresses of the solid state storage device.

The start address of the memory space

4 "Set stack pointer sp

Because the stack is growing downward, the SP's value is usually set to the top of that 1MB of RAM space.

5 "Jump to Stage2 's entry point

Once all of the above is ready, you can jump to Bootloader's stage2 to execute it.

Stage2 is written in C code, but you cannot use any of the support functions of the GLIBC Library when compiling a connection. The question is, where do I jump into the main function? It is perhaps the most straightforward method to directly place the starting address of the main () function as the entry point for the entire stage2 execution image, but there are two drawbacks to doing so:
Cannot pass function arguments through main () function
Could not handle the return of the main () function
Another method of trampoline (Spring bed) concept, that is, the use of assembly language to write a section of trampoline applet, and the trampoline program as the Stage2 executable image of the execution entry point. The CPU jump instruction can then be used to jump into the main () function in the Trampoline assembly applet, and when the main () function returns, the CPU execution path is clearly returned to the trampoline program. In short, the idea of this approach is to use this trampoline program as the outer parcel of the main () function (external wrapper)

Uboot Explanation and Practice-----------(I.)

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.