AR# 55997

PetaLinux - How do I add kernel modules to my PetaLinux root file system?

Description

I have kernel modules that I would like to include in my Linux root file system. How do I have the PetaLinux build process incorporate this code?

Solution

To have the PetaLinux build tools incorporate kernel modules, follow this general flow:

For PetaLinux 2013.10 and later:
 
Build-time Compiled Modules
 
  1. Use the petalinux-create -t modules to create a module project.
    The new module will be located in ${PETALINUX}/components/modules/<MODULE>/.
  2. Place the modules source code into ${PETALINUX_PROJECT}/components/modules/<MODULE>/
  3. Modify the makefile located inside ${PETALINUX_PROJECT}/components/modules/<MODULE>/ as required.

Pre-built Kernel Modules
 
Ensure that the kernel module has been compiled for your PetaLinux target architecture (for example, MicroBlaze, ARM, etc.).
 
  1. Use petalinux-create -t modules to create a module project.
    The new module will be located in ${PETALINUX_PROJECT}/components/modules/<MODULE>/.
  2. Place the pre-built kernel modules into ${PETALINUX_PROJECT}/components/modules/<MODULE>/
  3. Modify the makefile located in ${PETALINUX_PROJECT}/components/modules/<MODULE>/.
    • Ensure that the all: and clean: sections of the makefile are empty.
    • Update the install: section to copy the pre-built binaries into ${PETALINUX_PROJECT}/build/linux/rootfs/targetroot/.
An example of the modifications is as follows:

{{{
APP=myapp
all:

clean:

install: $(APP)
        $(TARGETINST) -d $(APP)-prebuilt /bin/$(APP) }}}

 
For PetaLinux 2013.04 and earlier:
 

Build-time Compiled Modules

  1. Use the petalinux-new-module to create a module project.
    The new module will be located in ${PETALINUX}/software/user-modules/<MODULE>/.
  2. Place the modules source code into ${PETALINUX}/software/user-modules/<MODULE>/
  3. Modify the makefile located in ${PETALINUX}/software/user-apps/<APP>/ as needed.


Pre-built Kernel Modules

Ensure that the kernel modules have been compiled for your PetaLinux target architecture (e.g., MicroBlaze, ARM, etc.).

  1. Use petalinux-new-module to create a module project.
    The new module will be located in ${PETALINUX}/software/user-modules/<MODULE>/.
  2. Place the pre-built kernel modules into ${PETALINUX}/software/user-modules/<MODULE>/
  3. Modify the makefile located inside ${PETALINUX}/software/user-apps/<APP>/.
    • Ensure that the all:, install: and clean: sections of the makefile are empty.
    • Update the romfs: section to copy the pre-built binaries into ${PETALINUX}/software/petalinux-dist/romfs/.

An example of the modifications is as follows:

{{{
APP=myapp
all:

clean:

romfs:
$(ROMFSINST) -d $(APP) /lib/modules/<KERNELRELEASE>/extra/
}}}

AR# 55997
Date 03/30/2015
Status Active
Type General Article
Devices More Less
Tools More Less