U-boot Code Analysis

Source: Internet
Author: User

reprint Please specify address: http://blog.csdn.net/zsy2020314/article/details/9824035

1. About the start-up process

1.1 Start-up phase is divided into 3, bl0,bl1,bl2. The following is just the functional aspects of their description, the actual design, it may be the specific functions of the adjustment, that is, the division of these stages is functional, can not see too dead.

Bl0: The factory is cured in the Irom in a section of code, mainly responsible for copying 8kb BL1 to s5pv210 of a 96kb-size internal SRAM (Internal SRAM) run. It is noteworthy that the size of the BL1 supported by the S5PV210 internal SRAM can reach 16KB, and the capacity amplification is made to accommodate the complexity of the bootloder becoming more complex. Even so, the size of the BL1 we make today can still be within 8KB, as well as satisfying demand.

Bl1:u-boot's top 8KB code (s5pv210 also supports 16kb size, for a little mention), in addition to initializing the system clock and some basic hardware, mainly responsible for the implementation of the code to carry out the work (I designed to carry the BL1+BL2, not just BL2), That is, the full U-boot code (BL1+BL2) is read into memory from memory such as NAND flash or MMCSD, and then jumps into memory to run U-boot.

BL2: Complete hardware initialization and load OS into memory, then run OS.

The process descriptions for the above phases are described in detail in the S5pv210_irom_application manual. See Figure 1 below:


Figure 1

1.2 First put the starting part of the code into 3 parts, to start. s mainly, there are also lowlevel_init. S,mem_setup. S,ctr0. S

Which Lowlevel_init. S is primarily a part of the initialization of the hardware, especially the system clock and DRAM. If U-boot is moved into memory, it is necessary to skip the initialization of the clock and DRAM, as this has already been done before handling. And if your code is running in memory while you are initializing DRAM, it will inevitably cause a crash.

Mem_setup. The S:dram initialization code and the MMU related code are placed in this file.

Ctr0. S:u-boot comes with a code file that holds the assembler function main.

1.3 Boot code-related paths in u-boot for several files

Start. S:/arch/arm/cpu/armv7/start. S (need to modify it yourself)

Lowlevel_init. S:/board/samsung/zsy210/lowlevel_init. S (need to modify it yourself)

Mem_setup. S:/board/samsung/zsy210/mem_setup. S (U-boot No, need to add it yourself)

Ctr0. S:/arch/arm/lib/ctr0. S (u-boot, generally do not need to modify)


2. Principle of the starting process

It is important to understand that when the code is moved into DRAM from the storage medium (NAND flash,sd,norflash,onenand, etc.), it jumps into memory to run U-boot and then there is a relocation (relocate_code) process. The Relocate_code child function is at start. S, and the crt0 is the parameter that gives the Relocate_code sub-function. The main sub-function in S. When judging the current u-boot at the low address of memory, then Relocate_code will work, the U-boot code from the low address to the top of the memory address, and then jump to the new location to continue to run U-boot. The destination address of the transport is calculated in the Board_init_f () function (this function is in/ARCH/ARM/LIB/BOARD.C), as shown in Figure 2.


Figure 2


Below, to start. S is the main line, drawing out its program flowchart, the diagram also shows the start of the entire process and the startup code files between the organization. So the back directly post start. S of the complete code, we combine the flow chart can be seen to understand, as to the analysis of the sentence is not the focus of this article. See Figure 3.


Figure 3


3. Start. S Lowlevel_init. S Mem_setup. S crt0. S's complete code.


Start. Full code for S:

[CPP]  View plain copy/*   * armboot - Startup Code for OMAP3530/ARM  cortex cpu-core   *   * Copyright  (c)  2004   Texas  instruments <r-woodruff2@ti.com>   *   * Copyright  (c)  2001    Marius Gröger <mag@sysgo.de>   * Copyright  (c)  2002    Alex Züpke <azu@sysgo.de>   * Copyright  (c)  2002    Gary Jennejohn <garyj@denx.de>   * Copyright  (c)  2003    Richard Woodruff <r-woodruff2@ti.com>   * Copyright  (c)  2003   Kshitij <kshitij@ti.com>   * Copyright  (c)   2006-2008 syed mohammed khasim <x0khasim@ti.com>   *   * See  file&nbSp credits for list of people who contributed to this   *  project.   *   * this program is free software; you can  redistribute it and/or   * modify it under the terms of  the GNU General Public License as   * published by the  Free Software Foundation; either version 2 of   * the  license, or  (at your option)  any later version.   *   *  This program is distributed in the hope that it will  be useful,   * but without any warranty; without even the  implied warranty of   * merchantability or fitness for a  particular purpose.  see the   * gnu general public license for  more details.   *   * You should have received a  copy of the gnu general public license   * along with  this program; if not, write to the free software   *  foundation, inc., 59 temple place, suite 330, boston,   * MA  02111-1307 USA   */      #include  <asm-offsets.h>   #include  <config.h>   #include  <version.h>   #include  <asm/ system.h>  

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.