天天看点

【RK3399】【Uboot】 流程分析之常用宏定义说明

1、内核等固件加载地址:ENV_MEM_LAYOUT_SETTINGS,定义如下

./include/configs/rk3399_common.h

58 #define ENV_MEM_LAYOUT_SETTINGS \
 59     "scriptaddr=0x00500000\0" \
 60     "pxefile_addr_r=0x00600000\0" \
 61     "fdt_addr_r=0x08300000\0" \
 62     "kernel_addr_r=0x00280000\0" \
 63     "ramdisk_addr_r=0x0a200000\0"
           

uboot启动log如下:

Booting IMAGE kernel at 0x00280000 with fdt at 0x8300000...

2、PARTS_DEFAULT:默认的GPT分区

include/configs/rockchip-common.h

85 #define PARTS_DEFAULT \                                                                                                                                                                                 
 86     "uuid_disk=${uuid_gpt_disk};" \
 87     "name=loader1,start=32K,size=4000K,uuid=${uuid_gpt_loader1};" \
 88     "name=loader2,start=8MB,size=4MB,uuid=${uuid_gpt_loader2};" \
 89     "name=trust,size=4M,uuid=${uuid_gpt_atf};" \
 90     "name=boot,size=112M,bootable,uuid=${uuid_gpt_boot};" \
 91     "name=rootfs,size=-,uuid="ROOT_UUID
           

3、ROCKCHIP_DEVICE_SETTINGS 外设相关命令,主要是指定 stdio(一般会包含显示模块启动命

令)

include/configs/evb_rk3399.h

29 #define ROCKCHIP_DEVICE_SETTINGS \                                                                                                                                                                      
 30         "stdout=serial,vidconsole\0" \
 31         "stderr=serial,vidconsole\0"
           

4、BOOTENV:distro 方式启动 linux 时的启动设备探测命令

include/config_distro_bootcmd.h

315 #define BOOTENV \
316     BOOTENV_SHARED_HOST \
317     BOOTENV_SHARED_MMC \
318     BOOTENV_SHARED_PCI \
319     BOOTENV_SHARED_USB \
320     BOOTENV_SHARED_SATA \
321     BOOTENV_SHARED_SCSI \
322     BOOTENV_SHARED_IDE \
323     BOOTENV_SHARED_UBIFS \
324     BOOTENV_SHARED_EFI \
325     "boot_prefixes=/ /boot/\0" \
326     "boot_scripts=boot.scr.uimg boot.scr\0" \
327     "boot_script_dhcp=boot.scr.uimg\0" \
328     BOOTENV_BOOT_TARGETS \
329     \
330     "boot_extlinux="                                                  \
331         "sysboot ${devtype} ${devnum}:${distro_bootpart} any "    \
332             "${scriptaddr} ${prefix}extlinux/extlinux.conf\0" \
333     \
334     "scan_dev_for_extlinux="                                          \
335         "if test -e ${devtype} "                                  \
336                 "${devnum}:${distro_bootpart} "           \
337                 "${prefix}extlinux/extlinux.conf; then "  \
338             "echo Found ${prefix}extlinux/extlinux.conf; "    \
339             "run boot_extlinux; "                             \
340             "echo SCRIPT FAILED: continuing...; "             \
341         "fi\0"                                                    \
342     \
343     "boot_a_script="                                                  \
344         "load ${devtype} ${devnum}:${distro_bootpart} "           \
345             "${scriptaddr} ${prefix}${script}; "              \
346         "source ${scriptaddr}\0"                                  \
347     \
348     "scan_dev_for_scripts="                                           \
349         "for script in ${boot_scripts}; do "                      \
350             "if test -e ${devtype} "                          \
351                     "${devnum}:${distro_bootpart} "   \
352                     "${prefix}${script}; then "       \
353                 "echo Found U-Boot script "               \
354                     "${prefix}${script}; "            \
355                 "run boot_a_script; "                     \
356                 "echo SCRIPT FAILED: continuing...; "     \
357             "fi; "                                            \
358         "done\0"                                                  \
359     \
360     "scan_dev_for_boot="                                              \
361         "echo Scanning ${devtype} "                               \
362                 "${devnum}:${distro_bootpart}...; "       \
363         "for prefix in ${boot_prefixes}; do "                     \
364             "run scan_dev_for_extlinux; "                     \
365             "run scan_dev_for_scripts; "                      \
366         "done;"                                                   \
367         SCAN_DEV_FOR_EFI                                          \
368         "\0"                                                      \
369     \
370     "scan_dev_for_boot_part="                                         \
371         "part list ${devtype} ${devnum} -bootable devplist; "     \                                                                                                                                     
372         "env exists devplist || setenv devplist 1; "              \
373         "for distro_bootpart in ${devplist}; do "                 \
374             "if fstype ${devtype} "                           \
375                     "${devnum}:${distro_bootpart} "   \
376                     "bootfstype; then "               \
377                 "run scan_dev_for_boot; "                 \
378             "fi; "                                            \
379         "done\0"                                                  \
380     \
381     BOOT_TARGET_DEVICES(BOOTENV_DEV)                                  \
382     \
383     "distro_bootcmd=" BOOTENV_SET_SCSI_NEED_INIT                      \
384         "for target in ${boot_targets}; do "                      \
385             "run bootcmd_${target}; "                         \
386         "done\0"
           

5、CONFIG_SYS_MALLOC_LEN:malloc 内存池大小

include/config_distro_bootcmd.h

#define CONFIG_SYS_MALLOC_LEN       (192 << 20)

6、CONFIG_SYS_TEXT_BASE:U-Boot 运行的起始地址

#define CONFIG_SYS_TEXT_BASE        0x00200000

7、CONFIG_BOOTCOMMAND:启动命令,一般定义为 RKIMG_BOOTCOMMAND

include/configs/rockchip-common.h

128 #ifdef CONFIG_AVB_VBMETA_PUBLIC_KEY_VALIDATE
129 #define RKIMG_BOOTCOMMAND \
130     "boot_android ${devtype} ${devnum};" \
131     "echo AVB boot failed and enter rockusb or fastboot!;" \
132     "rockusb 0 ${devtype} ${devnum};" \
133     "fastboot usb 0;"
134 #else
135 #define RKIMG_BOOTCOMMAND \
136     "boot_android ${devtype} ${devnum};" \
137     "bootrkp;" \
138     "run distro_bootcmd;"                                                                                                                                                                               
139 #endif
140 #endif
           

8、CONFIG_PREBOOT:预启动命令,在 CONFIG_BOOTCOMMAND 前被执行

9、CONFIG_SYS_MMC_ENV_DEV:MMC 作为 ENV 存储介质时的 dev num,一般是 0

继续阅读