简体   繁体   中英

How to patch Linux kernel source code in yotco

The part I'm working on is kernel-devsrc , which is in the recipe recipes-kernel .

I want to change one of the source .c files in drivers/usb/serial in kernal-devsrc . From some of the online materials, I need to:

  • Have my own layer
  • In the layer, need a recipe with the same name as recipes-kernel (and further more, recipes-kernel/linux )
  • Add the .bbappend file and patch file.

The problem is : to create a patch file I need to know the 2 git SHAs of before and after the change, but I don't have access to the third party recipes-kernel , how do I get the SHA?? OR, if that is the wrong way to do this, could you point out the right way to do it? Thanks!

NOTE: This is problem is not like this one: How patching works in yocto , which the author has access to the source code (.c and .h files). I DON"T have access to the source code, the yotco kernel I'm working on is from a public git repo, and I am not able to git commit to get the SHA, which is necessary to create the patch file.

So, the way I do it is to use Quilt , follow the steps there then good to go: https://www.yoctoproject.org/docs/1.8/dev-manual/dev-manual.html#using-a-quilt-workflow

I don't need to know the SHA (though I still don't know why others in my organization end up writing SHAs in the patch files and how did they know the SHAs).

The power of Yocto is precisely that it makes it relatively straightforward to patch any existing recipes, without requiring write access to the upstream project source code or Yocto layer.

As a pre-requisite, the project needs to have its own layer to track the patches. Then, the easiest way it to use devtool . The general idea is to:

  1. Create a local sandbox to patch the project: devtool modify RECIPE_NAME (use the name of the target recipe here). This command will create a temporary workspace and print the path to this workspace.
  2. Move to the temporary workspace, apply the needed patches and commit them one by one.
  3. Once all the desired patches have been applied, use devtool finish RECIPE_NAME CUSTOM_LAYER_NAME to save the chances as clean patch files in a bbappend in the custom layer.

Under the hood, devtool modify initializes a (writable) git repository in the sandbox. When devtool finish is invoked, devtool checks the list of extra-commits and saves them as patch files in a .bbappend in the target layer.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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