0

I have one driver that shall get Major number from linux kernel (major number is assigned dynamically).

To create the a device node for my driver, I run the following steps manually

  • insmod my_driver

  • cat /proc/devices -- This is to know which Major number is assigned

  • mknod /dev/myDevName -c Assigned_Major_Number 0

Eventually, I have to use Buildroot to build my file system which should include my driver. In Buildroot, you can use device table file to create device node (this is instead of running mknod ... when linux system is up).

The missing part how to mention the Major Number in device table file as I don't have it yet (it will be assigned later by linux kernel when system is up)?!

Thanks for your help

Luca Ceresoli
  • 1,591
  • 8
  • 19
moibrahim
  • 89
  • 7

1 Answers1

1

Let the /dev entries be created dynamically and automatically for you. A static table is too cumbersome when you have dynamic numbers.

There are several dynamic /dev management methods. From most complex and featureful to simplest:

  • use udev and systemd (like many desktop/server distributions do)
  • use udev (if your init system is not systemd)
  • use mdev from Busybox (like udev, but simpler and very lightweight)
  • mount a devtmpfs on /dev (no daemon needed, the kernel will do it for you)

Buildroot can set up whichever you prefer. Just enter make menuconfig -> System configuration -> /dev management. See the manual section /dev management for the details.

Luca Ceresoli
  • 1,591
  • 8
  • 19
  • 1
    Note that even with udev, you automatically use `devtmpfs` too. So the device node is created automatically by the kernel when the device is registered by your driver. You can use a udev/mdev rule to rename the automatically created file to something that is more appropriate for you. – Arnout Nov 06 '18 at 22:19