LinuxQuestions.org
Review your favorite Linux distribution.
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-12-2014, 07:54 AM   #1
G_A
LQ Newbie
 
Registered: Jun 2014
Posts: 29

Rep: Reputation: Disabled
Make a .ko out of driver source files


Hello,
I've been fighting with one for a few days and followed some instructions found on the web, but, not success, to the point that I'm wondering if it can even be done with the files that I have.
The end goal is to have a .ko file which I can load to the kernel with insmod. The acutal driver is a firewire drive of a "Linux for Tegra" which an Nvidia board.

Any help/tips/guidance would be welcome:

The Makefile reads:
root@tegra-ubuntu:/usr/src/kernel/drivers/firewire# cat Makefile
#
# Makefile for the Linux IEEE 1394 implementation
#

firewire-core-y += core-card.o core-cdev.o core-device.o \
core-iso.o core-topology.o core-transaction.o
firewire-ohci-y += ohci.o
firewire-sbp2-y += sbp2.o
firewire-net-y += net.o

obj-$(CONFIG_FIREWIRE) += firewire-core.o
obj-$(CONFIG_FIREWIRE_OHCI) += firewire-ohci.o
obj-$(CONFIG_FIREWIRE_SBP2) += firewire-sbp2.o
obj-$(CONFIG_FIREWIRE_NET) += firewire-net.o
obj-$(CONFIG_FIREWIRE_NOSY) += nosy.o
obj-$(CONFIG_PROVIDE_OHCI1394_DMA_INIT) += init_ohci1394_dma.o



The files in the source directory are:

-rw-rw-r-- 1 ubuntu ubuntu 19999 Oct 8 02:13 core-card.c
-rw-rw-r-- 1 ubuntu ubuntu 47389 Oct 8 02:13 core-cdev.c
-rw-rw-r-- 1 ubuntu ubuntu 34197 Oct 8 02:13 core-device.c
-rw-rw-r-- 1 ubuntu ubuntu 7453 Oct 8 02:13 core.h
-rw-rw-r-- 1 ubuntu ubuntu 10521 Oct 8 02:13 core-iso.c
-rw-rw-r-- 1 ubuntu ubuntu 15219 Oct 8 02:13 core-topology.c
-rw-rw-r-- 1 ubuntu ubuntu 36243 Oct 8 02:13 core-transaction.c
-rw-rw-r-- 1 ubuntu ubuntu 9838 Oct 8 02:13 init_ohci1394_dma.c
-rw-rw-r-- 1 ubuntu ubuntu 2892 Oct 8 02:13 Kconfig
-rw-rw-r-- 1 ubuntu ubuntu 545 Oct 8 02:13 Makefile
-rw-rw-r-- 1 ubuntu ubuntu 42936 Oct 8 02:13 net.c
-rw-rw-r-- 1 ubuntu ubuntu 17656 Oct 8 02:13 nosy.c
-rw-rw-r-- 1 ubuntu ubuntu 9968 Oct 8 02:13 nosy.h
-rw-rw-r-- 1 ubuntu ubuntu 590 Oct 8 02:13 nosy-user.h
-rw-rw-r-- 1 ubuntu ubuntu 107683 Oct 8 02:13 ohci.c
-rw-rw-r-- 1 ubuntu ubuntu 7164 Oct 8 02:13 ohci.h
-rw-rw-r-- 1 ubuntu ubuntu 48566 Oct 8 02:13 sbp2.c
 
Old 12-12-2014, 08:54 AM   #2
smallpond
Senior Member
 
Registered: Feb 2011
Location: Massachusetts, USA
Distribution: Fedora
Posts: 4,140

Rep: Reputation: 1263Reputation: 1263Reputation: 1263Reputation: 1263Reputation: 1263Reputation: 1263Reputation: 1263Reputation: 1263Reputation: 1263
You don't need to look at "instructions on the web". The right place to look for information on the kernel is in the source Documentation directory. Here are the latest instructions for building a kernel module, but you should look in the source for your kernel.

http://lxr.free-electrons.com/source...ld/modules.txt
 
Old 12-12-2014, 09:04 AM   #3
G_A
LQ Newbie
 
Registered: Jun 2014
Posts: 29

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by smallpond View Post
You don't need to look at "instructions on the web". The right place to look for information on the kernel is in the source Documentation directory. Here are the latest instructions for building a kernel module, but you should look in the source for your kernel.

