Compiling a driver as a part of a kernel, not as a module
You're definitely going to have to put the driver source in the kernel source tree and update the makefile to include it. You can see how this works in steps 1.1 through 1.3 here.
If user-level software does any talking with the device driver it probably does it via system calls. Search through the source of the driver looking for asmlinkage
if you find any of these then you're looking at adding some system calls. The remainder of the above document will explain how to set them up. You'll have to modify at least two files (and they might vary slightly depending on your kernel version).
If the device driver does any talking with the kernel directly, we're dealing with Interrupts, Memory Mapped I/O, or DMA. To be honest with you I do not know whether they can be handled within the source file for your driver (in which case you're good do go), or whether they also require modifying other files in the source tree. The Linux Kernel Module Programming Guide is a good resource for such things.
Good Luck
Unable to compile a kernel module
For compiling loadable kernel modules in Linux tree apply the following command
make modules
.ko
is the proper kernel module extension. If.o
is tried withinsmod
, thenInvalid module format
error will be displayed.
How to compile a device driver into the kernel?
I'm afraid you will not be able to build a driver which is supported up to 2.6.18 and your kernel is 4.18.
Good news is that this NIC has upstream Linux driver for quite some time now, look here at the source of 4.18. As per Makefile, it is enabled via CONFIG_SUNDANCE
. So I believe this NIC should work out of the box.
If not, you might want to build just this driver as a module for your current kernel. How to do that - this falls out of the scope of this question.
Compiling out-of-tree kernel module against any kernel source tree on the filesystem
goal is to have it compile against any source tree
ya you can do it providing a compiled source-code path
just replace make -C /lib/modules/$(shell uname -r)/build M=$PWD modules
with this
make -C <path-to-compiled-src-code> M=$PWD modules
make -C /home/vinay/linux-3.9 M=$PWD modules
try below makefile
Makefile –
# if KERNELRELEASE is defined, we've been invoked from the
# kernel build system and can use its language.
ifneq (${KERNELRELEASE},)
obj-m := new-mod.o
# Otherwise we were called directly from the command line.
# Invoke the kernel build system.
else
KERNEL_SOURCE := /usr/src/linux
PWD := $(shell pwd)
default:
${MAKE} -C ${KERNEL_SOURCE} SUBDIRS=${PWD} modules
clean:
${MAKE} -C ${KERNEL_SOURCE} SUBDIRS=${PWD} clean
endif
In above you can change KERNEL_SOURCE := /usr/src/linux
-->to.--> your sr-code KERNEL_SOURCE := <path to compiled-src-code>
for further info find below liks
while building kernel modules why do we need /lib/modules?
A simple program on linux device driver
How to make a built-in device driver in linux
What is the difference for linux kernel :module or built-in?
If something is compiled in the linux kernel it will be part of the binary forever. So, it wont be loaded into the kernel on a "as-needed" basis. So, for example assume you have a realtek ethernet card on your machine why do you need drivers for intel ethernet cards?
One other thing, kernel modules in general can not reference a function in the kernel unless it is exported to modules using EXPORT_SYMBOL
and its variants. So, if your driver need to reference functions from the kernel sources (which should not be the case anyways) then you have to add your driver into the kernel source tree.
Related Topics
"Must Be Connected to a Terminal Error" with Screen -X Command on a Linux Container
Shared Volume in Docker Through Vagrant
In Linux, How to Create a File Descriptor for a Memory Region
Sudo Apt-Get Update Fail on Ubuntu 17.04
Getting Following Error After The Command Sudo Apt-Get Update on Ubuntu 16.04
Expect, Interact and Then Again Expect
What Is The Size of Coap Packet
Linux Asynch Io - Difference Between Aio.H and Libaio.H
Bash: Split Stdout from Multiple Concurrent Commands into Columns
Qemu on Raspberry Pi Arch Linux Latest Sd Image
Copy Lines Containing Word from One File to Another File in Linux
Autoconf Complains "C Compiler Cannot Create Executables" on Linux Mint
How to Find The Reason for a Dead Process Without Log File on Unix
Ld Does Not Link Opengl on Linux
Get Latest Release Version Number for Chrome Browser
Git Clone Fails: Server Certificate Verification Failed
Produce Lnk File on Gnu/Linux to Transfer to Windows
How to Idiomatically Package Dependencies for a Qt Application Using Cpack