您尚未登录。

楼主 #1 2019-04-23 14:54:43

还能这么玩
会员
注册时间: 2019-04-14
已发帖子: 119
积分: 119

zynq u-boot 启动会自动读取 uEnv.txt 的跟踪

arch/arm/mach-zynq/slcr.c 通过电阻跳线在寄存器读出启动 bootstrap 状态:

u32 zynq_slcr_get_boot_mode(void)
{
        /* Get the bootmode register value */
        return readl(&slcr_base->boot_mode);
}

board/xilinx/zynq/board.c 根据读到的启动选项设置环境变量 modeboot:

int board_late_init(void)
{
        switch ((zynq_slcr_get_boot_mode()) & ZYNQ_BM_MASK) {
        case ZYNQ_BM_NOR:
                setenv("modeboot", "norboot");
                break;
        case ZYNQ_BM_SD:
                setenv("modeboot", "sdboot");
                break;
        case ZYNQ_BM_JTAG:
                setenv("modeboot", "jtagboot");
                break;
        default:
                setenv("modeboot", "");
                break;
        }

        return 0;
}

include/configs/zynq-common.h 启动环境变量 preboot

/* enable preboot to be loaded before CONFIG_BOOTDELAY */
#define CONFIG_PREBOOT

include/configs/zynq-common.h 设置其他环境变量, 启动入口是 preboot 这个脚本:

/* Default environment */
#ifndef CONFIG_EXTRA_ENV_SETTINGS
#define CONFIG_EXTRA_ENV_SETTINGS       \
        "fit_image=fit.itb\0"           \
        "load_addr=0x2000000\0"         \
        "fit_size=0x800000\0"           \
        "flash_off=0x100000\0"          \
        "nor_flash_off=0xE2100000\0"    \
        "fdt_high=0x20000000\0"         \
        "initrd_high=0x20000000\0"      \
        "loadbootenv_addr=0x2000000\0" \
        "bootenv=uEnv.txt\0" \
        "bootenv_dev=mmc\0" \
        "loadbootenv=load ${bootenv_dev} 0 ${loadbootenv_addr} ${bootenv}\0" \
        "importbootenv=echo Importing environment from ${bootenv_dev} ...; " \
                "env import -t ${loadbootenv_addr} $filesize\0" \
        "bootenv_existence_test=test -e ${bootenv_dev} 0 /${bootenv}\0" \
        "setbootenv=if env run bootenv_existence_test; then " \
                        "if env run loadbootenv; then " \
                                "env run importbootenv; " \
                        "fi; " \
                "fi; \0" \
        "sd_loadbootenv=set bootenv_dev mmc && " \
                        "run setbootenv \0" \
        "usb_loadbootenv=set bootenv_dev usb && usb start && run setbootenv \0" \
        "preboot=if test $modeboot = sdboot; then " \
                        "run sd_loadbootenv; " \
                        "echo Checking if uenvcmd is set ...; " \
                        "if test -n $uenvcmd; then " \
                                "echo Running uenvcmd ...; " \
                                "run uenvcmd; " \
                        "fi; " \
                "fi; \0" \
        "norboot=echo Copying FIT from NOR flash to RAM... && " \
                "cp.b ${nor_flash_off} ${load_addr} ${fit_size} && " \
                "bootm ${load_addr}\0" \
        "sdboot=echo Copying FIT from SD to RAM... && " \
                "load mmc 0 ${load_addr} ${fit_image} && " \
                "bootm ${load_addr}\0" \
        "jtagboot=echo TFTPing FIT to RAM... && " \
                "tftpboot ${load_addr} ${fit_image} && " \
                "bootm ${load_addr}\0" \
        "usbboot=if usb start; then " \
                        "echo Copying FIT from USB to RAM... && " \
                        "load usb 0 ${load_addr} ${fit_image} && " \
                        "bootm ${load_addr}; fi\0" \
                DFU_ALT_INFO
#endif

离线

楼主 #2 2019-04-23 14:57:40

还能这么玩
会员
注册时间: 2019-04-14
已发帖子: 119
积分: 119

Re: zynq u-boot 启动会自动读取 uEnv.txt 的跟踪

参考这个帖子: https://whycan.cn/t_2297.html

上面有脚本检测到是 sdboot (sd卡启动) 读 首分区的 uEnv.txt, 然后再把这个文件 env import 到到环境变量中去, 完成了从 uEnv.txt 环境配置。

离线

#3 2019-04-23 21:48:20

posystorage
会员
注册时间: 2018-05-06
已发帖子: 170
积分: 561

Re: zynq u-boot 启动会自动读取 uEnv.txt 的跟踪

楼主研究的真深 支持下

离线

页脚

工信部备案:粤ICP备20025096号 Powered by FluxBB

感谢为中文互联网持续输出优质内容的各位老铁们。 QQ: 516333132, 微信(wechat): whycan_cn (哇酷网/挖坑网/填坑网) service@whycan.cn