1

I am having trouble compiling the Raspbian kernel from source.

I used the instructions here: https://www.raspberrypi.org/documentation/linux/kernel/building.md.

I am cross compiling on Ubuntu 16.04 64 bit, and compiling for the Raspberry Pi 2. I have followed all the necessary steps according to the guide.

At the moment, I did not change anything in the kernel source (I want to change out the rtlwifi drivers later like this, but for now, I just want to see if I can compile a kernel.)

The compiling worked, and I uploaded the new kernel to the SD card, also according to the instructions. The RPI boots to the desktop screen, but no peripherals are working. I can SSH into the Pi, but keyboard / mouse are not working. I assume this is a kernel issue, as this is the only thing I have changed since I installed a completely working Raspbian (via the SD card image).

I have seen an error message during start up:

Failed to load kernel modules. 

And then it suggests I should check

systemctl status systemd-modules-load.service

Which returns:

systemd-modules-load.service - Load Kernel Modules
   Loaded: loaded (/lib/systemd/system/systemd-modules-load.service; static; ven
   Active: failed (Result: exit-code) since Thu 2016-11-03 17:16:42 UTC; 1 years
     Docs: man:systemd-modules-load.service(8)
           man:modules-load.d(5)
  Process: 110 ExecStart=/lib/systemd/systemd-modules-load (code=exited, status=
 Main PID: 110 (code=exited, status=1/FAILURE)

Warning: Journal has been rotated since unit was started. Log output is incomple

Any advice on where I am going wrong? Or any ideas on how to debug? Thanks a lot!

EDIT: Thanks to @Gerhard, I realised the command that I install the modules were wrong. It was a simple typo - copy and paste is your friend!

Here is the script then in its working form for whoever would like to use it:

export KERNEL=kernel7
lsblk
sudo mount /dev/sdc1 mnt/fat32
sudo mount /dev/sdc2 mnt/ext4

sudo make ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- INSTALL_MOD_PATH=mnt/ext4 modules_install


sudo cp mnt/fat32/$KERNEL.img mnt/fat32/$KERNEL-backup.img
sudo cp arch/arm/boot/zImage mnt/fat32/$KERNEL.img
sudo cp arch/arm/boot/dts/*.dtb mnt/fat32
sudo cp arch/arm/boot/dts/overlays/*.dtb* mnt/fat32/overlays/
sudo cp arch/arm/boot/dts/overlays/README mnt/fat32/overlays/
sudo umount mnt/fat32
sudo umount mnt/ext4
goldilocks
  • 58,859
  • 17
  • 112
  • 227
  • Is your kernel a monolith containing all modules? Or is there an initrd.img that you didn't transfer to your RPi? In the manual you followed, "sudo make ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- INSTALL_MOD_PATH=mnt/ext4 modules_install" is all on one line. – Gerard H. Pille Mar 06 '18 at 10:34
  • I think it is a monolith as you say (although I am not quite clued up about what that means). I did not copy an initrd.img.

    I did install the modules using the one line as you said above. I put it in a bash script, so it is executed as one line if that answers your question.

    – Daniel Schoonwinkel Mar 06 '18 at 10:48
  • Monolith: all in one. Anyway, the problem on the RPi is that the kernel and the modules (if they are there, verify /lib/modules) do not correspond. Did you overwrite the original kernel or give yours a special name? – Gerard H. Pille Mar 06 '18 at 10:55
  • I simply overwrote the kernel7.img.

    Ok, so any suggestions on how the get the modules and kernel to correspond?

    – Daniel Schoonwinkel Mar 06 '18 at 10:58
  • Verify the contents of /lib/modules. Do you find those corresponding to kernel7.img's release? – Gerard H. Pille Mar 06 '18 at 11:01
  • Ok, I did sudo ls /lib/modules:

    In the the directory is two folders 4.9.59+ and 4.9.59-v7+, where are my compiled kernel is version 4.9.80-v7+.

    Obviously I then need to update the modules to the kernel version. Any ideas how to do that? Sorry for the repeated questions, this is the very first time that I am compiling a kernel

    – Daniel Schoonwinkel Mar 06 '18 at 11:09
  • I've compiled many a kernel, but not a single cross-compile succes as yet. Do you have a log of your "make modules_install".? – Gerard H. Pille Mar 06 '18 at 11:11
  • perhaps you could accept my answer, I could do with a couple of points. – Gerard H. Pille Mar 06 '18 at 12:23
  • I've removed the word "vanilla" here as it seems explicit to me you are not using the real vanilla, you are using "the Raspbian kernel", which is raspberry flavour ;) If that's incorrect feel free to clarify that you are using a source from kernel.org (which is probably a bad idea). – goldilocks Mar 06 '18 at 14:28

1 Answers1

1

Install modules to the correct location! ;-)

Gerard H. Pille
  • 461
  • 2
  • 5