http://lxr.free-electrons.com/source...ld/modules.txt
Yes, these are some of the instructions I was following, but, I cannot make it work.
output:
root@tegra-ubuntu:/usr/src/kernel/drivers/firewire# make -C /usr/src/kernel/ M=$PWD
make: Entering directory `/usr/src/kernel'

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

Building modules, stage 2.
MODPOST 0 modules
/bin/sh: 1: scripts/mod/modpost: not found
make[1]: *** [__modpost] Error 127
make: *** [modules] Error 2
make: Leaving directory `/usr/src/kernel'

Then, I 'cd' to /usr/src/kernel and issue:
root@tegra-ubuntu:/usr/src/kernel# make modules_prepare
and get:

make: *** No rule to make target `modules_prepare'. Stop.
root@tegra-ubuntu:/usr/src/kernel#
 
Old 12-12-2014, 09:26 AM   #4
smallpond
Senior Member
 
Registered: Feb 2011
Location: Massachusetts, USA
Distribution: Fedora
Posts: 4,140

Rep: Reputation: 1263Reputation: 1263Reputation: 1263Reputation: 1263Reputation: 1263Reputation: 1263Reputation: 1263Reputation: 1263Reputation: 1263
Then you do not have the source for your kernel installed in that directory.
 
Old 12-12-2014, 10:36 AM   #5
G_A
LQ Newbie
 
Registered: Jun 2014
Posts: 29

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by smallpond View Post
Then you do not have the source for your kernel installed in that directory.
Is there any identifer which will help me find where is the kernel installed ? I cannot find this exact kernel in the reops, I have downloaded the kernel from the vendor's website (Nvidia) and placed under /usr/src. Here's the ls -l on that direcotry. (/usr/src/kernal) .
As noted, I am not trying to build a whole kernel (and trying to avoid it), I only need the .ko for loading firewire support into the currently running system.

root@tegra-ubuntu:/usr/src/kernel# ls -l /usr/src/kernel/

drwxrwxr-x 3 ubuntu ubuntu 4096 Oct 8 02:13 android
drwxrwxr-x 32 ubuntu ubuntu 4096 Oct 8 02:13 arch
drwxrwxr-x 3 ubuntu ubuntu 4096 Oct 8 02:13 block
drwxrwxr-x 4 ubuntu ubuntu 4096 Oct 8 02:13 chromeos
-rw-rw-r-- 1 ubuntu ubuntu 18693 Oct 8 02:13 COPYING
-rw-rw-r-- 1 ubuntu ubuntu 95317 Oct 8 02:13 CREDITS
drwxrwxr-x 4 ubuntu ubuntu 4096 Oct 8 02:13 crypto
drwxrwxr-x 101 ubuntu ubuntu 12288 Dec 8 16:21 Documentation
drwxrwxr-x 116 ubuntu ubuntu 4096 Oct 8 02:13 drivers
drwxrwxr-x 36 ubuntu ubuntu 4096 Oct 8 02:13 firmware
drwxrwxr-x 73 ubuntu ubuntu 4096 Oct 8 02:13 fs
drwxrwxr-x 28 ubuntu ubuntu 4096 Dec 9 14:15 include
drwxrwxr-x 2 ubuntu ubuntu 4096 Oct 8 02:13 init
drwxrwxr-x 2 ubuntu ubuntu 4096 Oct 8 02:13 ipc
-rw-rw-r-- 1 ubuntu ubuntu 2536 Oct 8 02:13 Kbuild
-rw-rw-r-- 1 ubuntu ubuntu 252 Oct 8 02:13 Kconfig
drwxrwxr-x 11 ubuntu ubuntu 4096 Dec 9 15:00 kernel
drwxrwxr-x 9 ubuntu ubuntu 4096 Oct 8 02:13 lib
-rw-rw-r-- 1 ubuntu ubuntu 255053 Oct 8 02:13 MAINTAINERS
-rw-rw-r-- 1 ubuntu ubuntu 48532 Oct 8 02:13 Makefile
drwxrwxr-x 2 ubuntu ubuntu 4096 Oct 8 02:13 mm
-rw-r--r-- 1 root root 0 Dec 9 15:00 modules.order
drwxrwxr-x 56 ubuntu ubuntu 4096 Oct 8 02:13 net
-rw-rw-r-- 1 ubuntu ubuntu 10223 Oct 8 02:13 NVIDIA-REVIEWERS
-rw-rw-r-- 1 ubuntu ubuntu 18736 Oct 8 02:13 README
-rw-rw-r-- 1 ubuntu ubuntu 7485 Oct 8 02:13 REPORTING-BUGS
drwxrwxr-x 12 ubuntu ubuntu 4096 Oct 8 02:13 samples
drwxrwxr-x 13 ubuntu ubuntu 4096 Oct 8 02:13 scripts
drwxrwxr-x 10 ubuntu ubuntu 4096 Oct 8 02:13 security
drwxrwxr-x 22 ubuntu ubuntu 4096 Oct 8 02:13 sound
drwxrwxr-x 17 ubuntu ubuntu 4096 Oct 8 02:13 tools
drwxrwxr-x 2 ubuntu ubuntu 4096 Oct 8 02:13 usr
drwxrwxr-x 3 ubuntu ubuntu 4096 Oct 8 02:13 virt
 
Old 12-12-2014, 11:00 AM   #6
smallpond
Senior Member
 
Registered: Feb 2011
Location: Massachusetts, USA
Distribution: Fedora
Posts: 4,140

Rep: Reputation: 1263Reputation: 1263Reputation: 1263Reputation: 1263Reputation: 1263Reputation: 1263Reputation: 1263Reputation: 1263Reputation: 1263
If you are running a ubuntu kernel, then you want the kernel source package from Ubuntu. You can't build the module under a different kernel than the one you are running and expect to be able to load it. Should be something like

Code:
sudo apt-get source linux-source-`uname -r`
 
1 members found this post helpful.
Old 12-12-2014, 11:16 AM   #7
G_A
LQ Newbie
 
Registered: Jun 2014
Posts: 29

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by smallpond View Post
If you are running a ubuntu kernel, then you want the kernel source package from Ubuntu. You can't build the module under a different kernel than the one you are running and expect to be able to load it. Should be something like

Code:
sudo apt-get source linux-source-`uname -r`
Yes, that's where my problme is, this looks like an odd kernel (Nvidia),

Code:
root@tegra-ubuntu:/usr/src/kernel# sudo apt-get source linux-source-`uname -r`
Reading package lists... Done
Building dependency tree
Reading state information... Done
E: Unable to find a source package for linux-source-3.10.40-g8c4516e
 
Old 12-12-2014, 11:58 AM   #8
smallpond
Senior Member
 
Registered: Feb 2011
Location: Massachusetts, USA
Distribution: Fedora
Posts: 4,140

Rep: Reputation: 1263Reputation: 1263Reputation: 1263Reputation: 1263Reputation: 1263Reputation: 1263Reputation: 1263Reputation: 1263Reputation: 1263
Ok, so it's a special Nvidia kernel. You do need their source. You should not build the kernel under /usr/src/kernel. Build as a regular user under your own home directory. The only time you should need root permission is to install the kernel or modules. You should probably build the whole kernel just to make sure you have everything.
 
Old 12-20-2014, 08:32 AM   #9
onebuck
Moderator
 
Registered: Jan 2005
Location: Central Florida 20 minutes from Disney World
Distribution: SlackwareŽ
Posts: 13,925
Blog Entries: 44

Rep: Reputation: 3159Reputation: 3159Reputation: 3159Reputation: 3159Reputation: 3159Reputation: 3159Reputation: 3159Reputation: 3159Reputation: 3159Reputation: 3159Reputation: 3159
Moderator response

Moved: This thread is more suitable in <Linux - Kernel> and has been moved accordingly to help your thread/question get the exposure it deserves.
 
  


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
[SOLVED] Compiling a Driver with Source Files in Multiple Directories ACee Programming 2 09-19-2012 12:40 PM
how to create driver disk for NIC card from source files linuxqu Linux - Newbie 1 12-30-2007 11:35 AM
How to make network driver source code SMP safe? sybercop Linux - Wireless Networking 0 11-08-2007 03:05 AM
gnu make recompiles the source files fully even though the files are not modified yasothamani Linux - Software 4 02-07-2007 06:36 AM
Making a driver disk from source files Dhamon Linux - Hardware 0 08-11-2005 12:57 PM

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

All times are GMT -5. The time now is 08: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