cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
tdurand
Visitor
Visitor
297 Views
Registered: ‎10-19-2020

kernel module configuration in Petalinux: how to mknod?

Jump to solution

Using Petalinux (2020.2), I have roughly followed https://www.xilinx.com/support/answers/55997.html and have created a kernel module, and I see the module is loaded after booting up the system when I run "lsmod".

To make that module useful, I need to create a number of new devices in the /dev directory.  For a system that is already booted, I can type in the "mknod" commands in the linux shell and the module functions properly.  However, I can't figure out how to do this in the Petalinux configuration files.  I have added these mknod commands to the bitbake recipe in the do_install() section but the devices do not appear when I boot the system.  I don't see any errors (or any related messages) in /var/log/messages.

How can I configure Petalinux to create these new inodes?

0 Kudos
1 Solution

Accepted Solutions
rfs613
Scholar
Scholar
273 Views
Registered: ‎05-28-2013

While it is still possible to manually create device nodes via mknod, this has not been "fashionable" under Linux for perhaps a decade. Instead the device nodes are typically created on-the-fly using a combination of the device_create() function in the driver, and a pseudo-filesystem called "devtmpfs" that is normally mounted at /dev early in the boot process.

There are many example kernel drivers you can look at, both within the kernel source itself, and elsewhere.

If you really want to do it the manual way, then note that any device nodes you create at build time (in the rootfs) will vanish at boot time, when devtmpfs is mounted over top of /dev. So you'll need to use an init script or similar to call mknod after the system has booted.

Edit to add: using device_create() is preferable as it solves the problem of trying to sync major/minor numbers between the driver and the filesystem.

View solution in original post

2 Replies
rfs613
Scholar
Scholar
274 Views
Registered: ‎05-28-2013

While it is still possible to manually create device nodes via mknod, this has not been "fashionable" under Linux for perhaps a decade. Instead the device nodes are typically created on-the-fly using a combination of the device_create() function in the driver, and a pseudo-filesystem called "devtmpfs" that is normally mounted at /dev early in the boot process.

There are many example kernel drivers you can look at, both within the kernel source itself, and elsewhere.

If you really want to do it the manual way, then note that any device nodes you create at build time (in the rootfs) will vanish at boot time, when devtmpfs is mounted over top of /dev. So you'll need to use an init script or similar to call mknod after the system has booted.

Edit to add: using device_create() is preferable as it solves the problem of trying to sync major/minor numbers between the driver and the filesystem.

View solution in original post

tdurand
Visitor
Visitor
219 Views
Registered: ‎10-19-2020

Thank you so much for the explanation, advice, and the examples, rfs613.  This gives me the path forward I need.  I was really stuck.

0 Kudos