Adding New Devices
TracNav menu
-
User Guide
- Copyright Information
- Acknowledgements
- Terminology
- Introduction
-
PetaLinux Overview...
-
Working with PetaLinux - The Basics...
-
Customising PetaLinux...
-
Advanced Topics
- Non-standard PetaLinux Installations
- Adding new device nodes to the filesystem
- Enabling Uncached Shadow Option
-
Debugging...
-
PetaLinux Bootloader Solutions...
-
Supported Reference Designs...
- PetaLinux Tools Reference
- Getting Help
This page describes how to add new device file nodes to the PetaLinux root filesystem. It is not a tutorial on writing device drivers!
It is assumed that you know the device type (char vs block), major and minor numbers of your new device.
It is further assumed that you have either created a new PetaLinux platform, or are using the PetaLogix / microblaze-auto combination.
Adding the new device node
Edit the petalinux-dist vendors Makefile for your platform - it will be called
petalinux-dist/vendor/${VENDOR}/${PLATFORM}/Makefile
where ${VENDOR} and ${PLATFORM} are the vendor and platform names respectively that you gave to the petalinux-new-platform script. If you are using the default "microblaze-auto" platform, then this will be "PetaLogix" / "microblaze-auto" instead.
The file will look something like this:
#
# Makefile -- Build instructions for Generic uClinux-auto MicroBlaze system
#
include $(VEND)/PetaLogix/common/common.mak
romfs::
clean::
To add a new device node, add a line like the following, after the "include" directive:
#
# Makefile -- Build instructions for Generic uClinux-auto MicroBlaze system
#
include $(VEND)/PetaLogix/common/common.mak
DEVICES += mydev,c,20,0 <<<---- ADD NEW DEVICES HERE
romfs::
clean::
In this example, a new device node called "mydev", corresponding to character device with major number 20, and minor number 0, will be created.
The full syntax is
DEVICES += devname,type,maj,min
where::
devname is the name of the device node type is either b (for block devices) or c (for character devices) maj is the device major number min is the device minor number
Rebuild the filesystem image with the new device nodes
After editting and saving the Makefile, rebuild the romfs and image:
$ make romfs image ...
You may chain multiple device declarations into a single string, e.g.:
DEVICES += mydev0,c,20,0 mydev1,c,20,1
and so on.
Things to watch out for
- The DEVICES variable name must be in upper case
- Ensure you use the "+=" symbol, not "=" or ":="
- Spaces and other special characters are not permitted in the "devname,type,maj,min" string
- This procedure only creates a filesystem node for the device entry - you must still write, enable, build and debug the actual kernel driver for the device.
