Kernel hello world

deltrocc This page presents the kernel version of hello world, which is embodied as a kernel module.

The following files contain all of the pertinent information: * hello-module.c   * Makefile

The Makefile assumes that you create a directory parallel to the gumstix-buildroot (i.e. on my system, gumstix-build root can be found at /home/dhylands/gumstix/gumstix-buildroot, so for the hello-module example, I'd create /home/dhylands/gumstix/hello-module).

Once you've copied hello-module.c and Makefile into the hello-module directory, type make

and the hello-module.ko file will be built. Copy the hello-module.ko file onto the gumstix and use the command: insmod directory-path/hello-module.ko

insmod requires a path to the actual .ko file. A simpler method is to use modpobe, which will also cause any modules that your modules depends on to also be loaded. To use modprobe, copy your hello-module.ko file in /lib/modules/2.6.20-rt5gum/some-directory. The 2.6.20-rt5gum portion will change depending on the version of kernel and exact options selected. It's important that the module be located in a directory under the 2.6.20-rt5gum directory (you can create your own). Then type: /sbin/depmod -a modprobe hello-module

The depmod step is normally done as part of booting and only needs to be done when a new module is copied onto the gumstix.

To get your module to load automatically every time the gumstix boots, add a line to the /etc/modules file containing the name of the module as you would pass it to modprobe.

See the Resources section of the Kernel programming page for additional information on writing kernel modules.