Cross-compiling of kernel module for ARM architecture

Asked
Active3 hr before
Viewed126 times

8 Answers

module
90%

When i run make, the .ko produced is that of my host machine which means the makefile is invoking the native compiler instead of the cross compiler.What am I doing wrong? The cross compiler's binaries are in my path.,I'm trying to cross compile a helloworld kernel (2.6.x) module for ARM architecture on my intel x86 host., Will this Account Lockout mechanism increase the severity of a information leakage vulnerability that leaks usernames? , Stack Overflow for Teams Where developers & technologists share private knowledge with coworkers

Putting ARCH and CROSS_COMPILE in the Makefile doesn't work. You need to put them on the command line:

make ARCH = arm CROSS_COMPILE = arm - none - linux - gnueabi -
load more v
88%

To build a kernel with given config file,,Download the kernel source from https://www.kernel.org/pub/linux/kernel/.,Linaro’s prebuilt toolchain generally works well. Download one from https://releases.linaro.org/components/toolchain/binaries.,This guide will allow you to cross-compile a loadable kernel module (LKM; a.k.a. device driver) for a ARM Linux system.

/home/ubuntu/linux-3.2/include/linux/kconfig.h:4:32: fatal error: generated/autoconf.h: No such file or directory
#include <generated /autoconf.h>
   ^
load more v
72%

The codesourcery tool chain for ARM is located at: /home/ravi/workspace/hawk/arm-2009q3,I'm trying to cross compile a helloworld kernel (2.6.x) module for ARM architecture on my intel x86 host.,The kernel source is located at :/home/ravi/workspace/hawk/linux-omapl1,If you don't want to reconfigure everything, a quick (ugly) fix is to edit include/generated/autoconf.h

My Makefile:

ARCH = arm
CROSS_COMPILE = arm - none - linux - gnueabi
obj - m: = Hello.o
KDIR: = /home/ravi / workspace / hawk / linux - omapl1
PWD: = $(shell pwd)
default:
$(MAKE) - C $(KDIR) SUBDIRS = $(PWD) modules
clean:
   $(MAKE) - C $(KDIR) SUBDIRS = $(PWD) clean
load more v
65%

First I compile it normally for my native architecture (x86_64):,since x86_64 is the native architecture on my laptop.,Let’s start with a specific file: drivers/staging/rtl8712/rtl871x_mlme.c, because I have a fondness for the rtl8712 driver. I want to compile it for ARM, but my laptop architecture is x86_64. I’m going to attempt it in two ways: with the default make script, and with make.cross.,$ make allyesconfig drivers/staging/rtl8712/rtl871x_mlme.o

First I compile it normally for my native architecture (x86_64):

$ make ARCH=x86_64 allyesconfig drivers/staging/rtl8712/rtl871x_mlme.o

$ make ARCH = x86_64 allyesconfig drivers / staging / rtl8712 / rtl871x_mlme.o
load more v
75%

We have now successfully built and deployed a kernel for the BeagleBone Black platform.,Building the Linux Kernel - Cross-compiling for a BeagleBone Black,Expanding on my previous blog post, which covered the basics of natively building a Linux kernel from scratch, we will now look at building a kernel for a different architecture. This is called cross-compiling.,When cross-compiling there are some basic terms that we use to refer to the systems involved in the process. The two main elements are the target and the host. The target is the system that we wish to compile for. In this example we will compile a kernel for the BeagleBone Black system which is based on an ARM architecture. The host machine is the machine that we use to build the target software. This is where the toolchain will be installed. In this case, we are building on a 64-bit intel based architecture.

Since we are using Ubuntu, we have access to the Ubuntu repositories and the wealth of software they provide. This greatly simplifies the installation of an ARM based toolchain which we install with the following single line:

$ sudo apt - get install gcc - arm - linux - gnueabi
load more v
40%

load more v
22%

I'm trying to make a .ko file for ARM from a linux x86 machine. I tried the following Makefile:,You need to specify the source directory of your ARM Kernel. You may use following Makefile to cross-compile your module.,shell uname -r means that this Makefile will build the module for you host(x86) system and not for ARM.,... but I got an error on giving make -f Makefile ARCH=arm CROSS_COMPILER=arm-linux-gnueabi-gcc in command prompt as follows:

I'm trying to make a .ko file for ARM from a linux x86 machine. I tried the following Makefile:

1 obj - m += helloworldtest_module.o
2 modules_install:
   3 make ARCH = $(ARCH) CC = $(CROSS_COMPILER) - C / lib / modules / $(shell uname - r) / build M = $(PWD) modules
4 clean:
   5 make - C / lib / modules / $(shell uname - r) / build M = $(PWD) clean

... but I got an error on giving make -f Makefile ARCH=arm CROSS_COMPILER=arm-linux-gnueabi-gcc in command prompt as follows:

make ARCH = arm CC = arm - linux - gnueabi - gcc - C / lib / modules / 3.2 .0 - 29 - generic / build M = /home/terenesas / sample modules
make[1]: Entering directory `/usr/src/linux-headers-3.2.0-29-generic'
  CC [M]  /home/terenesas/sample/helloworldtest_module.o
In file included from /usr/src/linux-headers-3.2.0-29-generic/arch/arm/include/asm/types.h:4:0,
                 from include/linux/types.h:4,
                 from include/linux/list.h:4,
                 from include/linux/module.h:9,
                 from /home/terenesas/sample/helloworldtest_module.c:2:
include/asm-generic/int-ll64.h:11:29: fatal error: asm/bitsperlong.h: No such file or directory
compilation terminated.
make[2]: *** [/home/terenesas/sample/helloworldtest_module.o] Error 1
make[1]: *** [_module_/home/terenesas/sample] Error 2
make[1]: Leaving directory ` / usr / src / linux - headers - 3.2 .0 - 29 - generic '
make: ** * [modules_install] Error 2
load more v
60%

If you wish to cross-compile, then alter the following lines in the top level make file:,In order to compile ARM Linux, you will need a compiler capable of generating ARM ELF code with GNU extensions. GCC 3.3 is known to be a good compiler. Fortunately, you needn't guess. The kernel will report an error if your compiler is a recognized offender.,Working with the kernel development community,You can access image files on your ADFS partitions by mounting the ADFS partition, and then using the loopback device driver. You must have losetup installed.

ARCH = <whatever>
load more v

Other "module-undefined" queries related to "Cross-compiling of kernel module for ARM architecture"