Difference between revisions of "EBC Exercise 26 Device Drivers"
m |
(→Moving to Beagle: Finished the instructions) |
||
Line 19: | Line 19: | ||
=== Moving to Beagle === | === Moving to Beagle === | ||
− | On the beagle edit | + | On the beagle edit /lib/modules/2.6.32/modules.dep and add |
− | + | <pre> | |
− | + | /lib/modules/2.6.32/kernel/drivers/char/examples/hello1.ko: | |
− | + | </pre> | |
− | + | Then copy the file <code>…/drivers/char/examples/hello1.ko</code> on the host computer to <code>/lib/modules/2.6.32/kernel/drivers/char/examples/</code> on your Beagle. This can be done with a single command though you may have to mkdir the char/examples directory on the Beagle first. | |
− | + | <pre> | |
− | + | $ cd …/drivers/char/examples | |
− | /lib/modules/2.6. | + | $ rcp hello1.ko root@beagle:/lib/modules/2.6.32/kernel/drivers/char/examples |
− | + | </pre> | |
− | to Beagle | + | Now, on the Beagle, modprobe the module and check the log file. |
− | /lib/modules/2.6. | + | <pre> |
+ | # /sbin/modprobe hello1 | ||
+ | # dmesg | tail -4 | ||
+ | </pre> | ||
+ | You should see your Init message. And then... | ||
+ | <pre> | ||
+ | # /sbin/modprobe -r hello1 | ||
+ | # dmesg | tail -4 | ||
+ | </pre> | ||
+ | should show your Exit message. |
Revision as of 05:37, 1 April 2011
Chapter 8 of the text [1] gives a nice example of a minimal device driver. The purpose of this lab is to implement that driver.
Minimal Device Driver Example
Compiling
Follow the 5 steps given in section 8.1.4 on page 205. You can get a copy of Listing 8-1 here (ECE497_Listings_for_Embedded_Linux_Primer_Chapter_8). Once finished you will have a file called hello1.c
in .../drivers/char/examples
and have the kernel configure file and Makefile updated for the new driver. See section 4.4 on page 89 for help with modifying the config files.
Note: There is a typo in Listing 8-2.
If you have created the crossCompileEnv.sh file and sourced it, all you have to do to make the modules is cd to the top of the kernel directory and then:
$ make modules
Mine took a while the first time as it appears to compile all the modules. The second it only took 31 seconds.
Moving to Beagle
On the beagle edit /lib/modules/2.6.32/modules.dep and add
/lib/modules/2.6.32/kernel/drivers/char/examples/hello1.ko:
Then copy the file …/drivers/char/examples/hello1.ko
on the host computer to /lib/modules/2.6.32/kernel/drivers/char/examples/
on your Beagle. This can be done with a single command though you may have to mkdir the char/examples directory on the Beagle first.
$ cd …/drivers/char/examples $ rcp hello1.ko root@beagle:/lib/modules/2.6.32/kernel/drivers/char/examples
Now, on the Beagle, modprobe the module and check the log file.
# /sbin/modprobe hello1 # dmesg | tail -4
You should see your Init message. And then...
# /sbin/modprobe -r hello1 # dmesg | tail -4
should show your Exit message.