S3C6410 uboot re-engineering (5) Setting up the stack and jumping to the C entry

Publisher:清新家园Latest update time:2024-09-02 Source: cnblogsKeywords:S3C6410  uboot Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere

Get straight to the point


1. Set up the stack


1 skip_hw_init:

2 /* Set up the stack */

3 stack_setup:

4 ldr r0, =CONFIG_SYS_UBOOT_BASE /* base of copy in DRAM */

//0x57e0_0000

5 sub r0, r0, #CONFIG_SYS_MALLOC_LEN /* malloc area */

//#define CONFIG_SYS_MALLOC_LEN (CONFIG_ENV_SIZE + 1024 * 1024)

//#define CONFIG_ENV_SIZE 0x4000

// Subtract the size of the environment variable storage area

6 sub r0, r0, #CONFIG_SYS_GBL_DATA_SIZE /* bdinfo */

//#define CONFIG_SYS_GBL_DATA_SIZE 128

// Subtract the size of the global variable storage area

7 sub sp, r0, #12 /* leave 3 words for abort-stack */

//Leave 12 bytes (3 words) of stack space

8


I personally do not trust this code, because I have also referred to the code of s3c-uboot1.1.6.


In the code of s3c-uboot1.1.6, #ifdef considers more comprehensive and more logical basis.


Therefore, this time we only analyze and produce a set of codes that can successfully run various basic functions, but in later practical use, this set of codes will not be used as long-term support code to avoid encountering unknown bugs.


2. Clear the BSS (Block Started by Symbol) segment


9 clear_bss:

10 ldr r0, _bss_start /* find start of bss segment */

11 ldr r1, _bss_end /* stop here */

12 mov r2, #0 /* clear */

//The comments are very clear... I won't explain them anymore

13

14 clbss_l:

15 str r2, [r0] /* clear loop... */

16 add r0, r0, #4 // loop to clear bss

17 cmp r0, r1

18 ble clbss_l

19

20 #ifndef CONFIG_NAND_SPL

21 ldr pc, _start_armboot // C entry function, selected after the IRQ interrupt processing code analysis

twenty two

23 _start_armboot:

24.word start_armboot

25 #else

26 b nand_boot

27 /* .word nand_boot*/

28 #endif


At this point, the analysis of the assembly interface code is complete, and the next step is the analysis of start_armboot in C language.


To summarize the structure in start.S, I personally think that the original code structure is clearer.


In uboot2010, the code structure tends to place several addressing operations in start.S, and other operations in lowlevel_init.


However, uboot1.1.6 pays more attention to the use of #ifdef, which separates more setting items.


Personally, I think 2010 has better logic and 1.1.6 is easier to debug.


Keywords:S3C6410  uboot Reference address:S3C6410 uboot re-engineering (5) Setting up the stack and jumping to the C entry

Previous article:S3C6410 uboot re-engineering (6) abnormal interrupt handling
Next article:S3C6410 uboot re-engineering (4) enabling MMU

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号