当前位置:网站首页>Start of u-boot S analysis (III)
Start of u-boot S analysis (III)
2022-06-12 23:44:00 【Cheap sword】
Reset stack
/* get ready to call C functions */
ldr sp, _TEXT_PHY_BASE /* setup temp stack pointer */
sub sp, sp, #12
mov fp, #0 /* no previous frame, so fp=0 */
- stay u-boot And start.S analysis ( One ) We have set the stack address in the last part of the , however
Only less than 8KSize , This is obviously not enough . Because we did not initialize at that time DDR, Therefore, the stack can only be set to the interior that does not need initialization IRAM in . Now we have DDR Initialization is done , So you need to move the stack back to DDR in , This avoids the risk of stack overflow _TEXT_PHY_BASERefer to uboot The base address of the code segment's physical address , Finally, I found its source ( as follows )
- start.S The beginning of the is
CFG_PHY_UBOOT_BASEThe macro definition of , But because we definedCONFIG_ENABLE_MMU, So this is aboutCFG_PHY_UBOOT_BASEStatements defined by macros do not work .
#ifndef CONFIG_ENABLE_MMU
#ifndef CFG_PHY_UBOOT_BASE
#define CFG_PHY_UBOOT_BASE CFG_UBOOT_BASE
#endif
#endif
- Finally, the definition is found in the header file , So the final value is 0x33e00000, In our DRAM0 Inside
#define MEMORY_BASE_ADDRESS 0x30000000
#define CFG_PHY_UBOOT_BASE MEMORY_BASE_ADDRESS + 0x3e00000

