1_5.1.3_U-boot analysis and use_u-boot analysis source code stage 1_P

Publisher:MysticalWhisperLatest update time:2021-08-19 Source: eefocusKeywords:U-boot Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere

When we wrote bare metal programs before:


Initialization: turn off the watchdog, initialize the clock, and initialize SDRAM;

Copy the program from nand to SDRAM;

Set sp and call C language function;

Continue execution...

As an integrator of bare metal programs, uboot can do all of these, and it also needs to read the kernel and start the kernel.


As analyzed before, uboot will call cpu/arm920t/start.S first when it is powered on. Let's start the analysis from this file.


First it will jump to the reset section.

Then set the CPU to SVC32 mode (supervisory mode) and turn off the watchdog.

insert image description here
insert image description here

The fourth step is to set the clock. The video uses function calls, but I used assembly after patching locally. I won’t go into details here, just focus on understanding.

insert image description here
insert image description here
insert image description here
insert image description here
insert image description here

From here, we can see how the stack is divided. Starting from 0x33F80000, it is followed by the heap, bdinfo, interrupt stack, and 3-byte interrupt stack. Among them, the memory from 0x33F80000 to 0x34000000 is uboot, which has 512 bytes.

Then the clock initialization function is called.

insert image description here
insert image description here

Then relocate the code to the link address.

insert image description here

Finally, the start_armboot function is called, which is a C language function, and more complex functions are implemented in it.

Analyzing from top to bottom, start.S does the following:


Set to SVC mode;

Close the watchdog;

Shield interrupts;

Initialize SDRAM;

Set up the stack;

Clock configuration;

Relocation, copy the code from Flash to SDRAM;

Clear the bss segment (global variables and static variables whose initial value is 0 or uninitialized);

Call start_armboot;

The above are all hardware-related initializations. The last step is a C function. More complex functions are implemented in this function. 1 to 8 are called the first stage, and the second stage is after start_armboot.

Keywords:U-boot Reference address:1_5.1.3_U-boot analysis and use_u-boot analysis source code stage 1_P

Previous article:1_5.1.2_U-boot analysis and use_u-boot analysis Makefile structure analysis_P
Next article:1_5.1.5_U-boot analysis and use_u-boot analysis u-boot command implementation_P

Latest Microcontroller Articles
Change More Related Popular Components

EEWorld
subscription
account

EEWorld
service
account

Automotive
development
circle

About Us Customer Service Contact Information Datasheet Sitemap LatestNews


Room 1530, 15th Floor, Building B, No.18 Zhongguancun Street, Haidian District, Beijing, Postal Code: 100190 China Telephone: 008610 8235 0740

Copyright © 2005-2024 EEWORLD.com.cn, Inc. All rights reserved 京ICP证060456号 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号