[yocto] How do I patch the kernel before it is built?

autif khan autif.mlist at gmail.com
Mon Feb 6 11:35:01 PST 2012


>>> I could not find a way to patch the kernel source before its is built.
>>>
>>> I promise to update the Yocto wiki's How do I section when I have a
>>> working solution for the following :-)
>>
>> This should be covered in the existing documentation and also the
>> more general bitbake/oe-core docs.
>>
>>>
>>> Here is what I am trying to do:
>>>
>>> 1) Patch the kernel (add VID/PID to hid_ignore_list in
>>> drivers/hid/hid-core.c and also to add the VID/PID to .h file)
>>> 2) Build the kernel - no change here - standard kernel build
>>> 3) Build a kernel module
>>>
>>> I have a meta layer where I am keeping my changes. I am guessing that I need to:
>>>
>>> a) write a bbappend file to accomplish #1
>>> b) write a recipe to accomplish #3
>>>
>>> I have written recipes before, but just for libraries and autotools
>>> based applications. Not for a kernel module. If there is a recipe out
>>> there for some other module, I would be happy to steal from it.
>>>
>>> Please advise how I can go about patching the kernel and if there is a
>>
>> It's just like any other package. If your changes are simple, then
>> generating patches and putting them on the SRC_URI via a bbappend in
>> your layer is all you need. If you have complex changes, there are options
>> to manage them via git or via feature descriptions.

I tried this - attached at the end of this email are my bbappend file
and my patches, when the recipe is bitbaked, it does not actually
apply the patch.

On a similar note - there seems to be a file in
meta/recipes-kernel/linux/linux-yocto called
tools-perf-no-scripting.patch

However, it does not seem to be used anywhere - is this just crud or I
am missing something? I was hoping to cheat off of the recipe that
uses it.

>>> recipe for a kernel module - please point me to it.
>>
>> Darren validated and updated the kernel module example, so he'd probably
>> got this closer at hand than I do.
>
> See the hello-mod example under meta/recipes-kernel/hello-mod

Thank you for this recipe - it seems like this is exactly what I was
looking for. I will cheat off of this as soon as I can patch my
kernel.


R E C I P E

autif at fpbm:~/data/yocto/poky-edison-6.0/meta-koko/recipes/linux$ cat
linux-yocto_3.0.bbappend
FILESEXTRAPATHS_prepend := "${THISDIR}:"
SRC_URI += " file://linux/drivers/hid/hid-core.c.diff \
             file://linux/drivers/hid/hid-ids.h.diff "
PR = "r3"
autif at fpbm:~/data/yocto/poky-edison-6.0/meta-koko/recipes/linux$

P A T C H

autif at fpbm:~/data/yocto/poky-edison-6.0/meta-koko/recipes/linux/linux/drivers/hid$
cat hid-core.c.diff
--- linux.orig/drivers/hid/hid-core.c	2012-01-31 16:44:44.152001877 -0500
+++ linux/drivers/hid/hid-core.c	2012-01-31 16:46:34.608001870 -0500
@@ -1839,6 +1839,8 @@
 	{ HID_USB_DEVICE(USB_VENDOR_ID_WISEGROUP, USB_DEVICE_ID_1_PHIDGETSERVO_20) },
 	{ HID_USB_DEVICE(USB_VENDOR_ID_WISEGROUP, USB_DEVICE_ID_8_8_4_IF_KIT) },
 	{ HID_USB_DEVICE(USB_VENDOR_ID_YEALINK, USB_DEVICE_ID_YEALINK_P1K_P4K_B2K) },
+	{ HID_USB_DEVICE(USB_VENDOR_ID_PIXCIR, USB_DEVICE_ID_PIXCIR) },
 	{ }
 };
autif at fpbm:~/data/yocto/poky-edison-6.0/meta-koko/recipes/linux/linux/drivers/hid$
autif at fpbm:~/data/yocto/poky-edison-6.0/meta-koko/recipes/linux/linux/drivers/hid$
cat hid-ids.h.diff--- linux.orig/drivers/hid/hid-ids.h	2012-01-31
16:44:55.432001877 -0500
+++ linux/drivers/hid/hid-ids.h	2012-01-31 16:47:36.624001858 -0500
@@ -671,4 +671,7 @@
 #define USB_VENDOR_ID_ZYDACRON	0x13EC
 #define USB_DEVICE_ID_ZYDACRON_REMOTE_CONTROL	0x0006

+#define USB_VENDOR_ID_PIXCIR	0x040b
+#define USB_DEVICE_ID_PIXCIR	0x2000
+
 #endif
autif at fpbm:~/data/yocto/poky-edison-6.0/meta-koko/recipes/linux/linux/drivers/hid$



More information about the yocto mailing list