Generating the Linux kernel .config file is making the source folder unclean - linux

I am currently trying to rebuild a linux kernel, and I'm experimenting some difficulties.
I have modified the .config using make menuconfig.
...
make[1]: Entering directory '/home/doe/build/linux'
CHK include/config/kernel.release
GEN ./Makefile
CHK include/generated/uapi/linux/version.h
CHK include/generated/utsrelease.h
Using /home/doe/workspace/linux as source for kernel
/home/doe/workspace/linux is not clean, please run 'make mrproper'
in the '/home/doe/workspace/linux' directory.
/home/doe/workspace/linux/Makefile:1027: recipe for target 'prepare3' failed
make[1]: *** [prepare3] Error 1
...
Then I tried to run make mrproper. It works well and deletes my .config file from my build folder. Without surprise I cannot build because a .config file is missing.
I did a make defconfig followed by a make -j 8, just to try to build with some basic config file.
...
HOSTCC scripts/mod/file2alias.o
HOSTLD scripts/mod/modpost
HOSTCC arch/x86/tools/relocs_32.o
HOSTCC arch/x86/tools/relocs_64.o
HOSTCC arch/x86/tools/relocs_common.o
Using /home/doe/workspace/linux as source for kernel
/home/doe/workspace/linux is not clean, please run 'make mrproper'
in the '/home/doe/workspace/linux' directory.
/home/doe/workspace/linux/Makefile:1027: recipe for target 'prepare3' failed
make[1]: *** [prepare3] Error 1
make[1]: *** Waiting for unfinished jobs....
HOSTLD arch/x86/tools/relocs
make[1]: *** wait: No child processes. Stop.
Makefile:152: recipe for target 'sub-make' failed
make: *** [sub-make] Error 2
How am I supposed to build if generating a .config makes the source folder unclean ?

You should check whether the "include/config" directory exists in your kernel source.
The prepare3 target checks the '.config' file and the 'include/config' directory. You could find this by searching "prepare3" in the Makefile

Related

Cross-compiling linux module missing include file

I am having some issues cross-compiling a module for the Raspberry Pi 4.
The compiler used is: aarch64-linux-gnu-.
The kernel used is: linux-5.10.42
And the error during compilation is as follows:
make -C /opt/linux-5.10.42 ARCH=arm64 CROSS_COMPILE=aarch64-linux-gnu- M=/home/x/build/linux-driver-gpio-customled modules
make[1]: Entering directory '/opt/linux-5.10.42'
CC [M] /home/x/build/linux-driver-gpio-customled/customled.o
In file included from ./include/linux/types.h:6,
from ./include/linux/list.h:5,
from ./include/linux/module.h:12,
from /home/x/build/linux-driver-gpio-customled/customled.c:1:
./include/uapi/linux/types.h:5:10: fatal error: asm/types.h: No such file or directory
5 | #include <asm/types.h>
| ^~~~~~~~~~~~~
compilation terminated.
make[2]: *** [scripts/Makefile.build:279: /home/x/build/linux-driver-gpio-customled/customled.o] Error 1
make[1]: *** [Makefile:1821: /home/x/build/linux-driver-gpio-customled] Error 2
make[1]: Leaving directory '/opt/linux-5.10.42'
make: *** [Makefile:5: default] Error 2
So my question is as follows: Where should this file asm/types.h come from? To my knowledge it should be included in the kernel arch/arm64/include/asm/ subdirectory. But it's not. Other architectures, namely x86 have it.
Is there another way to build a module without including linux/module.h that i'm not aware of?
Any help is greatly appreciated.
Got it!
The files are autogenerated, there is a handy make command used to prepare the build environment for out-of-tree kernel modules. What I did was run
make ARCH=arm64 CROSS_COMPILE=aarch64-linux-gnu- modules_prepare
inside the kernel source.
Hope this helps someone with not spending time on such a simple mistake.

Downlgrading linux kernel version in openwrt throws build error

