【问题标题】:Linux: boot arguments with U-Boot and Flat Image Tree (FIT)Linux:使用 U-Boot 和平面映像树 (FIT) 的引导参数
【发布时间】:2014-12-24 22:16:50
【问题描述】:

我正在尝试构建自己的 U-Boot 以在 Jetson TK1 板上启动 Linux。当我们推动验证启动时,我使用平面映像树(统一内核映像、设备树 blob ......)来描述我的系统。 U-Boot 可以加载 ITB 文件并尝试启动内核,但出现此消息后系统挂起。

我认为这是因为没有将引导参数传递给内核(最初的启动添加了大量参数),但我对如何将参数传递给内核有点傻眼。我尝试设置 bootargs 环境变量,但这并没有改变这种情况。

使用 ITB 文件时如何将内核参数传递给内核?

命令行参数(取自示例 extlinux.conf 的 APPEND 命令):

console=ttyS0,115200n8 console=tty1 no_console_suspend=1 
lp0_vec=2064@0xf46ff000 video=tegrafb mem=1862M@2048M memtype=255 ddr_die=2048M@2048M 
section=256M pmuboard=0x0177:0x0000:0x02:0x43:0x00 vpr=151M@3945M tsec=32M@3913M 
otf_key=c75e5bb91eb3bd947560357b64422f85 usbcore.old_scheme_first=1 core_edp_mv=1150 
core_edp_ma=4000 tegraid=40.1.1.0.0 debug_uartport=lsport,3 power_supply=Adapter 
audio_codec=rt5640 modem_id=0 android.kerneltype=normal usb_port_owner_info=0 
fbcon=map:1 commchip_id=0 usb_port_owner_info=0 lane_owner_info=6 emc_max_dvfs=0 
touch_id=0@0 tegra_fbmem=32899072@0xad012000 board_info=0x0177:0x0000:0x02:0x43:0x00 
root=/dev/mmcblk0p1 rw rootwait tegraboot=sdmmc gpt

ITS 文件内容:

/dts-v1/;

/ {
    description = "Simple image with single Linux kernel and FDT blob";
    #address-cells = <1>;

    images {
        kernel@1 {
            description = "Vanilla Linux kernel";
            data = /incbin/("./zImage");
            type = "kernel";
            arch = "arm";
            os = "linux";
            compression = "none";
            load = <0x81008000>;
            entry = <0x81008000>;
            hash@1 {
                algo = "crc32";
            };
            hash@2 {
                algo = "sha1";
            };
        };
        fdt@1 {
            description = "Flattened Device Tree blob";
            data = /incbin/("./tegra124-pm375.dtb");
            type = "flat_dt";
            arch = "arm";
            compression = "none";
            hash@1 {
                algo = "crc32";
            };
            hash@2 {
                algo = "sha1";
            };
        };
    };

    configurations {
        default = "conf@1";
        conf@1 {
            description = "Boot Linux kernel with FDT blob";
            kernel = "kernel@1";
            fdt = "fdt@1";
        };
    };
};

U-Boot 输出:

Tegra124 (Jetson TK1) # fatload mmc 1 0x90000000 /kernel_fdt.itb
reading /kernel_fdt.itb
5946200 bytes read in 497 ms (11.4 MiB/s)
Tegra124 (Jetson TK1) # bootm 0x90000000
## Loading kernel from FIT Image at 90000000 ...
   Using 'conf@1' configuration
   Verifying Hash Integrity ... OK
   Trying 'kernel@1' kernel subimage
     Description:  Vanilla Linux kernel
     Type:         Kernel Image
     Compression:  uncompressed
     Data Start:   0x900000ec
     Data Size:    5910168 Bytes = 5.6 MiB
     Architecture: ARM
     OS:           Linux
     Load Address: 0x00000000
     Entry Point:  0x00000000
     Hash algo:    crc32
     Hash value:   c5b4b377
     Hash algo:    sha1
     Hash value:   f001007efe83f563425bfe0659186a32395c946c
   Verifying Hash Integrity ... crc32+ sha1+ OK
## Loading fdt from FIT Image at 90000000 ...
   Using 'conf@1' configuration
   Trying 'fdt@1' fdt subimage
     Description:  Flattened Device Tree blob
     Type:         Flat Device Tree
     Compression:  uncompressed
     Data Start:   0x905a30ac
     Data Size:    34678 Bytes = 33.9 KiB
     Architecture: ARM
     Hash algo:    crc32
     Hash value:   e466b23e
     Hash algo:    sha1
     Hash value:   ec909ae16e62233d0ed1e1f4c909085abc9b5879
   Verifying Hash Integrity ... crc32+ sha1+ OK
   Booting using the fdt blob at 0x905a30ac
   Loading Kernel Image ... OK
   Using Device Tree in place at 905a30ac, end 905ae821

Starting kernel ...

【问题讨论】:

  • 您能否提供控制台输出和当前引导参数,以便我们检查引导停止的位置?

标签: linux-kernel arguments u-boot device-tree


【解决方案1】:

使用设备树时,您仍然使用bootargs 来提供参数。

检查:

  • 您已经编译了树(在 Linux 内核中使用编译器 scripts/dtc/dtc
  • 在内核配置中启用了对设备树的支持(符号 CONFIG_USE_OF)(其中 OF 代表 “开放固件”
  • 您提供了 U-Boot 树的地址:bootm &lt;uImage address&gt; - &lt;dtb address&gt;
  • 设备驱动程序 -> 字符设备 -> 串行驱动程序下的内核配置中启用串行控制台
  • bootargs 中启用了控制台(例如console=ttyS0,115200

【讨论】:

  • 请注意,我使用的是一个镜像树,它将内核镜像、设备树 blob 和其他东西(配置、ramdisk,...)合并到一个文件中。
  • 更好。您是否启用了CONFIG_USE_OFbootargs 中的控制台?
  • 您的 bootargs 中有两个 console=ttyS0,115200n8 console=tty1。检查哪个是正确的(在没有 DTB 的情况下启动机器并检查)并删除错误的。
  • 我必须补充一点,如果在 extlinux.conf 文件中使用它们来在同一块板上启动 Linux,这些引导参数可以工作
  • 同时删除 tty1(因为 tty0 是我正在检索输出的那个)不会改变任何东西:-/
【解决方案2】:

突出的问题是U-Boot输出文本后系统似乎挂了

Starting kernel ...

如果加载了未压缩的内核图像文件,那么接下来会执行实际的内核启动代码。
但是如果一个 uImagezImage 文件已经被加载(它们也被报告为“未压缩”,因为它们是自解压的),那么接下来执行的代码就是解压附加到 zImage 文件的例程。通常这个解压程序会输出诸如

之类的文本
Uncompressing Linux............ done, booting the kernel.

在执行实际的内核启动代码之前,在内核命令行的任何处理之前,在设备树 blob 的任何处理之前,以及内核的任何控制台输出之前(包括 earlyprintk )。


镜像头中指定的内核加载和起始地址之间存在差异

 Load Address: 0x00000000
 Entry Point:  0x00000000

相对于 DT 中指定的内容:

        load = <0x81008000>;
        entry = <0x81008000>;

由于内核映像是临时加载的

## Loading kernel from FIT Image at 90000000 ...

DT 中的地址似乎是正确的,而图像标题中的地址是虚假的。

假设0x00000000处没有物理RAM,结果会是内核镜像被复制(或解压)到虚假的加载地址0,然后内核镜像会跳转到虚假的入口点执行为 0。CPU 可能会在尝试从不存在的内存中执行垃圾时挂起,这与您报告的内容完全相关。

解决方案是 (1) 确认内核链接到正确的地址和 (2) 使用 -a-e 命令选项在 mkimage 命令中指定正确的地址。
这个更正至少应该让你超过这一点。

【讨论】:

    【解决方案3】:

    我遇到了相同或类似的问题。对于这个问题,我的解决方案(或解决方法)是将 U-Boot 环境变量 initrd_high 和 fdt_high 设置为重新定位 U-boot 之前的 RAM 中的地址(在我的情况下为 8effffff)。

    【讨论】:

      猜你喜欢
      • 2013-04-17
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-08-15
      • 2021-07-18
      • 2017-03-23
      • 2018-09-27
      • 2021-03-11
      相关资源
      最近更新 更多