解决方案
To have the PetaLinux build tools incorporate pre-build binary code, follow this general flow:
PetaLinux 2013.04 (and prior)
- Ensure that the root file system includes an interpreter for your script (e.g., Perl, Python, etc.).
- 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.
- Place the scripts into ${PETALINUX}/software/user-apps/<APP>/
- 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)
- Ensure that the root filesystem includes an interpreter for your script (e.g., Perl, Python, etc.).
- 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.
- Place the script(s) into <PETALINUX_PROJECT_DIR>/components/apps/<APP>/
- 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.