问题
I am trying to compile a new Linux
kernel obtained from https://github.com/qoriq-open-source/linux (version 4.9) for T1042D4RDB-64B
embedded board using Yocto
. It's currently using 4.1.35-rt41
.
I followed these steps:
bitbake virtual/kernel -c cleansstate
bitbake virtual/kernel -c patch
replacing git folder with my new kernels source code (https://github.com/qoriq-open-source/linux)
make ARCH=powerpc menuconfig
bitbake virtual/kernel
Result is
The new kernel has compiled successfully but uImage does not contain the drivers I need. There are only 4 drivers in the new kernel (deploy/images/t1042d4rdb-64b/rootfs.tar.gz) which is "hid", "input", "misc" and "staging" like this.
There are lots of driver folders in Linux kernel 4.9
such as gpio,gpu,bluetooth, connector and so on..
Question is
How can I import the drivers I need to new uImage and put them into the board ? Or how can I compile this kernel and select the desired modules/drivers? I want a rich kernel like my Ubuntu kernel.
回答1:
Kernel Configuration:
The driver selection happens when compiling the kernel via the .config file. You can configure the kernel (including the drivers used) via menuconfig:
bitbake -c menuconfig virtual/kernel
Now, you need to convince bitbake to use those working changes. To do so you need to force compile the kernel:
bitbake -f -c compile virtual/kernel
Finally, you can compile the image and flash it on the target.
This though, does not make the changes permanent. To make the changes permanent you need a custom layer and a bbappend file. It's quite easy to do this with the devtool. The yocto mega manual explains the procedure in some detail. Here I'll just explain the very basic steps. Running
devtool modify virtual/kernel
will add a temporary working copy inside build/workspace/sources/linux-mainline (provided the kernel you use is called kernel-mainline) on a local branch. Here you can make all the changes you want and try them on the your hardware. Once you're happy and want to add those changes to your recipe you need to commit those. Finally running
devtool finish linux-mainline <path-to-your-layer>
will automatically generate a .bbappend and a defconfig (.config) file and put it inside your layer. If you want to patch some drivers etc. you probably want to take a look at the kernel-dev section of the manual.
Kernel Version selection:
I'm not quite sure about this one, but it should work like this: You need a recipe for the kernel already available as a recipe any layer known to bitbake. If you're not sure take a look at the openembedded layer index and search for the kernel version you want to use, download the recipe and put it inside your layer. Lastly you need to tell bitbake to use this version. This can be done inside the build/local.conf configuration file:
PREFERED_VERSION_linux-mainline = "5.3.11"
I have never tried the last one and have no clue if it works or what other dependencies this could break.
回答2:
I found the solution by upgrading Yocto version from 2.0 to 2.7. The version I used was newly designed for my board(t1042d4rdb-64b) including linux kernel 4.19.xxx. Installation instructions can be found here https://source.codeaurora.org/external/qoriq/qoriq-components/yocto-sdk/tree/readme?h=yocto_2.7
来源:https://stackoverflow.com/questions/58836721/yocto-change-kernel-version-and-select-drivers