Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Learning kernel hacking and embedded development at home? [closed]

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

Thanks!

like image 623
abyx Avatar asked Sep 13 '08 18:09

abyx


People also ask

Do I need to learn Linux for embedded systems?

Operating systems abound and the choices are many for an embedded system, both proprietary and open source. Linux is one of these choices. No matter what you use for your development host, whether Linux or Windows or Mac, you need to learn how to program using the target OS.

Can embedded system be hacked?

Attackers have hacked embedded systems to spy on the devices, to take control of them or simply to disable (brick) them. Embedded systems exist in a wide variety of devices including Internet and wireless access points, IP cameras, security systems, pace makers, drones and industrial control systems.


2 Answers

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.

A good place to start is probably Kernelnewbies.org - 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.

Some books to read:

Understanding the Linux Kernel - a very good reference detailing the design of the kernel subsystems

Linux Device Drivers - 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.

Linux Kernel Module Programming Guide - Some more introductory material

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 - lxr.linux.no

To understand the Kernel Build process, this link might be helpful:

Linux Kernel Makefiles (kbuild)

Last but not least, browse the Documentation directory of the Kernel Source distribution!

Here are some interesting exercises insolently stolen from a kernel development class:

  • Write a kernel module which creates the file /proc/jiffies reporting the current time in jiffies on every read access.
  • 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)
  • 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.
  • Modify the pipe example module to register as a character device /dev/pipe, add dynamic memory allocation for write requests.
  • Write a really simple file system.
like image 99
VolkA Avatar answered Sep 22 '22 14:09

VolkA


An absolute must is this book by Rubini. (available both as a hardcopy or a free soft copy)

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.

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)

They usually have vga connectors that make it easier to do debugging.

like image 42
Andrew Edgecombe Avatar answered Sep 23 '22 14:09

Andrew Edgecombe