Missing headers for kernel in bzImage loaded on qemu - linux-kernel

I am trying to compile a kernel module of kernel version 3.2.0 on a linux kernel bzImage loaded on a qemu emulator, however I am getting the following error:
/lib/modules/3.2.0/build no such file or directory. I tried to look up solutions over the net but nothing specific related to solve this for a kernel image being loaded over qemu. The command I issue to load the bzImage on qemu is qemu/qemu-system-x86_64 -m 2G -kernel ../linuxkernel/arch/x86/boot/bzImage -hda ../../sid.ext2 -append "root=/dev/sda"

bzImage only contain kernel's image, it doesn't contain files needed for build modules.
You should:
Find kernel headers(with some files built), corresponded to you kernel, and install them to directory, to which /lib/modules/3.2.0/build points.
Or build kernel from the sources by hands. In that case reference /lib/modules/<kernel-version>/build will point to your compiled source files automatically.

Related

How do I get a Linux kernel binary file?

I have downloaded the latest kernel from kernel.org . What I want is to compile it to get the executable file. I need the file to run some commands on it (like strings) to figure what how to identify the linux kernel from its binary file.
All the tutorials on the internet are for upgrading/changing the kernel but I only want the binary file.
I think what you want are vmlinux and *.ko elf files, but you must compile your kernel first. The bzImage is compressed so you cannot run strings on it.

Is it possible to run the rootfs containing kernel and DTB files for a specific board using qemu

Our hardware vendor provides us the yocto based rootfs for a gateway device (ARM softfloat) as a tar file. This file includes kernel image and the DTB files for that board. Is it possible to run this rootfs with no or minimal modifications using qemu? I extracted the tar file and created a CPIO archive (kept kernel image outside) and tried this command :
sudo qemu-system-arm -device virtio-net-pci,netdev=net0,mac=52:54:00:12:34:02 -netdev tap,id=net0,ifname=tap0,script=no,downscript=no -kernel boot/zImage -initrd ../initramfs.gz -machine versatilepb -m 2012
But it just showed blank UI window. Is this not possible?
Or do I need to ask our hardware vendor for a yocto build with MACHINE set as "qemuarm"?
Note: Its OK if QEMU is unable to simulate any hardware from the DTBs
It is highly unlikely that this will work to a sufficient extent. However, your hardware vendor is legally obliged to hand out the sources, and (given some jurisdictional nitpicking) also the the metadata layers used to build the rootfs. So instead of asking then for a favor, just ask for your rights and then build whatever you need to help your development/debugging needs.
NOTE: this might exclude sources to custom applications that they provide. If you intend to use such, it is up for discussion.

Install additional kernel modules

I need pwm-bl.ko kernel module for my Raspberry Pi, but it is not present in my /lib/modules directory. Sure, I can download kernel sources for my kernel version, select necessary modules to build, build and put it into this directory. But how to automate this process? I've found module-assistant utility, but it looks like a list of modules is very limited.

analyzing crash dumps with debian kernel packages

I’m trying to analyze a Linux kernel crash dump. The kernel was built out of 4.4.77 tree with some custom packages on top of that. The command to build the kernel was make-kpkg kernel_image debug_image, producing in 2 different debian packages. The idea is that the first package runs in production, the second package can be utilized for debugging if a problem is detected. So the “kernel_image” package was installed, configured for collecting crashes per instructions, ran, crashed and wrote a crash dump file.
I am using crash utility to analyze the dump. Running
crash vmlinux file.dump
for vmlinux file uncompressed per instructions outputs
crash: vmlinux: no .gnu_debuglink section
crash: vmlinux: no debugging data available
Installing the “debug_image” package does not change that.
I noticed that the “debug-image” package contains its own vmlinux file; it is placed in /usr/lib/debug/lib/modules/4.4.77+/ upon installation. Running
crash /usr/lib/debug/lib/modules/4.4.77+/vmlinux file.dump
Outputs
WARNING: kernels compiled by different gcc versions:
/usr/lib/debug/lib/modules/4.4.77+/vmlinux: (unknown)
dump.201802261029 kernel: 4.8.4
WARNING: kernel version inconsistency between vmlinux and dumpfile
crash: incompatible arguments:
/usr/lib/debug/lib/modules/4.4.77+/vmlinux is not SMP -- dump.201802261029 is SMP
What am I missing? Is it possible to analyze the the dump from “kernel_image” utilizing the info available in “debug_image” package?
Update: Apparently the system had a makedumpfile binary being too old for 4.4 kernels. At some point in the past the system's kernel was updated from 3.something to 4.4 but all user-mode binaries stayed as they were. That somehow caused an invalid crash dump. I could not just apt-get install newer makedumpfile (part of kdump-tools package) due to binary incompatibilities. The problem has been resolved after I re-built makedumpfile binary v 5.9 in the same dev environment as the one used to build user-mode applications for the system. Summarizing, pointing crash to vmlinux file from "debug-image" package worked for me at the end.

how to build linux kernel in OpenWrt distribution

I make a modification in linux kernel of OpenWrt and then I compile the new (kernel) with command :
make target/linux/compile V=99
but I don't found the new image under
build_dir\linux-x86_generic\linux-3.3.8
in order to upgrade the kernel in my OpenWrt running in VM VirtuaBox
how to proceed to get the new kernel and upgrade the Openwrt ?
I am a bit puzzled by the fact you are looking at the linux-x86 folder since with openWRT you usually cross-compile everytime, or at least I've never used it for not cross compilations.
What are you compiling for ?
You should see a build/$TARGET folder with a linux-x-x directory in it where the linux kernel was compiled.

Resources