Skip to contentSkip to conversation

Kernel development: integrating device driver in Kernel (Patch)

DISCUSSION [email protected] 1 participant 1 message Jul 30, 2024

lore
Share & tools
lore
#0 lore raw

hi
i am using ubuntu 22.04.4 LTS, bitbake 2.8.0, poky scarthgap branch and beaglebone black. I am trying to create my first device driver and integrate it in the kernel (with patch).

I am executing the following steps and the result is either that the image is built but doesnt contain the driver or an error is generated during compiling. The steps are:
1. i am creating a folder with name tabdriver in the path /poky/build/tmp/work-shared/beaglebone-yocto/kernel-source/drivers/char/
2. I am creating Kconfig, Makefile and tabdriver.c files in this folder.

Kconfig
===========
config TAB_DRIVER
tristate "CG Hello World Driver"
help
CG help
===========

Makefile
=======
obj-$(CONFIG_TAB_DRIVER) := tabdriver.o
=======

3. in Kconfig which is located in the folder poky/build/tmp/work-shared/beaglebone-yocto/kernel-source/drivers/char, the following line is added:
source "drivers/char/tabdriver/Kconfig"

4. in Makefile which is located in the folder poky/build/tmp/work-shared/beaglebone-yocto/kernel-source/drivers/char, the following line is added:
obj-$(CONFIG_TAB_DRIVER) += tabdriver/

5. A patch is created by using git git format-patch HEAD~1 which contains the changes in the file files above

6. The patch is copied in the location poky/meta-mylayer/recipes-kernel/linux/linux-yocto
7. The file linux-yocto_6.6.bbappend which is located in the location poky/meta-mylayer/recipes-kernel/linux has the content

======
FILESEXTRAPATHS:prepend := "${THISDIR}/${PN}:"
SRC_URI += "file://0001-tab-char-driver.patch"
======

8. Run bitbake -c cleansstate virtual/kernel
9. Run bitbake -c menuconfig virtual/kernel
10. The new driver is appearing in menu config and i am activating it
11.  Run bitbake -c diffconfig virtual/kernel
12. Build image bitbake core-image-full-cmdline

Are the steps that i am following correct?
is there any debug procedure i can follow?

Br
Christos