I was trying to downgrade the linux kernel version from 4.4.14(trunk) to 3.18.44.
I made the necessary makefile changes for my target linux system which is ipq806x.
But while building I am getting patch failed error. The build log snippet is given below. Has anyone come across such kind of an error. Please share your comments.
pplying patch platform/301-ARM-qcom-add-Netgear-Nighthawk-X4-R7500-device-tree.patch
patching file arch/arm/boot/dts/Makefile
The next patch would create the file arch/arm/boot/dts/qcom-ipq8064-r7500.dts,
which already exists! Applying it anyway.
patching file arch/arm/boot/dts/qcom-ipq8064-r7500.dts
Hunk #1 FAILED at 1.
1 out of 1 hunk FAILED -- rejects in file arch/arm/boot/dts/qcom-ipq8064-r7500.dts
Patch platform/301-ARM-qcom-add-Netgear-Nighthawk-X4-R7500-device-tree.patch does not apply (enforce with -f)
Makefile:26: recipe for target '/home/guru/punya/trunkpull_24112017/openwrt/build_dir/target-arm_cortex-a9+neon-vfpv4_musl-1.1.16_eabi/linux-ipq806x/linux-3.18.44/.quilt_checked' failed
make[4]: *** [/home/guru/punya/trunkpull_24112017/openwrt/build_dir/target-arm_cortex-a9+neon-vfpv4_musl-1.1.16_eabi/linux-ipq806x/linux-3.18.44/.quilt_checked] Error 1
make[4]: Leaving directory '/home/guru/punya/trunkpull_24112017/openwrt/target/linux/ipq806x'
Makefile:13: recipe for target 'compile' failed
make[3]: *** [compile] Error 2
make[3]: Leaving directory '/home/guru/punya/trunkpull_24112017/openwrt/target/linux'
target/Makefile:21: recipe for target 'target/linux/compile' failed
make[2]: *** [target/linux/compile] Error 2
make[2]: Leaving directory '/home/guru/punya/trunkpull_24112017/openwrt'
target/Makefile:16: recipe for target '/home/guru/punya/trunkpull_24112017/openwrt/staging_dir/target-arm_cortex-a9+neon-vfpv4_musl-1.1.16_eabi/stamp/.target_compile' failed
make[1]: *** [/home/guru/punya/trunkpull_24112017/openwrt/staging_dir/target-arm_cortex-a9+neon-vfpv4_musl-1.1.16_eabi/stamp/.target_compile] Error 2
make[1]: Leaving directory '/home/guru/punya/trunkpull_24112017/openwrt'
/home/guru/punya/trunkpull_24112017/openwrt/include/toplevel.mk:192: recipe for target 'world' failed
make: *** [world] Error 2
From the logs its clear the compilation failed because of patching of dts failed.
If the failed patch file is not required then try the compilation after removing it.

RTEMS compilation and installation error

I am trying to compile RTEMS on Ubuntu 14.04.
I am getting following error while trying run 'make':
Making all in tools/build
make[1]: Entering directory /home/user/development/rtems/b-sis/tools/build'
make all-am
make[2]: Entering directory/home/user/development/rtems/b-sis/tools/build'
make[2]: Leaving directory /home/user/development/rtems/b-sis/tools/build'
make[1]: Leaving directory/home/user/development/rtems/b-sis/tools/build'
Making all in tools/cpu
make[1]: Entering directory /home/user/development/rtems/b-sis/tools/cpu'
Making all in generic
make[2]: Entering directory/home/user/development/rtems/b-sis/tools/cpu/generic'
make[2]: Nothing to be done for all'.
make[2]: Leaving directory/home/user/development/rtems/b-sis/tools/cpu/generic'
make[2]: Entering directory /home/user/development/rtems/b-sis/tools/cpu'
make[2]: Nothing to be done forall-am'.
make[2]: Leaving directory /home/user/development/rtems/b-sis/tools/cpu'
make[1]: Leaving directory/home/user/development/rtems/b-sis/tools/cpu'
Making all in testsuites/tools
make[1]: Entering directory /home/user/development/rtems/b-sis/testsuites/tools'
Making all in generic
make[2]: Entering directory/home/user/development/rtems/b-sis/testsuites/tools/generic'
make[2]: Nothing to be done for all'.
make[2]: Leaving directory/home/user/development/rtems/b-sis/testsuites/tools/generic'
make[2]: Entering directory /home/user/development/rtems/b-sis/testsuites/tools'
make[2]: Nothing to be done forall-am'.
make[2]: Leaving directory /home/user/development/rtems/b-sis/testsuites/tools'
make[1]: Leaving directory/home/user/development/rtems/b-sis/testsuites/tools'
Making all in sparc-rtems4.11/c
make[1]: Entering directory /home/user/development/rtems/b-sis/sparc-rtems4.11/c'
Making all in .
make[2]: Entering directory/home/user/development/rtems/b-sis/sparc-rtems4.11/c'
make[2]: Nothing to be done for all-am'.
make[2]: Leaving directory/home/user/development/rtems/b-sis/sparc-rtems4.11/c'
Making all in sis
make[2]: Entering directory /home/user/development/rtems/b-sis/sparc-rtems4.11/c/sis'
make[2]: *** No rule to make targetall'. Stop.
make[2]: Leaving directory /home/user/development/rtems/b-sis/sparc-rtems4.11/c/sis'
make[1]: *** [all-recursive] Error 1
make[1]: Leaving directory/home/user/development/rtems/b-sis/sparc-rtems4.11/c'
make: *** [all-recursive] Error 1
Here, is a list of steps I followed:
To install toold I used RSB and ran all commands listed here:
https://devel.rtems.org/wiki/Developer/Tools/RSB
Then I have followed this list of commands:
https://devel.rtems.org/wiki/TBR/UserManual/Quick_Start
In this list, I have tried changing PATH variable = /development/rtems/4.11/bin=$PATH
Other then this everything is done by me following the commands listed here. I have done ./bootstrap -p as well.
You need the toolchain tools. Follow the source builder tutorial before compiling rtems.
1º Clone the tools
git clone git://git.rtems.org/rtems-source-builder.git
2º Check environment
${PATH-rtems-source-builder}/source-builder/sb-check
You must got:
RTEMS Source Builder - Check, 4.11 (6b0d76cc9b43 modified)
Environment is ok
If not, you need more dependencies.
3º Check the target arch you want:
cd ${PATH-rtems-source-builder}/rtems
../source-builder/sb-set-builder --list-bsets
${PATH-rtems-source-builder}/source-builder/sb-set-builder --log=l-sparc.txt --prefix=$HOME/development/rtems/4.11 4.11/rtems-sparc
You need to stay in ${PATH-rtems-source-builder}/rtems path, or the list won't be complete!
4º Configure
EXECUTABLE=$HOME/Repositories/git/rtems
TARGET=sparc-rtems4.11
PREFIX=${HOME}/opt/rtems
${EXECUTABLE}/configure --target=${TARGET} --enable-rtemsbsp=sis --enable-tests=samples --prefix=${PREFIX}
5º Execute boostrap
$HOME/Repositories/git/rtems/bootstrap
6º Go to your build path and compile & install
make
make install
Remember, you need the valid toolchain path in your environment variables.
In example:
export PATH=$HOME/development/rtems/4.11/bin:$PATH
If you don't want to do it everytime you restart, add that in your ~/.bashrc file. And use commando source to update the current terminal environment.
source ~/.bashrc
The problem is that it cannot find binaries.
That is probably because you haven't added them to your PATH environment variable.
You can do that with (use the correct path to the bin-directory of your setup)
export PATH=$HOME/development/rtems/compiler/4.12/bin:$PATH

Kernel compilation not finding .config file

EDIT: Solved it, check my comment below.
I'm trying to compile a kernel with make O=$BUILD
Where build is the build path: BUILD=~/lab/build
But then I get this error:
*** Configuration file ".config" not found!
***
*** Please run some configurator (e.g. "make oldconfig" or
*** "make menuconfig" or "make xconfig").
***
make[3]: *** [silentoldconfig] Error 1
make[2]: *** [silentoldconfig] Error 2
make[1]: *** No rule to make target `include/config/auto.conf', needed by`include/config/kernel.release'. Stop.
Before I compiled I used the old config file for the new kernel by copying it to my kernel folder:
cp -vi /boot/config-3.13.0-45-generic .config
and then i ran:
make oldconfig
and entered all defaults.
How can I fix the error?
I got it to compile now by doing
make O=$BUILD oldconfig and also by doing a make mrproper in my kernel directory, and then running make O=$BUILD again.

MPFR installation can't find gmp-impl.h

I'm trying to install MPFR on cygwin.
I successfully ran "./configure --with-gmp-build=../gmp-5.1.3" and it doesn't gave me any error.
But when I ran "make install", it fails and gives following error.
In file included from exceptions.c:23:0:
mpfr-impl.h:71:24: fatal error: gmp-impl.h: No such file or directory
compilation terminated.
Makefile:674: recipe for target `exceptions.lo' failed
make[2]: *** [exceptions.lo] Error 1
make[2]: Leaving directory `/cygdrive/d/chamila/mpfr-3.1.2/src'
Makefile:798: recipe for target `install' failed
make[1]: *** [install] Error 2
make[1]: Leaving directory `/cygdrive/d/chamila/mpfr-3.1.2/src'
Makefile:385: recipe for target `install-recursive' failed
make: *** [install-recursive] Error 1
I added gmp location to path as well. What is wrong here? How can I solve this?
Don't use the --with-gmp-build option (unless you know what you're doing) and don't use relative paths with configure. If you have installed GMP in directory DIR, just use --with-gmp=DIR.

Resources