LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Kernel (https://www.linuxquestions.org/questions/linux-kernel-70/)
-   -   Need help with cross-compiling self-written kernel modules (https://www.linuxquestions.org/questions/linux-kernel-70/need-help-with-cross-compiling-self-written-kernel-modules-4175458721/)

TeaYoung 04-18-2013 11:11 PM

Need help with cross-compiling self-written kernel modules
 
I do not speak English well.

I live in South Korea.

Courage was required to write the articles on this site. :redface:

I study device driver.

I made ​​a hello world module.

The link below is the result of the execution.

http://com.odroid.com/sigong/_Files/...1738298441.png

I want to cross-compile from the Host PC to the Target Borad.

The below source Hello.c and the Makefile

The red lettering is the part that is added to cross-compile.

[hello1.c]
#include <linux/module.h>
#include <linux/kernel.h>

static int debug_enable = 0;
module_param(debug_enable, int, 0);
MODULE_PARM_DESC(debug_enable, "Enable module debug mode.");

static int __init hello_init(void)
{
printk(KERN_ALERT "Hello Example Init - debug mode is %sn", debug_enable ? "enabled" : "disabled");
return 0;
}

static void __exit hello_exit(void)
{
printk(KERN_ALERT "Hello Example Exitn");
}

module_init(hello_init);
module_exit(hello_exit);

MODULE_AUTHOR("Chris Hallinan");
MODULE_DESCRIPTION("Hello world Example");
MODULE_LICENSE("GPL");

[Makefile]
obj-m := hello1.o

KDIR := /lib/modules/$(shell uname -r)/build

PWD := $(shell pwd)

CROSS=arm-linux-gnueabihf-
default:
$(MAKE) -C $(KDIR) SUBDIRS=$(PWD) ARCH=arm CROSS_COMPILE=$(CROSS) modules

test:
echo $(MAKE) -C $(KDIR) SUBDIRS=$(PWD) modules
clean:
rm -rf *.mod.c *.ko *.o *.symvers *.order


It will make the following error
http://com.odroid.com/sigong/_Files/...1800123246.png

Going to the folder of / usr/src/linux-headers-3.5.0-27-generic/arch/arm/include/asm the file does not exist.

However, this crab / usr/src/linux-headers-3.5.0-27-generic/include/asm-generic folder, the file was!!!

I am so copy bitsperlong.h, and make this time was not errono.h.

bitsperlong.h.....errno.h.....rwsem.h.... timex.h... :banghead:

How should be able to handle this problem?

Limited English proficiency, and my question has been passed, I do not know.

I do not know really was trying for two weeks.

Snark1994 04-20-2013 04:34 AM

Firstly: don't call your thread "Hello..... I need help". It gives us no information about what your problem is, and many people will not answer your thread. A better title is "Error compiling a 'hello world' device driver" (you can change it to that by clicking "Edit" on your post).

Secondly: if you're posting code, put [CODE][/CODE] tags around it, it makes it a lot easier for us to read.

I'm afraid I don't speak Korean - what does the error say? (after "fatal error: asm/bitsperlong.h")

Mara 04-21-2013 01:08 PM

Could you please run the make command in the following way:
sudo LC_ALL=C make

This will print the error message in English, it will be much easier for us to understand.

It seems that the file is missing. If so, please make sure that you have re-compiled the kernel on the machine you're using. Some files are generated during the build.

TeaYoung 04-21-2013 11:54 PM

Quote:

Originally Posted by Snark1994 (Post 4935191)
Firstly: don't call your thread "Hello..... I need help". It gives us no information about what your problem is, and many people will not answer your thread. A better title is "Error compiling a 'hello world' device driver" (you can change it to that by clicking "Edit" on your post).

Secondly: if you're posting code, put [CODE][/CODE] tags around it, it makes it a lot easier for us to read.

I'm afraid I don't speak Korean - what does the error say? (after "fatal error: asm/bitsperlong.h")

Oh... Sorry for the late reply

I did not think the Korean error

Fatal error: asm/bitsperlong.h: ]no such file or dirctory

business_kid 04-23-2013 08:40 AM

Doing things in /usr/src/ is not wise, because you have to be root. Better to use /home.

The error seems to occur because
Quote:

In file included from /usr/src/linux-headers-3.5.0-25-generic/arch/arm/include/asm/types.h:4:0,
This arm file includes other include files which are being found in your x86 includes(i.e. in /usr/include)

TeaYoung 04-23-2013 11:46 AM

Quote:

Originally Posted by business_kid (Post 4937199)
Doing things in /usr/src/ is not wise, because you have to be root. Better to use /home.

The error seems to occur because

This arm file includes other include files which are being found in your x86 includes(i.e. in /usr/include)

Thank you too for helping Leave a reply

A long period of time, no one was discouraged did not leave a reply.

Let's now 1:00 AM.

If the day is bright, I'm gonna try to go to school.

I did not think to use a different directory. /usr/src -> /home

I want to quickly go to the school to try to run.

Run, and once again, I will leave a reply.

Thank You!!

Snark1994 04-23-2013 05:09 PM

Okay, and what does

Code:

locate bitsperlong.h
print?

(if you don't have 'locate', try
Code:

find / -name bitsperlong.h
)


All times are GMT -5. The time now is 02:06 AM.