简体   繁体   English

在我自己的meta层上将自己的设备驱动程序加载为Yocto中的内置功能

[英]Loading my own device driver as builtin in Yocto on my own meta layer

I wrote my own USB driver for hardware and I want to add this driver as builtin. 我为硬件编写了自己的USB驱动程序,并且希望将此驱动程序添加为内置驱动程序。 I have seen this post where they create a recipe to set as module and not builtin. 我看过这篇文章,他们在其中创建了一个设置为模块而非内置的配方。

http://wiki.kaeilos.com/index.php/Howto_build_a_kernel_module_out_of_the_kernel_tree http://wiki.kaeilos.com/index.php/Howto_build_a_kernel_module_out_of_the_kernel_tree

Can you please guys help me in creating a recipe to set the module as builtin. 能否请大家帮我创建一个配方,以将模块设置为内置模块。

Thanks for your time. 谢谢你的时间。

You can't have external modules built into Linux Kernel. 您不能在Linux内核中内置外部模块。 So you need to place your driver into drivers/usb/ (based on the hardware type it needs to be placed in drivers/usb/host/ if it is host controller driver or drivers/usb/dwc* or drivers/usb/gadget/udc if it is gadget driver) of your Linux Kernel tree. 因此,您需要将驱动程序放入drivers/usb/ (基于硬件类型,如果它是主机控制器驱动程序或drivers/usb/dwc* driver drivers/usb/dwc*drivers/usb/gadget/udc则需要将其放置在drivers/usb/host/ drivers/usb/gadget/udc如果它是小工具驱动程序))。

Then you need to add according configuration in Kconfig and Makefile in drivers/usb . 然后,您需要在Kconfig添加相应的配置,并在drivers/usb添加Makefile Finally you need to enable this as build in driver in defconfig/.config for building. 最后,您需要在defconfig / .config中将其作为内置驱动程序启用以进行构建。

In short, 简而言之,

  1. Place your driver in drivers/usb 将驱动程序放在drivers/usb
  2. Add Kconfig and Makefile . 添加KconfigMakefile For example, CONFIG_USB_HW_HCD 例如, CONFIG_USB_HW_HCD
  3. Add to defconfig as CONFIG_USB_HW_HCD=y . 以CONFIG_USB_HW_HCD CONFIG_USB_HW_HCD=y添加到defconfig中。 In Yocto you can specify the defconfig file as file://defconfig in your SRC_URI . 在Yocto中,您可以在SRC_URI中将defconfig文件指定为file://defconfig SRC_URI

EDIT: As you are using meta-intel directly, you can create patch and bbappend to it. 编辑:当您直接使用meta-intel时,您可以创建补丁并对其进行bbappend。 To do it, 去做吧,

  1. git clone "intel kernel repo" git clone“英特尔内核存储库”
  2. Add driver as mentioned above. 如上所述添加驱动程序。 Copy to drivers/usb , add Kconfig, Makefile entry. 复制到drivers/usb ,添加Kconfig, Makefile条目。
  3. Add this driver to git repo using git add + git commit 使用git add + git commit将此驱动程序添加到git repo
  4. Create patch using git format-patch 使用git format-patch创建git format-patch
  5. Create a .bbappend file and add this patch. 创建一个.bbappend文件并添加此补丁。 You can place this .bbappend file in any of your custom layer or in meta-intel itself. 您可以将此.bbappend文件放置在您的任何自定义层中或meta-intel本身中。
  6. Add defconfig fragment also into the .bbappend file for your Linux Kernel. 也将defconfig片段添加到Linux内核的.bbappend文件中。

This way you don't need to have separate repo of same Linux Kernel. 这样,您无需具有相同Linux内核的单独存储库。

I hope your initial module will have module_init() and module_exit calls. 我希望您的初始模块将具有module_init()和module_exit调用。

To make this usb module to be part of builtin kernel, very first thing is to modify you source code to remove module_init or module_exit calls add platform calls probe, init, etc./ 要使此USB模块成为内置内核的一部分,第一件事就是修改您的源代码以删除module_init或module_exit调用,再添加platform调用probe,init等。/

Copy your source file to appropriate source directory like "driver/usb/*" 将您的源文件复制到适当的源目录,例如“ driver / usb / *”

Add a entry in KCONFIG file with some description of that driver and also add rules for its dependencies 在KCONFIG文件中添加一个带有该驱动程序描述的条目,并为其依赖关系添加规则

Add entry in Makefile for conditional compilation. 在Makefile中添加条目以进行条件编译。

Configure your kernel using make menuconfig to enable your config tag and build your kernel 使用make menuconfig配置内核以启用config标签并构建内核

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM