第五章之S5PV210将u-boot.bin从SD卡中搬到DDR中

时间:2023-03-08 19:13:02

1,在完成上一节的memory初始化后,接下来在arch/arm/cpu/armv7/start.S的160行:如下图

第五章之S5PV210将u-boot.bin从SD卡中搬到DDR中

2,跳转到arch/arm/lib/board.c下的board_init_f函数,如下图:

第五章之S5PV210将u-boot.bin从SD卡中搬到DDR中

第五章之S5PV210将u-boot.bin从SD卡中搬到DDR中

3,在285行的memset函数,此函数地址在0x3481c8c4,属于在BL2的地址范围。而_start地址在:0x34800000,很明显memset函数超出了BL1的16K的大小范围。

所以必需把BL2搬到DDR中,并且本身跳到DDR中执行BL2中的代码。

4,BL2移到内存中的代码,在光盘裸机代码的src下sdram中,删除了跳转,代码如下

 /*************************************************************************
> File Name: mem_relocate.c
> Author:
> Mail:
> Created Time: Thu 20 Jul 2017 02:42:15 PM CST
>将SD卡中的U-BOOT搬到SDDRAM中
************************************************************************/ typedef unsigned int (*copy_sd_mmc_to_mem) (unsigned int channel, unsigned int start_block, unsigned char block_size, unsigned int *trg, unsigned int init); void copy_code_to_dram(void)
{
unsigned long ch;
unsigned long dest = 0x34800000;
unsigned int sec_no = ; unsigned int ret; ch = *(volatile unsigned int *)(0xD0037488); copy_sd_mmc_to_mem copy_bl2 = (copy_sd_mmc_to_mem) (*(unsigned int *) (0xD0037F98)); if(ch == 0xEB000000)
{
//0:channel 0
//49:源,代码位于扇区49,1 sector = 512 bytes
//dest:目的链接地址0x34800000,
ret = copy_bl2(,sec_no, ,(unsigned int *)dest,);
ret = copy_bl2(,sec_no + ,,(unsigned int *)(dest + 0x10000),);
ret = copy_bl2(,sec_no + ,,(unsigned int *)(dest + 0x20000),);
}
}

5,将上面代码mem_relocate.c放在board/samsung/goni/下.

6,在board/samsung/goni/Makefile中添加上mem_relocate.o。如下图:

第五章之S5PV210将u-boot.bin从SD卡中搬到DDR中

7,在board/samsung/goni/lowlevel_init.S文件,在bl internal_ram_init下一行,添加bl copy_code_to_dram

执行内存初始化后直接将BL2搬到内存中.如图:

第五章之S5PV210将u-boot.bin从SD卡中搬到DDR中

8,将irom中运行中的BL1跳到DDR中运行,在arch/arm/cpu/armv7/start.S改动如下:注掉bl bl board_init_f

第五章之S5PV210将u-boot.bin从SD卡中搬到DDR中

9,修改inculd/configs/s5p_goni.h相关的配置文件

a,第五章之S5PV210将u-boot.bin从SD卡中搬到DDR中

b,第五章之S5PV210将u-boot.bin从SD卡中搬到DDR中

c,第五章之S5PV210将u-boot.bin从SD卡中搬到DDR中

10,make一下,生成如下错误:

第五章之S5PV210将u-boot.bin从SD卡中搬到DDR中

11,修改board/samsung/goni/goni.c。如下图:

第五章之S5PV210将u-boot.bin从SD卡中搬到DDR中

12,接下来再make一下,生成新的u-boot.bin