Yocto Customizing the Linux kernel: Difference between revisions
No edit summary |
(Consolidate device tree directory calculation to a variable DTS_DIR) |
||
Line 7: | Line 7: | ||
--> {{#varexists:DEBIAN_NAME | {{#vardefine:BUILD_PAGE|Debian_Build_Release}} {{#vardefine:PLATFORM_OS|Debian}} | }} <!-- Debian | --> {{#varexists:DEBIAN_NAME | {{#vardefine:BUILD_PAGE|Debian_Build_Release}} {{#vardefine:PLATFORM_OS|Debian}} | }} <!-- Debian | ||
--> {{#varexists:B2QT_BSP_VERSION | {{#vardefine:BUILD_PAGE|B2QT_Build_Release}} {{#vardefine:PLATFORM_OS|Boot2Qt}} | }} <!-- B2Qt | --> {{#varexists:B2QT_BSP_VERSION | {{#vardefine:BUILD_PAGE|B2QT_Build_Release}} {{#vardefine:PLATFORM_OS|Boot2Qt}} | }} <!-- B2Qt | ||
--> {{#vardefine:DTS_DIR|arch/{{#switch: {{#var:SOC_SERIES}}|imx8|imx9=arm64|arm}}/boot/dts/{{#ifeq: {{#var:HARDWARE_NAME}}| | |||
DART-MX8M|{{#ifeq: {{#var:YOCTO_NAME}}|Morty|variscite/|freescale/}}|{{#switch: {{#var:SOC_SERIES}} | imx8|imx9=freescale/|}}}}}} <!-- | |||
--> {{PageHeader|{{#var:HARDWARE_NAME}} - Customizing the Linux kernel}} {{DocImage|category1=Yocto|category2={{#var:HARDWARE_NAME}}}} __toc__ | --> {{PageHeader|{{#var:HARDWARE_NAME}} - Customizing the Linux kernel}} {{DocImage|category1=Yocto|category2={{#var:HARDWARE_NAME}}}} __toc__ | ||
Line 89: | Line 91: | ||
For example: | For example: | ||
$ cd {{#var:BUILD_FOLDER}}/local_repos/{{#var:KERNEL_REPO_NAME}} | $ cd {{#var:BUILD_FOLDER}}/local_repos/{{#var:KERNEL_REPO_NAME}} | ||
$ gedit | $ gedit {{#var:DTS_DIR}}/{{#ifeq: {{#var:HARDWARE_NAME}} | VAR-SOM-MX6 |imx6qdl-var-som.dtsi|}}{{#ifeq: {{#var:HARDWARE_NAME}} | DART-6UL |{{#var:EXAMPLE_DTSI}}|}}{{#ifeq: {{#var:HARDWARE_NAME}} | VAR-SOM-MX7 |imx7d-var-som.dtsi|}}{{#ifeq: {{#var:HARDWARE_NAME}} | DART-MX8M | {{#ifeq: {{#var:YOCTO_NAME}}|Morty | imx8m-var-dart-common.dtsi| {{#var:DTB_CARRIER|fsl-imx8mq-var-dart-common.dtsi}}}}|}}{{#ifeq: {{#var:HARDWARE_NAME}} | DART-MX8M-MINI |{{#var:DTB_PREFIX|fsl-imx8mm-var-dart}}.dts|}}{{#ifeq: {{#var:HARDWARE_NAME}} | VAR-SOM-MX8 |fsl-imx8qm-var-som-common.dtsi|}}{{#ifeq: {{#var:HARDWARE_NAME}} | VAR-SOM-MX8M-NANO |{{#var:DTB_PREFIX|fsl-imx8mn-var-som}}.dts|}}{{#ifeq: {{#var:HARDWARE_NAME}} | DART-MX8M-PLUS |{{#var:DTB_PREFIX|imx8mp-var-dart}}.dts|}} | ||
edit and save | edit and save | ||
Line 126: | Line 128: | ||
For example: | For example: | ||
$ cd {{#var:BUILD_FOLDER}}/local_repos/{{#var:KERNEL_REPO_NAME}} | $ cd {{#var:BUILD_FOLDER}}/local_repos/{{#var:KERNEL_REPO_NAME}} | ||
$ gedit | $ gedit {{#var:DTS_DIR}}/{{#ifeq: {{#var:HARDWARE_NAME}} | VAR-SOM-MX6 |imx6qdl-var-som.dtsi|}}{{#ifeq: {{#var:HARDWARE_NAME}} | DART-6UL |{{#var:EXAMPLE_DTSI}}|}}{{#ifeq: {{#var:HARDWARE_NAME}} | VAR-SOM-MX7 |imx7d-var-som.dtsi|}}{{#ifeq: {{#var:HARDWARE_NAME}} | DART-MX8M | {{#ifeq: {{#var:YOCTO_NAME}}|Morty | imx8m-var-dart-common.dtsi| {{#var:DTSI_CARRIER|fsl-imx8m-var-dart-common.dtsi}}}}|}}{{#ifeq: {{#var:HARDWARE_NAME}} | DART-MX8M-MINI |{{#var:DTB_PREFIX|fsl-imx8mm-var-dart}}.dts|}}{{#ifeq: {{#var:HARDWARE_NAME}} | VAR-SOM-MX8 |fsl-imx8qm-var-som-common.dtsi|}}{{#ifeq: {{#var:HARDWARE_NAME}} | VAR-SOM-MX8M-NANO |{{#var:DTB_PREFIX|fsl-imx8mn-var-som}}.dts|}}{{#ifeq: {{#var:HARDWARE_NAME}} | DART-MX8M-PLUS |{{#var:DTB_PREFIX|imx8mp-var-dart}}.dts|}} | ||
edit and save | edit and save | ||
Revision as of 18:03, 18 January 2023
This page is using the default release RELEASE_PYRO_V1.0_VAR-SOM-MX6.
To view this page for a specific Variscite SoM and software release, please follow these steps:
- Visit variwiki.com
- Select your SoM
- Select the software release
After customizing the kernel by following the below instructions, you can either bitbake your complete image (e.g. fsl-image-gui) and the updated kernel will be used, or you can bitbake the kernel alone by running " bitbake virtual/kernel" (see the Build Yocto from source code page for the initial setup and for more info on using bitbake).
Configuring the kernel
The default kernel configuration file used by Yocto is part of the kernel source tree and is located at:
arch/arm/configs/imx_v7_var_defconfig
To configure the kernel using Yocto:
- Follow steps 1-3 of the Build Yocto from source code page.
- Follow the first part of step 4 of the same page, to source the setup-environment script (stop after that - don't build any image). E.g.:
$ cd ~/var-fslc-yocto $ MACHINE=var-som-mx6 DISTRO=fslc-x11 . setup-environment build_x11
- Run menuconfig and configure the kernel:
$ bitbake -c menuconfig virtual/kernel
When finished, save and exit.
The .config file is saved to ~/var-fslc-yocto/build_x11/tmp/work/var_som_mx6-fslc-linux-gnueabi/linux-variscite/4.1.15-r0/build/.config
- At this point, you can continue following the rest of step 4 of the Build Yocto from source code page to build your image with the newly configured kernel, or just build the kernel by running " bitbake virtual/kernel", or, you can follow the next steps to use this configuration permanently.
To save the configuration in a defconfig format:
$ bitbake -c savedefconfig virtual/kernel
The defconfig file is saved to ~/var-fslc-yocto/build_x11/tmp/work/var_som_mx6-fslc-linux-gnueabi/linux-variscite/4.1.15-r0/build/defconfig
To make the kernel recipe use this configuration permanently, you can do either of the following:
- Use any of the three methods described in the Making changes in the source code section below to overwrite the default configuration file in the source tree, arch/arm/configs/imx_v7_var_defconfig, and replace it with the above defconfig.
- Make the kernel recipe use the defconfig from outside of the source tree:
Copy your defconfig:
$ cd ~/var-fslc-yocto/sources/meta-variscite-fslc/recipes-kernel/linux/ $ mkdir -p files $ cp ~/var-fslc-yocto/build_x11/tmp/work/var_som_mx6-fslc-linux-gnueabi/linux-variscite/4.1.15-r0/build/defconfig files/my_defconfig
Create a linux-variscite_%.bbappend file:
$ gedit linux-variscite_%.bbappend
and append the following to it:
SRC_URI += "file://my_defconfig" KERNEL_DEFCONFIG_var-som-mx6 = "${WORKDIR}/my_defconfig"
Making changes in the source code
Choose one of the following three methods to customize the Linux kernel and build it using Yocto:
Add your own patches on top of our source code
Using this method Yocto will take the source code from our default remote repository, and apply your patches to it before building it:
Setup Yocto:
- Follow steps 1-3 of the Build Yocto from source code page.
- Follow the first part of step 4 of the same page, to source the setup-environment script (stop after that - don't build any image). E.g.:
$ cd ~/var-fslc-yocto $ MACHINE=var-som-mx6 DISTRO=fslc-x11 . setup-environment build_x11
Get the source code:
$ bitbake -c patch virtual/kernel $ mkdir -p ../local_repos/linux-2.6-imx $ cp -a tmp/work-shared/var-som-mx6/kernel-source/. ../local_repos/linux-2.6-imx $ cd ../local_repos/linux-2.6-imx $ git reset --hard $ git clean -fdx
Make your changes in the source code and create a patch:
You can use either diff or patch file types.
For example:
$ cd ~/var-fslc-yocto/local_repos/linux-2.6-imx $ gedit arch/arm/boot/dts//imx6qdl-var-som.dtsi edit and save $ git diff > my_device_tree_changes.patch
Update the recipes to use your patch:
Copy your patch:
$ cd ~/var-fslc-yocto/sources/meta-variscite-fslc/recipes-kernel/linux/ $ mkdir -p files $ cp ~/var-fslc-yocto/local_repos/linux-2.6-imx/my_device_tree_changes.patch files/
Create a linux-variscite_%.bbappend file:
$ gedit linux-variscite_%.bbappend
and append the following line to it:
SRC_URI += "file://my_device_tree_changes.patch"
Use a local repository
Using this method Yocto will take the kernel source from a local repository instead of our remote ones on github:
Setup Yocto:
- Follow steps 1-3 of the Build Yocto from source code page.
- Follow the first part of step 4 of the same page, to source the setup-environment script (stop after that - don't build any image). E.g.:
$ cd ~/var-fslc-yocto $ MACHINE=var-som-mx6 DISTRO=fslc-x11 . setup-environment build_x11
Get the source code:
$ bitbake -c patch virtual/kernel $ mkdir -p ../local_repos/linux-2.6-imx $ cp -a tmp/work-shared/var-som-mx6/kernel-source/. ../local_repos/linux-2.6-imx $ cd ../local_repos/linux-2.6-imx $ git reset --hard $ git clean -fdx
Make your changes in the source code and commit them:
After making changes in the source code you need to commit them.
For example:
$ cd ~/var-fslc-yocto/local_repos/linux-2.6-imx $ gedit arch/arm/boot/dts//imx6qdl-var-som.dtsi edit and save $ git commit -a -m "my device tree changes"
To list all of the commits: $ git log
Get the latest commit id: $ git rev-parse HEAD
Update the recipes to use the local repository instead of the default one:
$ cd ~/var-fslc-yocto/sources/meta-variscite-fslc/recipes-kernel/linux/
Create a linux-variscite_%.bbappend file:
$ gedit linux-variscite_%.bbappend
and append the following lines to it (see the previous section for listing the commits or getting the latest commit id):
KERNEL_SRC = "git://${BSPDIR}/local_repos/linux-2.6-imx;protocol=file" SRCBRANCH = "imx-rel_imx_4.1.15_2.0.0_ga-var02" (or your own created branch) SRCREV = "The commit id you'd like to use"
(If you do so, make sure to run " bitbake -c cleansstate virtual/kernel" before rebuilding the kernel)
Use your own remote repository on github
Using this method Yocto will take the source code from your own remote repository on github:
Create your own github account and upload your proprietary kernel to a new repository:
For example, you can fork our repository to your own account by visiting the following link and clicking on "Fork" at the top right of the screen.
Alternatively, you can clone our repository to your local machine, and push it later to your own account.
https://github.com/varigit/linux-2.6-imx/tree/imx-rel_imx_4.1.15_2.0.0_ga-var02
Update the recipes to use your remote repository instead of the default one:
$ cd ~/var-fslc-yocto/sources/meta-variscite-fslc/recipes-kernel/linux/
Create a linux-variscite_%.bbappend file:
$ gedit linux-variscite_%.bbappend
and append the following lines to it (see the previous section for listing the commits or getting the latest commit id):
KERNEL_SRC = "git://github.com/your_account/linux-2.6-imx.git;protocol=git" SRCBRANCH = "imx-rel_imx_4.1.15_2.0.0_ga-var02" (or your own created branch) SRCREV = "The commit id you'd like to use"
(If you do so, make sure to run " bitbake -c cleansstate virtual/kernel" before rebuilding the kernel)