BBB Kernel Modules

From Klaus' wiki
Revision as of 15:35, 13 March 2016 by Klaus (Talk | contribs)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

Here you'll find inrofmation on kernel modules, i.e. the device drivers that extends the kernel so it will be able to handle specific hardware.

Getting started

First you'll need to download a few things before starting to develop kernel modules.

root ..$] apt-get update
root ..$] apt-cache search linux-headers-$(uname -r)

will update your local copy of the content on the remote repositories and then search through for the linux-headers.

Expect an output something like:

linux-headers-3.8.13-bone70 - Linux kernel headers for 3.8.13-bone70 on armhf

Then

root ..$] apt-get install linux-headers-$(uname -r)
 apt-get install linux-headers-$(uname -r)
 Reading package lists... Done
 Building dependency tree       
 Reading state information... Done
 The following NEW packages will be installed:
   linux-headers-3.8.13-bone70
 0 upgraded, 1 newly installed, 0 to remove and 161 not upgraded.
 Need to get 8430 kB of archives.
...

will install these development files on your BBB.

If you look into /usr/src/linux-headers-3.8.13-bone70 you'll find a Makefile. This is the main makefile for the kernel development. This is the one being use by the scull examples.

Add a user

If you havn't added yourself as a user do that now. You can develop and compile the kernel modules as an ordinary user. And this is the preferable way. <lang source=bash> $] useradd -d /home/<desired login name> -m -s `which bash` <desired login name> $] passwd <desired login name>

enter your desired password twice

</source> login as this user now.

The Linux Device Driver book

Along with the book "Linux Device Drivers" came a bunch of example drivers - the scull drivers.

Now create a directory for your copy of the examples of the scull drivers

$] mkdir /home/emb

next copy the drivers from bren to /home/emb

/home/emb $] scp klausk@bren.hih.au.dk:/home/emb/examples.tar.gz .

if you don't have a DNS entry for bren.hih.au.dk then use the IP address. And of course use your own login name.

Unpack the examples

$] tar zxvf examples.tar.gz