LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software > Linux - Kernel
User Name
Password
Linux - Kernel This forum is for all discussion relating to the Linux kernel.

Notices


Reply
  Search this Thread
Old 12-19-2018, 07:36 AM   #1
bremenpl
LQ Newbie
 
Registered: Apr 2013
Posts: 21

Rep: Reputation: Disabled
Cross-compiling kernel modules with Buildroot


Hello there,
I am using Buildroot to compile the kernel for my ARM target, which is a Beaglebone black. This part works. Now I would like to use the crosscompiler available from the output of the buildroot in order to compile a "Hello World" Kernel module. I have already checked a regular c file Hello World and it crosscompiles on host and runs on the target correctly. I am having problems with setting up the whole environment for the kernel module development. There are many tutorials available for kernel modules development, but they assume developing on the target/ host. I am able to compile a native host x86 kernel module, that works.

I am still missing some dependencies when trying to crosscompile for the Beagle, I am not sure either I need to build some further packages, but when doing xconfig I think I checked everything related to the kernel modules. At the moment I have the following Makefile:

Code:
obj-m	:= simp.o 
KERNELDIR ?= /home/lukasz/brl/Machine/beaglebone/build/linux-headers-a75d8e93056181d512f6c818e8627bd4554aaf92
PWD       := $(shell pwd)
 
all: default
 
default:
	$(MAKE) -C $(KERNELDIR) M=$(PWD) modules

clean:
	rm -rf *.o *~ core .depend .*.cmd *.ko *.mod.c .tmp_versions
And the example module code (simp.c):
Code:
#include <linux/init.h>
#include <linux/module.h>

MODULE_LICENSE("Dual BSD/GPL");

static int hello_init(void)
{
	printk(KERN_ALERT "Hello, world\n");
	return 0;
}

static void hello_exit(void)
{
	printk(KERN_ALERT "Goodbye, cruel world\n");
}

module_init(hello_init);
module_exit(hello_exit);
When trying to make:
Code:
make ARCH=arm CROSS_COMPILE=arm-buildroot-linux-uclibcgnueabihf- -I/home/lukasz/brl/Machine/beaglebone/build/linux-a75d8e93056181d512f6c818e8627bd4554aaf92/include -I/home/lukasz/brl/Machine/beaglebone/build/linux-a75d8e93056181d512f6c818e8627bd4554aaf92 -I/home/lukasz/brl/Machine/beaglebone/build/linux-a75d8e93056181d512f6c818e8627bd4554aaf92/include/generated/autoconf.h
I get the following error:
Code:
make -C /home/lukasz/brl/Machine/beaglebone/build/linux-headers-a75d8e93056181d512f6c818e8627bd4554aaf92 M=/tmp/test modules
make[1]: Entering directory '/home/lukasz/brl/Machine/beaglebone/build/linux-headers-a75d8e93056181d512f6c818e8627bd4554aaf92'

  WARNING: Symbol version dump ./Module.symvers
           is missing; modules will have no dependencies and modversions.

  CC [M]  /tmp/test/simp.o
In file included from <command-line>:0:0:
././include/linux/kconfig.h:4:32: fatal error: generated/autoconf.h: No such file or directory
 #include <generated/autoconf.h>
                                ^
compilation terminated.
scripts/Makefile.build:299: recipe for target '/tmp/test/simp.o' failed
make[2]: *** [/tmp/test/simp.o] Error 1
Makefile:1493: recipe for target '_module_/tmp/test' failed
make[1]: *** [_module_/tmp/test] Error 2
make[1]: Leaving directory '/home/lukasz/brl/Machine/beaglebone/build/linux-headers-a75d8e93056181d512f6c818e8627bd4554aaf92'
Makefile:8: recipe for target 'default' failed
make: *** [default] Error 2
Which I dont understand, since included the .h file specifically. I would appreciate all help regarding this. I was trying to find anyone else doing something similar (trying to cross compile a kernel module on the host using buildroot build tools), but was unable to. Most of the cases are already to advanced or dont apply to my problem.
 
Old 12-20-2018, 04:44 AM   #2
zeebra
Senior Member
 
Registered: Dec 2011
Distribution: Slackware
Posts: 1,830
Blog Entries: 17

Rep: Reputation: 638Reputation: 638Reputation: 638Reputation: 638Reputation: 638Reputation: 638
not sure what "buildroot" is, but have you had a look into QEMU?

I'm not an expert on cross-compiling either, but it could be worth looking into QEMU and even derivative projects like Scratchbox. Scratchbox was created with exactly what you are trying to do in mind (target environment on host).

Not sure if it helps, but you said all help, so I'm tossing this in here.
 
Old 12-20-2018, 04:55 AM   #3
bremenpl
LQ Newbie
 
Registered: Apr 2013
Posts: 21

Original Poster
Rep: Reputation: Disabled
Hi, thanks for answer. At this point I am not interested in compiling within QEMU environment just yet. That would be another thing to configure and I need to make this setup work first.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
buildroot-2015.11-rc2 - ARM Cross Compile Segfaulting On Target wt_kurtz Linux - Software 0 12-04-2015 07:50 PM
Need help with cross-compiling self-written kernel modules TeaYoung Linux - Kernel 6 04-23-2013 05:09 PM
Need help with cross-compiling self-written kernel modules TeaYoung Linux - Newbie 0 04-22-2013 09:17 AM
[SOLVED] cross compiling for arm with buildroot brooko Slackware 3 01-29-2011 11:42 AM
cross-compiling modules for a preemptive kernel(2.6.23) Trixy_Tree Linux - Embedded & Single-board computer 1 04-07-2009 10:47 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software > Linux - Kernel

All times are GMT -5. The time now is 11:39 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration