从 bitbake 配方中编写 udev 规则

从 bitbake 配方中编写 udev 规则

我可以通过创建 bitbake 配方在 yocto 上编译和安装东西。我想在连接特定设备时运行我的代码。

有没有一种优雅的方式从 bitbake 配方添加 udev 规则?做类似的事情echo "<my udev rule>" >> /etc/udev/rules.d/90-local.rules听起来不是一个好计划......

答案1

据我所知,您希望在构建操作系统时创建一条规则并将其驻留在 rootfs 中。如果这是正确的,那么您需要为其添加一个配方。将您的规则存储在如下目录中distro/meta-myproject/recipes-core/rfs-myproject/rfs-myproject/*myrule.rule*。然后,在 rfs-myproject 文件夹中上一层,您需要一个rfs-myproject_1.0.0.bb.该文件应如下所示

SUMMARY = "MyProject Additional files"
LICENSE = "CLOSED"
PR = "r1"    

SRC_URI = "file://my-rule1.rules file://my-rule2.rules \
           file://startup.sh file://rc.local "    

do_install[nostamp] = "1"
do_unpack[nostamp] = "1"    

do_install () {
    echo "my-project install task invoked"    

    install -m 0755 ${WORKDIR}/startup.sh         ${D}/home/root/startup.sh
    install -m 0777 ${WORKDIR}/rc.local           ${D}${sysconfdir}/rc.d/rc.local
    install -m 0666 ${WORKDIR}/my-rule1.rules     ${D}/etc/udev/rules.d/my-rule1.rules
    install -m 0666 ${WORKDIR}/my-rule2.rules     ${D}/etc/udev/rules.d/my-rule2.rules
    
}    

FILES_${PN} += " ${sysconfdir}/rc.local"
FILES_${PN} += " /home/root/startup.sh"
FILES_${PN} += " /etc/udev/rules.d/my-rule1.rules"
FILES_${PN} += " /etc/udev/rules.d/my-rule2.rules"    

PACKAGES = "${PN}"
PROVIDES = "rfs-my-project"

希望这能回答您的问题,如果您需要进一步的帮助,请告诉我。

哦,是的,不要忘记将 my-project 包含在 local.conf 中

相关内容