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. I have seen this post where they create a recipe to set as module and not builtin.


Can you please guys help me in creating a recipe to set the module as builtin.

Thanks for your time.

1 answer

  • answered 2018-09-20 08:41 Parthiban

    You can't have external modules built into Linux Kernel. 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.

    Then you need to add according configuration in Kconfig and Makefile in drivers/usb. Finally you need to enable this as build in driver in defconfig/.config for building.

    In short,

    1. Place your driver in drivers/usb
    2. Add Kconfig and Makefile. For example, CONFIG_USB_HW_HCD
    3. Add to defconfig as CONFIG_USB_HW_HCD=y. In Yocto you can specify the defconfig file as file://defconfig in your SRC_URI.

    EDIT: As you are using meta-intel directly, you can create patch and bbappend to it. To do it,

    1. git clone "intel kernel repo"
    2. Add driver as mentioned above. Copy to drivers/usb, add Kconfig, Makefile entry.
    3. Add this driver to git repo using git add + git commit
    4. Create patch using git format-patch
    5. Create a .bbappend file and add this patch. You can place this .bbappend file in any of your custom layer or in meta-intel itself.
    6. Add defconfig fragment also into the .bbappend file for your Linux Kernel.

    This way you don't need to have separate repo of same Linux Kernel.