u-boot 挂在 "Uncompressing/Loading Kernel Image"

u-boot hangs at "Uncompressing/Loading Kernel Image"

这是对同一平台 (MIPS VSC7427) 上一个问题 () 的跟进。

我正在尝试启动 Linux 5.11,但 u-boot 在“解压缩内核映像”(gzip 压缩)处挂起:

U-Boot 2019.10 (Mar 28 2021 - 20:41:55 +0000)

MSCC VCore-III MIPS 24Kec
Model: Cisco Meraki MS220-8P
DRAM:  128 MiB
Loading Environment from SPI Flash... SF: Detected mx25l12805d with page size 256 Bytes, erase size 64 KiB, total 16 MiB
OK
In:    serial@10100000
Out:   serial@10100000
Err:   serial@10100000
Net:   
Warning: switch@1010000 (eth0) using random MAC address - f6:22:ff:96:01:2d
eth0: switch@1010000
luton # setenv loadaddr 0x83000000
luton # dhcp
luton # tftp ${loadaddr} vmlinux.gz.itb
Using switch@1010000 device
TFTP from server 192.168.1.60; our IP address is 192.168.1.164
Filename 'vmlinux.gz.itb'.
Load address: 0x83000000
Loading: #################################################################
(snipped)
done
Bytes transferred = 5172240 (4eec10 hex)
luton # bootm 0x83000000
## Loading kernel from FIT Image at 83000000 ...
   Using 'conf@default' configuration
   Trying 'kernel@0' kernel subimage
     Description:  Linux 5.11.11
     Type:         Kernel Image
     Compression:  gzip compressed
     Data Start:   0x830000c0
     Data Size:    5167511 Bytes = 4.9 MiB
     Architecture: MIPS
     OS:           Linux
     Load Address: 0x80100000
     Entry Point:  0x809898f4
     Hash algo:    sha1
     Hash value:   b963ed48f45e332bd5df263dd69d69c3818e6586
   Verifying Hash Integrity ... sha1+ OK
   Uncompressing Kernel Image

尝试启动未压缩的 vmlinux 会导致 u-boot 在“正在加载内核映像”处挂起:

luton # setenv loadaddr 0x83000000
luton # setenv fdtaddr 0x85000000
luton # dhcp
luton # tftp ${loadaddr} vmlinux.bin
luton # tftp ${fdtaddr} ms220.dtb
luton # bootm ${loadaddr} - ${fdtaddr}
## Booting kernel from Legacy Image at 83000000 ...
   Image Name:   Linux 5.11.11
   Image Type:   MIPS Linux Kernel Image (uncompressed)
   Data Size:    11531664 Bytes = 11 MiB
   Load Address: 80100000
   Entry Point:  809898f4
   Verifying Checksum ... OK
## Flattened Device Tree blob at 85000000
   Booting using the fdt blob at 0x85000000
   Loading Kernel Image

我看过 other questions 关于 u-boot 挂在“加载内核映像”的问题,我不相信那里的建议(从不在 DRAM 中的地址读取)适用于我的情况。

Kernel Load Address of 0x80100000 corresponds to CONFIG_SYS_SDRAM_BASE + CONFIG_SYS_LOAD_ADDR defined in u-boot,所以我相当确定我是从 RAM 中的地址加载的。


使用相同版本的 u-boot (2019.10) 我能够启动从供应商的 GPL 源构建的 3.18.123 内核:

luton # tftpboot vmlinuz
Using switch@1010000 device
TFTP from server 192.168.1.60; our IP address is 192.168.1.157
Filename 'vmlinuz'.
Load address: 0x81000000
Loading: #################################################################
(snipped)
done
Bytes transferred = 1578176 (1814c0 hex)
luton # bootm ${load_addr}
## Booting kernel from Legacy Image at 81000000 ...
   Image Name:   Linux 3.18.123
   Image Type:   MIPS Linux Kernel Image (uncompressed)
   Data Size:    1578112 Bytes = 1.5 MiB
   Load Address: 81000000
   Entry Point:  81000000
   Verifying Checksum ... OK
   Loading Kernel Image
[    0.000000] Linux version 3.18.123-meraki-elemental (hmartin@alp) (gcc version 5.4.0 (GCC) ) #36 Tue Apr 14 20:11:18 UTC 2020

(我似乎记得需要将内核加载地址从 0x80100000 更改为 0x81000000 才能使内核解压缩工作,但否则它可以正常启动)


用于为内核 5.11.11 生成 FIT 映像的 its 文件:

/* SPDX-License-Identifier: GPL-2.0 */
/dts-v1/;
/ {
 description = "Linux 5.11.11";
 #address-cells = <1>;
 images {
  kernel@0 {
   description = "Linux 5.11.11";
   data = /incbin/("vmlinux.bin.gz");
   type = "kernel";
   arch = "mips";
   os = "linux";
   compression = "gzip";
   load = /bits/ 32 <0xffffffff80100000>;
   entry = /bits/ 32 <0xffffffff809898f4>;
   hash@0 {
    algo = "sha1";
   };
  };
 };
 configurations {
  default = "conf@default";
  conf@default {
   description = "Generic Linux kernel";
   kernel = "kernel@0";
  };
 };
};
/* SPDX-License-Identifier: (GPL-2.0 OR MIT) */
/ {
 images {
  fdt@luton_pcb091 {
   description = "MSCC Luton PCB091 Device Tree";
   data = /incbin/("boot/dts/mscc/luton_pcb091.dtb");
   type = "flat_dt";
   arch = "mips";
   compression = "none";
   hash@0 {
    algo = "sha1";
   };
  };
 };
 configurations {
  pcb091 {
   description = "Luton Linux kernel";
   kernel = "kernel@0";
   fdt = "fdt@luton_pcb091";
  };
 };
};

尝试以下任一 earlycon 引导参数都无效:

luton # setenv bootargs console=ttyS0,115200 earlycon=uart,mmio,0x10100000 mem=134152192
luton # setenv bootargs console=ttyS0,115200 earlycon=uart,mmio,0x70100000 mem=134152192

(0x10100000ahb section of the kernel dts and in u-boot, 0x70100000 is the UART base address used in the vendor kernel中的uart偏移量)


用于生成未压缩的 5.11 内核映像的 mkimage 命令:

mkimage -A mips -O linux -T kernel -C none -a 0x80100000 -e $(readelf -h vmlinux | grep "Entry point address" | awk '{print }') -n "Linux 5.11.11" -d arch/mips/boot/vmlinux.bin /var/lib/tftpboot/vmlinux.bin

mkimage version 2020.01

我使用 FIT 的经验有限,所以我下面的观察可能是错误的。无论如何,在我看来,您的 ftb 的第一个图像正在被使用,而该图像又具有不包含设备树的配置。您基本上是在加载内核时没有任何有关硬件的信息(例如在何处以及如何访问串行控制台的 uart),对吗?更具体地说,我认为内核需要此处描述的“选择的”节点(例如标准输出路径)https://www.kernel.org/doc/Documentation/devicetree/bindings/chosen.txt

我处于类似情况(开发基于 Vitesse->Microsemi->Microchip,VSC7425 的类似“luton”SoC 的电路板)。使用 u-boot 2021.07 启动 linux 5.9 没有任何问题。再一次,它既不是完全相同的硬件也不是完全相同的软件。

您可以尝试将您的设备树子图像移动到第一个图像中,并将第一个配置替换为第二个中的配置。