1. create a new app projects - startup, the best all lowercase letters, otherwise there will be compiled with warnning
cd <plnx-proj-proot>/
App project to establish a shell script file:
petalinux-create -t apps --template install -n startup --enable
Build applications engineering c language:
petalinux-create -t apps --template c -n startup --enable
2. Edit the file project-spec / meta-user / recipes-apps / startup / startup.bb
Relevant content shell script works as follows:
#
# This file is the startup recipe.
#
SUMMARY = "Simple startup application"
SECTION = "PETALINUX/apps"
LICENSE = "MIT"
LIC_FILES_CHKSUM = "file://${COMMON_LICENSE_DIR}/MIT;md5=0835ade698e0bcf8506ecda2f7b4f302"
SRC_URI = "file://startup \
"
S = "${WORKDIR}"
FILESEXTRAPATHS_prepend := "${THISDIR}/files:"
inherit update-rc.d
INITSCRIPT_NAME = "startup"
INITSCRIPT_PARAMS = "start 99 S ."
do_install() {
install -d ${D}/${sysconfdir}/init.d
install -m 0755 ${S}/startup ${D}/${sysconfdir}/init.d/startup
}
FILES_${PN} += "${sysconfdir}/*"
Relevant content c language works as follows:
#
# This file is the startup recipe.
#
SUMMARY = "Simple startup application"
SECTION = "PETALINUX/apps"
LICENSE = "MIT"
LIC_FILES_CHKSUM = "file://${COMMON_LICENSE_DIR}/MIT;md5=0835ade698e0bcf8506ecda2f7b4f302"
SRC_URI = "file://startup \
file://Makefile \
"
S = "${WORKDIR}"
FILESEXTRAPATHS_prepend := "${THISDIR}/files:"
inherit update-rc.d
INITSCRIPT_NAME = "startup"
INITSCRIPT_PARAMS = "start 99 S ."
do_compile() {
oe_runmake
}
do_install() {
install -d ${D}/${sysconfdir}/init.d
install -m 0755 ${S}/startup ${D}/${sysconfdir}/init.d/startup
}
FILES_${PN} += "${sysconfdir}/*"
3. Edit the application, project-spec / meta-user / recipes-apps / startup / files / folder in the startup file or startup.c
#!/bin/sh
echo "Auto starting, Hello PetaLinux World"
#include <stdio.h>
int main(int argc, char **argv)
{
printf("Auto starting, Hello PetaLinux World!\n");
return 0;
}
4. rootfs file system settings
petalinux-config -c rootfs
Select startup items in apps
5. compile
petalinux-build
6. The operation starts at PetaLinux ZYNQ test board, automatic operation Startup
Taken ug1144