TipsAndTricks/QuickAndDirtyKernelConfig: Difference between revisions

From Yocto Project
Jump to navigationJump to search
No edit summary
No edit summary
Line 24: Line 24:
and nothing else. What can I do then? With the standard settings,  we get:
and nothing else. What can I do then? With the standard settings,  we get:
  <code>  
  <code>  
  $grep DMA_API_DEBUG tmp/work/.../.config
  $grep CONFIG_DMA_API tmp/work/.../.config
  # CONFIG_DMA_API_DEBUG is not set
  # CONFIG_DMA_API_DEBUG is not set
  </code>
  </code>
Line 32: Line 32:
   SRC_URI_append_pn-linux-yocto = " file://myKernelConfigs.cfg "
   SRC_URI_append_pn-linux-yocto = " file://myKernelConfigs.cfg "
</code>
</code>
The file myKernelConfigs.cfg is in my conf directory. I could have put it anywhere I wanted, even into a separate git repo in ~/kernelconfigsrepo, for example.  myKernelConfigs.cfg contains the kernel configs I want to set. In this example it's pretty simple:
The file myKernelConfigs.cfg is in my conf directory. I could have put it anywhere I wanted, even into a separate git repo in ~/kernelconfigsrepo, for example.  myKernelConfigs.cfg contains the kernel configs I want to set. Let's suppose I want to turn on CONFIG_DMA_API_DEBUG.
So the file myKernelConfigs.cfg would have:
  <code>  
  <code>  
  # yes, comments are ok
  # yes, comments are ok
Line 39: Line 40:
If I delete the tmp folder and rerun <code> bitbake linux-yocto </code> I can then see the following:
If I delete the tmp folder and rerun <code> bitbake linux-yocto </code> I can then see the following:
  <code>
  <code>
  $grep DMA_API_DEBUG tmp/work/.../.config
  $grep CONFIG_DMA_API tmp/work/.../.config
 
CONFIG_DMA_API_DEBUG=y
</code>
</code>
The  CONFIG_DMA_API_DEBUG got turned on as we hoped, yay!

Revision as of 01:33, 1 November 2016

How to Quickly Set Some Options in the Kernel

The Real Way

The best in depth explanation/tutorial for working with the kernel in Yocto is located here: https://www.yoctoproject.org/training/kernel-lab. It has a pdf, and supporting layers/metadata to allow you to follow along. There is also a kernel development manual located at http://www.yoctoproject.org/docs/latest/kernel-dev/kernel-dev.html.
If you are going to do a lot with the kernel or are planning to ship it in a product/project, I'd strongly recommend going through the lab and reading the kernel manual.

The Quick and Dirty Way

But, sometimes, you really just want to be able to set an option. How can you do this?

Menuconfig

bitbake linux-yocto -c menuconfig 

This will put you into the standard ncurses menuconfig screen and you can select options as normal and then rebuild your kernel with:

bitbake linux-yocto 

This will modify the .config file that linux-yocto uses

tmp/work/<machine>-common-poky-linux/linux-yocto/<version>/linux-<machine>-common-standard-build/.config 

in the version I am working off of it looks like this for a machine=intel-corei7-64 and a linux-yocto near the time of Morty's (YP 2.2) release.

tmp/work/corei7-64-intel-common-poky-linux/linux-yocto/4.8+gitAUTOINC+552a83790b_67813e7efa-r0/linux-corei7-64-intel-common-standard-build/.config

The good news is that that was pretty easy. The bad news, is that

  • if I remove tmp, as I tend to do, then my .config will go away.
  • if I want to share my additions with someone else, I need to give them a whole .config file and tell them to read the above referenced lab for how to use it.

Just the Configs I want, nothing more

Suppose I know that I just want to set

CONFIG_DMA_API_DEBUG=y

and nothing else. What can I do then? With the standard settings, we get:

 
$grep CONFIG_DMA_API tmp/work/.../.config
# CONFIG_DMA_API_DEBUG is not set

So, the Quick & Dirty approach is to add the following to the end of my conf/local.conf file:

 
 FILESEXTRAPATHS_prepend_pn-linux-yocto := "/my/absolute/path/build/conf:"
 SRC_URI_append_pn-linux-yocto = " file://myKernelConfigs.cfg "

The file myKernelConfigs.cfg is in my conf directory. I could have put it anywhere I wanted, even into a separate git repo in ~/kernelconfigsrepo, for example. myKernelConfigs.cfg contains the kernel configs I want to set. Let's suppose I want to turn on CONFIG_DMA_API_DEBUG. So the file myKernelConfigs.cfg would have:

 
# yes, comments are ok
CONFIG_DMA_API_DEBUG=y

If I delete the tmp folder and rerun bitbake linux-yocto I can then see the following:


$grep CONFIG_DMA_API tmp/work/.../.config
CONFIG_DMA_API_DEBUG=y

The CONFIG_DMA_API_DEBUG got turned on as we hoped, yay!