简体   繁体   中英

u-boot: cannot boot linux kernel despite kernel being less than maximum BOOTM_LEN

I have a MIPS system (VSC7427) with u-boot and I am trying to boot a more recent kernel than the kernel provided by the vendor in their GPL release (which boots just fine ).

The kernel FIT image appears to be sane, and judging by the output I think it should be bootable:

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 - b2:6b:53:af:2d:a0
eth0: switch@1010000
luton # dhcp
(snipped)
luton # tftp vmlinux.gz.itb
Using switch@1010000 device
TFTP from server 192.168.1.60; our IP address is 192.168.1.154
Filename 'vmlinux.gz.itb'.
Load address: 0x80100000
Loading: #################################################################
(snipped)
done
Bytes transferred = 5172244 (4eec14 hex)
luton # iminfo 0x80100000

## Checking Image at 80100000 ...
   FIT image found
   FIT description: Linux 5.11.11
    Image 0 (kernel@0)
     Description:  Linux 5.11.11
     Type:         Kernel Image
     Compression:  gzip compressed
     Data Start:   0x801000c0
     Data Size:    5167511 Bytes = 4.9 MiB
     Architecture: MIPS
     OS:           Linux
     Load Address: 0x80100000
     Entry Point:  0x809898f4
     Hash algo:    sha1
     Hash value:   b963ed48f45e332bd5df263dd69d69c3818e6586
    Image 1 (fdt@luton_pcb091)
     Description:  MSCC Luton PCB091 Device Tree
     Type:         Flat Device Tree
     Compression:  uncompressed
     Data Start:   0x805edb60
     Data Size:    2851 Bytes = 2.8 KiB
     Architecture: MIPS
     Hash algo:    sha1
     Hash value:   5283ae4322294e594a7be5e6de65e4f039ff36a5
    Default Configuration: 'conf@default'
    Configuration 0 (conf@default)
     Description:  Generic Linux kernel
     Kernel:       kernel@0
    Configuration 1 (pcb091)
     Description:  Luton Linux kernel
     Kernel:       kernel@0
     FDT:          fdt@luton_pcb091
## Checking hash(es) for FIT Image at 80100000 ...
   Hash(es) for Image 0 (kernel@0): sha1+ 
   Hash(es) for Image 1 (fdt@luton_pcb091): sha1+

However, when I attempt to boot the kernel, u-boot gives the following error:

luton # bootm 0x80100000
## Loading kernel from FIT Image at 80100000 ...
   Using 'conf@default' configuration
   Trying 'kernel@0' kernel subimage
     Description:  Linux 5.11.11
     Type:         Kernel Image
     Compression:  gzip compressed
     Data Start:   0x801000c0
     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
Error: inflate() returned -3
gzip compressed: uncompress error -1
Must RESET board to recover

The size of the kernel is well below the limit defined by CONFIG_SYS_BOOTM_LEN (16MB) so I don't believe that is the root cause of this error.

The vmlinux.bin.gz used to generate the itb is a valid gzip archive and the decompressed size is also less than the CONFIG_SYS_BOOTM_LEN limit:

$ file vmlinux.bin.gz
vmlinux.bin.gz: gzip compressed data, max compression, from Unix, original size modulo 2^32 11494800

I have tried creating the itb file using the uncompressed vmlinux.bin (I simply edited vmlinux.its to have data = /incbin/("vmlinux.bin"); and compression = "none"; and the entry address indicated by readelf -h vmlinux ) but I receive the following error when trying to boot:

luton # bootm ${loadaddr}
## Loading kernel from FIT Image at 80100000 ...
   Using 'conf@luton_pcb091' configuration
   Trying 'kernel@0' kernel subimage
     Description:  Linux 5.11.0
     Type:         Kernel Image
     Compression:  uncompressed
     Data Start:   0x801000c0
     Data Size:    11584912 Bytes = 11 MiB
     Architecture: MIPS
     OS:           Linux
     Load Address: 0x80100000
     Entry Point:  0x809898f4
     Hash algo:    sha1
     Hash value:   d13175476fd38269a02a3e85bef53419092c01e1
   Verifying Hash Integrity ... sha1+ OK
## Loading fdt from FIT Image at 80100000 ...
   Using 'conf@luton_pcb091' configuration
   Trying 'fdt@luton_pcb091' fdt subimage
     Description:  img,luton_pcb091 Device Tree
     Type:         Flat Device Tree
     Compression:  uncompressed
     Data Start:   0x80c0c758
     Data Size:    2303 Bytes = 2.2 KiB
     Architecture: MIPS
     Hash algo:    sha1
     Hash value:   daa8a8147bbce692d81383af7b748a763212bb24
   Verifying Hash Integrity ... sha1+ OK
   Booting using the fdt blob at 0x80c0c758
   Loading Kernel Image
ERROR: new format image overwritten - must RESET the board to recover

Looking at bootm_load_os in common/bootm.c it appears that this error is telling me that there is some overlap between the kernel I'm trying to boot and... something, I'm not sure of what.

Here is vmlinux.its generated by kernel 5.11:

/* 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";
  };
 };
};

binwalk doesn't indicate that the gzip data in the ITB is invalid:

$ binwalk vmlinux.gz.itb 

DECIMAL       HEXADECIMAL     DESCRIPTION
--------------------------------------------------------------------------------
0             0x0             device tree image (dtb)
192           0xC0            gzip compressed data, maximum compression, from Unix, last modified: 1970-01-01 00:00:00 (null date)
3960903       0x3C7047        MySQL ISAM compressed data file Version 10
5167968       0x4EDB60        device tree image (dtb)

mkimage version 2020.01 is built by buildroot as part of host-uboot-tools-2020.01


As per the suggestion from Tom Rini, I changed the loadaddr of the FIT image and no longer receive the uncompress error, however the system still does not appear to boot. I've moved this to a follow up question .

The final problem you run in to:

ERROR: new format image overwritten - must RESET the board to recover

is because you've loaded the image in to memory in the same location as the entry point but you need to load it in to memory somewhere else so that U-Boot can unpack the image and put the contents where their load address is set to. Since you have 128MB of memory you should be able to put it at +32 or +64MB from start and then things should work.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM