Bug 10471

Summary: Building a mipsel kernel format vmlinuz (+ gzip + initrd) generates non-compressed, non-bootable image
Product: buildroot Reporter: Alexander Enchevich <a.enchevich>
Component: OtherAssignee: unassigned
Status: RESOLVED WONTFIX    
Severity: major CC: a.enchevich, buildroot
Priority: P5    
Version: 2017.02   
Target Milestone: ---   
Hardware: PC   
OS: Linux   
Host: Target:
Build:
Attachments: My buildroot's .config file
Kernel .config file
Buildroot defconfig
Kernel's defconfig
patch kernel to compile with buildroot's gcc 4.8.x
Enable kernel gzip compression

Description Alexander Enchevich 2017-10-31 16:16:19 UTC
Created attachment 7376 [details]
My buildroot's .config file

I have sources + images provided by Broadcom for their 7362a0 set top box boards. The kernel image there is has initrd linked in and is:

$ ls -l 
-rw-r--r-- 1  me users  5669240 Sep 20 17:52 vmlinuz-initrd-7362a0

$ file vmlinuz-initrd-7362a0
vmlinuz-initrd-7362a0: gzip compressed data, last modified: Wed Sep 20 14:52:20 2017, max compression, from Unix

So the vmlinuz that works is about 5.7MB, gzipped, with the initrd.

 = = =

When I try generating a vmlinuz kernel in buildroot, however, I am getting a file which is ELF and DOES NOT have the initrd and can not be booted:
-rw-r--r-- 1  me users  8814700 Oct 31 14:04 vmlinuz-from-BR2

$ file vmlinuz-from-BR2 
vmlinuz-from-BR2: ELF 32-bit LSB executable, MIPS, MIPS32 version 1 (SYSV), statically linked, stripped

The reasons I am saying that initrd is not linked in, is because:
a) the vmlinuz image dies very early during the TFTP transfer (packet 8 or 9).
b) because I also tried compiling a vmlinux image+initrd. That one is about 21MB and about 8.8MB stripped and gzipped. I tried booting the gzipped vmlinux and it works fine. I do not yet know the reason why it is so much bigger than Broadcom's original vmlinuz image, but I suppose it is because I linked in various packages to play with - DirectFB, SDL, SDL2, etc...

 = = =

So firstly, it seems that the option 'initial RAM filesystem linked into linux kernel' from the Filesystem images menu is ignored in the case of vmlinuz.

Secondly, I was expecting a gzipped data (not and ELF binary) when option 'Kernel compression format (gzip compression)' is selected (regardless of vmlinux/vmlinuz).
Comment 1 Alexander Enchevich 2017-10-31 16:17:51 UTC
Created attachment 7381 [details]
Kernel .config file
Comment 2 Alexander Enchevich 2017-10-31 16:27:42 UTC
Reading the above perhaps a quick clarification is in order to help understand why I believe the vmlinuz produced by buildroot is significantly smaller then it should be (and hence, IMO, is missing the initial ram disk):

Good vmlinuZ (from Broadcom):
compressed:    6 MB
uncompressed: 13 MB


Good vmlinuX (from buildroot):
compressed:    9 MB
uncompressed: 21 MB


BAD vmlinuZ (from buildroot):
compressed:    9 MB (8.8)
uncompressed:  9 MB (8.7)
Comment 3 Alexander Enchevich 2017-10-31 16:33:33 UTC
Created attachment 7386 [details]
Buildroot defconfig
Comment 4 Alexander Enchevich 2017-10-31 16:34:18 UTC
Created attachment 7391 [details]
Kernel's defconfig
Comment 5 Alexander Enchevich 2017-10-31 16:44:16 UTC
The git repo for Broadcom's stblinux 3.3 is https://github.com/Broadcom/stblinux-3.3.git. However it can not be used as a git URL directly because the kernel is not at the top level but dir down. The version I used is latest at time of filing this bug (tag: stblinux-3.3-4.2).

To make this kernel compile with the standard buildroot gcc compiler and binutils I made a patch, because there was a problem with binutils > v.2.24.51 not being able to mix hard- and softfloat FPU mode/instructions.

Also the the gzip compression option was ignored, for which there is also patch.
Comment 6 Alexander Enchevich 2017-10-31 16:45:38 UTC
Created attachment 7396 [details]
patch kernel to compile with buildroot's gcc 4.8.x
Comment 7 Alexander Enchevich 2017-10-31 16:46:30 UTC
Created attachment 7401 [details]
Enable kernel gzip compression
Comment 8 Thomas Petazzoni 2017-10-31 21:01:47 UTC
Could you reproduce this problem with a MIPS defconfig available in the upstream Linux kernel?

I personally really don't want to debug stuff deep down in the Broadcom BSP.
Comment 9 Thomas Petazzoni 2018-01-10 21:27:12 UTC
The original contributor never came back with a way to reproduce the problem with a reasonable kernel version (i.e not the Broadcom BSP), so let's mark  the bug as WONTFIX.

Do not hesitate to reopen with an easier way to reproduce the problem. Thanks!