<p>I was always attracted to the world of kernel hacking and embedded systems.<br>
Has anyone got good tutorials (+easily available hardware) on starting to mess with such stuff?<br>
Something like kits for writing drivers etc, which come with good documentation and are affordable?</p>

<p>Thanks!</p>

[{'answer_id': 60812, 'author': 'readonly', 'author_id': 4883, 'author_profile': 'https://Stackoverflow.com/users/4883', 'pm_score': 2, 'selected': False, 'text': '<p>For embedded Linux hacking, simple Linksys WRT54G router that you can buy everywhere is a development platform on its own <a href="http://en.wikipedia.org/wiki/Linksys_WRT54G_series" rel="nofollow noreferrer">http://en.wikipedia.org/wiki/Linksys_WRT54G_series</a>:</p>\n\n<blockquote>\n  <p>The WRT54G is notable for being the first consumer-level network device that had its firmware source code released to satisfy the obligations of the GNU GPL. This allows programmers to modify the firmware to change or add functionality to the device. Several third-party firmware projects provide the public with enhanced firmware for the WRT54G. </p>\n</blockquote>\n\n<p>I\'ve tried installing <a href="http://www.openwrt.org" rel="nofollow noreferrer">OpenWrt</a> and <a href="http://www.dd-wrt.com" rel="nofollow noreferrer">DD-WRT</a> firmware on it.  You can check those out as a starting point for hacking on a low-cost platform.</p>\n'}, {'answer_id': 61124, 'author': 'DGentry', 'author_id': 4761, 'author_profile': 'https://Stackoverflow.com/users/4761', 'pm_score': 1, 'selected': False, 'text': '<p>Some things to be prepared for:</p>\n\n<ul>\n<li>you\'ll be cross-compiling. The embedded device will use a MIPS, PowerPC, or ARM CPU but won\'t have enough CPU power, memory, or storage to compile its own kernel in a reasonable amount of time.  </li>\n<li>An embedded system often uses a serial port as the console, and to lower the cost there is usually no connector soldered onto production boards. Debugging kernel panics is very difficult unless you can solder on a serial port connector, you won\'t have much information about what went wrong.  </li>\n</ul>\n\n<p>The <A HREF="http://www.nslu2-linux.org/" rel="nofollow noreferrer">Linksys NSLU2</A> is a low-cost way to get a real embedded system to work with, and has a USB port to add peripherals. Any of a number of wireless access points can also be used, see the <A HREF="http://wiki.openwrt.org/TableOfHardware" rel="nofollow noreferrer">OpenWrt compatibility page.</A> Be aware that current models of the Linksys WRT54G you\'ll find in stores can no longer be used with Linux: they have less RAM and Flash in order to reduce the cost. Cisco/Linksys now uses vxWorks on the WRT54G, with a smaller memory footprint.</p>\n\n<p>If you really want to get into it, evaluation kits for embedded CPUs start at a couple hundred US dollars. I\'d recommend not spending money on these unless you need it professionally for a job or consulting contract.</p>\n'}, {'answer_id': 65433, 'author': 'terminus', 'author_id': 9232, 'author_profile': 'https://Stackoverflow.com/users/9232', 'pm_score': 2, 'selected': False, 'text': '<p>For starters, the best way is to read a lot of code. Since Linux is Open Source, you\'ll find dozens of drivers. Find one that works in some ways like what you want to write. You\'ll find some decent and relatively easy-to-understand code (the loopback device, ROM fs, etc.)</p>\n\n<p>You can also use the <a href="http://lxr.linux.no" rel="nofollow noreferrer">lxr.linux.no</a>, which is the Linux code cross-referenced. If you have to find out how something works, and need to look into the code, this is a good and easy way.</p>\n\n<p>There\'s also an O\'Reilly book (Understanding the Linux Kernel, the 3rd edition is about the 2.6 kernels) or if you want something for free, you can use the Advanced Linux Programing book (<a href="http://www.advancedlinuxprogramming.com/" rel="nofollow noreferrer">http://www.advancedlinuxprogramming.com/</a>). There are also a lot of specific documentation about file systems, networking, etc.</p>\n'}, {'answer_id': 152175, 'author': 'Andrew Edgecombe', 'author_id': 11694, 'author_profile': 'https://Stackoverflow.com/users/11694', 'pm_score': 3, 'selected': False, 'text': '<p>An absolute <strong>must</strong> is <a href="http://lwn.net/Kernel/LDD3/" rel="noreferrer">this</a> book by Rubini. (available both as a hardcopy or a free soft copy)</p>\n\n<p>He gives implementations of several dummy drivers that don\'t require that you have any hardware other than your pc. So for getting started in kernel development it\'s the easiest way to go.</p>\n\n<p>As for doing embedded work I would recommend purchasing one of the numerous SBC (single board computers) that are out there. There are a number of these that are based on x86 processors, usually with PC/104 interfaces (electrically PC/104 is identical to the ISA bus standard, but based on stackable connectors rather than edge connectors - very easy to interface custom hardware to)</p>\n\n<p>They usually have vga connectors that make it easier to do debugging.</p>\n'}, {'answer_id': 174559, 'author': 'VolkA', 'author_id': 25472, 'author_profile': 'https://Stackoverflow.com/users/25472', 'pm_score': 6, 'selected': True, 'text': '<p>If you are completely new to kernel development, i would suggest not starting with hardware development and going to some "software-only" kernel modules like proc file / sysfs or for more complex examples filesystem / network development , developing on a uml/vmware/virtualbox/... machine so crashing your machine won\'t hurt so much :) For embedded development you could go for a small ARM Development Kit or a small Via C3/C4 machine, or any old PC which you can burn with your homebrew USB / PCI / whatever device.</p>\n\n<p>A good place to start is probably <a href="http://kernelnewbies.org/" rel="noreferrer">Kernelnewbies.org</a> - which has lots of links and useful information for kernel developers, and also features a list of easy to implement tasks to tackle for beginners.</p>\n\n<p>Some books to read:</p>\n\n<p><a href="http://books.google.de/books?id=cbbMrRNiC4cC&amp;dq=understanding+the+linux+kernel&amp;pg=PP1&amp;ots=TvUb8_r9Yd&amp;sig=7Cn76JnJktn0B9cvLjh-pxFEdfo&amp;hl=de&amp;sa=X&amp;oi=book_result&amp;resnum=5&amp;ct=result#PPP1,M1" rel="noreferrer">Understanding the Linux Kernel</a> - a very good reference detailing the design of the kernel subsystems</p>\n\n<p><a href="http://lwn.net/Kernel/LDD3/" rel="noreferrer">Linux Device Drivers</a> - is written more like a tutorial with a lot of example code, focusing on getting you going and explaining key aspects of the linux kernel. It introduces the build process and the basics of kernel modules.</p>\n\n<p><a href="http://www.tldp.org/LDP/lkmpg/2.6/html/" rel="noreferrer">Linux Kernel Module Programming Guide</a> - Some more introductory material</p>\n\n<p>As suggested earlier, looking at the linux code is always a good idea, especially as Linux Kernel API\'s tend to change quite often ... LXR helps a lot with a very nice browsing interface - <a href="http://lxr.linux.no" rel="noreferrer">lxr.linux.no</a></p>\n\n<p>To understand the Kernel Build process, this link might be helpful:</p>\n\n<p><a href="http://www.ravnborg.org/kbuild/makefiles.html" rel="noreferrer">Linux Kernel Makefiles (kbuild)</a></p>\n\n<p>Last but not least, browse the Documentation directory of the Kernel Source distribution!</p>\n\n<p>Here are some interesting exercises insolently stolen from a kernel development class: </p>\n\n<ul>\n<li>Write a kernel module which creates the file /proc/jiffies reporting the current time in jiffies on every read access.</li>\n<li>Write a kernel module providing the proc file /proc/sleep. When an application writes a number of seconds as ASCII text into this file ("echo 3 > /proc/sleep"), it should block for the specified amount of seconds. Write accesses should have no side effect on the contents of the file, i.e., on the read accesses, the file should appear to be empty (see LDD3, ch. 6/7)</li>\n<li>Write a proc file where you can store some text temporarily (using echo "blah" > /proc/pipe) and get it out again (cat /proc/pipe), clearing the file. Watch out for synchronisation issues.</li>\n<li>Modify the pipe example module to register as a character device /dev/pipe, add dynamic memory allocation for write requests.</li>\n<li>Write a really simple file system.</li>\n</ul>\n'}, {'answer_id': 3608144, 'author': 'rsajdok', 'author_id': 360417, 'author_profile': 'https://Stackoverflow.com/users/360417', 'pm_score': 1, 'selected': False, 'text': '<p>I am completely beginner in kernel hacking :) I decided to buy two books "Linux Program Development: a guide with exercises" and "Writing Linux Device Drivers: a guide with exercises"  They are very clearly written and provide good base to further learning.</p>\n'}]
['https://Stackoverflow.com/questions/60763', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/573/']