Skip to content. | Skip to navigation

Sections
You are here: Home Resources Documentation PetaLinux 0.40 final User Guide Customising PetaLinux Creating New Kernel Modules

Creating New Kernel Modules

In addition to user applications, embedded Linux systems often use custom kernel modules to create new functionality such as device drivers. This section describes the process of adding or creating a new user module into PetaLinux.

The 'user-modules' Directory

PetaLinux includes the '$PETALINUX/software/user-modules' directory to house all custom kernel modules. Any new module can be added into this directory.

Using 'petalinux-new-module' Script

The 'petalinux-new-module' script automates the creation of a new module build environment, including the directory structure and template Makefile and 'C' source file. The created module environment can also be used to import an existing module, ready for cross-compilation to the MicroBlaze. The usage information of the 'pertalinux-new-module' script can be found in the PetaLinux Tools Section.

$ cd $PETALINUX/software/user-modues
$ petalinux-new-module my_new_module
New module template successfully created in software/user-modules/my_new_module
See my_new_module/README for what to do next.

The above example will create a module directory called 'my_new_module' along with a Makefile, C source file and a README file.

You can now start extending this module to meet your needs.

Adding an Existing Module

Adding an existing module is just as straight forward.

Create a directory for the module

Use the 'petalinux-new-module' script to create a directory structure within '$PETALINUX/software/user-modules'

$ cd $PETALINUX/software/user-modules
$ petelinux-new-module my_existing_module
New module template successfully created in software/user-modules/my_existing_module
See my_existing_module/README for what to do next.

Copy source files to the new module directory

Copy the source files of the module into the new module directory created in the previous step.

Note: Ensure that the Makefile in the new module directory is not overwritten.

Edit the Makefile

Edit the Makefile to include the build rules for your existing module.

Installing Modules into Root Filesystem

The module binaries must be installed into the romfs of the target system before they can be used. This romfs directory is compile into the kernel image during the kernel image build process.

To install the module simply use the 'make romfs' command.

$ cd $PETALINUX/software/user-modules/my_existing_module
$ make romfs
Document Actions
Quick Contact

spartan6-package

 

Xilinx Spartan 6 fully supported in PetaLinux SDK

 
Site by:
Personal tools