top of page
  • Zach Pfeffer

Use PetaLinux Tools to Add a Script that Will Execute at Boot


This post lists how to install an initscript into a build using PetaLinux Tools.

Looking for PetaLinux help? Email inquiries@centennialsoftwaresolutions.com today to schedule a 30-min consult for $99.00

Notes

  • This write up was done using PetaLinux Tools 2017.4.

  • If you need help installing PetaLinux Tools check out link.

  • The write up follows

Steps

1. cd into your PetaLinux project directory

2. Run:

Changes to the PetaLinux project from this command:

These files are also created automatically:

project-spec/meta-user/recipes-apps/bootscript/.gdbinit

project-spec/meta-user/recipes-apps/bootscript/README

project-spec/meta-user/recipes-apps/bootscript/bootscript.bb

Note:

All variables are defined below.

project-spec/meta-user/recipes-apps/bootscript/files/bootscript

3. Edit project-spec/meta-user/recipes-apps/bootscript/files/bootscript

Add a :)

4. Edit project-spec/meta-user/recipes-apps/bootscript/bootscript.bb

Add the following (listed in diff form, add the lines with '+', remove the lines with '-'):

5. Run:

Note: I had to run all three of these commands, in this order, to have bootscript installed into the rootfs.

6. Boot the rootfs:

References

  • The Xilinx + Yocto graphic is an amalgamation of Xilinx and Yocto icons

  • Free Online HTML Escape / Unescape @ link

  • PetaLinux Tools 2017.4 Reference Guide UG1144 (v2017.4) December 20, 2017 @ link

  • Yocto Project Mega-Manual 2.2.3 @ link

  • ​Note: using 2.2.3 because PetaLinux Tools 2017.4 is built on Yocto 2.2.3

Additional Info

All definitions listed from the Yocto Mega Manual.

${WORKDIR}

The pathname of the work directory in which the OpenEmbedded build system builds a recipe. This directory is located within the TMPDIR directory structure and is specific to the recipe being built and the system for which it is being built.

The WORKDIR directory is defined as follows: ${TMPDIR}/work/${MULTIMACH_TARGET_SYS}/${PN}/${EXTENDPE}${PV}-${PR}

The actual directory depends on several things:

• TMPDIR: The top-level build output directory

• MULTIMACH_TARGET_SYS: The target system identifier

• PN: The recipe name

• EXTENDPE: The epoch - (if PE is not specified, which is usually the case for most recipes, then EXTENDPE is blank)

• PV: The recipe version

• PR: The recipe revision

As an example, assume a Source Directory top-level folder name poky, a default Build Directory at poky/build, and a qemux86-poky-linux machine target system. Furthermore, suppose your recipe is named foo_1.3.0-r0.bb. In this case, the work directory the build system uses to build the package would be as follows:

poky/build/tmp/work/qemux86-poky-linux/foo/1.3.0-r0

inherit update-rc.d

The OpenEmbedded build system provides support for starting services two different ways:

SysVinit: SysVinit is a system and service manager that manages the init system used to control the very basic functions of your system. The init program is the first program started by the Linux kernel when the system boots. Init then controls the startup, running and shutdown of all other programs.

To enable a service using SysVinit, your recipe needs to inherit the update-rc.d class. The class helps facilitate safely installing the package on the target.

You will need to set the INITSCRIPT_PACKAGES, INITSCRIPT_NAME, and INITSCRIPT_PARAMS variables within your recipe.

systemd: System Management Daemon (systemd) was designed to replace SysVinit and to provide enhanced management of services. For more information on systemd, see the systemd homepage at http://freedesktop.org/wiki/Software/systemd/.

To enable a service using systemd, your recipe needs to inherit the systemd class. See the systemd.bbclass file located in your Source Directory. section for more information.

INITSCRIPT_NAME

The filename of the initialization script as installed to ${sysconfdir}/init.d.

This variable is used in recipes when using update-rc.d.bbclass. The variable is mandatory.

INITSCRIPT_PARAMS

Specifies the options to pass to update-rc.d. Here is an example:

INITSCRIPT_PARAMS = "start 99 5 2 . stop 20 0 1 6 ." In this example, the script has a runlevel of 99, starts the script in initlevels 2 and 5, and stops the script in levels 0, 1 and 6.

The variable's default value is "defaults", which is set in the update-rc.d class.

The value in INITSCRIPT_PARAMS is passed through to the update-rc.d command. For more information on valid parameters, please see the update-rc.d manual page at http://www.tin.org/bin/man.cgi?section=8&topic=update-rc.d.

${D}

The destination directory. The location in the Build Directory where components are installed by the do_install task. This location defaults to: ${WORKDIR}/image

Caution Tasks that read from or write to this directory should run under fakeroot.

${bindir}

/usr/bin

${sysconfdir}

/etc

${PN}

This variable can have two separate functions depending on the context: a recipe name or a resulting package name.

PN refers to a recipe name in the context of a file used by the OpenEmbedded build system as input to create a package. The name is normally extracted from the recipe file name. For example, if the recipe is named expat_2.0.1.bb, then the default value of PN will be "expat".

The variable refers to a package name in the context of a file created or produced by the OpenEmbedded build system.

If applicable, the PN variable also contains any special suffix or prefix. For example, using bash to build packages for the native machine, PN is bash-native. Using bash to build packages for the target and for Multilib, PN would be bash and lib64-bash, respectively.

bottom of page