AR# 55998

PetaLinux - How do I add a script to my PetaLinux root file system that runs at startup?

描述

I have a script that I would like to include in my PetaLinux root file system to have it execute at system startup.

How do I have the PetaLinux build process incorporate this code properly?

解决方案

To have the PetaLinux build tools incorporate pre-build binary code, follow this general flow:

PetaLinux 2013.04 (and prior)

  1. Ensure that the root file system includes an interpreter for your script (e.g., Perl, Python, etc.).
  2. Use the petalinux-new-app to create an application. The new application will be located in ${PETALINUX}/software/user-apps/<APP>/. The -e option for petalinux-new-app will automatically select the application from menuconfig and will allow the application to be automatically built when the PetaLinux system is built.
  3. Place the scripts into ${PETALINUX}/software/user-apps/<APP>/
  4. Modify the makefile for the new application located inside ${PETALINUX}/software/user-apps/<APP>/.
    • Ensure that the all: and clean: sections of the makefile are empty.
    • Update the romfs: section to copy the scripts into ${PETALINUX}/software/petalinux-dist/romfs/.

Below is an example of the modifications:

{{{
all:
 
clean:
romfs:
     $(ROMFSINST) -d -p 0755 mystartup /etc/init.d/mystartup
     $(ROMFSINST) -s /etc/init.d/mystartup /etc/rcS.d/S99mystartup
}}}

Note: The scripts in /etc/rcS.d/ run in alphabetical order.

PetaLinux 2013.10 (and later)

  1. Ensure that the root filesystem includes an interpreter for your script (e.g., Perl, Python, etc.).
  2. Use petalinux-create -t apps -n <APP> to create an application.  The new application will be located in <PETALINUX_PROJECT_DIR>/components/apps/<APP>/. The --enable option for petalinux-create will automatically select the application from menuconfig and will allow the application to be automatically built when the PetaLinux system is built.
  3. Place the script(s) into <PETALINUX_PROJECT_DIR>/components/apps/<APP>/
  4. Modify the makefile for the new application located inside <PETALINUX_PROJECT_DIR>/components/apps/<APP>/.
    • Ensure that the all:, build:, and clean: sections of the makefile are empty.
    • Update the install:: section to copy the scripts into <PETALINUX_PROJECT_DIR>/build/linux/roofts/targetroot/.
Below is an example of the modifications:
all: build install
build: $(APP)
clean:
.PHONY: install image
install: $(APP)
 $(TARGETINST) -d -p 0755 mystartup /etc/init.d/mystartup
 $(TARGETINST) -s /etc/init.d/mystartup /etc/rc5.d/S99mystartup
Note: The scripts in /etc/rc5.d/ run in alphabetical order.
AR# 55998
日期 04/23/2014
状态 Active
Type 综合文章
器件 More Less
Tools More Less