Udev

從 bitbake 配方中寫入 udev 規則

  • July 22, 2016

我可以通過創建 bitbake 配方在 yocto 上編譯和安裝東西。我想在連接特定設備時執行我的程式碼。

有沒有一種優雅的方法可以從 bitbake 配方中添加 udev 規則?做類似的事情聽起來echo "<my udev rule>" >> /etc/udev/rules.d/90-local.rules不是一個好計劃……

據我了解,您希望在建構作業系統並將其駐留在 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"

希望這能回答您的問題,如果您需要進一步的幫助,請告訴我。

哦,是的,別忘了在你的 local.conf 中包含 my-project

引用自:https://unix.stackexchange.com/questions/297659