I have been trying to cross compile a loadable kernel module and I have been getting warning message that I would like to get help.
Below is the warning message
make[1]: Entering directory `/home/userid/rowboat-android/kernel'
Building modules, stage 2.
MODPOST 1 modules
WARNING: "omap_device_build" [/home/userid/myfiles/lcdc_load_device.ko] undefined!
WARNING: "omap_hwmod_lookup" [/home/userid/myfiles/lcdc_load_device.ko] undefined!
make[1]: Leaving directory `/home/userid/rowboat-android/kernel'
Below is the Makefile
obj-m :=lcdc_load_device.o
lcdc_load_device-m := ../rowboat-android/kernel/arch/arm/plat-omap/omap_device.o
lcdc_load_device-m += ../rowboat-android/kernel/arch/arm/mach-omap2/omap_hwmod.o
ccflags-m := -I$(src)/../rowboat-android/kernel/arch/arm/plat-omap/include/plat/
KDIR := /home/userid/rowboat-android/kernel/
PWD := $(shell pwd)
default:
$(MAKE) ARCH=arm CROSS_COMPILE=/home/userid/rowboat-android/prebuilt/linux-x86/toolchain/arm-eabi-4.4.3/bin/arm-eabi- -C $(KDIR) SUBDIRS=$(PWD) modules
clean:
$(MAKE) -C $(KDIR) SUBDIRS=$(PWD) clean
I am suspecting that the makefile is finding the header file for "omap_device_build" and "omap_hwmod_lookup" functions.
Appreciate your help, and thank you advance.
Thank you to mbratch and artless noise for their comments
To address the WARNINGS, the symbols need to be exported. For the above question place
EXPORT_SYMBOL(omap_device_build) in omap_device.c
EXPORT_SYMBOL(omap_hwmod_lookup) in omap_hwmod.c
and compile the kernel. Then compile the loadable kernel module against the compiled kernel. Perform the following to verify if the symbols have been exported
grep omap_device_build /proc/kallsyms
or
grep omap_device_build Module.symvers
For more details reference the following links
Kernel Symbols: What's available to Your Module
Building and Running Modules
Comments are welcome
Thank you
Related
When trying to run Repast HPC executables I get the following error:
./main.exe: error while loading shared libraries: libboost_mpi-mt.so.1.61.0: cannot open shared object file: No such file or directory ./main.exe: error while loading shared libraries: libboost_mpi-mt.so.1.61.0: cannot open shared object
In the make file I define the link to boost in an env file with the below:
BOOST_INCLUDE= -I$(HOME)/sfw/Boost/Boost_1.61/include/
BOOST_LIB_DIR= -L$(HOME)/sfw/Boost/Boost_1.61/lib/
This is linked to a make file with the following make file
include ./env
.PHONY: clean
clean:
rm -f *.o
rm -f *.exe
.PHONY: compile
compile:
$(MPICXX) $(BOOST_INCLUDE) -c Main.cpp -o Main.o
$(MPICXX) $(BOOST_LIB_DIR) -o main.exe Main.o $(BOOST_LIBS)
.PHONY: all
all: clean compile
Boost in tsnow#DESKTOP-IF7CEHL:~/sfw/Boost/Boost_1.61/lib$ so it should link well across.
Any help appreciated, just trying to get a tutorial running.
We typically don't link repast to boost, but rather use rpath to let the model executable know where the boost and repast libraries are. For example in your Makefile:
REPAST_LIB_DIR = $(REPAST_HOME)/lib
BOOST_LIB_DIR = $(HOME)/theta/sfw/boost-1.66.0/lib
RPATHS += -Wl,-rpath -Wl,$(REPAST_LIB_DIR) -Wl,-rpath -Wl,$(BOOST_LIB_DIR)
and then add $(RPATHS) after the list of libraries during linking.
model : $(EXEC_OBJECTS)
$(CXXLD) -fopenmp -dynamic $^ $(LIBS) $(RPATHS) -o $(NAME)
Some of those args might not be appropriate for WSL, but hopefully the RPATHS part makes sense.
So, if after your include directive, you add
RPATHS=-Wl,-rpath -Wl,$(BOOST_LIB_DIR)
and update the second line of your compile target with
$(MPICXX) $(BOOST_LIB_DIR) -o main.exe Main.o $(BOOST_LIBS) $(RPATHS)
The location of your boost libs is compiled into main.exe, and it should find it.
The command:
export LD_LIBRARY_PATH=/home/tsnow/sfw/Boost/Boost_1.61/lib/
allowed boost to be found.
I've just started learning linux kernel modules and trying to write simple Hello world program.
So mymod.c:
#include <linux/module.h>
#include <linux/kernel.h>
MODULE_LICENSE("GPL");
MODULE_AUTHOR("Author");
MODULE_DESCRIPTION("\"Hello, world!\" minimal module");
MODULE_VERSION("printk");
int init_module(void)
{
printk("<1>Hello world 1.\n");
return 0;
}
void cleanup_module(void)
{
printk(KERN_ALERT "Goodbye world 1.\n");
}
Makefile:
obj-m += mymod.o
all:
make -C /lib/modules/$(shell uname -r)/build M=$(PWD) modules
clean:
make -C /lib/modules/$(shell uname -r)/build M=$(PWD) clean
make outout:
make -C /lib/modules/3.2.0-23-generic-pae/build M=/root modules
make[1]: Entering directory `/usr/src/linux-3.2.42'
WARNING: Symbol version dump /usr/src/linux-3.2.42/Module.symvers
is missing; modules will have no dependencies and modversions.
Building modules, stage 2.
MODPOST 1 modules
make[1]: Leaving directory `/usr/src/linux-3.2.42'
So it creates files I needed, but when I try to install this by
insmod mymod.ko
I get next output:
insmod: error inserting 'mymod.ko': -1 Invalid module format
So I'd like to know what's the problem?
PS. OS - Ubuntu Server 12.04. Kernel - linux 3.2.0-23 pae
UPDATE:
I've downloaded from kernel.org kernel 3.2.42 and put it in /usr/src and did 'make defconfig && make prepare', 'make modules_prepare'. Also I've created link in /lib/modules/3.2.0-23-generic-pae/build.
Is this the source tree for the running kernel? If not, it should fail.
Install the kernel-devel (or similarly named) package for your distribution, it adds enough machinery to build modules against it.
You missed the module_init and module_cleanup declaration,
module_init (module_init);
module_exit (cleanup_module);
Otherwise it would have no entry point defined, and it wouldn't load.
Because this task requires so many details, and small files to be coordinated it is best to use UML (user mode linux) so that the kprintf (kernel printf) always outputs to the terminal even in a graphical environment.
I am new to kernel module development. So I started with simple hello world kernel module
I am using "The Linux Kernel Module Programming Guide" book for the reference (it is addressing to kernel 2.6).
I installed kernel-devel and kenel headers with yum. I am using fedora 17.
I found that a symlink
/lib/modules/3.3.4-5.fc17.x86_64/build -> /usr/src/kernels/3.3.4-5.fc17.x86_64
Now, I have one hello-1.c (the simple kernel module and a Makefile in my working directory)
The Makefile is:
obj-m += hello-1.o
all:
make -C /lib/modules/$(shell uname -r)/build M=$(PWD) modules
clean:
make -C /lib/modules/$(shell uname -r)/build M=$(PWD) clean
when in $make i get error:
make -C /lib/modules/3.3.4-5.fc17.x86_64/build M=/root/kerneldev modules
make: *** /lib/modules/3.3.4-5.fc17.x86_64/build: No such file or directory. Stop.
make: *** [all] Error 2
I make same program on Centos-5.x it run successfully , because the /lib/modules/3.3.4-5.fc17.x86_64/build was containing the actual module (not a symlink).
What should be problem ? why such difference?
The message
make: *** /lib/modules/3.3.4-5.fc17.x86_64/build: No such file or directory. Stop.
Is telling you that the directory path after the *** does not exist. Make issues this exact format of error when the -C directory doesn't exist. Other non-existent path situations will result in more words. For example, if the /lib/modules/3.3.4-5.fc17.x86_64/build directory does exist but it contains no makefile, make will specifically say no makefile found.
So the other answers are giving you ideas to help you create that directory with its proper contents.
And this answer is intended to also help people who have the above form of error message and for whom installing 'kernel-devel' will not help, by explaining the message itself.
I have few doubts like, where your issuing the make command.
Your current directory seems to be
M=/root/kerneldev
whether your hello-1.c is in /root/kerneldev folder.
try "yum install kernel-devel"(for kernel headers)
I am trying to compile a hello world module given over here
I have followed the following step.
Downloaded Linux kernel 2.6.35-rc5
extracted to directory /general/source/linux
Complied the entire kernel.
created a dir test in the linux folder.
Created and complied a hello world module as mentioned there.
when I run the insmod command, I get this error
insmod: error inserting 'hello.ko': -1 Invalid module format
How do I sort out this error?
Regards,
Ok the mistake that you are making is the kernel version.
First try
uname -r
You would get the kernel version. The downloaded version mostly likely won't be the kernel version of your system.
So change the make file to
ifeq ($(KERNELRELEASE),)
KERNELDIR ?= /lib/modules/$(shell uname -r)/build
PWD := $(shell pwd)
.PHONY: build clean
build:
$(MAKE) -C $(KERNELDIR) M=$(PWD) modules
clean:
rm -rf *.o *~ core .depend .*.cmd *.ko *.mod.c
else
$(info Building with KERNELRELEASE = ${KERNELRELEASE})
obj-m := hello.o
endif
Make sure the tabs are in the order as mentioned in the above script.
Your kernel module must match the running kernel. If you want to install this specific module, for example, you'd need to also install the kernel that you've built.
Normally, you'd not build the kernel on your own and use a pre-built version that matches your distribution's kernel. Look for a kernel-headers package in your distribution's repository.
I am trying to run 'make' on a module in User Mode Linux to install a simple makefile. Here is my make file:
obj-m := hello.o
KDIR := /lib/modules/$(shell uname -r)/build
PWD := $(shell pwd)
default:
$(MAKE) -C $(KDIR) SUBDIRS=$(PWD) modules
When I run this in User Mode Linux I get the following error:
make[1]: Entering directory `/lib/modules/2.6.28/build'
make[1]: *** No rule to make target `modules'. Stop.
make[1]: Leaving directory `/lib/modules/2.6.28/build'
make: *** [default] Error 2
The problem is that no files are present under /lib/modules/. There's no directory for 2.6.28 or build. From what I've read, these should be symlinks to /usr/src, but under /usr/src, I don't see any files under that either.
Sources and headers of your UML kernel must be used to compile module for it.
You can compile it either inside UML or just in main system, but you must to use UML's kernel's headers and build scripts
You need to build and install the version of the kernel you are compiling for. Get the source from kernel.org, configure (I think make menuconfig picks the config up from the running kernel), build, and install it. You can do the build in your home directory under regular user, then of course you would need root to install it.
Edit:
Just in case you missed this - here's User Mode Linux HOWTO. It contains specific items for building and installing kernel and modules. Hope this helps.