Creating and applying a git patch in a yocto build?

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Creating and applying a git patch in a yocto build?

Creating and applying a git patch in a yocto build?

Hey everyone! If you are looking for concise steps to create and apply a patch in a yocto build, this article will serve you well.


The reference taken in this article is of iMX93EVK yocto build. For this exercise, we are modifying a lpspi dts file in the BSP and creating a patch file but you may apply the same steps to other files in the BSP as well.

Step-1 Make changes to the dts file in your directory
example - arch/arm64/boot/dts/freescale/imx93-11x11-evk-lpspi.dts

Step-2 In your yocto build, go to the git folder 

cd imx-yocto-bsp-home/build_11x11/tmp/work/imx93_11x11_lpddr4x_evk-poky-linux/linux-imx/6.1.36+gitAUTOINC+04b05c5527-r0/git


Step-3 Execute 'git diff' to check the difference between your changes and the default ones 

gauravsharma7_1-1707236992081.png

 

Check the status by executing 'git status'

 

gauravsharma7_2-1707237129604.png

 

Step-4 Execute 'git add <file>'  , 'git commit -m <message>', and 'git format-patch -1'
to add a file and create a git format patch file for your changes.

gauravsharma7_3-1707237447073.png

 
copy the generated patch file to a location which yocto build look for the patches
Example- My yocto build looks for the patch in various locations, one of them is this one :-

sources/meta-imx/meta-bsp/recipes-kernel/linux/files,
so after creating the directory 'files', we can move the patch file to this folder

gauravsharma7_5-1707238332064.png

 

 Step-5 Edit the .bb file for linux recipes-kernel

for example - Open  /home/nxg06361/imx-yocto-bsp-home/sources/meta-imx/meta-bsp/recipes-kernel/linux/linux-imx_6.1.bb  for editing

Append the patch file name to the SRC_URI variable
 

gauravsharma7_4-1707237771771.png

 


You can also verify that your patch has been successfully applied or not by doing 'git log'

gauravsharma7_6-1707238632342.png

 




Voila ! that's all you need to do in order to create and apply a git patch for your yocto build.

Labels (1)
Comments

Thank you for the instructions. One question, since you changed the original dts, is it the best practice to do this? 

The reason is the dts in tmp directory? If next time the yocto build the kernel, it will fectch the original source code and cover the change? 

I tried to copy the dts file to my new layer and changed it, but it looks like my method is wroing. Thanks again for your instructions.

Hi @Blake001 the changes that I have done in the original dts, this practice is somewhat subjective. There will be times you would not want to maintain different copies of the dts for a small change. The other times you would want a different copy so it is not a hard-requirement.

yes the dts source is fetched again the next time you trigger build and the changes get overridden. That's the reason we're making a patch in one of the instructions so that every time you trigger a build, this patch gets applied.

No ratings
Version history
Last update:
‎02-06-2024 09:59 AM
Updated by: