cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Contributor
Contributor
10,359 Views
Registered: ‎11-17-2014

Getting a kernel module to load at start up

Jump to solution

I just finished building a petalinux 2014.2 test project and I was able to get a custom library and kernel module into the rootfs and on the image with no issues.

 

I am noticing however, that I still have to load the kernel module manually using insmod. Is there a a config setting I missed to have the OS load the module at start up, or do I have to write an init.d script to perform the action.

 

Thanks.

0 Kudos
Reply
1 Solution

Accepted Solutions
Contributor
Contributor
18,605 Views
Registered: ‎11-17-2014

Hi Vanmierlo,

 

I found the solution in this forum post:

 

https://forums.xilinx.com/t5/Embedded-Linux/petalinux-How-to-load-module-automatically-at-boot-time/m-p/636616/highlight/true#M13247

 

 

Adding the line to the install sectionof the makefile in the moduleproject will load the kernel module at boot:

 

$(TARGETINST) -d -a "module_name" /etc/modules

 

 

View solution in original post

0 Kudos
Reply
3 Replies
Xilinx Employee
Xilinx Employee
10,352 Views
Registered: ‎08-01-2008

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/
}}}

Thanks and Regards
Balkrishan
--------------------------------------------------------------------------------------------
Please mark the post as an answer "Accept as solution" in case it helped resolve your query.
Give kudos in case a post in case it guided to the solution.
0 Kudos
Reply
Mentor
Mentor
10,284 Views
Registered: ‎06-10-2008

Maybe I don't understand too well, but this answer tells how to add a kernel module to the rootfs, but not how to auto-load it at startup.

0 Kudos
Reply
Contributor
Contributor
18,606 Views
Registered: ‎11-17-2014

Hi Vanmierlo,

 

I found the solution in this forum post:

 

https://forums.xilinx.com/t5/Embedded-Linux/petalinux-How-to-load-module-automatically-at-boot-time/m-p/636616/highlight/true#M13247

 

 

Adding the line to the install sectionof the makefile in the moduleproject will load the kernel module at boot:

 

$(TARGETINST) -d -a "module_name" /etc/modules

 

 

View solution in original post

0 Kudos
Reply