九鼎创展论坛

标题: 关于uboot基地址 = 0x33e00000 的问题 [打印本页]

作者: laotang365    时间: 2014-11-15 14:16
标题: 关于uboot基地址 = 0x33e00000 的问题
本帖最后由 laotang365 于 2014-11-15 14:18 编辑

本帖讨论在usb启动模式中,uboot为何能在能在0x23e00000地址处运行。

先从nand启动模式说起。
x210因为只有512MB内存,nand启动模式下,初始化后内存物理地址空间为0x3000 0000 ~ 0x4FFF FFFF。
在x210_nand.h中有代码基址的定义:

#define MEMORY_BASE_ADDRESS        0x30000000

/* base address for uboot */
#ifdef CONFIG_ENABLE_MMU
#define CFG_UBOOT_BASE                0xc3e00000
#else
#define CFG_UBOOT_BASE                0x33e00000  /*yan*/
//#define CFG_UBOOT_BASE                0x23e00000  /*yan*/
#endif

#define CFG_PHY_UBOOT_BASE        MEMORY_BASE_ADDRESS + 0x3e00000
#define CFG_PHY_KERNEL_BASE        MEMORY_BASE_ADDRESS + 0x8000

一、nand启动
上电启动后,加载运行BL1,初始化硬件后,执行uboot中的 copy_uboot_to_ram 函数:
int copy_uboot_to_ram (void)
{
        int large_block = 0;
        int i;
        vu_char id;

        int rv;

        NAND_CONTROL_ENABLE();
        NAND_ENABLE_CE();
        NFCMD_REG = NAND_CMD_READID;
        NFADDR_REG =  0x00;

        /* wait for a while */
        for (i=0; i<200; i++);
        id = NFDATA8_REG;
        id = NFDATA8_REG;

        if (id > 0x80)
                large_block = 1;
        else
                return -1;        // Do not support small page (512B) any more

        /* read NAND blocks */
        rv = nandll_read_blocks(CFG_PHY_UBOOT_BASE, COPY_BL2_SIZE);

#if defined(CONFIG_SECURE_BOOT)
        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 != SB_OK)
                while(1);
#endif

        return rv;
}
这里拷贝从nand flash 拷贝 uboot.bin到0x33e0 0000,大小为COPY_BL2_SIZE = 0x80000。

那么问题来了,nand启动时uboot 在0x33e0 0000处运行,然而,首次下载uboot时,使用dnw下载uboot.bin到0x23e0 0000,此时uboot位于0x23e0 0000,运行地址如何对应得上?不同的物理地址能运行同一个uboot?
我猜测是因为启用了MMU的关系.
在start.S中,配置MMU的代码如下
after_copy:

#if defined(CONFIG_ENABLE_MMU)
enable_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 the MMU */

首先利用_mmu_table_base和0xfff00000进行位清除,得到当前uboot运行状态下,_mmu_table_base的低地址,存到r0。   r1存放CFG_PHY_UBOOT_BASE
CFG_PHY_UBOOT_BASE即0x33e00000和_mmu_table_base低地址进行或运算,得到0x33e_____,存入协处理器的转换表基址。
但依然分析不出代码如何能在0x23e00000运行。







欢迎光临 九鼎创展论坛 (http://bbs.9tripod.com/) Powered by Discuz! X3.2