Difference between revisions of "How to customize the Linux kernel"
[quality revision] | [quality revision] |
m
|
|
Template:ArticleMainWriter Template:ArticleApprovedVersion
Contents
1 Purpose of article[edit]
This article gives the main steps needed to add kernel customization within the Yocto build process (with a Distribution Package).
2 Pre-requesites[edit]
You are already familiar with the Yocto build process and OpenSTLinux distribution.
You have already created a customer layer (How to create a new open embedded layer) to update, for your own needs, the OpenSTLinux distribution.
We describe here what you must do once you have:
- modified the kernel configuration
- modified the Linux kernel device tree
- modified a built-in device driver
so that these modifications are taken into account in your build process.
3 Adding kernel customization (including Linux kernel device tree, configuration, driver modification)[edit]
- First, create (in your custom layer) a <name of kernel recipe>.bbappend file
touch ../meta-my-custo-layer/recipes-kernel/linux/<name of kernel recipe>.bbappend
3.1 Adding kernel configuration modifications[edit]
- Identify all new configs you set or unset with: bitbake <name of kernel recipe> -c menuconfig
- Put them inside a new fragment file and copy the fragment here:
cp <custom-fragment>.config ../meta-my-custo-layer/recipes-kernel/linux/<name of kernel recipe>/<kernel version>/
- Update accordingly <name of kernel recipe>.bbappend:
KERNEL_CONFIG_FRAGMENTS_append += "${WORKDIR}/fragments/<kernel version>/<custom-fragment>.config" SRC_URI_append = " file://<kernel version>/<custom-fragment>.config;subdir=fragments "
For the use case described in the How to cross-compile with the Distribution Package#modifying_kernel_configuration example, you should:
- Create fragment-cma-size.config with the following line:
CONFIG_CMA_SIZE_MBYTES=256
- Copy fragment-cma-size.config to ../meta-my-custo-layer/recipes-kernel/linux/linux-stm32mp/4.14/
- Update ../meta-my-custo-layer/recipes-kernel/linux/linux-stm32mp.bbappend accordingly by adding these lines:
KERNEL_CONFIG_FRAGMENTS_append += "${WORKDIR}/fragments/4.14/fragment-cma-size.config" SRC_URI_append = " file://4.14/fragment-cma-size.config;subdir=fragments "
3.2 Adding kernel driver or device tree modifications[edit]
The example given below is associated with the STM32MP15 Evaluation board, but the method is independent of the board.
Once you have made the changes for the device tree in <build dir>/workspace/sources/<name of kernel recipe>/arch/arm/boot/dts/stm32mp157c-ed1.dts AND, for built-in device driver in <build dir>/workspace/sources/<name of kernel recipe>/drivers/gpu/drm/stm/drv.c, you must:
- Create the corresponding patch files:
cd <build dir>/workspace/sources/<name of kernel recipe>/ git format-patch -2
- Copy these patch files into the custom layer
cp *.patch ../meta-my-custo-layer/recipes-kernel/linux/<name of kernel recipe>/<kernel version>/<kernel version>.<revision>/
![]() |
Patches are linked to a kernel version, which means that these patches are rebuilt if the kernel version changes, and copied to the according kernel version sub-folder |
- Update <name of kernel recipe>.bbappend accordingly:
SRC_URI_append = " \ file://<kernel version>/<kernel version>.<revision>/0001-DT-leds-change.patch \ file://<kernel version>/<kernel version>.<revision>/0002-Driver-change.patch \ "
<noinclude> {{ArticleMainWriter | ChristopheM}} {{ArticleApprovedVersion | ChristopheM | BernardP, Jean-ChristopheT, NathalieS | No previous approved version | PhilipS - 29Aug'18 - 8461 | 19Sep'18}} [[Category:How to customize software]] [[Category:Distribution Package]]</noinclude> ==Purpose of article== This article gives the main steps needed to add kernel customization within the Yocto build process (with a Distribution Package). ==Pre-requesites== You are already familiar with the Yocto build process and OpenSTLinux distribution. You have already created a customer layer ([[How to create a new open embedded layer]]) to update, for your own needs, the OpenSTLinux distribution.<br> We describe here what you must do once you have: * [[How to cross-compile with the Distribution Package#modifying_kernel_configuration|modified the kernel configuration]] * [[How to cross-compile with the Distribution Package#Modifying_the_Linux_kernel_device_tree|modified the Linux kernel device tree]] * [[How to cross-compile with the Distribution Package#Modifying_a_built-in_Linux_kernel_device_driver|modified a built-in device driver]] so that these modifications are taken into account in your build process. ==Adding kernel customization (including Linux kernel device tree, configuration, driver modification)== * First, create (in your custom layer) a <name of kernel recipe>.bbappend file {{PC$}} touch ../meta-my-custo-layer/recipes-kernel/linux/<name of kernel recipe>.bbappend ===Adding kernel configuration modifications=== * Identify all new configs you set or unset with: {{PC$}} bitbake <name of kernel recipe> -c menuconfig * Put them inside a new fragment file and copy the fragment here: {{PC$}} cp <custom-fragment>.config ../meta-my-custo-layer/recipes-kernel/linux/<name of kernel recipe>/<kernel version>/ * Update accordingly <name of kernel recipe>.bbappend: KERNEL_CONFIG_FRAGMENTS_append += "${WORKDIR}/fragments/<kernel version>/<custom-fragment>.config" SRC_URI_append = " file://<kernel version>/<custom-fragment>.config;subdir=fragments " For the use case described in the [[How to cross-compile with the Distribution Package#modifying_kernel_configuration]] example, you should: * Create fragment-cma-size.config with the following line: CONFIG_CMA_SIZE_MBYTES=256 * Copy fragment-cma-size.config to ../meta-my-custo-layer/recipes-kernel/linux/linux-stm32mp/4.14/ * Update ../meta-my-custo-layer/recipes-kernel/linux/linux-stm32mp.bbappend accordingly by adding these lines: KERNEL_CONFIG_FRAGMENTS_append += "${WORKDIR}/fragments/4.14/fragment-cma-size.config" SRC_URI_append = " file://4.14/fragment-cma-size.config;subdir=fragments " ===Adding kernel driver or device tree modifications=== The example given below is associated with the STM32MP15 Evaluation board, but the method is independent of the board. Once you have made the changes for the device tree in <build dir>/workspace/sources/<name of kernel recipe>/arch/arm/boot/dts/stm32mp157c-ed1.dts '''AND''', for built-in device driver in <build dir>/workspace/sources/<name of kernel recipe>/drivers/gpu/drm/stm/drv.c, you must: * Create the corresponding patch files: {{PC$}} cd <build dir>/workspace/sources/<name of kernel recipe>/ {{PC$}} git format-patch -2 * Copy these patch files into the custom layer {{PC$}} cp *.patch ../meta-my-custo-layer/recipes-kernel/linux/<name of kernel recipe>/<kernel version>/<kernel version>.<revision>/ {{Warning|Patches are linked to a kernel version, which means that these patches are rebuilt if the kernel version changes, and copied to the according kernel version sub-folder}} * Update <name of kernel recipe>.bbappend accordingly: SRC_URI_append = " \ file://<kernel version>/<kernel version>.<revision>/0001-DT-leds-change.patch \ file://<kernel version>/<kernel version>.<revision>/0002-Driver-change.patch \ " <noinclude> [[Category:How to customize software]] [[Category:Distribution Package]] {{PublicationRequestId | 8461 | 2018-08-29 | PhilipS}}</noinclude>
Line 1: | Line 1: | ||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
==Purpose of article== |
==Purpose of article== |
||
This article gives the main steps needed to add kernel customization within the Yocto build process (with a Distribution Package). |
This article gives the main steps needed to add kernel customization within the Yocto build process (with a Distribution Package). |
||
Line 58: | Line 50: | ||
file://<kernel version>/<kernel version>.<revision>/0002-Driver-change.patch \ |
file://<kernel version>/<kernel version>.<revision>/0002-Driver-change.patch \ |
||
" |
" |
||
+ | <noinclude> |
||
+ | [[Category:How to customize software]] |
||
+ | [[Category:Distribution Package]] |
||
+ | {{PublicationRequestId | 8461 | 2018-08-29 | PhilipS}} |
||
+ | </noinclude> |