首页 > 解决方案 > u-boot 在“解压缩/加载内核映像”处挂起

问题描述

这是对同一平台(MIPS VSC7427)上上一个问题( u-boot: cannot boot linux kernel 尽管内核小于最大 BOOTM_LEN )的跟进。

我正在尝试启动 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

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

0x80100000的内核加载地址对应于 u-boot 中定义的CONFIG_SYS_SDRAM_BASE+ ,所以我相当确定我是从 RAM 中的地址加载的。CONFIG_SYS_LOAD_ADDR


使用相同版本的 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为内核解压缩才能工作,但否则它启动就好了)


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

/* 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

(是内核 dts 的 ahb 部分中0x10100000的 uart 偏移量,在u-boot中,是供应商内核中使用的 UART 基地址0x70100000


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

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

mkimage version 2020.01

标签: linuxlinux-kernelmipsu-boot

解决方案


我在使用 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 没有任何问题。再说一次,它不是完全相同的硬件或软件。

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


推荐阅读