1

Cross-compiling a kernel module

 2 years ago
source link: https://www.codesd.com/item/cross-compiling-a-kernel-module.html
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
neoserver,ios ssh client

Cross-compiling a kernel module

advertisements

I'm trying to cross compile a helloworld kernel (2.6.x) module for ARM architecture on my intel x86 host.

The codesourcery tool chain for ARM is located at: /home/ravi/workspace/hawk/arm-2009q3

The kernel source is located at :/home/ravi/workspace/hawk/linux-omapl1

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

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.


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-

Related Articles

Cross compiles the kernel modules using kernel headers from the rootfs of the target ARM map

I have an OLinuXino board. I downloaded the ArchLinux img file (ArchLinuxARM-2013.02-olinuxino-rootfs.img) and wrote it to the SD card using dd and booted the board using the card. I connected the board to the internet using ethernet and installed gc

How to organize a Makefile to compile a kernel module with several .c files?

How to arrange a Makefile to compile a kernel module with multiple .c files? Here is my current Makefile. It was auto generated by KDevelop TARGET = nlb-driver OBJS = nlb-driver.o MDIR = drivers/misc EXTRA_CFLAGS = -DEXPORT_SYMTAB CURRENT = $(shell u

Difficulty compiling a kernel module in linux

I wrote a simple hello world kernel module. A make file was written by me as below: obj -m += hello.o KDIR: /usr/src/linux-headers-3.2.0-21-generic-pae all: $(MAKE) -C $(KDIR) SUBDIRS=$(PWD) modules clean: rm -rf *.o *.ko *.mod.* *.symvers *.order Th

How to include standard header files when compiling a kernel module source?

I've downloaded, compiled and installed the latest kernel in my machine. Now, I'm trying to write a kernel module. When I try compiling it, I get errors of following similar sort - fatal error: sys/syscall.h: No such file or directory fatal error: li

How do I know if there is a device driver (compiled in / kernel module) that controls a device on a running Linux?

How can I know if a device is supported on a running Linux and if so, which device driver controls it? For instance, lspci on a server (PowerEdge 2900) gives: 00:00.0 Host bridge: Intel Corporation 5000X Chipset Memory Controller Hub (rev 12) 00:02.0

How to compile a kernel module against a new source

I am trying to compile a Hello World module. I am having a fresh Ubuntu in my system which doesn't have any compiled kernel. My kernel is: 2.6.32-34-generic I gave the following Makefile and got the error: obj-m += hello-1.o all: make -C /lib/modules

Compile error: kernel module

I am a newbie at kernel programming & I wish to run this kernel module (posted below)... and i ran the makefile (posted below) for that, but I am getting the following errors: Can someone please help me understand how to overcome this: The kernel pro

Meaning of some commands when cross-compiling the kernel for Raspberry Pi

This Raspberry Pi's official document details the procedures of how to cross-compile new Linux Kernel for Raspberry Pi. Some commands in this document which are shown below, however, I can hardly understand. For Pi 2: $ cd linux $ KERNEL=kernel7 $ ma

& ldquo; __ floatsidf & rdquo; undefined warning when compiling the kernel module

I was writing a loadable kernel module and when trying to compile it, the linker fails with the following message: *** Warning: "__floatsidf" [/testing/Something.ko] undefined! I am NOT using floating point variables, so that's not it. What is t

How to create new directories and move .o files while compiling a kernel module from multiple directories / files

I'm trying to build a kernel module from files in multiple directories. I want to place the resulting .o files in new directories, created corresponding to each source directories. For example, if my sources are A/a1.c , A/a2.c , B/b.c ; I want the .

Loading the kernel module in the Android kernel

I am listing my problem here. I have a Google Nexus one a.k.a. "passion" phone with me. Fastboot and adb tools are installed in the phone. And the boot loader is unlocked. My task: I have to add a linux kernel module to the Android kernel. What

Compile a kernel - no bzImage / vmlinuz product

I'm trying to compile a kernel (altered version of 2.6.32.9, found here https://github.com/rabeeh/linux-2.6.32.9). I am doing the compilation on a emulated ARM system (qemu) (yes, I should probably cross-compile, but that's a different topic) running

Mode dedicated to the cross-compilation of Open Source software

I am very newbie in this kind of business. I have just cross compiled Linux kernel. But I have few question to ask which I have to know. When we compile a Linux kernel I am using this piece of command, because my target platform is ARM. make ARCH=arm

by building kernel modules, why do we need / lib / modules?

In the Kbuild tree, when we are writing a simple hello.ko program then why do we need to use -C /lib/module/ in the build rule. Why this is required? Can it be build solely? What is the purpose of it?while building kernel modules why do we need /lib/

Recommend

About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK