How to create a kernel source tree? Announcing the arrival of Valued Associate #679: Cesar...
How come Sam didn't become Lord of Horn Hill?
How do I keep my slimes from escaping their pens?
List *all* the tuples!
Extract all GPU name, model and GPU ram
How to align text above triangle figure
Identifying polygons that intersect with another layer using QGIS?
Why aren't air breathing engines used as small first stages
Dating a Former Employee
Using et al. for a last / senior author rather than for a first author
What does an IRS interview request entail when called in to verify expenses for a sole proprietor small business?
Using audio cues to encourage good posture
How widely used is the term Treppenwitz? Is it something that most Germans know?
2001: A Space Odyssey's use of the song "Daisy Bell" (Bicycle Built for Two); life imitates art or vice-versa?
English words in a non-english sci-fi novel
Why didn't this character "real die" when they blew their stack out in Altered Carbon?
In predicate logic, does existential quantification (∃) include universal quantification (∀), i.e. can 'some' imply 'all'?
When were vectors invented?
Why did the rest of the Eastern Bloc not invade Yugoslavia?
What would be the ideal power source for a cybernetic eye?
Why is "Consequences inflicted." not a sentence?
What causes the vertical darker bands in my photo?
Check which numbers satisfy the condition [A*B*C = A! + B! + C!]
Sci-Fi book where patients in a coma ward all live in a subconscious world linked together
What does this icon in iOS Stardew Valley mean?
How to create a kernel source tree?
Announcing the arrival of Valued Associate #679: Cesar Manara
Planned maintenance scheduled April 17/18, 2019 at 00:00UTC (8:00pm US/Eastern)
2019 Community Moderator Election Results
Why I closed the “Why is Kali so hard” questionConfiguring, compiling and installing a custom Linux kernelWhat does the 'i8042.nomux=1' kernel option do during booting of Ubuntu?Linux kernel: task vs threadA fast and lightweight distro with GUI (for web development)How to add a system call in linux kernel 4.xBest way to approach HID_MAX_USAGES kernel errors?How to to insmod a module build with linux-headers-generic?why does my gamepad work via bluetooth but not via usbGenerate bootable ELF from bootloader, kernel, device tree, ramdiskWhen to use /dev and /sys for userspace-kernel communication?How to find out which linux distro is suitable for certain hardware?
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty{ margin-bottom:0;
}
I am reading a book on creating drivers on Linux, I do not have too much experience with Linux, I have installed a quite a few distros before but I have always used windows as my main operating system.
I know some C
, but I am mainly a C#
programmer.
I wish to learn (for fun) driver programming, and hope it will teach me some things about Linux and "get into it".
My first hurdle is to find a distro with a standard 2.6.x
kernel. I tried to find one but they are all past 3.x
now. Any one know of a suitable one for this kind of task?
Also the book says I should get a standard kernel from kernel.org
and build a source tree. I have no idea what that means.
This is the book: http://oreilly.com/openbook/linuxdrive3/book/
kernel drivers distributions tree
add a comment |
I am reading a book on creating drivers on Linux, I do not have too much experience with Linux, I have installed a quite a few distros before but I have always used windows as my main operating system.
I know some C
, but I am mainly a C#
programmer.
I wish to learn (for fun) driver programming, and hope it will teach me some things about Linux and "get into it".
My first hurdle is to find a distro with a standard 2.6.x
kernel. I tried to find one but they are all past 3.x
now. Any one know of a suitable one for this kind of task?
Also the book says I should get a standard kernel from kernel.org
and build a source tree. I have no idea what that means.
This is the book: http://oreilly.com/openbook/linuxdrive3/book/
kernel drivers distributions tree
You can download older kernels from kernel.org
– mkc
Feb 17 '14 at 17:02
@Ketan yes fortunately I know that part. However I do not know what building a source tree means.
– sprocket12
Feb 17 '14 at 17:03
AFAIK building means compiling in this context. Once you have your kernel unpacked look intoREADME
,INSTALL
etc. docs.
– mkc
Feb 17 '14 at 17:10
1
Questions like this one come up regularly and we should have a canonical version, so I wrote one: unix.stackexchange.com/questions/115620/…
– goldilocks
Feb 17 '14 at 21:59
add a comment |
I am reading a book on creating drivers on Linux, I do not have too much experience with Linux, I have installed a quite a few distros before but I have always used windows as my main operating system.
I know some C
, but I am mainly a C#
programmer.
I wish to learn (for fun) driver programming, and hope it will teach me some things about Linux and "get into it".
My first hurdle is to find a distro with a standard 2.6.x
kernel. I tried to find one but they are all past 3.x
now. Any one know of a suitable one for this kind of task?
Also the book says I should get a standard kernel from kernel.org
and build a source tree. I have no idea what that means.
This is the book: http://oreilly.com/openbook/linuxdrive3/book/
kernel drivers distributions tree
I am reading a book on creating drivers on Linux, I do not have too much experience with Linux, I have installed a quite a few distros before but I have always used windows as my main operating system.
I know some C
, but I am mainly a C#
programmer.
I wish to learn (for fun) driver programming, and hope it will teach me some things about Linux and "get into it".
My first hurdle is to find a distro with a standard 2.6.x
kernel. I tried to find one but they are all past 3.x
now. Any one know of a suitable one for this kind of task?
Also the book says I should get a standard kernel from kernel.org
and build a source tree. I have no idea what that means.
This is the book: http://oreilly.com/openbook/linuxdrive3/book/
kernel drivers distributions tree
kernel drivers distributions tree
edited 5 hours ago
Rui F Ribeiro
42.1k1484142
42.1k1484142
asked Feb 17 '14 at 16:53
sprocket12sprocket12
1941112
1941112
You can download older kernels from kernel.org
– mkc
Feb 17 '14 at 17:02
@Ketan yes fortunately I know that part. However I do not know what building a source tree means.
– sprocket12
Feb 17 '14 at 17:03
AFAIK building means compiling in this context. Once you have your kernel unpacked look intoREADME
,INSTALL
etc. docs.
– mkc
Feb 17 '14 at 17:10
1
Questions like this one come up regularly and we should have a canonical version, so I wrote one: unix.stackexchange.com/questions/115620/…
– goldilocks
Feb 17 '14 at 21:59
add a comment |
You can download older kernels from kernel.org
– mkc
Feb 17 '14 at 17:02
@Ketan yes fortunately I know that part. However I do not know what building a source tree means.
– sprocket12
Feb 17 '14 at 17:03
AFAIK building means compiling in this context. Once you have your kernel unpacked look intoREADME
,INSTALL
etc. docs.
– mkc
Feb 17 '14 at 17:10
1
Questions like this one come up regularly and we should have a canonical version, so I wrote one: unix.stackexchange.com/questions/115620/…
– goldilocks
Feb 17 '14 at 21:59
You can download older kernels from kernel.org
– mkc
Feb 17 '14 at 17:02
You can download older kernels from kernel.org
– mkc
Feb 17 '14 at 17:02
@Ketan yes fortunately I know that part. However I do not know what building a source tree means.
– sprocket12
Feb 17 '14 at 17:03
@Ketan yes fortunately I know that part. However I do not know what building a source tree means.
– sprocket12
Feb 17 '14 at 17:03
AFAIK building means compiling in this context. Once you have your kernel unpacked look into
README
, INSTALL
etc. docs.– mkc
Feb 17 '14 at 17:10
AFAIK building means compiling in this context. Once you have your kernel unpacked look into
README
, INSTALL
etc. docs.– mkc
Feb 17 '14 at 17:10
1
1
Questions like this one come up regularly and we should have a canonical version, so I wrote one: unix.stackexchange.com/questions/115620/…
– goldilocks
Feb 17 '14 at 21:59
Questions like this one come up regularly and we should have a canonical version, so I wrote one: unix.stackexchange.com/questions/115620/…
– goldilocks
Feb 17 '14 at 21:59
add a comment |
3 Answers
3
active
oldest
votes
You know of kernel.org
, and this is where you can get vanilla kernels from old or new. For the newest kernels you can also use git.
Once you have a kernel, to create a "source tree", you just unpack it. For example, if you downloaded a .bz2
archive, you could unpack it with the command tar -jxvf <kernel version>.bz2
. Traditionally this tree is located in /usr/src
and the symlink /usr/src/linux
is made to point at the specific kernel directory you are using.
Once you have unpacked the source tree, to build it you need to first configure it e.g. make menuconfig
(ncurses based) or make xconfig
(X based). There are a few other config make targets if you are migrating a .config from a different kernel version. Finally, to build the kernel and its modules, use make
. To install and boot the kernel use make modules_install
for the modules and copy arch/<your arch>/boot/bzImage
to wherever your bootloader expects kernels to be and configure it to boot that kernel. You will need to boot into the kernel if you expect to load any modules you build against it.
With that said, if you just want to experiment with building modules, just grab the source from your current distro kernel (there will be a package) and build modules against that kernel rather than going through the above process. It's not hard, but if you are new to the kernel it may be a bit overwhelming.
I have downloaded an ISO for CentOS 6.5 which uses a 2.6 kernel. Would that be sufficient (in a VM) or would I have to download another to get a source tree?
– sprocket12
Feb 18 '14 at 11:47
add a comment |
It has been a while since I played with kernel drivers, but the following is what I had set up:
- A multiboot machine, with at least 2 partitions for two distributions
- One partition with an up-to-date Linux that stays stable, from which the MBR is boots.
- A virtual machine with the target development kernel, running under the up-to-date Linux.
- second partition with the target development kernel, which is booted through the grub configuration on the stable up-to-date Linux.
Initial development and testing is done on the virtual machine (VM) with only working drivers copied to the target development machine. You take regular snapshots of the VM, in particular before you inject a possible broken driver in the kernel of the VM. That way you can easily roll-back to a working development system state. If you don't need to test your driver on real hardware you do not need the second partition at all.
In your case I would install something like Ubuntu 10.04 on the VM (and the second partition). It comes with a 2.6 kernel and everything is there and fits together (any other distribution with a 2.6 kernel version). You just have to download the kernel sources and the development tools.
I think that will get you up and running faster than starting from scratch with a new kernel checked out from kernel.org, at least it did back in my SuSE 6 days.
Anthon, are you saying if I get Ubuntu 10.04 it already has its source tree of a 2.6 kernal, so I would not need to download/compile etc. for the book?
– sprocket12
Feb 18 '14 at 11:46
@Muhammad you would have to install the source for the kernel, but you could do that with the normalapt-get install
command, and you would get any dependencies as well -> less searching to get something that is compilable.
– Anthon
Feb 18 '14 at 11:48
Anthon, could I do the same with the current CentOS 6.5 which comes with a 2.6.x kernel? I know that would useyum
but the same downloading of source should be possible right?
– sprocket12
Feb 18 '14 at 11:50
I have not used CentOS, but I guess that would amount to the same, I suggested Ubuntu because that is what I am familiar with (now). You would have to search for kernel and src/source and get the package. There is a good chance that also pulls in all of the necessary tools to build the kernel (assuming the dependencies are correct).
– Anthon
Feb 18 '14 at 11:52
add a comment |
As per my commment, having seen questions similar to this before, I decided to write a canonical version which I think should get you started with configuring, building, and installing a kernel. But here I wanted to address some points specific to your case:
I wish to learn (for fun) driver programming, and hope it will teach me some things about Linux and help me "get into it".
I don't think this is a good reason. 99.9%+ of even long term power users never get involved with driver programming, including those who use the platform for development in C. By analogy, if someone who had never used MS Windows before said to you, "Well, I've got it installed now, and I thought a good way to learn about Windows would be to start writing a device driver for it...", what would you think?
I'd start fooling around with C doing platform specific things in userspace first, e.g., filesystem and networking stuff.
My first hurdle is to find a distro with a standard 2.6.x kernel. I tried to find one but they are all past 3.x now.
You don't need to do that. Most likely, a 2.6 kernel will still run fine on a current distro -- it's easy enough to try, of course. But beyond that, if the reason is because you are using LDD3 (the O'Reilly book), a 3.x kernel will still be compatible with most or all of that. Much (probably, most) of the driver code in the 3.x kernel exists unchanged from 2.6, and I'm sure the kernel devs consider it a priority to maintain this backward compatibility. The vanilla source is something like 16 million LOC; it can't all be constantly re-written.
So go ahead and try with whatever version you want.
Thanks goldilocks you are right it doesn't seem like a natural place to start with drivers, however since I have been programming at a higher level for the last 8 years I wished to try something low level, learning a bit of c and Linux at the same time.
– sprocket12
Feb 18 '14 at 11:37
add a comment |
Your Answer
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "106"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: false,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f115577%2fhow-to-create-a-kernel-source-tree%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
3 Answers
3
active
oldest
votes
3 Answers
3
active
oldest
votes
active
oldest
votes
active
oldest
votes
You know of kernel.org
, and this is where you can get vanilla kernels from old or new. For the newest kernels you can also use git.
Once you have a kernel, to create a "source tree", you just unpack it. For example, if you downloaded a .bz2
archive, you could unpack it with the command tar -jxvf <kernel version>.bz2
. Traditionally this tree is located in /usr/src
and the symlink /usr/src/linux
is made to point at the specific kernel directory you are using.
Once you have unpacked the source tree, to build it you need to first configure it e.g. make menuconfig
(ncurses based) or make xconfig
(X based). There are a few other config make targets if you are migrating a .config from a different kernel version. Finally, to build the kernel and its modules, use make
. To install and boot the kernel use make modules_install
for the modules and copy arch/<your arch>/boot/bzImage
to wherever your bootloader expects kernels to be and configure it to boot that kernel. You will need to boot into the kernel if you expect to load any modules you build against it.
With that said, if you just want to experiment with building modules, just grab the source from your current distro kernel (there will be a package) and build modules against that kernel rather than going through the above process. It's not hard, but if you are new to the kernel it may be a bit overwhelming.
I have downloaded an ISO for CentOS 6.5 which uses a 2.6 kernel. Would that be sufficient (in a VM) or would I have to download another to get a source tree?
– sprocket12
Feb 18 '14 at 11:47
add a comment |
You know of kernel.org
, and this is where you can get vanilla kernels from old or new. For the newest kernels you can also use git.
Once you have a kernel, to create a "source tree", you just unpack it. For example, if you downloaded a .bz2
archive, you could unpack it with the command tar -jxvf <kernel version>.bz2
. Traditionally this tree is located in /usr/src
and the symlink /usr/src/linux
is made to point at the specific kernel directory you are using.
Once you have unpacked the source tree, to build it you need to first configure it e.g. make menuconfig
(ncurses based) or make xconfig
(X based). There are a few other config make targets if you are migrating a .config from a different kernel version. Finally, to build the kernel and its modules, use make
. To install and boot the kernel use make modules_install
for the modules and copy arch/<your arch>/boot/bzImage
to wherever your bootloader expects kernels to be and configure it to boot that kernel. You will need to boot into the kernel if you expect to load any modules you build against it.
With that said, if you just want to experiment with building modules, just grab the source from your current distro kernel (there will be a package) and build modules against that kernel rather than going through the above process. It's not hard, but if you are new to the kernel it may be a bit overwhelming.
I have downloaded an ISO for CentOS 6.5 which uses a 2.6 kernel. Would that be sufficient (in a VM) or would I have to download another to get a source tree?
– sprocket12
Feb 18 '14 at 11:47
add a comment |
You know of kernel.org
, and this is where you can get vanilla kernels from old or new. For the newest kernels you can also use git.
Once you have a kernel, to create a "source tree", you just unpack it. For example, if you downloaded a .bz2
archive, you could unpack it with the command tar -jxvf <kernel version>.bz2
. Traditionally this tree is located in /usr/src
and the symlink /usr/src/linux
is made to point at the specific kernel directory you are using.
Once you have unpacked the source tree, to build it you need to first configure it e.g. make menuconfig
(ncurses based) or make xconfig
(X based). There are a few other config make targets if you are migrating a .config from a different kernel version. Finally, to build the kernel and its modules, use make
. To install and boot the kernel use make modules_install
for the modules and copy arch/<your arch>/boot/bzImage
to wherever your bootloader expects kernels to be and configure it to boot that kernel. You will need to boot into the kernel if you expect to load any modules you build against it.
With that said, if you just want to experiment with building modules, just grab the source from your current distro kernel (there will be a package) and build modules against that kernel rather than going through the above process. It's not hard, but if you are new to the kernel it may be a bit overwhelming.
You know of kernel.org
, and this is where you can get vanilla kernels from old or new. For the newest kernels you can also use git.
Once you have a kernel, to create a "source tree", you just unpack it. For example, if you downloaded a .bz2
archive, you could unpack it with the command tar -jxvf <kernel version>.bz2
. Traditionally this tree is located in /usr/src
and the symlink /usr/src/linux
is made to point at the specific kernel directory you are using.
Once you have unpacked the source tree, to build it you need to first configure it e.g. make menuconfig
(ncurses based) or make xconfig
(X based). There are a few other config make targets if you are migrating a .config from a different kernel version. Finally, to build the kernel and its modules, use make
. To install and boot the kernel use make modules_install
for the modules and copy arch/<your arch>/boot/bzImage
to wherever your bootloader expects kernels to be and configure it to boot that kernel. You will need to boot into the kernel if you expect to load any modules you build against it.
With that said, if you just want to experiment with building modules, just grab the source from your current distro kernel (there will be a package) and build modules against that kernel rather than going through the above process. It's not hard, but if you are new to the kernel it may be a bit overwhelming.
answered Feb 17 '14 at 18:20
caseycasey
11.7k33558
11.7k33558
I have downloaded an ISO for CentOS 6.5 which uses a 2.6 kernel. Would that be sufficient (in a VM) or would I have to download another to get a source tree?
– sprocket12
Feb 18 '14 at 11:47
add a comment |
I have downloaded an ISO for CentOS 6.5 which uses a 2.6 kernel. Would that be sufficient (in a VM) or would I have to download another to get a source tree?
– sprocket12
Feb 18 '14 at 11:47
I have downloaded an ISO for CentOS 6.5 which uses a 2.6 kernel. Would that be sufficient (in a VM) or would I have to download another to get a source tree?
– sprocket12
Feb 18 '14 at 11:47
I have downloaded an ISO for CentOS 6.5 which uses a 2.6 kernel. Would that be sufficient (in a VM) or would I have to download another to get a source tree?
– sprocket12
Feb 18 '14 at 11:47
add a comment |
It has been a while since I played with kernel drivers, but the following is what I had set up:
- A multiboot machine, with at least 2 partitions for two distributions
- One partition with an up-to-date Linux that stays stable, from which the MBR is boots.
- A virtual machine with the target development kernel, running under the up-to-date Linux.
- second partition with the target development kernel, which is booted through the grub configuration on the stable up-to-date Linux.
Initial development and testing is done on the virtual machine (VM) with only working drivers copied to the target development machine. You take regular snapshots of the VM, in particular before you inject a possible broken driver in the kernel of the VM. That way you can easily roll-back to a working development system state. If you don't need to test your driver on real hardware you do not need the second partition at all.
In your case I would install something like Ubuntu 10.04 on the VM (and the second partition). It comes with a 2.6 kernel and everything is there and fits together (any other distribution with a 2.6 kernel version). You just have to download the kernel sources and the development tools.
I think that will get you up and running faster than starting from scratch with a new kernel checked out from kernel.org, at least it did back in my SuSE 6 days.
Anthon, are you saying if I get Ubuntu 10.04 it already has its source tree of a 2.6 kernal, so I would not need to download/compile etc. for the book?
– sprocket12
Feb 18 '14 at 11:46
@Muhammad you would have to install the source for the kernel, but you could do that with the normalapt-get install
command, and you would get any dependencies as well -> less searching to get something that is compilable.
– Anthon
Feb 18 '14 at 11:48
Anthon, could I do the same with the current CentOS 6.5 which comes with a 2.6.x kernel? I know that would useyum
but the same downloading of source should be possible right?
– sprocket12
Feb 18 '14 at 11:50
I have not used CentOS, but I guess that would amount to the same, I suggested Ubuntu because that is what I am familiar with (now). You would have to search for kernel and src/source and get the package. There is a good chance that also pulls in all of the necessary tools to build the kernel (assuming the dependencies are correct).
– Anthon
Feb 18 '14 at 11:52
add a comment |
It has been a while since I played with kernel drivers, but the following is what I had set up:
- A multiboot machine, with at least 2 partitions for two distributions
- One partition with an up-to-date Linux that stays stable, from which the MBR is boots.
- A virtual machine with the target development kernel, running under the up-to-date Linux.
- second partition with the target development kernel, which is booted through the grub configuration on the stable up-to-date Linux.
Initial development and testing is done on the virtual machine (VM) with only working drivers copied to the target development machine. You take regular snapshots of the VM, in particular before you inject a possible broken driver in the kernel of the VM. That way you can easily roll-back to a working development system state. If you don't need to test your driver on real hardware you do not need the second partition at all.
In your case I would install something like Ubuntu 10.04 on the VM (and the second partition). It comes with a 2.6 kernel and everything is there and fits together (any other distribution with a 2.6 kernel version). You just have to download the kernel sources and the development tools.
I think that will get you up and running faster than starting from scratch with a new kernel checked out from kernel.org, at least it did back in my SuSE 6 days.
Anthon, are you saying if I get Ubuntu 10.04 it already has its source tree of a 2.6 kernal, so I would not need to download/compile etc. for the book?
– sprocket12
Feb 18 '14 at 11:46
@Muhammad you would have to install the source for the kernel, but you could do that with the normalapt-get install
command, and you would get any dependencies as well -> less searching to get something that is compilable.
– Anthon
Feb 18 '14 at 11:48
Anthon, could I do the same with the current CentOS 6.5 which comes with a 2.6.x kernel? I know that would useyum
but the same downloading of source should be possible right?
– sprocket12
Feb 18 '14 at 11:50
I have not used CentOS, but I guess that would amount to the same, I suggested Ubuntu because that is what I am familiar with (now). You would have to search for kernel and src/source and get the package. There is a good chance that also pulls in all of the necessary tools to build the kernel (assuming the dependencies are correct).
– Anthon
Feb 18 '14 at 11:52
add a comment |
It has been a while since I played with kernel drivers, but the following is what I had set up:
- A multiboot machine, with at least 2 partitions for two distributions
- One partition with an up-to-date Linux that stays stable, from which the MBR is boots.
- A virtual machine with the target development kernel, running under the up-to-date Linux.
- second partition with the target development kernel, which is booted through the grub configuration on the stable up-to-date Linux.
Initial development and testing is done on the virtual machine (VM) with only working drivers copied to the target development machine. You take regular snapshots of the VM, in particular before you inject a possible broken driver in the kernel of the VM. That way you can easily roll-back to a working development system state. If you don't need to test your driver on real hardware you do not need the second partition at all.
In your case I would install something like Ubuntu 10.04 on the VM (and the second partition). It comes with a 2.6 kernel and everything is there and fits together (any other distribution with a 2.6 kernel version). You just have to download the kernel sources and the development tools.
I think that will get you up and running faster than starting from scratch with a new kernel checked out from kernel.org, at least it did back in my SuSE 6 days.
It has been a while since I played with kernel drivers, but the following is what I had set up:
- A multiboot machine, with at least 2 partitions for two distributions
- One partition with an up-to-date Linux that stays stable, from which the MBR is boots.
- A virtual machine with the target development kernel, running under the up-to-date Linux.
- second partition with the target development kernel, which is booted through the grub configuration on the stable up-to-date Linux.
Initial development and testing is done on the virtual machine (VM) with only working drivers copied to the target development machine. You take regular snapshots of the VM, in particular before you inject a possible broken driver in the kernel of the VM. That way you can easily roll-back to a working development system state. If you don't need to test your driver on real hardware you do not need the second partition at all.
In your case I would install something like Ubuntu 10.04 on the VM (and the second partition). It comes with a 2.6 kernel and everything is there and fits together (any other distribution with a 2.6 kernel version). You just have to download the kernel sources and the development tools.
I think that will get you up and running faster than starting from scratch with a new kernel checked out from kernel.org, at least it did back in my SuSE 6 days.
answered Feb 17 '14 at 18:18
AnthonAnthon
61.7k17107171
61.7k17107171
Anthon, are you saying if I get Ubuntu 10.04 it already has its source tree of a 2.6 kernal, so I would not need to download/compile etc. for the book?
– sprocket12
Feb 18 '14 at 11:46
@Muhammad you would have to install the source for the kernel, but you could do that with the normalapt-get install
command, and you would get any dependencies as well -> less searching to get something that is compilable.
– Anthon
Feb 18 '14 at 11:48
Anthon, could I do the same with the current CentOS 6.5 which comes with a 2.6.x kernel? I know that would useyum
but the same downloading of source should be possible right?
– sprocket12
Feb 18 '14 at 11:50
I have not used CentOS, but I guess that would amount to the same, I suggested Ubuntu because that is what I am familiar with (now). You would have to search for kernel and src/source and get the package. There is a good chance that also pulls in all of the necessary tools to build the kernel (assuming the dependencies are correct).
– Anthon
Feb 18 '14 at 11:52
add a comment |
Anthon, are you saying if I get Ubuntu 10.04 it already has its source tree of a 2.6 kernal, so I would not need to download/compile etc. for the book?
– sprocket12
Feb 18 '14 at 11:46
@Muhammad you would have to install the source for the kernel, but you could do that with the normalapt-get install
command, and you would get any dependencies as well -> less searching to get something that is compilable.
– Anthon
Feb 18 '14 at 11:48
Anthon, could I do the same with the current CentOS 6.5 which comes with a 2.6.x kernel? I know that would useyum
but the same downloading of source should be possible right?
– sprocket12
Feb 18 '14 at 11:50
I have not used CentOS, but I guess that would amount to the same, I suggested Ubuntu because that is what I am familiar with (now). You would have to search for kernel and src/source and get the package. There is a good chance that also pulls in all of the necessary tools to build the kernel (assuming the dependencies are correct).
– Anthon
Feb 18 '14 at 11:52
Anthon, are you saying if I get Ubuntu 10.04 it already has its source tree of a 2.6 kernal, so I would not need to download/compile etc. for the book?
– sprocket12
Feb 18 '14 at 11:46
Anthon, are you saying if I get Ubuntu 10.04 it already has its source tree of a 2.6 kernal, so I would not need to download/compile etc. for the book?
– sprocket12
Feb 18 '14 at 11:46
@Muhammad you would have to install the source for the kernel, but you could do that with the normal
apt-get install
command, and you would get any dependencies as well -> less searching to get something that is compilable.– Anthon
Feb 18 '14 at 11:48
@Muhammad you would have to install the source for the kernel, but you could do that with the normal
apt-get install
command, and you would get any dependencies as well -> less searching to get something that is compilable.– Anthon
Feb 18 '14 at 11:48
Anthon, could I do the same with the current CentOS 6.5 which comes with a 2.6.x kernel? I know that would use
yum
but the same downloading of source should be possible right?– sprocket12
Feb 18 '14 at 11:50
Anthon, could I do the same with the current CentOS 6.5 which comes with a 2.6.x kernel? I know that would use
yum
but the same downloading of source should be possible right?– sprocket12
Feb 18 '14 at 11:50
I have not used CentOS, but I guess that would amount to the same, I suggested Ubuntu because that is what I am familiar with (now). You would have to search for kernel and src/source and get the package. There is a good chance that also pulls in all of the necessary tools to build the kernel (assuming the dependencies are correct).
– Anthon
Feb 18 '14 at 11:52
I have not used CentOS, but I guess that would amount to the same, I suggested Ubuntu because that is what I am familiar with (now). You would have to search for kernel and src/source and get the package. There is a good chance that also pulls in all of the necessary tools to build the kernel (assuming the dependencies are correct).
– Anthon
Feb 18 '14 at 11:52
add a comment |
As per my commment, having seen questions similar to this before, I decided to write a canonical version which I think should get you started with configuring, building, and installing a kernel. But here I wanted to address some points specific to your case:
I wish to learn (for fun) driver programming, and hope it will teach me some things about Linux and help me "get into it".
I don't think this is a good reason. 99.9%+ of even long term power users never get involved with driver programming, including those who use the platform for development in C. By analogy, if someone who had never used MS Windows before said to you, "Well, I've got it installed now, and I thought a good way to learn about Windows would be to start writing a device driver for it...", what would you think?
I'd start fooling around with C doing platform specific things in userspace first, e.g., filesystem and networking stuff.
My first hurdle is to find a distro with a standard 2.6.x kernel. I tried to find one but they are all past 3.x now.
You don't need to do that. Most likely, a 2.6 kernel will still run fine on a current distro -- it's easy enough to try, of course. But beyond that, if the reason is because you are using LDD3 (the O'Reilly book), a 3.x kernel will still be compatible with most or all of that. Much (probably, most) of the driver code in the 3.x kernel exists unchanged from 2.6, and I'm sure the kernel devs consider it a priority to maintain this backward compatibility. The vanilla source is something like 16 million LOC; it can't all be constantly re-written.
So go ahead and try with whatever version you want.
Thanks goldilocks you are right it doesn't seem like a natural place to start with drivers, however since I have been programming at a higher level for the last 8 years I wished to try something low level, learning a bit of c and Linux at the same time.
– sprocket12
Feb 18 '14 at 11:37
add a comment |
As per my commment, having seen questions similar to this before, I decided to write a canonical version which I think should get you started with configuring, building, and installing a kernel. But here I wanted to address some points specific to your case:
I wish to learn (for fun) driver programming, and hope it will teach me some things about Linux and help me "get into it".
I don't think this is a good reason. 99.9%+ of even long term power users never get involved with driver programming, including those who use the platform for development in C. By analogy, if someone who had never used MS Windows before said to you, "Well, I've got it installed now, and I thought a good way to learn about Windows would be to start writing a device driver for it...", what would you think?
I'd start fooling around with C doing platform specific things in userspace first, e.g., filesystem and networking stuff.
My first hurdle is to find a distro with a standard 2.6.x kernel. I tried to find one but they are all past 3.x now.
You don't need to do that. Most likely, a 2.6 kernel will still run fine on a current distro -- it's easy enough to try, of course. But beyond that, if the reason is because you are using LDD3 (the O'Reilly book), a 3.x kernel will still be compatible with most or all of that. Much (probably, most) of the driver code in the 3.x kernel exists unchanged from 2.6, and I'm sure the kernel devs consider it a priority to maintain this backward compatibility. The vanilla source is something like 16 million LOC; it can't all be constantly re-written.
So go ahead and try with whatever version you want.
Thanks goldilocks you are right it doesn't seem like a natural place to start with drivers, however since I have been programming at a higher level for the last 8 years I wished to try something low level, learning a bit of c and Linux at the same time.
– sprocket12
Feb 18 '14 at 11:37
add a comment |
As per my commment, having seen questions similar to this before, I decided to write a canonical version which I think should get you started with configuring, building, and installing a kernel. But here I wanted to address some points specific to your case:
I wish to learn (for fun) driver programming, and hope it will teach me some things about Linux and help me "get into it".
I don't think this is a good reason. 99.9%+ of even long term power users never get involved with driver programming, including those who use the platform for development in C. By analogy, if someone who had never used MS Windows before said to you, "Well, I've got it installed now, and I thought a good way to learn about Windows would be to start writing a device driver for it...", what would you think?
I'd start fooling around with C doing platform specific things in userspace first, e.g., filesystem and networking stuff.
My first hurdle is to find a distro with a standard 2.6.x kernel. I tried to find one but they are all past 3.x now.
You don't need to do that. Most likely, a 2.6 kernel will still run fine on a current distro -- it's easy enough to try, of course. But beyond that, if the reason is because you are using LDD3 (the O'Reilly book), a 3.x kernel will still be compatible with most or all of that. Much (probably, most) of the driver code in the 3.x kernel exists unchanged from 2.6, and I'm sure the kernel devs consider it a priority to maintain this backward compatibility. The vanilla source is something like 16 million LOC; it can't all be constantly re-written.
So go ahead and try with whatever version you want.
As per my commment, having seen questions similar to this before, I decided to write a canonical version which I think should get you started with configuring, building, and installing a kernel. But here I wanted to address some points specific to your case:
I wish to learn (for fun) driver programming, and hope it will teach me some things about Linux and help me "get into it".
I don't think this is a good reason. 99.9%+ of even long term power users never get involved with driver programming, including those who use the platform for development in C. By analogy, if someone who had never used MS Windows before said to you, "Well, I've got it installed now, and I thought a good way to learn about Windows would be to start writing a device driver for it...", what would you think?
I'd start fooling around with C doing platform specific things in userspace first, e.g., filesystem and networking stuff.
My first hurdle is to find a distro with a standard 2.6.x kernel. I tried to find one but they are all past 3.x now.
You don't need to do that. Most likely, a 2.6 kernel will still run fine on a current distro -- it's easy enough to try, of course. But beyond that, if the reason is because you are using LDD3 (the O'Reilly book), a 3.x kernel will still be compatible with most or all of that. Much (probably, most) of the driver code in the 3.x kernel exists unchanged from 2.6, and I'm sure the kernel devs consider it a priority to maintain this backward compatibility. The vanilla source is something like 16 million LOC; it can't all be constantly re-written.
So go ahead and try with whatever version you want.
edited Apr 13 '17 at 12:36
Community♦
1
1
answered Feb 17 '14 at 22:18
goldilocksgoldilocks
63.5k18157214
63.5k18157214
Thanks goldilocks you are right it doesn't seem like a natural place to start with drivers, however since I have been programming at a higher level for the last 8 years I wished to try something low level, learning a bit of c and Linux at the same time.
– sprocket12
Feb 18 '14 at 11:37
add a comment |
Thanks goldilocks you are right it doesn't seem like a natural place to start with drivers, however since I have been programming at a higher level for the last 8 years I wished to try something low level, learning a bit of c and Linux at the same time.
– sprocket12
Feb 18 '14 at 11:37
Thanks goldilocks you are right it doesn't seem like a natural place to start with drivers, however since I have been programming at a higher level for the last 8 years I wished to try something low level, learning a bit of c and Linux at the same time.
– sprocket12
Feb 18 '14 at 11:37
Thanks goldilocks you are right it doesn't seem like a natural place to start with drivers, however since I have been programming at a higher level for the last 8 years I wished to try something low level, learning a bit of c and Linux at the same time.
– sprocket12
Feb 18 '14 at 11:37
add a comment |
Thanks for contributing an answer to Unix & Linux Stack Exchange!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f115577%2fhow-to-create-a-kernel-source-tree%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
You can download older kernels from kernel.org
– mkc
Feb 17 '14 at 17:02
@Ketan yes fortunately I know that part. However I do not know what building a source tree means.
– sprocket12
Feb 17 '14 at 17:03
AFAIK building means compiling in this context. Once you have your kernel unpacked look into
README
,INSTALL
etc. docs.– mkc
Feb 17 '14 at 17:10
1
Questions like this one come up regularly and we should have a canonical version, so I wrote one: unix.stackexchange.com/questions/115620/…
– goldilocks
Feb 17 '14 at 21:59