PetaLinux is a great utility that allows designers to easily create Linux images to run on their target platforms. PetaLinux will also create user applications and modules with a template Makefile and BB files so that they can be built and added to a rootfs.
However, for users trying to develop a module, creating, building, and deploying from the command line speeds up the process.
In this blog entry we will discuss how to create a module and then build and deploy it on a ZCU104 board outside of the PetaLinux flow. Once users are content that the module is working, they can then add it to the rootfs.
Building the Linux Image:
petalinux-create -t project -s <path to bsp>.bsp cd <plnx proj>
PetaLinux uses a TMP directory for the staging files. These are normally removed to save space on your disk.
However, in this case we do not want these files to be removed, so we need to comment out the line below in the build/conf/local.conf.
First, do a petalinux-build, then use Ctrl + c to stop it. This will create the files for you.
Note the location of the TMP directory.
This can be found below:
Now build the PetaLinux Project:
petalinux-build cd images/linux petalinux-package --boot --fpga system.bit --u-boot
Creating the Module:
I have a very simple module shown below that we can use for demo purposes:
#include <linux/module.h> /* Needed by all modules */
#include <linux/kernel.h> /* Needed for KERN_INFO */
#include <linux/init.h> /* Needed for the macros */
static int __init hello_start(void)
printk(KERN_INFO "Loading hello module...\n");
printk(KERN_INFO "Hello world\n");
static void __exit hello_end(void)
printk(KERN_INFO "Goodbye!! \n");