所有命令均需在非管理员模式下执行
1. 初始化 PetaLinux 运行环境
运行命令:source PetaLinux安装目录/settings.sh
2. 创建自动执行脚本相关文件
(1) cd 到项目工程目录下;
(2) 运行命令:petalinux-create -t apps --template install -n autorunapp --enable
(3) 修改 项目工程目录/project-spec/meta-user/recipes-apps/autorunapp 下的 autorunapp.bb 文件内容,如下所示:
# # This file is the autorunapp recipe. # SUMMARY = "Simple autorunapp application" SECTION = "PETALINUX/apps" LICENSE = "MIT" LIC_FILES_CHKSUM = "file://${COMMON_LICENSE_DIR}/MIT;md5=0835ade698e0bcf8506ecda2f7b4f302" SRC_URI = "file://autorunapp " S = "${WORKDIR}" FILESEXTRAPATHS_prepend := "${THISDIR}/files:" inherit update-rc.d INITSCRIPT_NAME = "autorunapp" INITSCRIPT_PARAMS = "start 99 S ." do_install() { install -d ${D}${sysconfdir}/init.d install -m 0755 ${S}/autorunapp ${D}${sysconfdir}/init.d/autorunapp } FILES_${PN} += "${sysconfdir}/*"
(4) 修改 项目工程目录/project-spec/meta-user/recipes-apps/autorunapp/files 下的 autorunapp 文件内容,如下所示:
#!/bin/sh
echo "Begin Auto Run ...(DEBUG INFO) "
/run/media/mmcblk0p1/./autorun.sh &
echo "End Auto Run ...(DEBUG INFO) "
3. 重新生成项目
运行命令:petalinux-build