Compiling error - Kernel source for Raspberry Pi - linux

I am trying to build a Linux kernel version rpi-4.14 for Raspberry Pi on Linux system.
The build is done with cross compiler arm-linux-gnueabihf with the configuration bcm2709_defconfig.
I'm running the command:
make ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- zImage modules dtbs
But I get the following error:
arch/arm/boot/dts/overlays/midi-uart0-overlay.dts:4:39: fatal error: dt-bindings/clock/bcm2835.h: No such file or directory
compilation terminated.
scripts/Makefile.lib:328: recipe for target 'arch/arm/boot/dts/overlays/midi-uart0.dtbo' failed
make[2]: *** [arch/arm/boot/dts/overlays/midi-uart0.dtbo] Error 1
scripts/Makefile.build:587: recipe for target 'arch/arm/boot/dts/overlays' failed
make[1]: *** [arch/arm/boot/dts/overlays] Error 2
arch/arm/Makefile:350: recipe for target 'dtbs' failed
make: *** [dtbs] Error 2
The file dt-bindings/clock/bcm2835.h is in place, so I do not really know what the problem is.

The error is telling you that there is a file missing.
arch/arm/boot/dts/overlays/midi-uart0-overlay.dts:4:39: fatal error: dt-bindings/clock/bcm2835.h: No such file or directory
Check if the directory exists, look for the file you need and change the directory in the Makefile.

In my case it was an erroneous symbolic link under arch/arm/boot/dts/include. The kernel sources have been packed/unpacked by 7z, maybe that was an issue.
Solved it via
ln -s ~/kernel-building/linux-raspberrypi-kernel_1.20170703-2/include/dt-bindings arch/arm/boot/dts/include/dt-bindings
Trying to link in relative to the current directory did not work.

Related

Problems building driver on Linux kernel 5.8.x

I'm working with a Linux driver that is building on v5.7.x kernels but not on the latest v5.8.x releases.
To summarise, most of the driver is pre-built and the kernel interface is built on the target. This involves a make -f Kbuild command.
Having checked all of the relevant kernel interface files for any changes that would affect us, normally the driver would just build as usual on a new kernel. However, this time we get the following error:
make[2]: *** [scripts/Makefile.modpost:111: /path/to/source/Module.symvers] Error 1
make[1]: *** [Makefile:1669: modules] Error 2
make[1]: Leaving directory '/usr/src/kernels/5.8.0-1.el8.elrepo.x86_64'
make: *** [Kbuild:26: default] Error 2
This is from CentOS 8.1, but the same error has been seen on Ubuntu 20.04.
I am no expert on this so interpreting these errors is a bit difficult. I have tried building with the KBUILD_VERBOSE flag and it doesn't really provide any useful information, other than the build succeeding until this point.
On previous kernels the Module.symvers file would be created but empty. On 5.8 this file is not created at all presumably due to this error. As a result, the .ko file is not created.
Finally, if we drop in the source files rather than the pre-built .o files the build does succeed. These .o files are built with a very old version of GCC (4.4.7) but we have also tried building with a much newer version (8.3.1), the same version as the target machine.
I would appreciate suggestions for things to check. Let me know if any other details would help.
Edit:
I ran make on Makefile.modpost manually and got the following output:
sudo make -f ./scripts/Makefile.modpost
WARNING: Symbol version dump "vmlinux.symvers" is missing.
Modules may not have dependencies or modversions.
make -f /scripts/Makefile.modfinal
make[1]: Entering directory '/usr/src/linux-headers-5.8.0-050800-generic'
make[1]: /scripts/Makefile.modfinal: No such file or directory
make[1]: *** No rule to make target '/scripts/Makefile.modfinal'. Stop.
make[1]: Leaving directory '/usr/src/linux-headers-5.8.0-050800-generic'
make: *** [scripts/Makefile.modpost:117: __modpost] Error 2
I am answering my own question in case it helps anyone else with this problem. Although it has never been an issue in the past, we've always had a warning that the corresponding .o.cmd file was not present for our .o_shipped files. This appears to be important in kernel 5.8 onwards and my fix was to add a touch command to the Kbuild file (i.e. "touch .driver.o.cmd"). This does not remove the warning but it allows the driver to build as normal.

kernel compilation error during make modules_install

I was trying to make my raspberry pi more Real-time and I use the PREEMPT_RT.But when sudo make modules_install, an error occurs.
Here are some information about the error.
Any help or suggestions welcome.Thank you~
cp: cannot stat ‘./modules.builtin’: No such file or directory
Makefile:1143: recipe for target '_modinst_' failed
make: *** [_modinst_] Error 1

Linux Kernel Module development compile for other kernel

