Add external module to kernel4.1.15-8

Its being hard time for me adding external modules to kernel…

Basically I have a module completely designed and tested over Ubuntu and currently I tried to added as a external module to Open SUSE kernel.

After compile the driver in Open SUSE, when I want to added… returns the code of below:


$ sudo zypper install kernel-desktop-devel kernel-syms
$ make -C /lib/modules/4.1.15-8-default/kernel/* SUBDIRS=$home/user/Development/Module
$ make -C /lib/modules/4.1.15-8-default/kernel/* SUBDIRS=$home/user/Development/Module module
.....
sudo make
.....
module_x.h: error: pasting "+"does not give a valid preprocessing token
/usr/src/linux-4.1.15-8/scripts/Makefile.build:274: receipe for target 'home/user/Development/Module/module.o' failed
make[4]:*** [home/user/Development/Module/module.o] Error 2
/usr/src/linux-4.1.15-8/scripts/Makefile.build:274: receipe for target 'home/user/Development/Module/module1' failed
make[3]:*** [home/user/Development/Module/module1] Error 2
Makefile:146: receipe for target 'sub-make' failed
make[2]:***[sub-make] Error 2
Makefile:146: receipe for target '__sub-make' failed
make[1]:***[__sub-make] Error 2
make[1]: leaving directory '/usr/src/linux-4.1.15-8-obj/x86_64/default'
Makefile:98: receipe for target 'all' failed
make:*** [all] Error 2

Maybe I miss some essencial steps before start to add modules to kernel, but the main folders seems created and the files inside as well.

Regards,

Just a remark, in ubuntu I have used different kernel (3.2.0-56 kernel ).

Where have you got this command from? It is so wrong that I do not even know where to start :slight_smile:

make -C /lib/modules/$(uname -r)/build M=$home/user/Development/Module
sudo make -C /lib/modules/$(uname -r)/build M=$home/user/Development/Module modules_install

Replace $(uname -r) with kernel version you need if compiling for non-currently running kernel.

.....
sudo make

Never ever compile anything, especially kernel, as root. In particular, it prevents you from screwing up installed kernel devel files. At this point I’d suggest to remove installed RPM, manually clean remaining directories if any, reinstall RPMs again and do it once more. Your command may accidentally have change something.

I’d prefer reinstall :\because I did many changes as a root related to kernel files.

Thank you :slight_smile:

I’ve reinstalled open SUSE and all packages that I had before, to be able to compile the module. Actually the scenario changed a bit but still making problems when I try to compile it, below I’ve attached the code;


user@linux-9hyc:/run/media/user/UUI/Module> make -C /lib/modules/$(uname -r)/build M=$/run/media/user/UUI/Module
make: Entering directory '/usr/src/linux-4.1.15-8-obj/x86_64/default'
arch/x86/Makefile:129: CONFIG_X86_X32 enabled but no binutils support
/usr/src/linux-4.1.15-8/Makefile:678: Cannot use CONFIG_CC_STACKPROTECTOR_REGULAR: -fstack-protector not supported by compiler
mkdir: cannot create directory ‘run’: Permission denied
make[3]: *** No rule to make target '/usr/src/linux-4.1.15-8/run/media/user/UUI/Module/Makefile'.  Stop.
/usr/src/linux-4.1.15-8/Makefile:1410: recipe for target '_module_run/media/user/UUI/Module' failed
make[2]: *** [_module_run/media/user/UUI/Module] Error 2
Makefile:146: recipe for target 'sub-make' failed
make[1]: *** [sub-make] Error 2
Makefile:24: recipe for target '__sub-make' failed
make: *** [__sub-make] Error 2
make: Leaving directory '/usr/src/linux-4.1.15-8-obj/x86_64/default'


user@linux-9hyc:/run/media/user/UUI/Module> make -C /lib/modules/$(uname -r)/build M=$/run/media/user/UUI/Module  module_install
make: Entering directory '/usr/src/linux-4.1.15-8-obj/x86_64/default'
arch/x86/Makefile:129: CONFIG_X86_X32 enabled but no binutils support
/usr/src/linux-4.1.15-8/Makefile:678: Cannot use CONFIG_CC_STACKPROTECTOR_REGULAR: -fstack-protector not supported by compiler
make[2]: *** No rule to make target 'module_install'.  Stop.
Makefile:146: recipe for target 'sub-make' failed
make[1]: *** [sub-make] Error 2
Makefile:24: recipe for target '__sub-make' failed
make: *** [__sub-make] Error 2
make: Leaving directory '/usr/src/linux-4.1.15-8-obj/x86_64/default'
user@linux-9hyc:/run/media/user/UUI/Module> 

Note: Concerning to binultis I have downloaded all possible packages

I have solved the problem with binultis support and -fstack-protector as well, so the code of below is not appearing when I try to compile. However, the rest still in the same point…

File name is obviously bogus. What $ does here?

If there is no secrecy involved, I’d recommend you post the stdout you’re sanitizing in its original form and the makefile on a pastebin so we can see exactly what is happening.

At this point, I’m speculating that your latest error about unable to create “run” is because your original makefile script has a hard-coded Ubuntu path. If it’s pointing to a variable path, the script likely would have found an existing “run” path common to all distros.

Am also curious whether this module is very widely used, if so it might already be compiled by someone else ready to load immediately (and depending on what it does might be loadable on the fly).

TSU

It’s basically the same module as before but now I am using a external disk, just changed the path.

Indeed I realized afterwards anyway this was very simple to solve.

I think I found the main reason why is not adding the module. If I try to install the new kernel module it’s returning invalid format of my module when I want to insert the module (module+.ko) as shown below in the source code attached.


user@linux-9hyc:/run/media/user/UUI/module/modulePlus> make install
if /sbin/lsmod | grep -q 'module\+'; then sudo /sbin/rmmod module+; fi                                                                         
sudo cp 99-module+.rules /lib/udev/rules.d;                                                                                                    
sudo udevadm control --reload-rules                                                                                                            
sudo /sbin/insmod module+.ko                                                                                                                   
insmod: ERROR: could not insert module module+.ko: Invalid module format                                                                       
Makefile:114: recipe for target 'install' failed                                                                                               
make: *** [install] Error 1                                                                                                                    
user@linux-9hyc:/run/media/user/UUI/module/modulePlus>

Yup, looks like something fundamentally wrong in the makefile itself. At this point, I’d say you should ask yourself how difficult this might be to resolve and maybe look for anything anyone else may have posted doing exactly what you’re now trying to do.

TSU