Linux kernel compiler for FriendlyARM - linux

I'm trying to compile a Linux kernel for my FriendlyARM, but I'm getting this error:
kevin#kevin-VirtualBox:~/Desktop/FriendlyARM/linux-2.6.38-friendlyarm-newgccpatched$ make
make: arm-linux-gcc: Command not found
CHK include/linux/version.h
CHK include/generated/utsrelease.h
make[1]: `include/generated/mach-types.h' is up to date.
CC kernel/bounds.s
/bin/sh: 1: arm-linux-gcc: not found
make[1]: *** [kernel/bounds.s] Error 127
make: *** [prepare0] Error 2
kevin#kevin-VirtualBox:~/Desktop/FriendlyARM/linux-2.6.38-friendlyarm-newgccpatched$
Is there an easy way to resolve this?
I have never done this before, therefore, if I'm asking a stupid question, please forgive me.

Firstly, you need to have arm cross compiler toolchain. For example arm-none-linux-gnueabi. You can download it here
When you have successfully installed the toolchain follow below steps to compile the kernel.
cd to kernel directory
execute
$ make ARCH=arm CROSS_COMPILE=arm-none-linux-gnueabi- defconfig

Related

Kernel module on cross-compile kernel: /bin/sh: 1: scripts/basic/fixdep: Exec format error

I'm doing some experiment on rpi4, and trying to reproduce this kernel module from github https://github.com/sysprog21/dont-trace on my rpi4. I encounter this problem:
make -C /lib/modules/`uname -r`/build M=/home/ubuntu/dont-trace modules
make[1]: Entering directory '/usr/src/linux-headers-5.15.65-rt49-preemptrt-full-raspi'
warning: the compiler differs from the one used to build the kernel
The kernel was built by: aarch64-linux-gnu-gcc (Debian 10.2.1-6) 10.2.1 20210110
You are using: gcc (Ubuntu 11.2.0-19ubuntu1) 11.2.0
CC [M] /home/ubuntu/dont-trace/dont_trace.o
/bin/sh: 1: scripts/basic/fixdep: Exec format error
make[2]: *** [scripts/Makefile.build:289: /home/ubuntu/dont-trace/dont_trace.o] Error 126
make[2]: *** Deleting file '/home/ubuntu/dont-trace/dont_trace.o'
make[1]: *** [Makefile:1896: /home/ubuntu/dont-trace] Error 2
make[1]: Leaving directory '/usr/src/linux-headers-5.15.65-rt49-preemptrt-full-raspi'
make: *** [Makefile:7: all] Error 2
The kernel here is cross-compiled from x86 server and do show above. I was wondering how to solve this problem & what's the root cause. I can make it on x86 server. It should be something fundamental knowledge I don't understand. Thks!
it seems work this time
My solution might be a bit workaround, but it works. I follow the clues /bin/sh: 1: scripts/basic/fixdep: Exec format error. So I copy the source code to local raspberry pi, and make modules_prepare to construct complete /scripts, then move it into /lib/modules/`uname -r\`/build. It remain the gcc version warning, but work properly.

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.

While building kernel image i am getting this error while doing make -j4 (Using ubuntu)

lib/mpi/generic_mpih-lshift.o:/home/shubh/Root/XENO_WS/linux-3.8.13/lib/mpi/mpi-inline.h:110: first defined here
scripts/Makefile.build:443: recipe for target 'lib/mpi/mpi.o' failed
make[2]: *** [lib/mpi/mpi.o] Error 1
scripts/Makefile.build:454: recipe for target 'lib/mpi' failed
make[1]: *** [lib/mpi] Error 2
Makefile:791: recipe for target 'lib' failed
make: *** [lib] Error 2
make: *** Waiting for unfinished jobs....
How can I resolve this? When I am doing same steps in OpenSUSE it is not giving any error. I followed these steps:
make mrproper
make oldconfig
make -j4
then I get the error in between this.
So you use gcc of version 5, which is incompatible with Linux kernel version you want to compile. – Tsyvarev
It is resolve now. I build the kernel with lower version of gcc. – sam1006

Make cannot find present cross compiler

I'm using a make file to compile a kernel for an arm/Xilinx platform.
I'm setting an env variable CROSS_COMPILE which the make file will then use.
I'm trying to use a cross compiler, which is present on my system, called arm-xilinx-linux-gnueabi-gcc by setting the env var in the following ways;
export CROSS_COMPILE=/opt/Xilinx/SDK/2015.2/gnu/arm/lin/bin/arm-xilinx-linux-gnueabi-
export CROSS_COMPILE=arm-xilinx-linux-gnueabi-
The make file should append gcc.
The error given for both is
make: /opt/Xilinx/SDK/2015.2/gnu/arm/lin/bin/arm-xilinx-linux-gnueabi-gcc: Command not found
scripts/kconfig/conf --silentoldconfig Kconfig
make: /opt/Xilinx/SDK/2015.2/gnu/arm/lin/bin/arm-xilinx-linux-gnueabi-gcc: Command not found
CHK include/config/kernel.release
CHK include/generated/uapi/linux/version.h
CHK include/generated/utsrelease.h
make[1]: `include/generated/mach-types.h' is up to date.
CC kernel/bounds.s
/bin/sh: 1: /opt/Xilinx/SDK/2015.2/gnu/arm/lin/bin/arm-xilinx-linux-gnueabi-gcc: not found
make[1]: *** [kernel/bounds.s] Error 127
make: *** [prepare0] Error 2
It works with other arm cross compilers but this one.
Why is this?
According answers you gave in comments, you are trying to run a 32bits executable on a 64bits host platform.
So, if your are on Ubuntu check this answer from askubuntu.

make[1]: arm-linux-gcc: Command not found in ubuntu [duplicate]

This question already has answers here:
Closed 10 years ago.
Possible Duplicate:
what is arm-linux-gcc and how to install this in ubuntu
While I'm trying this command
$ make ARCH=arm devkit8000 defconfig
I get this error:
make[1]: arm-linux-gcc: Command not found
make[1]: arm-linux-gcc: Command not found
scripts/kconfig/conf -s arch/arm/Kconfig
***
*** You have not yet configured your kernel!
*** (missing kernel .config file)
***
*** 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 `devkit8000'. Stop.
make: *** [devkit8000] Error 2
How can i solve this error?
Do you have ARM toolchain installed? If there is no such package in Ubuntu you can download it from the internet and add it to your $PATH.
Take a look at what is arm-linux-gcc and how to install this in ubuntu
EDIT:
It might be, that your makefile is looking for different filenames, than you have.
Try locating arm-linux-gnueabi-gcc file. Go to that directory and you may create links for each file with arm-linux-gnueabi- prefix.
Try after sudo su:
ln -s arm-linux-gnueabi-gcc arm-linux-gcc
ln -s arm-linux-gnueabi-cc arm-linux-cc
etc.
Might help, but I do not guarantee. Usually works ;-)

Resources