- Here, the address of the stack is located at 0x33e00000, because MMU The relationship between , The address is
TEXT_BASEDefined snippet address0xc3e00000(u-boot Memory address mapping ). because ARM yes Full reduction stack , So the stack goes down from the high address , So there is no impact on the code snippet .
Determine if relocation is required
/* when we already run in ram, we don't need to relocate U-Boot. * and actually, memory controller must be configured before U-Boot * is running in ram. */
ldr r0, =0xff000fff
bic r1, pc, r0 /* r0 <- current base addr of code */
ldr r2, _TEXT_BASE /* r1 <- original base addr in ram */
bic r2, r2, r0 /* r0 <- current base addr of code */
cmp r1, r2 /* compare r0, r1 */
beq after_copy /* r0 == r1 then skip flash copy */
- Determine whether the running address is in SRAM still DDR in , To carry on uboot The repositioning of .
- Cold start uboot The previous part of the boot automatically starts from SD The card is loaded into SRAM Run in ,uboot Part two ( It's actually the whole uboot) Still in SD In the card .
- All you have to do here is load the second part into DDR At the link address of (0x33e00000).
SD Card device judgment
#if defined(CONFIG_EVT1)
/* If BL1 was copied from SD/MMC CH2 */
ldr r0, =0xD0037488
ldr r1, [r0]
ldr r2, =0xEB200000
cmp r1, r2
beq mmcsd_boot
#endif
- 0xD0037488 Address from
《S5PV210_iROM_ApplicationNote_Preliminary_20091126.pdf》file , The value in this address indicates from which SD Card address enabled .

- SDMMC0,1,2 The starting addresses of the devices are 0xEB00_0000,0xEB10_0000,0xEB20_0000
- therefore
cmp r1, r2Is to detect whether from the outside SD Card activation - The code eventually enters
mmcsd_bootPerform relocation
relocation
void movi_bl2_copy(void)
{
ulong ch;
#if defined(CONFIG_EVT1)
ch = *(volatile u32 *)(0xD0037488);
copy_sd_mmc_to_mem copy_bl2 =
(copy_sd_mmc_to_mem) (*(u32 *) (0xD0037F98));
#if defined(CONFIG_SECURE_BOOT)
ulong rv;
#endif
#else
ch = *(volatile u32 *)(0xD003A508);
copy_sd_mmc_to_mem copy_bl2 =
(copy_sd_mmc_to_mem) (*(u32 *) (0xD003E008));
#endif
u32 ret;
if (ch == 0xEB000000) {
ret = copy_bl2(0, MOVI_BL2_POS, MOVI_BL2_BLKCNT,
CFG_PHY_UBOOT_BASE, 0);
#if defined(CONFIG_SECURE_BOOT)
/* do security check */
rv = Check_Signature( (SecureBoot_CTX *)SECURE_BOOT_CONTEXT_ADDR,
(unsigned char *)CFG_PHY_UBOOT_BASE, (1024*512-128),
(unsigned char *)(CFG_PHY_UBOOT_BASE+(1024*512-128)), 128 );
if (rv != 0){
while(1);
}
#endif
}
else if (ch == 0xEB200000) {
ret = copy_bl2(2, MOVI_BL2_POS, MOVI_BL2_BLKCNT,
CFG_PHY_UBOOT_BASE, 0);
#if defined(CONFIG_SECURE_BOOT)
/* do security check */
rv = Check_Signature( (SecureBoot_CTX *)SECURE_BOOT_CONTEXT_ADDR,
(unsigned char *)CFG_PHY_UBOOT_BASE, (1024*512-128),
(unsigned char *)(CFG_PHY_UBOOT_BASE+(1024*512-128)), 128 );
if (rv != 0) {
while(1);
}
#endif
}
else
return;
if (ret == 0)
while (1)
;
else
return;
}
- The code ends up executing a long jump statement
bl movi_bl2_copyperform C Language program , After searching , This function is located incpu/s5pc11x/movi.cIn file
Memory management unit (MMU)
/* enable domain access */
ldr r5, =0x0000ffff
mcr p15, 0, r5, c3, c0, 0 @load domain access register
/* Set the TTB register */
ldr r0, _mmu_table_base
ldr r1, =CFG_PHY_UBOOT_BASE
ldr r2, =0xfff00000
bic r0, r0, r2
orr r1, r0, r1
mcr p15, 0, r1, c2, c0, 0
/* enable domain access */
ldr r5, =0x0000ffff
mcr p15, 0, r5, c3, c0, 0 @load domain access register
/* Set the TTB register */
ldr r0, _mmu_table_base
ldr r1, =CFG_PHY_UBOOT_BASE
ldr r2, =0xfff00000
bic r0, r0, r2
orr r1, r0, r1
mcr p15, 0, r1, c2, c0, 0
/* Enable the MMU */
mmu_on:
mrc p15, 0, r0, c1, c0, 0
orr r0, r0, #1
mcr p15, 0, r0, c1, c0, 0
- MMU Unit in CP15 Control in coprocessor , So we have to do something about cp15 Coprocessor registers are programmed
- To set the base address of the address translation table (translation table base,TTB) And enable MMU
_mmu_table_baseIs to convert the base address of the table , This last indication ismmu_table, This is inlowlevel_init.Sin- The memory address is mapped to u-boot Memory address mapping Detailed analysis
边栏推荐
- [leetcode] understanding and usage of map[key]+
- dict和set的基本操作
- 2022年危险化学品经营单位安全管理人员考试试题及在线模拟考试
- Dry goods sharing | BitSet application details
- 2022年R2移动式压力容器充装考试题及在线模拟考试
- [opencv learning] small ticket recognition based on perspective transformation and OCR recognition
- Leetcode 890 finding and replacing patterns [map] the leetcode path of heroding
- 如何让矢量瓦片配图神器maputnik支持 geoserver
- Find out the data that can match the keyword key in field 1 or field 2 in the database table. If you want to display the matching data in field 1 first
- Operation of simulation test platform for G3 boiler water treatment test questions in 2022
猜你喜欢

Enterprise wechat H5_ Authentication, H5 application web page authorization login to obtain identity
![[opencv learning] perspective transformation matrix](/img/6e/7a53b257f6baafe8a3ae21cd0fe340.jpg)
[opencv learning] perspective transformation matrix

Theory + practice will help you master the dynamic programming method

〖Kubernetes指南④〗Pod快速入门

Redis实现短信验证码登录

测试平台系列(97) 完善执行case部分

Alien Skin Exposure X7调色滤镜插件,RAW后期处理工具

2022 R2 mobile pressure vessel filling test questions and online simulation test
![[North Asia data recovery] data recovery cases in which the partitions disappear and the partitions are inaccessible after the server reinstalls the system](/img/a9/7726139037860a5f880667cec4b6c2.jpg)
[North Asia data recovery] data recovery cases in which the partitions disappear and the partitions are inaccessible after the server reinstalls the system

Develop a web office suite from scratch (5): mouse hover over text
随机推荐
Access static variables within class in swift
支持Canvas的Leaflet.Path.DashFlow动态流向线
Deep feature synthesis and genetic feature generation, comparison of two automatic feature generation strategies
[redis sentinel] failed listening on port 26379 (TCP) & sentinel mode no response problem solved
Save state when viewpager is used with fragment fragmentpageradapter
VS2015 DLIB 1916 USER_ ERROR__ inconsistent_ build_ configuration__ see_ dlib_ faq_ 1 USER_ ERROR__ inconsiste
Test platform series (97) perfect the case part
测试平台系列(97) 完善执行case部分
leaflet中如何优雅的解决百度、高德地图的偏移问题
Mgr and greatsql resource summary
Abstract methods and abstract classes
Leetcode 890 finding and replacing patterns [map] the leetcode path of heroding
SAP 业务技术平台(BTP) Workflow(工作流)功能介绍
2022年R2移动式压力容器充装考试题及在线模拟考试
AWS lambda: how to store secrets to external APIs- AWS Lambda: How to store secret to external API?
2022 questions d'examen pour le personnel de gestion de la sécurité de l'unit é de gestion des produits chimiques dangereux et examen de simulation en ligne
QT actual combat case (38) -- using qpprocess class to realize the function of starting process
Tsinghua University image source will cause tensorflow GPU installation failure
KConfig
PostgreSQL 中文社区黑龙江分会和辽宁分会成立啦!