I'm using LinK+ in other to develop a linux kernel module. My development machine has a Linux Mint 18 installed operating system with kernel version 4.4.xx. For testing I want to deploy the kernel module to a Debian machine(in a virtualbox) which has a kernel version 3.16.xx.
LinK+ has an option called "Compile for other kernel" (see image below)
When I press that button a dialog ask me to point to Kernel Source Location. I've downloaded kernel version 3.16.xx from https://www.kernel.org/ and then pointed to extracted files from that archive.
The output of the make command is this:
**** Build of configuration Debug for project VMDD ****
make --makefile=Makefile --directory=KERN_SRC modules
make: Entering directory '/home/george/linkProjects/VMDD/KERN_SRC'
make -C /home/george/kernels/linux-3.16.43/ M=/home/george/linkProjects/VMDD/KERN_SRC modules
make[1]: Entering directory '/home/george/kernels/linux-3.16.43'
WARNING: Symbol version dump ./Module.symvers
is missing; modules will have no dependencies and modversions.
CC [M] /home/george/linkProjects/VMDD/KERN_SRC/VMDD.o
/bin/sh: 1: ./scripts/recordmcount: not found
scripts/Makefile.build:263: recipe for target '/home/george/linkProjects/VMDD/KERN_SRC/VMDD.o' failed
make[2]: *** [/home/george/linkProjects/VMDD/KERN_SRC/VMDD.o] Error 127
Makefile:1337: recipe for target '_module_/home/george/linkProjects/VMDD/KERN_SRC' failed
make[1]: Leaving directory '/home/george/kernels/linux-3.16.43'
make[1]: *** [_module_/home/george/linkProjects/VMDD/KERN_SRC] Error 2
make: *** [modules] Error 2
Makefile:8: recipe for target 'modules' failed
make: Leaving directory '/home/george/linkProjects/VMDD/KERN_SRC'
What did I do wrong ?
I've downloaded kernel version 3.16.xx from https://www.kernel.org/ and then pointed to extracted files from that archive.
You can't compile modules for some kernel if you have only its original source. You need point IDE to configured and partially build kernel. Actually, all files needed to build modules for some kernel version are in kbuild directory of compiled kernel, installed into /lib/modules/version/kbuild. There are linux-kbuild-version (https://packages.debian.org/jessie/kernel/linux-kbuild-3.16) package with some files https://packages.debian.org/jessie/amd64/linux-kbuild-3.16/filelist and linux-headers-version (https://packages.debian.org/jessie/linux-headers-3.16.0-4-amd64) which includes Module.symvers (https://packages.debian.org/jessie/amd64/linux-headers-3.16.0-4-amd64/filelist):
/usr/src/linux-headers-3.16.0-4-amd64/Module.symvers

Linux 3.13 Kernel Fails to Compile

After configuring various options inside .conf using
$make config
I try to compile the entire linux kernel using
$make
However it throws an error as below:
root#localbox:/LinuxKernel/linux-3.13# make
scripts/kconfig/conf --silentoldconfig Kconfig
***
*** Configuration file ".config" not found!
***
*** Please run some configurator (e.g. "make oldconfig" or
*** "make menuconfig" or "make xconfig").
***
make[2]: *** [silentoldconfig] Error 1
make[1]: *** [silentoldconfig] Error 2
make[1]: Nothing to be done for `all'.
make[1]: Nothing to be done for `relocs'.
make: *** No rule to make target `include/config/auto.conf', needed by `include/config/kernel.release'. Stop.
root#localbox:/LinuxKernel/linux-3.13#
I tried to search for .conf by using:
$find -name ".conf"
However it turns up no results. But since make config worked I assume .config must exist somewhere.
Please advise me on how to overcome this annoying problem. I am doing this for the first time and I am not sure if there are any dependencies that have to be installed before trying to compile the kernel. Your feedbacks are highly appreciated.
There must have been some error with make config, e.g. disk full or you aborted it with Ctrl-C. The .config file (not .conf) is right in the main directory.
The error message says it already
*** Please run some configurator (e.g. "make oldconfig" or
*** "make menuconfig" or "make xconfig").
There are several textbased (config, oldconfig, menuconfig) and graphical (xconfig, gconfig) configuration programs. You might want to pick a graphical one and run it, e.g.
make gconfig
These graphical configurators also help to avoid all the hundreds of irrelevant questions. When you're done selecting the needed options, don't forget to save the .config file and try again compiling the kernel and modules.

Error in compiling the kernel

I am trying to compile linux 3.5.2 kernel. I followed this tutorial
"http://blog.techveda.org/index.php/adding-system-calls-linux-kernel-3-5-x/"
and everything was going perfect.but when I tried to do build the kernel I get this error
here are the commands I used to build my kernel
sudo cp /boot/config-3.5.0-17-generic ./config
make oldconfig
sudo make -j8
the error when I do the make -j8 is:
ERROR: "__modver_version_show" [drivers/staging/rts5139/rts5139.ko] undefined!
WARNING: modpost: Found 2 section mismatch(es).
To see full details build your kernel with:
'make CONFIG_DEBUG_SECTION_MISMATCH=y'
make[1]: *** [__modpost] Error 1
make: *** [modules] Error 2
I really can't find what is the problem it looks like I have a problem with a driver but how could this happen and I am using my old configuration file that is already working. ??
I have met the same problem while compiling kernel 3.2, and solve it by "su -" to root and then recompile.
If you do not need this driver simply mod the config fiel like follows:
CONFIG_RTS5139=n

Resources